diff --git a/cfg/config.json b/cfg/config.json index cd65f36..aceb176 100644 --- a/cfg/config.json +++ b/cfg/config.json @@ -356,8 +356,8 @@ "access_token": null, "wsdl_header": { "Authentification": { - "user": "33333333331010", - "signature": "pass" + "user": "user-valid", + "signature": "SandboxPasswort2023!" } } }, diff --git a/package-lock.json b/package-lock.json index 7688b9d..12e83f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "@restorecommerce/service-config": "^1.0.15", "@types/soap": "^0.21.0", "@types/xml-js": "^1.0.0", + "bignumber.js": "^9.1.2", "dayjs": "^1.11.10", "redis": "^4.6.14", "soap": "^1.0.1", @@ -3886,6 +3887,15 @@ "dev": true, "peer": true }, + "node_modules/bignumber.js": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", + "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==", + "license": "MIT", + "engines": { + "node": "*" + } + }, "node_modules/binary-search": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/binary-search/-/binary-search-1.3.6.tgz", diff --git a/package.json b/package.json index 745ce9b..b21590d 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@restorecommerce/service-config": "^1.0.15", "@types/soap": "^0.21.0", "@types/xml-js": "^1.0.0", + "bignumber.js": "^9.1.2", "dayjs": "^1.11.10", "redis": "^4.6.14", "soap": "^1.0.1", diff --git a/src/services/fulfillment_product.ts b/src/services/fulfillment_product.ts index 41233d0..595a55f 100644 --- a/src/services/fulfillment_product.ts +++ b/src/services/fulfillment_product.ts @@ -1,4 +1,5 @@ import { randomUUID } from 'node:crypto'; +import { BigNumber } from 'bignumber.js'; import { createClient, createChannel, @@ -838,12 +839,12 @@ export class FulfillmentProductService !!customer.payload.private?.user_id, ) ); - const gross = price.sale ? price.sale_price : price.regular_price; + const gross = new BigNumber(price.sale ? price.sale_price : price.regular_price); const vats = taxes.map((tax): VAT => ({ tax_id: tax.id, - vat: gross * tax.rate, + vat: gross.multipliedBy(tax.rate).decimalPlaces(2).toNumber(), })); - const net = vats.reduce((a, b) => a + b.vat, gross); + const net = vats.reduce((a, b) => a.plus(b.vat), gross).decimalPlaces(2).toNumber(); return { id: randomUUID(), @@ -862,7 +863,7 @@ export class FulfillmentProductService price, amount: { currency_id: price.currency_id, - gross, + gross: gross.toNumber(), net, vats, } diff --git a/src/stubs/dhl_soap.ts b/src/stubs/dhl_soap.ts index ba979d4..c511584 100644 --- a/src/stubs/dhl_soap.ts +++ b/src/stubs/dhl_soap.ts @@ -615,8 +615,6 @@ export class DHLSoap extends Stub { if (config.ordering?.access_token) { client.addHttpHeader('Authorization', `Bearer ${config.ordering.access_token}`); } - - console.log(client.getHttpHeaders()) return client; } ); diff --git a/test/fulfillment-srv-dhl.spec.ts b/test/fulfillment-srv-dhl.spec.ts index 4ca41e6..ee50493 100644 --- a/test/fulfillment-srv-dhl.spec.ts +++ b/test/fulfillment-srv-dhl.spec.ts @@ -295,7 +295,6 @@ describe('Testing Fulfillment Service Cluster:', () => { it(`should submit fulfillment by valid samples: ${sample_name}`, async function() { this.timeout(60000); const response = await fulfillment_client.submit(sample); - console.log(response); should.equal( response?.operationStatus?.code, 200, 'response.operationStatus.code expected to be 200', diff --git a/test/mocks.ts b/test/mocks.ts index 39b0e92..9482169 100644 --- a/test/mocks.ts +++ b/test/mocks.ts @@ -465,7 +465,7 @@ const validFulfillmentProducts: { [key:string]: FulfillmentProductList } = { attributes: [], },{ id: 'urn:restorecommerce:fulfillment:product:attribute:dhl:accountNumber', - value: '22222222220104', + value: '33333333330102', attributes: [], }], variants: [{ @@ -531,7 +531,7 @@ const validFulfillmentProducts: { [key:string]: FulfillmentProductList } = { attributes: [], },{ id: 'urn:restorecommerce:fulfillment:product:attribute:dhl:accountNumber', - value: '22222222220104', + value: '33333333330102', attributes: [], }], variants: [{ @@ -597,7 +597,7 @@ const validFulfillmentProducts: { [key:string]: FulfillmentProductList } = { attributes: [], },{ id: 'urn:restorecommerce:fulfillment:product:attribute:dhl:accountNumber', - value: '22222222220104', + value: '33333333330102', attributes: [], }], variants: [{ @@ -663,7 +663,7 @@ const validFulfillmentProducts: { [key:string]: FulfillmentProductList } = { attributes: [], },{ id: 'urn:restorecommerce:fulfillment:product:attribute:dhl:accountNumber', - value: '22222222220104', + value: '33333333330102', attributes: [], }], variants: [{