@fuzzle/opencode-accountant 0.15.1-next.1 → 0.16.0-next.1
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 +8 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -24035,7 +24035,7 @@ function buildRetryCommand(contextId, closingBalance, account) {
|
|
|
24035
24035
|
}
|
|
24036
24036
|
return parts.join(" ");
|
|
24037
24037
|
}
|
|
24038
|
-
function determineAccount(csvFile, rulesDir, importContext, manualAccount, relativeCsvPath, metadata) {
|
|
24038
|
+
function determineAccount(csvFile, rulesDir, directory, importContext, manualAccount, relativeCsvPath, metadata) {
|
|
24039
24039
|
let account = manualAccount;
|
|
24040
24040
|
const rulesMapping = loadRulesMapping(rulesDir);
|
|
24041
24041
|
const rulesFile = findRulesForCsv(csvFile, rulesMapping);
|
|
@@ -24043,6 +24043,12 @@ function determineAccount(csvFile, rulesDir, importContext, manualAccount, relat
|
|
|
24043
24043
|
if (rulesFile) {
|
|
24044
24044
|
account = getAccountFromRulesFile(rulesFile) ?? undefined;
|
|
24045
24045
|
}
|
|
24046
|
+
if (!account && importContext.rulesFile) {
|
|
24047
|
+
const contextRulesPath = path10.join(directory, importContext.rulesFile);
|
|
24048
|
+
if (fs11.existsSync(contextRulesPath)) {
|
|
24049
|
+
account = getAccountFromRulesFile(contextRulesPath) ?? undefined;
|
|
24050
|
+
}
|
|
24051
|
+
}
|
|
24046
24052
|
}
|
|
24047
24053
|
if (!account) {
|
|
24048
24054
|
const rulesHint = rulesFile ? `Add 'account1 assets:bank:...' to ${rulesFile} or retry with: ${buildRetryCommand(importContext.id, undefined, "assets:bank:...")}` : `Create a rules file in ${rulesDir} with 'account1' directive or retry with: ${buildRetryCommand(importContext.id, undefined, "assets:bank:...")}`;
|
|
@@ -24160,7 +24166,7 @@ async function reconcileStatement(directory, agent, options, configLoader = load
|
|
|
24160
24166
|
return balanceResult.error;
|
|
24161
24167
|
}
|
|
24162
24168
|
const { closingBalance, metadata, fromCSVAnalysis } = balanceResult;
|
|
24163
|
-
const accountResult = determineAccount(csvFile, rulesDir, importContext, options.account, relativeCsvPath, metadata);
|
|
24169
|
+
const accountResult = determineAccount(csvFile, rulesDir, directory, importContext, options.account, relativeCsvPath, metadata);
|
|
24164
24170
|
if ("error" in accountResult) {
|
|
24165
24171
|
return accountResult.error;
|
|
24166
24172
|
}
|
|
@@ -27170,7 +27176,6 @@ async function preprocessIbkr(csvPath, directory, currency, year, lotInventoryPa
|
|
|
27170
27176
|
saveLotInventory(directory, lotInventoryPath, inventory, logger);
|
|
27171
27177
|
let journalFilePath = null;
|
|
27172
27178
|
if (journalEntries.length > 0) {
|
|
27173
|
-
const yearJournalPath = ensureYearJournalExists(directory, year);
|
|
27174
27179
|
const header = `; IBKR ${currency.toUpperCase()} investment transactions for ${year}
|
|
27175
27180
|
; Generated by opencode-accountant
|
|
27176
27181
|
; This file is auto-generated - do not edit manually`;
|
|
@@ -27181,13 +27186,6 @@ async function preprocessIbkr(csvPath, directory, currency, year, lotInventoryPa
|
|
|
27181
27186
|
}
|
|
27182
27187
|
fs22.writeFileSync(journalPath, journalContent);
|
|
27183
27188
|
journalFilePath = journalPath;
|
|
27184
|
-
const yearJournalContent = fs22.readFileSync(yearJournalPath, "utf-8");
|
|
27185
|
-
const includeDirective = `include investments/${path17.basename(journalPath)}`;
|
|
27186
|
-
if (!yearJournalContent.includes(includeDirective)) {
|
|
27187
|
-
fs22.writeFileSync(yearJournalPath, yearJournalContent.trimEnd() + `
|
|
27188
|
-
` + includeDirective + `
|
|
27189
|
-
`);
|
|
27190
|
-
}
|
|
27191
27189
|
if (tradedSymbols.size > 0) {
|
|
27192
27190
|
const commodityJournalPath = path17.join(directory, "ledger", "investments", "commodities.journal");
|
|
27193
27191
|
ensureCommodityDeclarations(commodityJournalPath, tradedSymbols, logger);
|
package/package.json
CHANGED