feat(core): improve in-memory validation, FatturaPA detection coverage, and published type compatibility
This commit is contained in:
@@ -263,6 +263,11 @@ export class UBLEncoder extends UBLBaseEncoder {
|
||||
* @param invoice Invoice data
|
||||
*/
|
||||
private addPaymentMeans(doc: Document, parentElement: Element, invoice: TInvoice): void {
|
||||
const paymentOptions = invoice.paymentOptions;
|
||||
if (!paymentOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
const paymentMeansNode = doc.createElement('cac:PaymentMeans');
|
||||
parentElement.appendChild(paymentMeansNode);
|
||||
|
||||
@@ -276,26 +281,26 @@ export class UBLEncoder extends UBLBaseEncoder {
|
||||
this.appendElement(doc, paymentMeansNode, 'cbc:PaymentDueDate', this.formatDate(dueDate.getTime()));
|
||||
|
||||
// Add payment channel code if available
|
||||
if (invoice.paymentOptions.description) {
|
||||
this.appendElement(doc, paymentMeansNode, 'cbc:InstructionNote', invoice.paymentOptions.description);
|
||||
if (paymentOptions.description) {
|
||||
this.appendElement(doc, paymentMeansNode, 'cbc:InstructionNote', paymentOptions.description);
|
||||
}
|
||||
|
||||
// Add payment ID information if available - use invoice ID as payment reference
|
||||
this.appendElement(doc, paymentMeansNode, 'cbc:PaymentID', invoice.id);
|
||||
|
||||
// Add bank account information if available
|
||||
if (invoice.paymentOptions.sepaConnection && invoice.paymentOptions.sepaConnection.iban) {
|
||||
if (paymentOptions.sepaConnection && paymentOptions.sepaConnection.iban) {
|
||||
const payeeFinancialAccountNode = doc.createElement('cac:PayeeFinancialAccount');
|
||||
paymentMeansNode.appendChild(payeeFinancialAccountNode);
|
||||
|
||||
this.appendElement(doc, payeeFinancialAccountNode, 'cbc:ID', invoice.paymentOptions.sepaConnection.iban);
|
||||
this.appendElement(doc, payeeFinancialAccountNode, 'cbc:ID', paymentOptions.sepaConnection.iban);
|
||||
|
||||
// Add financial institution information if BIC is available
|
||||
if (invoice.paymentOptions.sepaConnection.bic) {
|
||||
if (paymentOptions.sepaConnection.bic) {
|
||||
const financialInstitutionNode = doc.createElement('cac:FinancialInstitutionBranch');
|
||||
payeeFinancialAccountNode.appendChild(financialInstitutionNode);
|
||||
|
||||
this.appendElement(doc, financialInstitutionNode, 'cbc:ID', invoice.paymentOptions.sepaConnection.bic);
|
||||
this.appendElement(doc, financialInstitutionNode, 'cbc:ID', paymentOptions.sepaConnection.bic);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1038,4 +1043,4 @@ export class UBLEncoder extends UBLBaseEncoder {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user