Files
dashlibstorage/API.ledger.md
2026-10-16 22:09:12 +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 new append-only entry/entries to the ledger table according to manifest rules: - quote / order: no bookings possible (throws error) - delivery: acceptance entry (warehouse_id=null) + warehouse entry (if tracked) in one transaction - shipment: shipment entry (warehouse_id=null, negative amount) + warehouse entry (if tracked) in one transaction - adjustment: single warehouse inventory movement

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 primary ledger row.

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 }]