u
This commit is contained in:
@@ -651,4 +651,47 @@ describe('store.article', () => {
|
||||
assert.deepEqual(untouched.eans, []);
|
||||
});
|
||||
});
|
||||
|
||||
describe('supplier incoming deliveries', () => {
|
||||
it('returns incoming dates and unbooked amounts for each supplier', async () => {
|
||||
const art = await createArticle(store, tenant, { name: 'Incoming Article', sku: 'INC-ART-1' });
|
||||
const supp = await store.supplier.create(gid, { name: 'Supplier Incoming' });
|
||||
await store.articlesupplier.create(gid, art.sku, {
|
||||
entityId: supp.id,
|
||||
sku: 'SUP-SKU-1',
|
||||
pu: 10,
|
||||
});
|
||||
|
||||
let res = await store.article.getBySku(gid, art.sku);
|
||||
assert.equal(res.article.suppliers.length, 1);
|
||||
assert.deepEqual(res.article.suppliers[0].incoming, []);
|
||||
|
||||
const d1 = await store.delivery.create(gid, {
|
||||
supplierId: supp.id,
|
||||
date: '2026-11-01T00:00:00.000Z',
|
||||
lines: [{ sku: 'SUP-SKU-1', name: 'Item', pu: 10, amount: 25, net: 5, taxrate: 19 }],
|
||||
});
|
||||
|
||||
const d2 = await store.delivery.create(gid, {
|
||||
supplierId: supp.id,
|
||||
date: '2026-11-15T00:00:00.000Z',
|
||||
lines: [{ sku: 'SUP-SKU-1', name: 'Item', pu: 10, amount: 15, net: 5, taxrate: 19 }],
|
||||
});
|
||||
|
||||
res = await store.article.getBySku(gid, art.sku);
|
||||
assert.equal(res.article.suppliers[0].incoming.length, 2);
|
||||
assert.equal(res.article.suppliers[0].incoming[0].amount, 25);
|
||||
assert.equal(res.article.suppliers[0].incoming[0].date, '2026-11-01T00:00:00.000Z');
|
||||
assert.equal(res.article.suppliers[0].incoming[1].amount, 15);
|
||||
assert.equal(res.article.suppliers[0].incoming[1].date, '2026-11-15T00:00:00.000Z');
|
||||
|
||||
const wh = await store.warehouse.create(gid, { name: 'Inc WH' });
|
||||
await store.stock.accept(gid, { deliveryId: d1.id, warehouseId: wh.id });
|
||||
|
||||
res = await store.article.getBySku(gid, art.sku);
|
||||
assert.equal(res.article.suppliers[0].incoming.length, 1);
|
||||
assert.equal(res.article.suppliers[0].incoming[0].amount, 15);
|
||||
assert.equal(res.article.suppliers[0].incoming[0].date, '2026-11-15T00:00:00.000Z');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user