fix(prestashop): resolve bundle item VAT with fallback (1.1.14)
This commit is contained in:
@@ -160,6 +160,39 @@ test('uses a combination image before the base product cover', async () => {
|
||||
assert.match(url, /ws_key=secret/);
|
||||
});
|
||||
|
||||
test('derives a combination VAT rate from the base product tax calculation and caches it', async t => {
|
||||
const originalFetch = Core.fetch;
|
||||
t.after(() => { Core.fetch = originalFetch; });
|
||||
const urls = [];
|
||||
Core.fetch = async url => {
|
||||
urls.push(url);
|
||||
return response(200, { product: { orbito_price_net: '100.00', orbito_price_gross: '123.00' } });
|
||||
};
|
||||
const api = new PrestashopApi('https://shop.example', 'secret', true, { maxGetAttempts: 1 });
|
||||
const context = { countryId: '1', stateId: '0', postcode: '00-001', currencyId: '2' };
|
||||
|
||||
assert.equal(await api.getProductTaxRate('20', '200', context), 0.23);
|
||||
assert.equal(await api.getProductTaxRate('20', '200', context), 0.23);
|
||||
assert.equal(urls.length, 1);
|
||||
assert.match(urls[0], /products\/20\?/);
|
||||
assert.match(urls[0], /price%5Borbito_price_net%5D%5Buse_tax%5D=0/);
|
||||
assert.match(urls[0], /price%5Borbito_price_gross%5D%5Buse_tax%5D=1/);
|
||||
assert.match(urls[0], /price%5Borbito_price_gross%5D%5Bproduct_attribute%5D=200/);
|
||||
assert.match(urls[0], /price%5Borbito_price_gross%5D%5Bcountry%5D=1/);
|
||||
assert.match(urls[0], /price%5Borbito_price_gross%5D%5Bpostcode%5D=00-001/);
|
||||
});
|
||||
|
||||
test('returns no VAT rate when PrestaShop cannot provide comparable net and gross prices', async t => {
|
||||
const originalFetch = Core.fetch;
|
||||
t.after(() => { Core.fetch = originalFetch; });
|
||||
Core.fetch = async () => response(200, {
|
||||
product: { orbito_price_net: 'invalid', orbito_price_gross: '123.00' },
|
||||
});
|
||||
const api = new PrestashopApi('https://shop.example', 'secret', true, { maxGetAttempts: 1 });
|
||||
|
||||
assert.equal(await api.getProductTaxRate('20', '0', { countryId: '1' }), null);
|
||||
});
|
||||
|
||||
test('collects public customer notes from order, cart and customer thread without cross-order leakage', async t => {
|
||||
const originalFetch = Core.fetch;
|
||||
t.after(() => { Core.fetch = originalFetch; });
|
||||
|
||||
Reference in New Issue
Block a user