@actual-app/api 6.8.0 → 6.8.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.
@@ -12,7 +12,7 @@ declare function SplitTransactionError(total: number, parent: TransactionEntity)
12
12
  difference: number;
13
13
  };
14
14
  type GenericTransactionEntity = NewTransactionEntity | TransactionEntity | TransactionEntityWithError;
15
- export declare function makeChild<T extends GenericTransactionEntity>(parent: T, data: object): T;
15
+ export declare function makeChild<T extends GenericTransactionEntity>(parent: T, data?: object): T;
16
16
  export declare function recalculateSplit(trans: TransactionEntity): TransactionEntityWithError;
17
17
  export declare function ungroupTransactions(transactions: TransactionEntity[]): TransactionEntity[];
18
18
  export declare function groupTransaction(split: TransactionEntity[]): TransactionEntity;
@@ -54,7 +54,7 @@ export declare function deleteTransaction(transactions: TransactionEntity[], id:
54
54
  newTransaction: TransactionEntityWithError | TransactionEntity;
55
55
  diff: any;
56
56
  };
57
- export declare function splitTransaction(transactions: TransactionEntity[], id: string): {
57
+ export declare function splitTransaction(transactions: TransactionEntity[], id: string, createSubtransactions?: (parentTransaction: TransactionEntity) => TransactionEntity[]): {
58
58
  data: any[];
59
59
  diff: {
60
60
  deleted: any[];
@@ -79,6 +79,7 @@ export type IntervalEntity = {
79
79
  date?: string;
80
80
  change?: number;
81
81
  intervalStartDate?: string;
82
+ intervalEndDate?: string;
82
83
  totalAssets: number;
83
84
  totalDebts: number;
84
85
  totalTotals: number;
@@ -5,8 +5,7 @@ export type FeatureFlag =
5
5
  | 'goalTemplatesEnabled'
6
6
  | 'customReports'
7
7
  | 'spendingReport'
8
- | 'simpleFinSync'
9
- | 'splitsInRules';
8
+ | 'simpleFinSync';
10
9
 
11
10
  export type LocalPrefs = Partial<
12
11
  {
@@ -26370,18 +26370,17 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
26370
26370
  /* harmony export */ rankRules: () => ( /* binding */rankRules)
26371
26371
  /* harmony export */
26372
26372
  });
26373
- /* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! date-fns */ "./node_modules/date-fns/esm/isValid/index.js");
26374
- /* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! date-fns */ "./node_modules/date-fns/esm/parseISO/index.js");
26375
- /* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! date-fns */ "./node_modules/date-fns/esm/subDays/index.js");
26376
- /* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! date-fns */ "./node_modules/date-fns/esm/addDays/index.js");
26373
+ /* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! date-fns */ "./node_modules/date-fns/esm/isValid/index.js");
26374
+ /* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! date-fns */ "./node_modules/date-fns/esm/parseISO/index.js");
26375
+ /* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! date-fns */ "./node_modules/date-fns/esm/subDays/index.js");
26376
+ /* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! date-fns */ "./node_modules/date-fns/esm/addDays/index.js");
26377
26377
  /* harmony import */ var _shared_months__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../shared/months */ "./packages/loot-core/src/shared/months.ts");
26378
26378
  /* harmony import */ var _shared_rules__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../shared/rules */ "./packages/loot-core/src/shared/rules.ts");
26379
26379
  /* harmony import */ var _shared_schedules__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../shared/schedules */ "./packages/loot-core/src/shared/schedules.ts");
26380
26380
  /* harmony import */ var _shared_transactions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../shared/transactions */ "./packages/loot-core/src/shared/transactions.ts");
26381
26381
  /* harmony import */ var _shared_util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../shared/util */ "./packages/loot-core/src/shared/util.ts");
26382
26382
  /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../errors */ "./packages/loot-core/src/server/errors.ts");
26383
- /* harmony import */ var _prefs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../prefs */ "./packages/loot-core/src/server/prefs.ts");
26384
- /* harmony import */ var _util_rschedule__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../util/rschedule */ "./packages/loot-core/src/server/util/rschedule.ts");
26383
+ /* harmony import */ var _util_rschedule__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../util/rschedule */ "./packages/loot-core/src/server/util/rschedule.ts");
26385
26384
  // @ts-strict-ignore
26386
26385
  function assert(test, type, msg) {
26387
26386
  if (!test) {
@@ -26393,7 +26392,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
26393
26392
  const rules = (0, _shared_schedules__WEBPACK_IMPORTED_MODULE_2__.recurConfigToRSchedule)(desc);
26394
26393
  return {
26395
26394
  type: 'recur',
26396
- schedule: new _util_rschedule__WEBPACK_IMPORTED_MODULE_7__.Schedule({
26395
+ schedule: new _util_rschedule__WEBPACK_IMPORTED_MODULE_6__.Schedule({
26397
26396
  rrules: rules,
26398
26397
  data: {
26399
26398
  skipWeekend: desc.skipWeekend,
@@ -26412,7 +26411,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
26412
26411
  }
26413
26412
  else if (str.length === 10) {
26414
26413
  // YYYY-MM-DD
26415
- if (!date_fns__WEBPACK_IMPORTED_MODULE_8__["default"](date_fns__WEBPACK_IMPORTED_MODULE_9__["default"](str))) {
26414
+ if (!date_fns__WEBPACK_IMPORTED_MODULE_7__["default"](date_fns__WEBPACK_IMPORTED_MODULE_8__["default"](str))) {
26416
26415
  return null;
26417
26416
  }
26418
26417
  return {
@@ -26422,7 +26421,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
26422
26421
  }
26423
26422
  else if (str.length === 7) {
26424
26423
  // YYYY-MM
26425
- if (!date_fns__WEBPACK_IMPORTED_MODULE_8__["default"](date_fns__WEBPACK_IMPORTED_MODULE_9__["default"](str + '-01'))) {
26424
+ if (!date_fns__WEBPACK_IMPORTED_MODULE_7__["default"](date_fns__WEBPACK_IMPORTED_MODULE_8__["default"](str + '-01'))) {
26426
26425
  return null;
26427
26426
  }
26428
26427
  return {
@@ -26432,7 +26431,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
26432
26431
  }
26433
26432
  else if (str.length === 4) {
26434
26433
  // YYYY
26435
- if (!date_fns__WEBPACK_IMPORTED_MODULE_8__["default"](date_fns__WEBPACK_IMPORTED_MODULE_9__["default"](str + '-01-01'))) {
26434
+ if (!date_fns__WEBPACK_IMPORTED_MODULE_7__["default"](date_fns__WEBPACK_IMPORTED_MODULE_8__["default"](str + '-01-01'))) {
26436
26435
  return null;
26437
26436
  }
26438
26437
  return {
@@ -26611,7 +26610,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
26611
26610
  const { schedule } = this.value;
26612
26611
  if (this.op === 'isapprox') {
26613
26612
  const fieldDate = (0, _shared_months__WEBPACK_IMPORTED_MODULE_0__.parseDate)(fieldValue);
26614
- return schedule.occursBetween(date_fns__WEBPACK_IMPORTED_MODULE_10__["default"](fieldDate, 2), date_fns__WEBPACK_IMPORTED_MODULE_11__["default"](fieldDate, 2));
26613
+ return schedule.occursBetween(date_fns__WEBPACK_IMPORTED_MODULE_9__["default"](fieldDate, 2), date_fns__WEBPACK_IMPORTED_MODULE_10__["default"](fieldDate, 2));
26615
26614
  }
26616
26615
  else {
26617
26616
  return schedule.occursOn({
@@ -26797,7 +26796,8 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
26797
26796
  const childActions = actions.filter((action) => action.options?.splitIndex);
26798
26797
  const totalSplitCount = actions.reduce((prev, cur) => Math.max(prev, cur.options?.splitIndex ?? 0), 0) + 1;
26799
26798
  let update = execNonSplitActions(parentActions, transaction);
26800
- if (!_prefs__WEBPACK_IMPORTED_MODULE_6__.getPrefs()?.['flags.splitsInRules'] || totalSplitCount === 1) {
26799
+ if (totalSplitCount === 1) {
26800
+ // No splits, no need to do anything else.
26801
26801
  return update;
26802
26802
  }
26803
26803
  if (update.is_child) {
@@ -27487,7 +27487,14 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
27487
27487
  // matched transaction. See the final pass below for the needed
27488
27488
  // fields.
27489
27489
  fuzzyDataset = await _db__WEBPACK_IMPORTED_MODULE_4__.all(`SELECT id, is_parent, date, imported_id, payee, category, notes, reconciled FROM v_transactions
27490
- WHERE date >= ? AND date <= ? AND amount = ? AND account = ?`, [
27490
+ WHERE
27491
+ -- If both ids are set, and we didn't match earlier then skip dedup
27492
+ ( imported_id IS NULL OR ? IS NULL )
27493
+ -- Look 7 days ahead, 7 days behind
27494
+ AND date >= ? AND date <= ? AND amount = ?
27495
+ AND account = ?
27496
+ `, [
27497
+ trans.imported_id || null,
27491
27498
  _db__WEBPACK_IMPORTED_MODULE_4__.toDateRepr(_shared_months__WEBPACK_IMPORTED_MODULE_1__.subDays(trans.date, 7)),
27492
27499
  _db__WEBPACK_IMPORTED_MODULE_4__.toDateRepr(_shared_months__WEBPACK_IMPORTED_MODULE_1__.addDays(trans.date, 7)),
27493
27500
  trans.amount || 0,
@@ -36867,6 +36874,9 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
36867
36874
  else if (cat.category_group_id === findIdByName(data.category_groups, 'Credit Card Payments')) {
36868
36875
  return 'creditCard';
36869
36876
  }
36877
+ else if (cat.category_group_id === findIdByName(data.category_groups, 'Income')) {
36878
+ return 'income';
36879
+ }
36870
36880
  }
36871
36881
  // Can't be done in parallel to have
36872
36882
  // correct sort order.
@@ -36874,13 +36884,17 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
36874
36884
  if (!group.deleted) {
36875
36885
  let groupId;
36876
36886
  // Ignores internal category and credit cards
36877
- if (!equalsIgnoreCase(group.name, 'Internal Master Category') && !equalsIgnoreCase(group.name, 'Credit Card Payments')) {
36887
+ if (!equalsIgnoreCase(group.name, 'Internal Master Category') && !equalsIgnoreCase(group.name, 'Credit Card Payments') && !equalsIgnoreCase(group.name, 'Income')) {
36878
36888
  groupId = await _actual_app_api_methods__WEBPACK_IMPORTED_MODULE_0__.createCategoryGroup({
36879
36889
  name: group.name,
36880
36890
  is_income: false
36881
36891
  });
36882
36892
  entityIdMap.set(group.id, groupId);
36883
36893
  }
36894
+ if (equalsIgnoreCase(group.name, 'Income')) {
36895
+ groupId = incomeCatId;
36896
+ entityIdMap.set(group.id, groupId);
36897
+ }
36884
36898
  const cats = data.categories.filter((cat) => cat.category_group_id === group.id);
36885
36899
  for (const cat of cats.reverse()) {
36886
36900
  if (!cat.deleted) {
@@ -44701,7 +44715,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
44701
44715
  difference
44702
44716
  };
44703
44717
  }
44704
- function makeChild(parent, data) {
44718
+ function makeChild(parent, data = {}) {
44705
44719
  const prefix = parent.id === 'temp' ? 'temp' : '';
44706
44720
  return {
44707
44721
  amount: 0,
@@ -44920,21 +44934,22 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
44920
44934
  }
44921
44935
  });
44922
44936
  }
44923
- function splitTransaction(transactions, id) {
44937
+ function splitTransaction(transactions, id, createSubtransactions) {
44924
44938
  return replaceTransactions(transactions, id, (trans) => {
44925
44939
  if (trans.is_parent || trans.is_child) {
44926
44940
  return trans;
44927
44941
  }
44942
+ const subtransactions = createSubtransactions?.(trans) || [
44943
+ makeChild(trans)
44944
+ ];
44928
44945
  return {
44929
44946
  ...trans,
44930
44947
  is_parent: true,
44931
44948
  error: num(trans.amount) === 0 ? null : SplitTransactionError(0, trans),
44932
- subtransactions: [
44933
- makeChild(trans, {
44934
- amount: 0,
44935
- sort_order: -1
44936
- })
44937
- ]
44949
+ subtransactions: subtransactions.map((t) => ({
44950
+ ...t,
44951
+ sort_order: t.sort_order || -1
44952
+ }))
44938
44953
  };
44939
44954
  });
44940
44955
  }
@@ -45331,9 +45346,9 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
45331
45346
  if (amount.startsWith('(') && amount.endsWith(')')) {
45332
45347
  amount = amount.replace('(', '-').replace(')', '');
45333
45348
  }
45334
- //look for a decimal marker, then look for either 5 or 1-2 decimal places.
45349
+ // Look for a decimal marker, then look for either 1-2 or 5-9 decimal places.
45335
45350
  // This avoids matching against 3 places which may not actually be decimal
45336
- const m = amount.match(/[.,]([^.,]{5}|[^.,]{1,2})$/);
45351
+ const m = amount.match(/[.,]([^.,]{5,9}|[^.,]{1,2})$/);
45337
45352
  if (!m || m.index === undefined || m.index === 0) {
45338
45353
  return safeNumber(parseFloat(extractNumbers(amount)));
45339
45354
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actual-app/api",
3
- "version": "6.8.0",
3
+ "version": "6.8.1",
4
4
  "license": "MIT",
5
5
  "description": "An API for Actual",
6
6
  "engines": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actual-app/api",
3
- "version": "6.8.0",
3
+ "version": "6.8.1",
4
4
  "license": "MIT",
5
5
  "description": "An API for Actual",
6
6
  "engines": {
@@ -22,7 +22,7 @@
22
22
  "clean": "rm -rf dist @types"
23
23
  },
24
24
  "dependencies": {
25
- "@actual-app/crdt": "workspace:^",
25
+ "@actual-app/crdt": "^2.1.0",
26
26
  "better-sqlite3": "^9.6.0",
27
27
  "compare-versions": "^6.1.0",
28
28
  "node-fetch": "^3.3.2",
@@ -37,4 +37,4 @@
37
37
  "tsc-alias": "^1.8.8",
38
38
  "typescript": "^5.0.2"
39
39
  }
40
- }
40
+ }