This commit is contained in:
seb
2026-09-24 23:26:50 +02:00
parent 68aadd483b
commit 37828fdef9
13 changed files with 1078 additions and 4 deletions

43
src/db/ledger.js Normal file
View File

@@ -0,0 +1,43 @@
import { getStore } from './store.js';
/**
* Appends a new entry to the append-only ledger table.
*
* @param {number} googleAuthId - The id of the Google auth user.
* @param {object} input - Ledger payload.
* @param {number} input.manifestarticle_id - ID of the referenced manifest article.
* @param {string} input.transaction_type - Transaction type.
* @param {number} input.amount - Movement amount.
* @param {string} input.transaction_text - Transaction text / memo.
* @returns {Promise<object>} The inserted ledger row.
*/
export async function add(googleAuthId, input) {
const store = await getStore();
return store.ledger.add(googleAuthId, input);
}
/**
* Lists ledger entries for a specific manifest article line, optionally filtered by transaction type.
*
* @param {number} googleAuthId - The id of the Google auth user.
* @param {number} manifestarticleId - Manifest line ID.
* @param {string} [transactionType] - Optional transaction type filter.
* @returns {Promise<Array<object>>} List of ledger entries.
*/
export async function listByManifestarticleId(googleAuthId, manifestarticleId, transactionType) {
const store = await getStore();
return store.ledger.listByManifestarticleId(googleAuthId, manifestarticleId, transactionType);
}
/**
* Lists ledger entries for a specific article SKU, optionally filtered by transaction type.
*
* @param {number} googleAuthId - The id of the Google auth user.
* @param {string} sku - Article SKU.
* @param {string} [transactionType] - Optional transaction type filter.
* @returns {Promise<Array<object>>} List of ledger entries.
*/
export async function listBySku(googleAuthId, sku, transactionType) {
const store = await getStore();
return store.ledger.listBySku(googleAuthId, sku, transactionType);
}

View File

@@ -32,6 +32,7 @@ const STORE_NAMESPACES = [
'companysetting',
'articlesupplier',
'manifestattachment',
'ledger',
];
/**