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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/builder/DocumentBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* @param invoice The invoice data
* @returns The the invoice in Peppol format as an object
*/
private __buildInvoice(invoice: Invoice) {

Check warning on line 47 in src/builder/DocumentBuilder.ts

View workflow job for this annotation

GitHub Actions / lint

Refactor this function to reduce its Cognitive Complexity from 25 to the 15 allowed
return {
...this.__xmlHeader,
Invoice: {
Expand Down Expand Up @@ -237,7 +237,7 @@
* @param creditNote The credit-note data
* @returns The creditNote in Peppol format as an object
*/
private __buildCreditNote(creditNote: CreditNote) {

Check warning on line 240 in src/builder/DocumentBuilder.ts

View workflow job for this annotation

GitHub Actions / lint

Refactor this function to reduce its Cognitive Complexity from 23 to the 15 allowed
return {
...this.__xmlHeader,
CreditNote: {
Expand Down Expand Up @@ -994,7 +994,7 @@
);
}

private __buildLineItem(

Check warning on line 997 in src/builder/DocumentBuilder.ts

View workflow job for this annotation

GitHub Actions / lint

Refactor this function to reduce its Cognitive Complexity from 25 to the 15 allowed
line: Invoice['invoiceLines'][number],
quantityTag: string
) {
Expand Down Expand Up @@ -1143,7 +1143,7 @@
},
'cac:Price': {
'cbc:PriceAmount': {
'#text': line.price.toFixed(2),
'#text': String(line.price),
...XMLAttributes({
currencyID: line.currency,
}),
Expand Down
16 changes: 16 additions & 0 deletions tests/builder-creditnote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,20 @@ describe('Creditnote Builder', () => {
/<cac:TaxRepresentativeParty>\s*<cac:Party>/
);
});

it('should preserve line price precision in PriceAmount', () => {
const creditNoteXML = toolkit.creditNoteToPeppolUBL({
...basicCreditNote,
creditNoteLines: [
{
...basicCreditNote.creditNoteLines[0],
price: 10.129,
},
],
});

expect(creditNoteXML).toContain(
'<cbc:PriceAmount currencyID="EUR">10.129</cbc:PriceAmount>'
);
});
});
16 changes: 16 additions & 0 deletions tests/builder-invoice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,20 @@ describe('Invoices Builder', () => {
/<cac:TaxRepresentativeParty>\s*<cac:Party>/
);
});

it('should preserve line price precision in PriceAmount', () => {
const invoiceXML = toolkit.invoiceToPeppolUBL({
...basicInvoice,
invoiceLines: [
{
...basicInvoice.invoiceLines[0],
price: 10.129,
},
],
});

expect(invoiceXML).toContain(
'<cbc:PriceAmount currencyID="EUR">10.129</cbc:PriceAmount>'
);
});
});
Loading