Files
dashback/src/db/ledger.js
2026-10-18 03:15:23 +02:00

42 lines
1.5 KiB
JavaScript

import { getStore } from './store.js';
/**
* 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);
}
/**
* Lists ledger entries across all articles with pagination, seekMonths, and search.
*
* @param {number} googleAuthId - The id of the Google auth user.
* @param {object} [opts] - Query options.
* @returns {Promise<object>} Paged ledger history.
*/
export async function listHistory(googleAuthId, opts) {
const store = await getStore();
return store.ledger.listHistory(googleAuthId, opts);
}