diff --git a/package.json b/package.json index dbda76f..75965a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pixeldrive/peppol-toolkit", - "version": "0.8.3", + "version": "0.8.4", "description": "A TypeScript toolkit for building and reading peppol UBL documents", "keywords": [ "peppol", diff --git a/src/builder/DocumentBuilder.ts b/src/builder/DocumentBuilder.ts index 85c7b4a..dae180f 100644 --- a/src/builder/DocumentBuilder.ts +++ b/src/builder/DocumentBuilder.ts @@ -1143,7 +1143,7 @@ export class DocumentBuilder { }, 'cac:Price': { 'cbc:PriceAmount': { - '#text': line.price.toFixed(2), + '#text': String(line.price), ...XMLAttributes({ currencyID: line.currency, }), diff --git a/tests/builder-creditnote.test.ts b/tests/builder-creditnote.test.ts index 3e87a3a..1e8c9fb 100644 --- a/tests/builder-creditnote.test.ts +++ b/tests/builder-creditnote.test.ts @@ -132,4 +132,20 @@ describe('Creditnote Builder', () => { /\s*/ ); }); + + it('should preserve line price precision in PriceAmount', () => { + const creditNoteXML = toolkit.creditNoteToPeppolUBL({ + ...basicCreditNote, + creditNoteLines: [ + { + ...basicCreditNote.creditNoteLines[0], + price: 10.129, + }, + ], + }); + + expect(creditNoteXML).toContain( + '10.129' + ); + }); }); diff --git a/tests/builder-invoice.test.ts b/tests/builder-invoice.test.ts index 341d0f4..11f06a8 100644 --- a/tests/builder-invoice.test.ts +++ b/tests/builder-invoice.test.ts @@ -148,4 +148,20 @@ describe('Invoices Builder', () => { /\s*/ ); }); + + it('should preserve line price precision in PriceAmount', () => { + const invoiceXML = toolkit.invoiceToPeppolUBL({ + ...basicInvoice, + invoiceLines: [ + { + ...basicInvoice.invoiceLines[0], + price: 10.129, + }, + ], + }); + + expect(invoiceXML).toContain( + '10.129' + ); + }); });