Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/CreditNote.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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;
}
}
16 changes: 16 additions & 0 deletions src/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/InvoiceTypeCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}