u
This commit is contained in:
@@ -391,13 +391,15 @@ export function createChunkListAutomat({
|
||||
? res.items
|
||||
: Array.isArray(res?.history)
|
||||
? res.history
|
||||
: Array.isArray(res?.rows)
|
||||
? res.rows
|
||||
: Array.isArray(res?.entries)
|
||||
? res.entries
|
||||
: Array.isArray(res)
|
||||
? res
|
||||
: [];
|
||||
: Array.isArray(res?.ledger)
|
||||
? res.ledger
|
||||
: Array.isArray(res?.rows)
|
||||
? res.rows
|
||||
: Array.isArray(res?.entries)
|
||||
? res.entries
|
||||
: Array.isArray(res)
|
||||
? res
|
||||
: [];
|
||||
const total = Number(res?.total ?? res?.totalRows ?? res?.totalCount ?? records.length);
|
||||
const unfilteredTotal = res?.unfilteredTotal != null ? Number(res.unfilteredTotal) : total;
|
||||
return { records, total, unfilteredTotal };
|
||||
|
||||
@@ -191,6 +191,7 @@ export {
|
||||
|
||||
export { default as articleHistoryGridAutomat } from './articleHistoryAutomat';
|
||||
export { default as globalHistoryAutomat, globalHistoryGridAutomat } from './globalHistoryAutomat';
|
||||
export { default as ledgerHistoryAutomat, ledgerHistoryGridAutomat } from './ledgerHistoryAutomat';
|
||||
|
||||
export { default as chatAutomat } from './chatAutomat';
|
||||
export {
|
||||
|
||||
26
src/automats/ledgerHistoryAutomat.js
Normal file
26
src/automats/ledgerHistoryAutomat.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @file ledgerHistoryAutomat.js
|
||||
* @description Double-buffered chunk list automat (`ledgerHistoryAutomat`) for
|
||||
* append-only ledger transactions and stock journal with multi-filter caching and LRU eviction.
|
||||
*
|
||||
* Upstream Triggers:
|
||||
* - `authAutomat`: Subscribes to auth state changes — resets on `'anon'` or when
|
||||
* `selectedCompanyId` changes.
|
||||
* - Consumer UI: Calls `getItems()`, `requireChunk(start, end)`, `filter(search)`,
|
||||
* `addSeekMonth()`, `addSeekYear()`, `resetNegativeSeek()`.
|
||||
*/
|
||||
|
||||
import { createChunkListAutomat } from './createChunkListAutomat';
|
||||
import { ledger } from '../api';
|
||||
|
||||
export const ledgerHistoryAutomat = createChunkListAutomat({
|
||||
name: 'ledgerHistory',
|
||||
chunkSize: 50,
|
||||
maxLruChunks: 50,
|
||||
fetchPage: (params) => ledger.getHistory(params),
|
||||
});
|
||||
|
||||
// Alias for consistency with other grid/chunk automats
|
||||
export const ledgerHistoryGridAutomat = ledgerHistoryAutomat;
|
||||
|
||||
export default ledgerHistoryAutomat;
|
||||
Reference in New Issue
Block a user