@actual-app/core 26.4.0-nightly.20260404 → 26.4.0
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/package.json
CHANGED
|
@@ -477,46 +477,6 @@ describe('Account sync', () => {
|
|
|
477
477
|
]);
|
|
478
478
|
});
|
|
479
479
|
|
|
480
|
-
test('addTransactions does not override explicitly provided category', async () => {
|
|
481
|
-
const { id: acctId } = await prepareDatabase();
|
|
482
|
-
|
|
483
|
-
await db.insertCategoryGroup({
|
|
484
|
-
id: 'group2',
|
|
485
|
-
name: 'group2',
|
|
486
|
-
});
|
|
487
|
-
const explicitCategoryId = await db.insertCategory({
|
|
488
|
-
id: 'api-cat',
|
|
489
|
-
name: 'API Category',
|
|
490
|
-
cat_group: 'group2',
|
|
491
|
-
});
|
|
492
|
-
const ruleCategoryId = await db.insertCategory({
|
|
493
|
-
id: 'rule-cat',
|
|
494
|
-
name: 'Rule Category',
|
|
495
|
-
cat_group: 'group2',
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
const payeeId = await db.insertPayee({ name: 'P' });
|
|
499
|
-
await insertRule({
|
|
500
|
-
stage: null,
|
|
501
|
-
conditionsOp: 'and',
|
|
502
|
-
conditions: [{ op: 'is', field: 'payee', value: payeeId }],
|
|
503
|
-
actions: [{ op: 'set', field: 'category', value: ruleCategoryId }],
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
await addTransactions(acctId, [
|
|
507
|
-
{
|
|
508
|
-
date: '2017-10-21',
|
|
509
|
-
payee_name: 'P',
|
|
510
|
-
amount: -2947,
|
|
511
|
-
category: explicitCategoryId,
|
|
512
|
-
},
|
|
513
|
-
]);
|
|
514
|
-
|
|
515
|
-
const [addedTransaction] = await getAllTransactions();
|
|
516
|
-
expect(addedTransaction.category).toBe(explicitCategoryId);
|
|
517
|
-
expect(addedTransaction.category).not.toBe(ruleCategoryId);
|
|
518
|
-
});
|
|
519
|
-
|
|
520
480
|
test("reconcile does not merge transactions with different 'imported_id' values", async () => {
|
|
521
481
|
const { id } = await prepareDatabase();
|
|
522
482
|
|
|
@@ -350,9 +350,6 @@ async function normalizeTransactions(
|
|
|
350
350
|
// Strip off the irregular properties
|
|
351
351
|
const { payee_name: originalPayeeName, subtransactions, ...rest } = trans;
|
|
352
352
|
trans = rest;
|
|
353
|
-
const explicitFields = Object.entries(rest)
|
|
354
|
-
.filter(([, value]) => value != null)
|
|
355
|
-
.map(([field]) => field);
|
|
356
353
|
|
|
357
354
|
let payee_name = originalPayeeName;
|
|
358
355
|
if (payee_name) {
|
|
@@ -379,7 +376,6 @@ async function normalizeTransactions(
|
|
|
379
376
|
|
|
380
377
|
normalized.push({
|
|
381
378
|
payee_name,
|
|
382
|
-
explicitFields,
|
|
383
379
|
subtransactions: subtransactions
|
|
384
380
|
? subtransactions.map(t => ({ ...t, account: acctId }))
|
|
385
381
|
: null,
|
|
@@ -880,28 +876,15 @@ export async function addTransactions(
|
|
|
880
876
|
const accounts: db.DbAccount[] = await db.getAccounts();
|
|
881
877
|
const accountsMap = new Map(accounts.map(account => [account.id, account]));
|
|
882
878
|
|
|
883
|
-
for (const {
|
|
884
|
-
trans: originalTrans,
|
|
885
|
-
subtransactions,
|
|
886
|
-
explicitFields,
|
|
887
|
-
} of normalized) {
|
|
879
|
+
for (const { trans: originalTrans, subtransactions } of normalized) {
|
|
888
880
|
// Run the rules
|
|
889
881
|
const trans = await runRules(originalTrans, accountsMap);
|
|
890
882
|
|
|
891
|
-
// Rules should enrich missing fields but not override explicit values provided by API clients.
|
|
892
|
-
const transWithExplicitFields = { ...trans };
|
|
893
|
-
for (const field of explicitFields) {
|
|
894
|
-
transWithExplicitFields[field] = originalTrans[field];
|
|
895
|
-
}
|
|
896
|
-
|
|
897
883
|
const finalTransaction = {
|
|
898
884
|
id: uuidv4(),
|
|
899
|
-
...
|
|
885
|
+
...trans,
|
|
900
886
|
account: acctId,
|
|
901
|
-
cleared:
|
|
902
|
-
transWithExplicitFields.cleared != null
|
|
903
|
-
? transWithExplicitFields.cleared
|
|
904
|
-
: true,
|
|
887
|
+
cleared: trans.cleared != null ? trans.cleared : true,
|
|
905
888
|
};
|
|
906
889
|
|
|
907
890
|
// Add split transactions if they are given
|