diff --git a/src/EndpointCollection/SalesInvoiceEndpointCollection.php b/src/EndpointCollection/SalesInvoiceEndpointCollection.php index c1b28f78..5d5ed5b0 100644 --- a/src/EndpointCollection/SalesInvoiceEndpointCollection.php +++ b/src/EndpointCollection/SalesInvoiceEndpointCollection.php @@ -32,7 +32,7 @@ public function get(string $id): SalesInvoice /** * Creates a SalesInvoice in Mollie. * - * @param array|CreateSalesInvoicePayload $payload + * @param array|CreateSalesInvoicePayload $payload * * @throws ApiException */ diff --git a/src/Factories/CreateSalesInvoicePayloadFactory.php b/src/Factories/CreateSalesInvoicePayloadFactory.php index de6200a6..cfb2d67d 100644 --- a/src/Factories/CreateSalesInvoicePayloadFactory.php +++ b/src/Factories/CreateSalesInvoicePayloadFactory.php @@ -3,16 +3,14 @@ namespace Mollie\Api\Factories; use Mollie\Api\Http\Payload\CreateSalesInvoicePayload; -use Mollie\Api\Http\Payload\PaymentDetails; -use Mollie\Api\Http\Payload\EmailDetails; use Mollie\Api\Http\Payload\Discount; +use Mollie\Api\Http\Payload\EmailDetails; +use Mollie\Api\Http\Payload\PaymentDetails; class CreateSalesInvoicePayloadFactory extends Factory { /** * Create a new CreateSalesInvoicePayload instance. - * - * @return CreateSalesInvoicePayload */ public function create(): CreateSalesInvoicePayload { @@ -27,14 +25,14 @@ public function create(): CreateSalesInvoicePayload $this ->mapIfNotNull( 'lines', - fn(array $items) => InvoiceLineCollectionFactory::new($items)->create() + fn (array $items) => InvoiceLineCollectionFactory::new($items)->create() ), $this->get('profileId'), $this->get('memo'), - $this->mapIfNotNull('paymentDetails', fn(array $data) => PaymentDetails::fromArray($data)), - $this->mapIfNotNull('emailDetails', fn(array $data) => EmailDetails::fromArray($data)), + $this->mapIfNotNull('paymentDetails', fn (array $data) => PaymentDetails::fromArray($data)), + $this->mapIfNotNull('emailDetails', fn (array $data) => EmailDetails::fromArray($data)), $this->get('webhookUrl'), - $this->mapIfNotNull('discount', fn(array $data) => Discount::fromArray($data)) + $this->mapIfNotNull('discount', fn (array $data) => Discount::fromArray($data)) ); } } diff --git a/src/Factories/InvoiceLineCollectionFactory.php b/src/Factories/InvoiceLineCollectionFactory.php index d90f10f3..e457ebef 100644 --- a/src/Factories/InvoiceLineCollectionFactory.php +++ b/src/Factories/InvoiceLineCollectionFactory.php @@ -9,7 +9,7 @@ class InvoiceLineCollectionFactory extends Factory public function create(): DataCollection { return new DataCollection(array_map( - fn(array $item) => InvoiceLineFactory::new($item)->create(), + fn (array $item) => InvoiceLineFactory::new($item)->create(), $this->data )); } diff --git a/src/Factories/InvoiceLineFactory.php b/src/Factories/InvoiceLineFactory.php index bd929792..bb5a2c2b 100644 --- a/src/Factories/InvoiceLineFactory.php +++ b/src/Factories/InvoiceLineFactory.php @@ -14,7 +14,7 @@ public function create(): InvoiceLine $this->get('quantity'), $this->get('vatRate'), MoneyFactory::new($this->get('unitPrice'))->create(), - $this->mapIfNotNull('discount', fn(array $data) => Discount::fromArray($data)) + $this->mapIfNotNull('discount', fn (array $data) => Discount::fromArray($data)) ); } } diff --git a/src/Factories/UpdateSalesInvoicePayloadFactory.php b/src/Factories/UpdateSalesInvoicePayloadFactory.php index 005780d2..e0f323c2 100644 --- a/src/Factories/UpdateSalesInvoicePayloadFactory.php +++ b/src/Factories/UpdateSalesInvoicePayloadFactory.php @@ -2,17 +2,15 @@ namespace Mollie\Api\Factories; -use Mollie\Api\Http\Payload\UpdateSalesInvoicePayload; -use Mollie\Api\Http\Payload\PaymentDetails; -use Mollie\Api\Http\Payload\EmailDetails; use Mollie\Api\Http\Payload\Discount; +use Mollie\Api\Http\Payload\EmailDetails; +use Mollie\Api\Http\Payload\PaymentDetails; +use Mollie\Api\Http\Payload\UpdateSalesInvoicePayload; class UpdateSalesInvoicePayloadFactory extends Factory { /** * Create a new UpdateSalesInvoicePayload instance. - * - * @return UpdateSalesInvoicePayload */ public function create(): UpdateSalesInvoicePayload { @@ -21,16 +19,16 @@ public function create(): UpdateSalesInvoicePayload $this->get('recipientIdentifier'), $this->get('paymentTerm'), $this->get('memo'), - $this->mapIfNotNull('paymentDetails', fn(array $data) => PaymentDetails::fromArray($data)), - $this->mapIfNotNull('emailDetails', fn(array $data) => EmailDetails::fromArray($data)), - $this->mapIfNotNull('recipient', fn(array $data) => RecipientFactory::new($data)->create()), + $this->mapIfNotNull('paymentDetails', fn (array $data) => PaymentDetails::fromArray($data)), + $this->mapIfNotNull('emailDetails', fn (array $data) => EmailDetails::fromArray($data)), + $this->mapIfNotNull('recipient', fn (array $data) => RecipientFactory::new($data)->create()), $this ->mapIfNotNull( 'lines', - fn(array $items) => InvoiceLineCollectionFactory::new($items)->create() + fn (array $items) => InvoiceLineCollectionFactory::new($items)->create() ), $this->get('webhookUrl'), - $this->mapIfNotNull('discount', fn(array $data) => Discount::fromArray($data)) + $this->mapIfNotNull('discount', fn (array $data) => Discount::fromArray($data)) ); } } diff --git a/src/Http/Payload/EmailDetails.php b/src/Http/Payload/EmailDetails.php index be78009d..48bb178a 100644 --- a/src/Http/Payload/EmailDetails.php +++ b/src/Http/Payload/EmailDetails.php @@ -8,6 +8,7 @@ class EmailDetails implements DataProvider { use ComposableFromArray; + public string $subject; public string $body; diff --git a/src/Http/Requests/CreateSalesInvoiceRequest.php b/src/Http/Requests/CreateSalesInvoiceRequest.php index 18168770..0bf03545 100644 --- a/src/Http/Requests/CreateSalesInvoiceRequest.php +++ b/src/Http/Requests/CreateSalesInvoiceRequest.php @@ -13,6 +13,7 @@ class CreateSalesInvoiceRequest extends ResourceHydratableRequest implements Has use HasJsonPayload; protected static string $method = Method::POST; + public static string $targetResourceClass = SalesInvoice::class; private CreateSalesInvoicePayload $payload; diff --git a/src/Http/Requests/UpdateSalesInvoiceRequest.php b/src/Http/Requests/UpdateSalesInvoiceRequest.php index 1584378d..421eb198 100644 --- a/src/Http/Requests/UpdateSalesInvoiceRequest.php +++ b/src/Http/Requests/UpdateSalesInvoiceRequest.php @@ -13,9 +13,11 @@ class UpdateSalesInvoiceRequest extends ResourceHydratableRequest implements Has use HasJsonPayload; protected static string $method = Method::PATCH; + public static string $targetResourceClass = SalesInvoice::class; private string $id; + private UpdateSalesInvoicePayload $payload; public function __construct(string $id, UpdateSalesInvoicePayload $payload) diff --git a/src/MollieApiClient.php b/src/MollieApiClient.php index 77935bc6..7ffb52af 100644 --- a/src/MollieApiClient.php +++ b/src/MollieApiClient.php @@ -32,6 +32,7 @@ use Mollie\Api\EndpointCollection\ProfileEndpointCollection; use Mollie\Api\EndpointCollection\ProfileMethodEndpointCollection; use Mollie\Api\EndpointCollection\RefundEndpointCollection; +use Mollie\Api\EndpointCollection\SalesInvoiceEndpointCollection; use Mollie\Api\EndpointCollection\SessionEndpointCollection; use Mollie\Api\EndpointCollection\SettlementCaptureEndpointCollection; use Mollie\Api\EndpointCollection\SettlementChargebackEndpointCollection; @@ -42,7 +43,6 @@ use Mollie\Api\EndpointCollection\SubscriptionPaymentEndpointCollection; use Mollie\Api\EndpointCollection\TerminalEndpointCollection; use Mollie\Api\EndpointCollection\WalletEndpointCollection; -use Mollie\Api\EndpointCollection\SalesInvoiceEndpointCollection; use Mollie\Api\Helpers\Url; use Mollie\Api\Http\Adapter\MollieHttpAdapterPicker; use Mollie\Api\Idempotency\DefaultIdempotencyKeyGenerator; diff --git a/src/Resources/SalesInvoice.php b/src/Resources/SalesInvoice.php index 432d0cde..58b48917 100644 --- a/src/Resources/SalesInvoice.php +++ b/src/Resources/SalesInvoice.php @@ -60,6 +60,7 @@ class SalesInvoice extends BaseResource * @var object */ public $paymentDetails; + /** * @var object */ diff --git a/src/Traits/HasEndpoints.php b/src/Traits/HasEndpoints.php index 22d339a0..a6de71cf 100644 --- a/src/Traits/HasEndpoints.php +++ b/src/Traits/HasEndpoints.php @@ -28,6 +28,7 @@ use Mollie\Api\EndpointCollection\ProfileEndpointCollection; use Mollie\Api\EndpointCollection\ProfileMethodEndpointCollection; use Mollie\Api\EndpointCollection\RefundEndpointCollection; +use Mollie\Api\EndpointCollection\SalesInvoiceEndpointCollection; use Mollie\Api\EndpointCollection\SessionEndpointCollection; use Mollie\Api\EndpointCollection\SettlementCaptureEndpointCollection; use Mollie\Api\EndpointCollection\SettlementChargebackEndpointCollection; @@ -38,7 +39,6 @@ use Mollie\Api\EndpointCollection\SubscriptionPaymentEndpointCollection; use Mollie\Api\EndpointCollection\TerminalEndpointCollection; use Mollie\Api\EndpointCollection\WalletEndpointCollection; -use Mollie\Api\EndpointCollection\SalesInvoiceEndpointCollection; use Mollie\Api\MollieApiClient; /** diff --git a/src/Types/PaymentTerm.php b/src/Types/PaymentTerm.php index 9b9e4372..7691a2e0 100644 --- a/src/Types/PaymentTerm.php +++ b/src/Types/PaymentTerm.php @@ -5,10 +5,16 @@ class PaymentTerm { const DAYS_7 = '7 days'; + const DAYS_14 = '14 days'; + const DAYS_30 = '30 days'; + const DAYS_45 = '45 days'; + const DAYS_60 = '60 days'; + const DAYS_90 = '90 days'; + const DAYS_120 = '120 days'; } diff --git a/src/Types/RecipientType.php b/src/Types/RecipientType.php index c6befc02..e40f617f 100644 --- a/src/Types/RecipientType.php +++ b/src/Types/RecipientType.php @@ -5,5 +5,6 @@ class RecipientType { const CONSUMER = 'consumer'; + const BUSINESS = 'business'; } diff --git a/src/Types/VatMode.php b/src/Types/VatMode.php index 4178502b..da566eca 100644 --- a/src/Types/VatMode.php +++ b/src/Types/VatMode.php @@ -5,5 +5,6 @@ class VatMode { const EXCLUSIVE = 'exclusive'; + const INCLUSIVE = 'inclusive'; } diff --git a/src/Types/VatScheme.php b/src/Types/VatScheme.php index f331c17b..d51cd3e4 100644 --- a/src/Types/VatScheme.php +++ b/src/Types/VatScheme.php @@ -5,5 +5,6 @@ class VatScheme { const STANDARD = 'standard'; + const ONE_STOP_SHOP = 'one-stop-shop'; } diff --git a/tests/EndpointCollection/SalesInvoiceEndpointCollectionTest.php b/tests/EndpointCollection/SalesInvoiceEndpointCollectionTest.php index 8886e132..3c9b9312 100644 --- a/tests/EndpointCollection/SalesInvoiceEndpointCollectionTest.php +++ b/tests/EndpointCollection/SalesInvoiceEndpointCollectionTest.php @@ -52,7 +52,7 @@ public function create() 1, '21', new Money('EUR', '10,00'), - ) + ), ]; // Create a sales invoice diff --git a/tests/Http/Requests/CreateSalesInvoiceRequestTest.php b/tests/Http/Requests/CreateSalesInvoiceRequestTest.php index 60f71ef5..f8edc7a4 100644 --- a/tests/Http/Requests/CreateSalesInvoiceRequestTest.php +++ b/tests/Http/Requests/CreateSalesInvoiceRequestTest.php @@ -33,7 +33,7 @@ public function it_creates_sales_invoice() 1, '21', new Money('EUR', '10,00'), - ) + ), ]; // Create a sales invoice @@ -89,7 +89,7 @@ public function it_resolves_correct_resource_path() 1, '21', new Money('EUR', '10,00'), - ) + ), ]) ));