u
This commit is contained in:
@@ -34,6 +34,25 @@ async function run() {
|
||||
});
|
||||
await store.google_auth.setSelectedCompany(googleAuthId, company.id);
|
||||
|
||||
await store.unit.upsert(googleAuthId, {
|
||||
si: 'stk',
|
||||
basesi: 'stk',
|
||||
basesifactor: 1,
|
||||
symbol: 'Stk',
|
||||
name: 'Stück',
|
||||
});
|
||||
const supplier = await store.supplier.create(googleAuthId, { name: 'Supplier X' });
|
||||
const article = await store.article.createUnderParent({
|
||||
googleAuthId,
|
||||
parentId: company.rootCategoryId,
|
||||
name: 'Ledger Linked Article',
|
||||
});
|
||||
await store.articlesupplier.create(googleAuthId, article.sku, {
|
||||
entityId: supplier.id,
|
||||
sku: 'SKU-ABC',
|
||||
pu: 1,
|
||||
});
|
||||
|
||||
// Create a delivery manifest with lines
|
||||
const delivery = await store.delivery.create(googleAuthId, {
|
||||
externalNumber: 'DEL-1',
|
||||
@@ -193,16 +212,14 @@ async function run() {
|
||||
const listUnknownSku = await store.ledger.listBySku(googleAuthId, 'UNKNOWN-SKU');
|
||||
assert.equal(listUnknownSku.length, 0);
|
||||
|
||||
// 7. Test validation & company authorization
|
||||
console.log('6. Testing authorization & validation errors...');
|
||||
await assert.rejects(
|
||||
() => store.ledger.listByManifestarticleId(googleAuthId, 999999),
|
||||
/Manifest article not found/,
|
||||
);
|
||||
await assert.rejects(
|
||||
() => store.ledger.listBySku(googleAuthId, ''),
|
||||
/Invalid SKU/,
|
||||
);
|
||||
// 8. Test article history created from ledger
|
||||
console.log('7. Testing article history entries from ledger rows...');
|
||||
const history = await store.article.getHistoryBySku(googleAuthId, article.sku);
|
||||
const historyTexts = history.map((h) => h.text);
|
||||
console.log('Article history texts:', historyTexts);
|
||||
assert(historyTexts.includes('Initial delivery movement'), 'History should include initial delivery movement');
|
||||
assert(historyTexts.includes('Damaged item written off'), 'History should include damaged item written off');
|
||||
assert(historyTexts.includes('Second line goods receipt'), 'History should include second line goods receipt');
|
||||
|
||||
console.log('✓ All ledger tests passed successfully!');
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user