@fuzzle/opencode-accountant 0.7.3-next.1 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +13 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -23050,7 +23050,7 @@ function findRulesForCsv(csvPath, mapping) {
|
|
|
23050
23050
|
// src/utils/hledgerExecutor.ts
|
|
23051
23051
|
var {$: $2 } = globalThis.Bun;
|
|
23052
23052
|
var STDERR_TRUNCATE_LENGTH = 500;
|
|
23053
|
-
var TX_HEADER_PATTERN = /^(\d{4})-(\d{2}-\d{2})
|
|
23053
|
+
var TX_HEADER_PATTERN = /^(\d{4})-(\d{2}-\d{2})\s+(.+)$/;
|
|
23054
23054
|
async function defaultHledgerExecutor(cmdArgs) {
|
|
23055
23055
|
try {
|
|
23056
23056
|
const result = await $2`hledger ${cmdArgs}`.quiet().nothrow();
|
|
@@ -23088,7 +23088,7 @@ function parseUnknownPostings(hledgerOutput) {
|
|
|
23088
23088
|
const headerMatch = line.match(TX_HEADER_PATTERN);
|
|
23089
23089
|
if (headerMatch) {
|
|
23090
23090
|
currentDate = `${headerMatch[1]}-${headerMatch[2]}`;
|
|
23091
|
-
currentDescription =
|
|
23091
|
+
currentDescription = headerMatch[3].trim();
|
|
23092
23092
|
continue;
|
|
23093
23093
|
}
|
|
23094
23094
|
const postingMatch = line.match(/^\s+(income:unknown|expenses:unknown)\s+([^\s]+(?:\s+[^\s=]+)?)\s*(?:=\s*(.+))?$/);
|
|
@@ -24921,7 +24921,7 @@ async function executeAccountDeclarationsStep(context, contextId, logger) {
|
|
|
24921
24921
|
}
|
|
24922
24922
|
}
|
|
24923
24923
|
if (!transactionYear) {
|
|
24924
|
-
context.result.steps.accountDeclarations = buildStepResult(
|
|
24924
|
+
context.result.steps.accountDeclarations = buildStepResult(false, "Could not determine transaction year from CSV files", {
|
|
24925
24925
|
accountsAdded: [],
|
|
24926
24926
|
journalUpdated: "",
|
|
24927
24927
|
rulesScanned: Array.from(matchedRulesFiles).map((f) => path12.relative(context.directory, f))
|
|
@@ -25064,13 +25064,6 @@ async function executeImportStep(context, contextId, logger) {
|
|
|
25064
25064
|
transactionCount: importParsed.summary?.totalTransactions
|
|
25065
25065
|
});
|
|
25066
25066
|
}
|
|
25067
|
-
const totalTx = importParsed.summary?.totalTransactions ?? 0;
|
|
25068
|
-
const hasNoTransactions = totalTx === 0 && (importParsed.summary?.unknown ?? 0) === 0 && (importParsed.summary?.filesWithErrors ?? 0) === 0;
|
|
25069
|
-
if (hasNoTransactions) {
|
|
25070
|
-
logger?.info("No transactions found for this context");
|
|
25071
|
-
logger?.endSection();
|
|
25072
|
-
throw new NoTransactionsError;
|
|
25073
|
-
}
|
|
25074
25067
|
if (!importParsed.success) {
|
|
25075
25068
|
if (detailsLog) {
|
|
25076
25069
|
logger?.error("Import found unknown accounts or errors");
|
|
@@ -25083,6 +25076,10 @@ async function executeImportStep(context, contextId, logger) {
|
|
|
25083
25076
|
context.result.hint = detailsLog ? "Add rules to categorize unknown transactions, then retry. See details above for suggestions." : undefined;
|
|
25084
25077
|
throw new Error("Import failed");
|
|
25085
25078
|
}
|
|
25079
|
+
if (importParsed.summary?.totalTransactions === 0) {
|
|
25080
|
+
logger?.endSection();
|
|
25081
|
+
throw new NoTransactionsError;
|
|
25082
|
+
}
|
|
25086
25083
|
logger?.endSection();
|
|
25087
25084
|
}
|
|
25088
25085
|
async function executeReconcileStep(context, contextId, logger) {
|
|
@@ -25126,12 +25123,8 @@ async function executeReconcileStep(context, contextId, logger) {
|
|
|
25126
25123
|
logger?.endSection();
|
|
25127
25124
|
}
|
|
25128
25125
|
function handleNoTransactions(result) {
|
|
25129
|
-
|
|
25130
|
-
|
|
25131
|
-
}
|
|
25132
|
-
if (!result.steps.reconcile) {
|
|
25133
|
-
result.steps.reconcile = buildStepResult(true, "Reconciliation skipped (no transactions)");
|
|
25134
|
-
}
|
|
25126
|
+
result.steps.import = buildStepResult(true, "No transactions to import");
|
|
25127
|
+
result.steps.reconcile = buildStepResult(true, "Reconciliation skipped (no transactions)");
|
|
25135
25128
|
return buildPipelineSuccessResult(result, "No transactions found to import");
|
|
25136
25129
|
}
|
|
25137
25130
|
async function importPipeline(directory, agent, options, configLoader = loadImportConfig, hledgerExecutor = defaultHledgerExecutor) {
|
|
@@ -25169,18 +25162,10 @@ async function importPipeline(directory, agent, options, configLoader = loadImpo
|
|
|
25169
25162
|
for (const contextId of contextIds) {
|
|
25170
25163
|
const importContext = loadContext(context.directory, contextId);
|
|
25171
25164
|
logger.info(`Processing: ${importContext.filename} (${importContext.accountNumber || "unknown account"})`);
|
|
25172
|
-
|
|
25173
|
-
|
|
25174
|
-
|
|
25175
|
-
|
|
25176
|
-
totalTransactions += context.result.steps.import?.details?.summary?.totalTransactions || 0;
|
|
25177
|
-
} catch (error45) {
|
|
25178
|
-
if (error45 instanceof NoTransactionsError) {
|
|
25179
|
-
logger.info(`No transactions to import for ${importContext.filename}, skipping`);
|
|
25180
|
-
continue;
|
|
25181
|
-
}
|
|
25182
|
-
throw error45;
|
|
25183
|
-
}
|
|
25165
|
+
await executeAccountDeclarationsStep(context, contextId, logger);
|
|
25166
|
+
await executeImportStep(context, contextId, logger);
|
|
25167
|
+
await executeReconcileStep(context, contextId, logger);
|
|
25168
|
+
totalTransactions += context.result.steps.import?.details?.summary?.totalTransactions || 0;
|
|
25184
25169
|
}
|
|
25185
25170
|
logger.startSection("Summary");
|
|
25186
25171
|
logger.info(`Import completed successfully`);
|