diff --git a/src/CreditNote.php b/src/CreditNote.php index 75a418f..90e3bb2 100644 --- a/src/CreditNote.php +++ b/src/CreditNote.php @@ -34,6 +34,11 @@ public function setCreditNoteLines(array $creditNoteLines) /** * The xmlDeserialize method is called during xml reading. + * + * Overrides parent to read CreditNoteTypeCode instead of InvoiceTypeCode. + * CreditNotes use CreditNoteTypeCode (e.g., 261 for self-billing credit note) + * while Invoices use InvoiceTypeCode (e.g., 389 for self-billing invoice). + * * @param Reader $reader * @return static */ @@ -42,7 +47,19 @@ public static function xmlDeserialize(Reader $reader) $mixedContent = mixedContent($reader); $collection = new ArrayCollection($mixedContent); - return (static::deserializedTag($mixedContent)) + $instance = static::deserializedTag($mixedContent) ->setCreditNoteLines(ReaderHelper::getArrayValue(Schema::CAC . 'CreditNoteLine', $collection)); + + // Read CreditNoteTypeCode (CreditNotes use this instead of InvoiceTypeCode) + $creditNoteTypeCode = ReaderHelper::getTagValue( + Schema::CBC . 'CreditNoteTypeCode', + $collection + ); + + if ($creditNoteTypeCode !== null) { + $instance->setInvoiceTypeCode((int) $creditNoteTypeCode); + } + + return $instance; } } diff --git a/src/Invoice.php b/src/Invoice.php index 9a5a957..aa08ecd 100644 --- a/src/Invoice.php +++ b/src/Invoice.php @@ -89,6 +89,14 @@ public function setId(?string $id) return $this; } + /** + * @return string|null + */ + public function getCustomizationId(): ?string + { + return $this->customizationID; + } + /** * @param mixed $customizationID * @return static @@ -99,6 +107,14 @@ public function setCustomizationId(?string $customizationID) return $this; } + /** + * @return string|null + */ + public function getProfileId(): ?string + { + return $this->profileID; + } + /** * @param mixed $profileID * @return static diff --git a/src/InvoiceTypeCode.php b/src/InvoiceTypeCode.php index 26d2910..15a2001 100644 --- a/src/InvoiceTypeCode.php +++ b/src/InvoiceTypeCode.php @@ -14,4 +14,8 @@ class InvoiceTypeCode public const CORRECTED_INVOICE = 384; public const ADVANCE_INVOICE = 386; public const SELF_BILLING_INVOICE = 389; + + // Self-billing credit note (UNCL1001 code 261) + // Used when the buyer issues a credit note on behalf of the seller + public const SELF_BILLING_CREDIT_NOTE = 261; }