Files
dashlibstorage/API.ledger.md
2026-09-26 23:06:05 +02:00

3.8 KiB

ledger

This document is auto-generated from the JSDoc comments in src/store by running npm run api-doc.

ledger.add

Source: src/store/ledger/add.js

Appends a new append-only entry to the ledger table.

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
input object Ledger entry payload.
input.manifestarticle_id number ID of the referenced manifest line (can also pass manifestarticleId).
[input.warehouse_id] `number null`
input.transaction_type string Transaction type (can also pass transactionType).
input.amount number Movement amount.
input.transaction_text string Transaction memo/details (can also pass transactionText).
[tx] object Optional transaction to run within.

Returns

Promise<{id: number, manifestarticle_id: number, warehouse_id: number|null, transaction_type: string, amount: number, transaction_text: string, hash_version: number, prev_hash: string, created_at: string}> — The created ledger row.

Throws

Error — If user not authorized, company not selected, manifest article not found, or input invalid.

Example

const entry = await store.ledger.add(googleAuthId, {
  manifestarticle_id: 1,
  warehouse_id: 1,
  transaction_type: 'DELIVERY',
  amount: 100.5,
  transaction_text: 'Invoice paid',
});

ledger.listByManifestarticleId

Source: src/store/ledger/listByManifestarticleId.js

Lists ledger entries for a specific manifest article line, optionally filtered by transaction type and/or warehouse.

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
manifestarticleId number The id of the manifest article line.
[optionsOrType] `string object`
[tx] object Optional transaction to run within.

Returns

Promise<Array<{id: number, manifestarticle_id: number, warehouse_id: number|null, sku: string|null, transaction_type: string, amount: number, transaction_text: string, hash_version: number, prev_hash: string, created_at: string}>>

Throws

Error — If user not authorized, company not selected, or manifest article not found.

Example

const entries = await store.ledger.listByManifestarticleId(googleAuthId, 42, 'DELIVERY');
// => [{ id, manifestarticle_id, warehouse_id, sku, transaction_type, amount, transaction_text, hash_version, prev_hash, created_at }]

ledger.listBySku

Source: src/store/ledger/listBySku.js

Lists ledger entries for a given article SKU, optionally filtered by transaction type and/or warehouse.

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
sku string The article SKU.
[optionsOrType] `string object`
[tx] object Optional transaction to run within.

Returns

Promise<Array<{id: number, manifestarticle_id: number, warehouse_id: number|null, sku: string|null, transaction_type: string, amount: number, transaction_text: string, hash_version: number, prev_hash: string, created_at: string}>>

Throws

Error — If user not authorized, company not selected, or SKU invalid.

Example

const entries = await store.ledger.listBySku(googleAuthId, 'SKU-001', 'DELIVERY');
// => [{ id, manifestarticle_id, warehouse_id, sku, transaction_type, amount, transaction_text, hash_version, prev_hash, created_at }]