UNPKG

einvoicing

Version:

A JavaScript library for creating and parsing electronic invoices compliant with the eInvoicing Directive, EN 16931, and popular extensions

864 lines (863 loc) 96.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var UblReader_1 = tslib_1.__importDefault(require("./UblReader")); var IDocument_1 = require("../interface/IDocument"); var DateOnly_1 = tslib_1.__importDefault(require("../valueObject/DateOnly")); var DocumentType_1 = tslib_1.__importDefault(require("../valueObject/DocumentType")); var CurrencyCode_1 = tslib_1.__importDefault(require("../valueObject/CurrencyCode")); var Party_1 = tslib_1.__importDefault(require("../valueObject/Party")); var Address_1 = tslib_1.__importDefault(require("../valueObject/Address")); var DocumentLine_1 = tslib_1.__importDefault(require("../entity/DocumentLine")); var IDocumentLine_1 = require("../interface/IDocumentLine"); var Identifier_1 = tslib_1.__importDefault(require("../valueObject/Identifier")); var Delivery_1 = tslib_1.__importDefault(require("../valueObject/Delivery")); var Attribute_1 = tslib_1.__importDefault(require("../valueObject/Attribute")); var Payment_1 = tslib_1.__importDefault(require("../valueObject/Payment")); var PaymentTransfer_1 = tslib_1.__importDefault(require("../valueObject/PaymentTransfer")); var AllowanceCharge_1 = tslib_1.__importDefault(require("../valueObject/AllowanceCharge")); var Tax_1 = tslib_1.__importDefault(require("../entity/Tax")); var ITax_1 = require("../interface/ITax"); var Attachment_1 = tslib_1.__importDefault(require("../valueObject/Attachment")); var BinaryObject_1 = tslib_1.__importDefault(require("../valueObject/BinaryObject")); var InvoiceReference_1 = tslib_1.__importDefault(require("../valueObject/InvoiceReference")); var Payee_1 = tslib_1.__importDefault(require("../valueObject/Payee")); describe('UblReader', function () { var ublReader; beforeEach(function () { ublReader = new UblReader_1.default(); }); afterEach(function () { jest.clearAllMocks(); }); describe('readFromFile', function () { // examples from https://github.com/ConnectingEurope/eInvoicing-EN16931/tree/master/ubl/examples test('bis3_invoice_negativ.xml', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () { var result, vat; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, ublReader.readFromFile('tests/files/bis3_invoice_negativ.xml')]; case 1: result = _a.sent(); vat = Tax_1.default.create({ "id": new ITax_1.TaxId('S', 25), "currency": CurrencyCode_1.default.create("DKK"), "percent": 25, "taxAmount": -156435.89, "taxableAmount": -625743.54 }); expect(result.toPrimitive()).toEqual({ "id": new IDocument_1.DocumentId('12345'), "dueDate": DateOnly_1.default.create("2019-02-24"), "issueDate": DateOnly_1.default.create("2019-01-25"), "periodStart": DateOnly_1.default.create('2018-09-01'), "periodEnd": DateOnly_1.default.create('2018-09-30'), "currency": CurrencyCode_1.default.create("DKK"), buyerReference: 'n/a', buyerAccountingReference: 'n/a', "notes": 'text', "type": DocumentType_1.default.create('380'), "payment": Payment_1.default.create({ "id": "12345667890", "meansCode": "58", "transfer": PaymentTransfer_1.default.create({ "account": "1234567891234" }) }), buyer: Party_1.default.create({ additionalIdentifiers: ['87654321'], companyId: '87654321', contactName: "n/a", endpointId: '87654321', tradingName: "Company B", address: Address_1.default.create({ "addressLines": [ "Bjerkåsholmen 125" ], streetName: 'Bjerkåsholmen 125', cityName: 'Slemmestad', postalZone: 'NO-3470', countryCode: 'DK' }), vatNumber: 'DK87654321' }), seller: Party_1.default.create({ additionalIdentifiers: ['12345678'], companyId: '12345678', endpointId: '12345678', tradingName: "Company A", address: Address_1.default.create({ "addressLines": [ "Street" ], streetName: 'Street', cityName: 'Copenhagen', postalZone: '1057', countryCode: 'DK' }), vatNumber: 'DK12345678' }), "taxes": [vat], delivery: Delivery_1.default.create({ date: DateOnly_1.default.create('2019-01-25') }), lines: [ DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('1'), quantity: -1, unitCode: 'KWH', buyerAccountingReference: "n/a", periodStart: DateOnly_1.default.create('2018-09-01'), periodEnd: DateOnly_1.default.create('2018-09-30'), name: 'text', description: 'text', sellerIdentifier: '12345', originCountryCode: 'DK', price: 625743.54, netAmount: -625743.54, tax: vat }) ] }); return [2 /*return*/]; } }); }); }); test('bis3_invoice_positive.xml', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () { var result, vat; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, ublReader.readFromFile('tests/files/bis3_invoice_positive.xml')]; case 1: result = _a.sent(); vat = Tax_1.default.create({ "id": new ITax_1.TaxId('S', 25), "currency": CurrencyCode_1.default.create("DKK"), "percent": 25, "taxAmount": 156435.89, "taxableAmount": 625743.54 }); expect(result.toPrimitive()).toEqual({ "id": new IDocument_1.DocumentId('12345'), "dueDate": DateOnly_1.default.create("2019-02-24"), "issueDate": DateOnly_1.default.create("2019-01-25"), "periodStart": DateOnly_1.default.create('2018-09-01'), "periodEnd": DateOnly_1.default.create('2018-09-30'), "currency": CurrencyCode_1.default.create("DKK"), buyerReference: 'n/a', buyerAccountingReference: 'n/a', "notes": 'text', "type": DocumentType_1.default.create('380'), "payment": Payment_1.default.create({ "id": "12345667890", "meansCode": "58", "transfer": PaymentTransfer_1.default.create({ "account": "1234567891234" }) }), buyer: Party_1.default.create({ additionalIdentifiers: ['87654321'], companyId: '87654321', contactName: "n/a", endpointId: '87654321', tradingName: "Company B", address: Address_1.default.create({ "addressLines": [ "Bjerkåsholmen 125" ], streetName: 'Bjerkåsholmen 125', cityName: 'Slemmestad', postalZone: 'NO-3470', countryCode: 'DK' }), vatNumber: 'DK87654321' }), seller: Party_1.default.create({ additionalIdentifiers: ['12345678'], companyId: '12345678', endpointId: '12345678', tradingName: "Company A", address: Address_1.default.create({ "addressLines": [ "Street" ], streetName: 'Street', cityName: 'Copenhagen', postalZone: '1057', countryCode: 'DK' }), vatNumber: 'DK12345678' }), "taxes": [vat], delivery: Delivery_1.default.create({ date: DateOnly_1.default.create('2019-01-25') }), lines: [ DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('1'), quantity: 1, unitCode: 'KWH', buyerAccountingReference: "n/a", periodStart: DateOnly_1.default.create('2018-09-01'), periodEnd: DateOnly_1.default.create('2018-09-30'), name: 'text', description: 'text', sellerIdentifier: '12345', originCountryCode: 'DK', price: 625743.54, netAmount: 625743.54, tax: vat }) ] }); return [2 /*return*/]; } }); }); }); test('ft_g2g_td01_con_allegato_bonifico_e_split_payment.xml', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () { var result, vat; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, ublReader.readFromFile('tests/files/ft_g2g_td01_con_allegato_bonifico_e_split_payment.xml')]; case 1: result = _a.sent(); vat = Tax_1.default.create({ "id": new ITax_1.TaxId('B', 22), "currency": CurrencyCode_1.default.create("EUR"), "percent": 22, "taxAmount": 274.12, "taxableAmount": 1246 }); expect(result.attachments[0].toPrimitive().content.toPrimitive()).toEqual({ content: expect.any(String), "filename": "mappatura_ubl_sdi.pdf", "mimeCode": "application/pdf" }); expect(result.toPrimitive()).toEqual({ attachments: [expect.any(Attachment_1.default)], "id": new IDocument_1.DocumentId('1316/85'), "issueDate": DateOnly_1.default.create('2020-02-13'), "type": DocumentType_1.default.create('380'), "payment": Payment_1.default.create({ "meansCode": "30", "terms": "D.LGS. 231/2002 S.M.I", "transfer": PaymentTransfer_1.default.create({ "account": "IT64W0100003245243300306301" }) }), buyer: Party_1.default.create({ "endpointId": "UFLCTZ", "tradingName": "AZIENDA USL DI MODENA", "vatNumber": "IT02241850367", address: Address_1.default.create({ "addressLines": [ "VIA SAN GIOVANNI DEL CANTONE 23" ], "cityName": "MODENA", "countryCode": "IT", "postalZone": "41121", "streetName": "VIA SAN GIOVANNI DEL CANTONE 23", "subdivision": "MO" }), }), "buyerReference": "110#2020-02-05#ABCDEF", currency: CurrencyCode_1.default.create('EUR'), seller: Party_1.default.create({ "endpointId": "UF6WX8", "tradingName": "Azienda Unita Sanitaria Locale di Reggio Emilia", "vatNumber": "IT01598570354", address: Address_1.default.create({ "addressLines": [ "Via Amendola,2" ], "cityName": "REGGIO EMILIA", "countryCode": "IT", "postalZone": "42100", "streetName": "Via Amendola,2", "subdivision": "RE" }) }), "taxes": [vat], lines: [ DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('1'), "buyerAccountingReference": "B09.01.068", "name": "EBIXA 5MG/EROGAZIONE SOL. ORALE 50 ML", "netAmount": 1246, "price": 62.3, "quantity": 20, "sellerIdentifier": "689910", "unitCode": "C62", tax: vat }) ], "notes": "Scissione Pagamenti", "paidAmount": 274.12, }); return [2 /*return*/]; } }); }); }); test('guide-example1.xml', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () { var result, tax, tax2; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, ublReader.readFromFile('tests/files/guide-example1.xml')]; case 1: result = _a.sent(); tax = Tax_1.default.create({ "id": new ITax_1.TaxId('S', 6), "currency": CurrencyCode_1.default.create("EUR"), "percent": 6, "taxAmount": 10.99, "taxableAmount": 183.23 }); tax2 = Tax_1.default.create({ "id": new ITax_1.TaxId('S', 21), "currency": CurrencyCode_1.default.create("EUR"), "percent": 21, "taxAmount": 9.74, "taxableAmount": 46.37 }); expect(result.toPrimitive()).toEqual({ "id": new IDocument_1.DocumentId('12115118'), "issueDate": DateOnly_1.default.create('2015-01-09'), "dueDate": DateOnly_1.default.create('2015-01-09'), "type": DocumentType_1.default.create('380'), "payment": Payment_1.default.create({}), buyer: Party_1.default.create({ "additionalIdentifiers": [ "10202" ], "contactName": "Dhr. J BLOKKER", address: Address_1.default.create({ "addressLines": [ "POSTBUS 367" ], "cityName": "HEEMSKERK", "countryCode": "NL", "postalZone": "1960 AJ", "streetName": "POSTBUS 367" }), }), "notes": "Alle leveringen zijn franco. Alle prijzen zijn incl. BTW. Betalingstermijn: 14 dagen netto. Prijswijzigingen voorbehouden. Op al onze aanbiedingen, leveringen en overeenkomsten zijn van toepassing in de algemene verkoop en leveringsvoorwaarden. Gedeponeerd bij de K.v.K. te Amsterdam 25-04-'85##Delivery terms", currency: CurrencyCode_1.default.create('EUR'), seller: Party_1.default.create({ "companyId": "57151520", "vatNumber": "NL8200.98.395.B.01", address: Address_1.default.create({ "addressLines": [ "Postbus 7l" ], "cityName": "Velsen-Noord", "countryCode": "NL", "postalZone": "1950 AB", "streetName": "Postbus 7l" }) }), "taxes": [tax, tax2], lines: [ DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('1'), "name": "PATAT FRITES 10MM 10KG", "netAmount": 19.9, "price": 9.95, "quantity": 2, "sellerIdentifier": "166022", tax: tax, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('2'), "name": "PKAAS 50PL. JONG BEL. 1KG", "netAmount": 9.85, "price": 9.85, "quantity": 1, "sellerIdentifier": "661813", tax: tax, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('3'), "name": "POT KETCHUP 3 LT", "netAmount": 8.29, "price": 8.29, "quantity": 1, "sellerIdentifier": "438146", tax: tax, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('4'), "name": "FRITESSAUS 3 LRR", "netAmount": 14.46, "price": 7.23, "quantity": 2, "sellerIdentifier": "438103", tax: tax, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('5'), "name": "KOFFIE BLIK 3,5KG SNELF", "netAmount": 35, "price": 35, "quantity": 1, "sellerIdentifier": "666955", tax: tax, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('6'), "name": "KOFFIE 3.5 KG BLIK STAND", "netAmount": 35, "price": 35, "quantity": 1, "sellerIdentifier": "664871", tax: tax, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('7'), "name": "SUIKERKLONT", "netAmount": 10.65, "price": 10.65, "quantity": 1, "sellerIdentifier": "350257", tax: tax, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('8'), "name": "1 KG UL BLOKJES", "netAmount": 1.55, "price": 1.55, "quantity": 1, "sellerIdentifier": "350258", tax: tax, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('9'), "name": "BLOCKNOTE A5", "netAmount": 14.37, "price": 4.79, "quantity": 3, "sellerIdentifier": "999998", tax: tax, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('10'), "name": "CHIPS NAT KLEIN ZAKJES", "netAmount": 8.29, "price": 8.29, "quantity": 1, "sellerIdentifier": "740810", tax: tax, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('11'), "name": "CHIPS PAP KLEINE ZAKJES", "netAmount": 16.58, "price": 8.29, "quantity": 2, "sellerIdentifier": "740829", tax: tax, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('12'), "name": "TR KL PAKJES APPELSAP", "netAmount": 9.95, "price": 9.95, "quantity": 1, "sellerIdentifier": "740828", tax: tax, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('13'), "name": "PK CHOCOLADEMEL", "netAmount": 3.3, "price": 1.65, "quantity": 2, "sellerIdentifier": "740827", tax: tax, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('14'), "name": "KRAT BIER", "netAmount": 10.8, "price": 10.8, "quantity": 1, "sellerIdentifier": "999996", tax: tax2, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('15'), "name": "STATIEGELD", "netAmount": 3.9, "price": 3.9, "quantity": 1, "sellerIdentifier": "999995", tax: tax, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('16'), "name": "BLEEK 3 X 750 ML", "netAmount": 7.6, "price": 3.8, "quantity": 2, "sellerIdentifier": "102172", tax: tax2, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('17'), "name": "WC PAPIER", "netAmount": 9.34, "price": 4.67, "quantity": 2, "sellerIdentifier": "999994", tax: tax2, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('18'), "name": "BALPENNEN 50 ST BLAUW", "netAmount": 18.63, "price": 18.63, "quantity": 1, "sellerIdentifier": "999993", tax: tax2, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('19'), "name": "EM FRITUURVETxºxxx", "netAmount": 102.12, "price": 17.02, "quantity": 6, "sellerIdentifier": "999992", tax: tax, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('20'), "name": "FRITUUR VET 10 KG RETOUR", "netAmount": -109.98, "price": 18.33, "quantity": 6, "sellerIdentifier": "175137", tax: tax, "unitCode": "EA" }) ], }); return [2 /*return*/]; } }); }); }); test('guide-example2.xml', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () { var result, tax, tax2, tax3; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, ublReader.readFromFile('tests/files/guide-example2.xml')]; case 1: result = _a.sent(); tax = Tax_1.default.create({ "id": new ITax_1.TaxId('S', 25), "currency": CurrencyCode_1.default.create("NOK"), "percent": 25, "taxAmount": 365.13, "taxableAmount": 1460.5 }); tax2 = Tax_1.default.create({ "id": new ITax_1.TaxId('S', 15), "currency": CurrencyCode_1.default.create("NOK"), "percent": 15, "taxAmount": 0.15, "taxableAmount": 1 }); tax3 = Tax_1.default.create({ "id": new ITax_1.TaxId('E', 0), "currency": CurrencyCode_1.default.create("NOK"), "taxAmount": 0, "taxExemptionReason": "Exempt New Means of Transport", "taxableAmount": -25 }); expect(result.toPrimitive()).toEqual({ "attachments": [ Attachment_1.default.create({ "description": "Timesheet", "id": "Doc1" }), Attachment_1.default.create({ "description": "EHF specification", "id": "Doc2" }) ], "id": new IDocument_1.DocumentId('TOSL108'), "issueDate": DateOnly_1.default.create('2013-06-30'), "dueDate": DateOnly_1.default.create('2013-07-20'), taxPointDate: DateOnly_1.default.create('2013-06-30'), periodStart: DateOnly_1.default.create('2013-06-01'), periodEnd: DateOnly_1.default.create('2013-06-30'), "type": DocumentType_1.default.create('380'), "payment": Payment_1.default.create({ "id": "3434323213231", "meansCode": "30", "terms": "2 % discount if paid within 2 days Penalty percentage 10% from due date", "transfer": PaymentTransfer_1.default.create({ "account": "NO9386011117947" }) }), delivery: Delivery_1.default.create({ date: DateOnly_1.default.create('2013-06-15') }), "notes": "Ordered in our booth at the convention", "paidAmount": 1000, "payee": Payee_1.default.create({ "additionalIdentifiers": [ "2298740918237" ], "companyId": "989823401", "name": "Ebeneser Scrooge AS" }), buyer: Party_1.default.create({ "additionalIdentifiers": [ "3456789012098" ], "companyId": "987654321", "contactEmail": "john@buyercompany.no", "contactName": "John Doe", "contactPhone": "5121230", "vatNumber": "NO987654321MVA", address: Address_1.default.create({ "addressLines": [ "Anystreet 8", "Back door" ], "cityName": "Anytown", "countryCode": "NO", "postalZone": "101", "streetName": "Anystreet 8", "subdivision": "RegionB" }), }), currency: CurrencyCode_1.default.create('NOK'), seller: Party_1.default.create({ "additionalIdentifiers": [ "1238764941386" ], "companyId": "123456789", "contactEmail": "antonio@salescompany.no", "contactName": "Antonio Salesmacher", "contactPhone": "46211230", "vatNumber": "NO123456789MVA", address: Address_1.default.create({ "addressLines": [ "Main street 34", "Suite 123" ], "cityName": "Big city", "countryCode": "NO", "postalZone": "303", "streetName": "Main street 34", "subdivision": "RegionA" }) }), "buyerAccountingReference": "Project cost code 123", "charges": [ AllowanceCharge_1.default.create({ "amount": 100, "isCharge": false, "reasonCode": "71", "reasonText": "Promotion discount", tax: tax }), AllowanceCharge_1.default.create({ "amount": 100, "isCharge": false, "reasonText": "Freight", tax: tax }) ], "taxes": [tax, tax2, tax3], lines: [ DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('1'), attributes: [Attribute_1.default.create({ name: 'Color', value: 'Black' })], "baseQuantity": 1, "buyerAccountingReference": "BookingCode001", "charges": [AllowanceCharge_1.default.create({ "amount": 12, "isCharge": false, "reasonText": "Damage" }), AllowanceCharge_1.default.create({ "amount": 12, "isCharge": false, "reasonText": "Testing" })], "classificationIdentifiers": [Identifier_1.default.create({ "id": "65434568", "scheme": "STI" })], "description": "Processor: Intel Core 2 Duo SU9400 LV (1.4GHz). RAM: 3MB. Screen\n 1440x900", "name": "Laptop computer", "netAmount": 1273, "note": "Scratch on box", "orderLineReference": "1", "originCountryCode": "DE", "periodStart": DateOnly_1.default.create('2013-06-01'), "periodEnd": DateOnly_1.default.create('2013-06-30'), "price": 1273, "quantity": 2, "sellerIdentifier": "JB007", "standardIdentifier": "1234567890128", tax: tax, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('2'), "baseQuantity": 1, "buyerAccountingReference": "BookingCode002", "classificationIdentifiers": [Identifier_1.default.create({ "id": "65434567", "scheme": "STI" })], "name": "Returned \"Advanced computing\" book", "netAmount": -3.96, "note": "Cover is slightly damaged.", "orderLineReference": "5", "price": 3.96, "quantity": -1, "sellerIdentifier": "JB008", "standardIdentifier": "1234567890135", tax: tax2, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('3'), "buyerAccountingReference": "BookingCode003", "baseQuantity": 1, "classificationIdentifiers": [Identifier_1.default.create({ "id": "65434567", "scheme": "STI" })], "name": "\"Computing for dummies\" book", "netAmount": 4.96, "orderLineReference": "3", "price": 2.48, "quantity": 2, "sellerIdentifier": "JB009", "standardIdentifier": "1234567890135", tax: tax2, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('4'), "buyerAccountingReference": "BookingCode004", "baseQuantity": 1, "classificationIdentifiers": [Identifier_1.default.create({ "id": "65434565", "scheme": "STI" })], "name": "Returned IBM 5150 desktop", "netAmount": -25, "orderLineReference": "2", "price": 25, "quantity": -1, "sellerIdentifier": "JB010", "standardIdentifier": "1234567890159", tax: tax3, "unitCode": "EA" }), DocumentLine_1.default.create({ id: new IDocumentLine_1.DocumentLineId('5'), attributes: [Attribute_1.default.create({ name: 'Type', value: 'Cat5' })], "baseQuantity": 1, "classificationIdentifiers": [Identifier_1.default.create({ "id": "65434564", "scheme": "STI" })], "buyerAccountingReference": "BookingCode005", "name": "Network cable", "netAmount": 187.5, "price": 0.75, "quantity": 250, "sellerIdentifier": "JB011", "standardIdentifier": "1234567890166", tax: tax, "unitCode": "MTR" }) ], }); return [2 /*return*/]; } }); }); }); test('guide-example3.xml', function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () { var result, tax; return tslib_1.__generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, ublReader.readFromFile('tests/files/guide-example3.xml')]; case 1: result = _a.sent(); tax = Tax_1.default.create({ "id": new ITax_1.TaxId('S', 25), "currency": CurrencyCode_1.default.create("DKK"), "percent": 25, "taxAmount": 225, "taxableAmount": 900 }); expect(result.toPrimitive()).toEqual({ "id": new IDocument_1.DocumentId('TOSL108'), "issueDate": DateOnly_1.default.create('2013-04-10'), "dueDate": DateOnly_1.default.create('2013-05-10'), "periodStart": DateOnly_1.default.create('2013-01-01'), "periodEnd": DateOnly_1.default.create('2013-04-01'), "type": DocumentType_1.default.create('380'), "payment": Payment_1.default.create({ "id": "Payref1", "meansCode": "30", transfer: PaymentTransfer_1.default.create({ "account": "DK1212341234123412" }) }), "charges": [ AllowanceCharge_1.default.create({ "amount": 100, "isCharge": false, "reasonText": "Freight charge", tax: tax }) ], buyer: Party_1.default.create({ "additionalIdentifiers": [ "5790000435975" ], address: Address_1.default.create({ "addressLines": [ "Anystreet, Building 1" ], "cityName": "Anytown", "countryCode": "DK", "postalZone": "101", "streetName": "Anystreet, Building 1" }), }), "notes": "Contract was established through our website", currency: CurrencyCode_1.default.create('DKK'), seller: Party_1.default.create({ "additionalIdentifiers": [ "1238764941386" ], "companyId": "DK16356706", "contactEmail": "antonio@SubscriptionsSeller.dk", "vatNumber": "DK16356706", address: Address_1.default.create({ "addressLines": [ "Main street 2, Building 4" ], "cityName": "Big city", "countryCode": "DK", "postalZone": "54321", "streetName": "Main street 2, Building 4" }) }), "taxes": [tax],