@actual-app/api 6.4.0 → 6.5.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/dist/app/bundle.api.js +815 -623
- package/dist/app/query.js +2 -1
- package/dist/index.js +6 -1
- package/dist/methods.js +2 -9
- package/dist/methods.test.js +74 -0
- package/dist/migrations/1632571489012_remove_cache.js +1 -1
- package/dist/migrations/1704572023730_add_account_sync_source.sql +5 -0
- package/dist/migrations/1704572023731_add_missing_goCardless_sync_source.sql +9 -0
- package/dist/package.json +10 -8
- package/package.json +10 -8
- package/dist/app/bundle.api.d.ts +0 -6
- package/dist/app/query.d.ts +0 -19
- package/dist/index.d.ts +0 -6
- package/dist/injected.d.ts +0 -2
- package/dist/jest.config.d.ts +0 -9
- package/dist/methods.d.ts +0 -39
- package/dist/methods.test.d.ts +0 -1
- package/dist/migrations/1632571489012_remove_cache.d.ts +0 -1
- package/dist/utils.d.ts +0 -2
- package/dist/validateNodeVersion.d.ts +0 -1
package/dist/app/bundle.api.js
CHANGED
|
@@ -26821,7 +26821,7 @@
|
|
|
26821
26821
|
"use strict";
|
|
26822
26822
|
__webpack_require__.r(__webpack_exports__);
|
|
26823
26823
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
26824
|
-
/* harmony export */
|
|
26824
|
+
/* harmony export */ q: () => ( /* binding */q)
|
|
26825
26825
|
/* harmony export */
|
|
26826
26826
|
});
|
|
26827
26827
|
function _array_like_to_array(arr, len) {
|
|
@@ -27108,9 +27108,9 @@
|
|
|
27108
27108
|
}
|
|
27109
27109
|
/***/
|
|
27110
27110
|
}),
|
|
27111
|
-
/***/ "./packages/api/methods.
|
|
27111
|
+
/***/ "./packages/api/methods.ts":
|
|
27112
27112
|
/*!*********************************!*\
|
|
27113
|
-
!*** ./packages/api/methods.
|
|
27113
|
+
!*** ./packages/api/methods.ts ***!
|
|
27114
27114
|
\*********************************/
|
|
27115
27115
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
27116
27116
|
"use strict";
|
|
@@ -27129,7 +27129,6 @@
|
|
|
27129
27129
|
/* harmony export */ deletePayee: () => ( /* binding */deletePayee),
|
|
27130
27130
|
/* harmony export */ deleteTransaction: () => ( /* binding */deleteTransaction),
|
|
27131
27131
|
/* harmony export */ downloadBudget: () => ( /* binding */downloadBudget),
|
|
27132
|
-
/* harmony export */ filterTransactions: () => ( /* binding */filterTransactions),
|
|
27133
27132
|
/* harmony export */ getAccounts: () => ( /* binding */getAccounts),
|
|
27134
27133
|
/* harmony export */ getBudgetMonth: () => ( /* binding */getBudgetMonth),
|
|
27135
27134
|
/* harmony export */ getBudgetMonths: () => ( /* binding */getBudgetMonths),
|
|
@@ -27138,7 +27137,7 @@
|
|
|
27138
27137
|
/* harmony export */ getTransactions: () => ( /* binding */getTransactions),
|
|
27139
27138
|
/* harmony export */ importTransactions: () => ( /* binding */importTransactions),
|
|
27140
27139
|
/* harmony export */ loadBudget: () => ( /* binding */loadBudget),
|
|
27141
|
-
/* harmony export */ q: () => ( /* reexport safe */_app_query__WEBPACK_IMPORTED_MODULE_1__
|
|
27140
|
+
/* harmony export */ q: () => ( /* reexport safe */_app_query__WEBPACK_IMPORTED_MODULE_1__.q),
|
|
27142
27141
|
/* harmony export */ reopenAccount: () => ( /* binding */reopenAccount),
|
|
27143
27142
|
/* harmony export */ runImport: () => ( /* binding */runImport),
|
|
27144
27143
|
/* harmony export */ runQuery: () => ( /* binding */runQuery),
|
|
@@ -27154,6 +27153,7 @@
|
|
|
27154
27153
|
});
|
|
27155
27154
|
/* harmony import */ var _injected__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./injected */ "./packages/api/injected.js");
|
|
27156
27155
|
/* harmony import */ var _app_query__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./app/query */ "./packages/api/app/query.js");
|
|
27156
|
+
// @ts-strict-ignore
|
|
27157
27157
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
27158
27158
|
try {
|
|
27159
27159
|
var info = gen[key](arg);
|
|
@@ -27501,12 +27501,6 @@
|
|
|
27501
27501
|
endDate: endDate
|
|
27502
27502
|
});
|
|
27503
27503
|
}
|
|
27504
|
-
function filterTransactions(accountId, text) {
|
|
27505
|
-
return send("api/transactions-filter", {
|
|
27506
|
-
accountId: accountId,
|
|
27507
|
-
text: text
|
|
27508
|
-
});
|
|
27509
|
-
}
|
|
27510
27504
|
function updateTransaction(id, fields) {
|
|
27511
27505
|
return send("api/transaction-update", {
|
|
27512
27506
|
id: id,
|
|
@@ -29453,7 +29447,7 @@
|
|
|
29453
29447
|
/* harmony export */ "default": () => ( /* binding */runMigration)
|
|
29454
29448
|
/* harmony export */
|
|
29455
29449
|
});
|
|
29456
|
-
async function runMigration(db
|
|
29450
|
+
async function runMigration(db) {
|
|
29457
29451
|
function getValue(node) {
|
|
29458
29452
|
return node.expr != null ? node.expr : node.cachedValue;
|
|
29459
29453
|
}
|
|
@@ -29610,11 +29604,12 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
29610
29604
|
/* harmony import */ var _shared_months__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../shared/months */ "./packages/loot-core/src/shared/months.ts");
|
|
29611
29605
|
/* harmony import */ var _shared_query__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../shared/query */ "./packages/loot-core/src/shared/query.ts");
|
|
29612
29606
|
/* harmony import */ var _random__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./random */ "./packages/loot-core/src/mocks/random.ts");
|
|
29607
|
+
// @ts-strict-ignore
|
|
29613
29608
|
function pickRandom(list) {
|
|
29614
|
-
return list[Math.floor((0, _random__WEBPACK_IMPORTED_MODULE_11__
|
|
29609
|
+
return list[Math.floor((0, _random__WEBPACK_IMPORTED_MODULE_11__.random)() * list.length) % list.length];
|
|
29615
29610
|
}
|
|
29616
29611
|
function number(start, end) {
|
|
29617
|
-
return start + (end - start) * (0, _random__WEBPACK_IMPORTED_MODULE_11__
|
|
29612
|
+
return start + (end - start) * (0, _random__WEBPACK_IMPORTED_MODULE_11__.random)();
|
|
29618
29613
|
}
|
|
29619
29614
|
function integer(start, end) {
|
|
29620
29615
|
return Math.round(number(start, end));
|
|
@@ -29660,7 +29655,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
29660
29655
|
const transactions = [];
|
|
29661
29656
|
for (let i = 0; i < numTransactions; i++) {
|
|
29662
29657
|
let payee;
|
|
29663
|
-
if ((0, _random__WEBPACK_IMPORTED_MODULE_11__
|
|
29658
|
+
if ((0, _random__WEBPACK_IMPORTED_MODULE_11__.random)() < 0.09) {
|
|
29664
29659
|
payee = incomePayee;
|
|
29665
29660
|
}
|
|
29666
29661
|
else {
|
|
@@ -29678,7 +29673,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
29678
29673
|
amount = integer(50000, 70000);
|
|
29679
29674
|
}
|
|
29680
29675
|
else {
|
|
29681
|
-
amount = integer(0, (0, _random__WEBPACK_IMPORTED_MODULE_11__
|
|
29676
|
+
amount = integer(0, (0, _random__WEBPACK_IMPORTED_MODULE_11__.random)() < 0.05 ? -8000 : -700);
|
|
29682
29677
|
}
|
|
29683
29678
|
const transaction = {
|
|
29684
29679
|
amount,
|
|
@@ -29688,7 +29683,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
29688
29683
|
category: category.id
|
|
29689
29684
|
};
|
|
29690
29685
|
transactions.push(transaction);
|
|
29691
|
-
if ((0, _random__WEBPACK_IMPORTED_MODULE_11__
|
|
29686
|
+
if ((0, _random__WEBPACK_IMPORTED_MODULE_11__.random)() < 0.2) {
|
|
29692
29687
|
const a = Math.round(transaction.amount / 3);
|
|
29693
29688
|
const pick = () => payee === incomePayee ? incomeGroup.categories.find((c) => c.name === 'Income').id : pickRandom(expenseCategories).id;
|
|
29694
29689
|
transaction.subtransactions = [
|
|
@@ -29784,7 +29779,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
29784
29779
|
const transactions = [];
|
|
29785
29780
|
for (let i = 0; i < numTransactions; i++) {
|
|
29786
29781
|
let payee;
|
|
29787
|
-
if ((0, _random__WEBPACK_IMPORTED_MODULE_11__
|
|
29782
|
+
if ((0, _random__WEBPACK_IMPORTED_MODULE_11__.random)() < 0.04) {
|
|
29788
29783
|
payee = incomePayee;
|
|
29789
29784
|
}
|
|
29790
29785
|
else {
|
|
@@ -29854,7 +29849,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
29854
29849
|
const transactions = [];
|
|
29855
29850
|
for (let i = 0; i < numTransactions; i++) {
|
|
29856
29851
|
let payee;
|
|
29857
|
-
if ((0, _random__WEBPACK_IMPORTED_MODULE_11__
|
|
29852
|
+
if ((0, _random__WEBPACK_IMPORTED_MODULE_11__.random)() < 0.3) {
|
|
29858
29853
|
payee = incomePayee;
|
|
29859
29854
|
}
|
|
29860
29855
|
else {
|
|
@@ -30067,26 +30062,26 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30067
30062
|
},
|
|
30068
30063
|
{
|
|
30069
30064
|
name: 'Vanguard 401k',
|
|
30070
|
-
offBudget:
|
|
30065
|
+
offBudget: true
|
|
30071
30066
|
},
|
|
30072
30067
|
{
|
|
30073
30068
|
name: 'Mortgage',
|
|
30074
|
-
offBudget:
|
|
30069
|
+
offBudget: true
|
|
30075
30070
|
},
|
|
30076
30071
|
{
|
|
30077
30072
|
name: 'House Asset',
|
|
30078
|
-
offBudget:
|
|
30073
|
+
offBudget: true
|
|
30079
30074
|
},
|
|
30080
30075
|
{
|
|
30081
30076
|
name: 'Roth IRA',
|
|
30082
|
-
offBudget:
|
|
30077
|
+
offBudget: true
|
|
30083
30078
|
}
|
|
30084
30079
|
];
|
|
30085
|
-
await (0, _server_mutators__WEBPACK_IMPORTED_MODULE_5__.runMutator)(
|
|
30080
|
+
await (0, _server_mutators__WEBPACK_IMPORTED_MODULE_5__.runMutator)(async () => {
|
|
30086
30081
|
for (const account of accounts) {
|
|
30087
30082
|
account.id = await handlers['account-create'](account);
|
|
30088
30083
|
}
|
|
30089
|
-
})
|
|
30084
|
+
});
|
|
30090
30085
|
const payees = [
|
|
30091
30086
|
{
|
|
30092
30087
|
name: 'Starting Balance'
|
|
@@ -30210,7 +30205,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30210
30205
|
for (const group of categoryGroups) {
|
|
30211
30206
|
group.id = await handlers['category-group-create']({
|
|
30212
30207
|
name: group.name,
|
|
30213
|
-
isIncome: group.is_income
|
|
30208
|
+
isIncome: group.is_income
|
|
30214
30209
|
});
|
|
30215
30210
|
for (const category of group.categories) {
|
|
30216
30211
|
category.id = await handlers['category-create']({
|
|
@@ -30255,13 +30250,13 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30255
30250
|
// don't want to show that as it'd be weird. We modify the latest
|
|
30256
30251
|
// deposit transaction to force it to be positive
|
|
30257
30252
|
const primaryAccount = accounts.find((a) => a.name = 'Bank of America');
|
|
30258
|
-
const { data: primaryBalance } = await (0, _server_aql__WEBPACK_IMPORTED_MODULE_1__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_10__
|
|
30253
|
+
const { data: primaryBalance } = await (0, _server_aql__WEBPACK_IMPORTED_MODULE_1__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_10__.q)('transactions').filter({
|
|
30259
30254
|
account: primaryAccount.id
|
|
30260
30255
|
}).calculate({
|
|
30261
30256
|
$sum: '$amount'
|
|
30262
30257
|
}).serialize());
|
|
30263
30258
|
if (primaryBalance < 0) {
|
|
30264
|
-
const { data: results } = await (0, _server_aql__WEBPACK_IMPORTED_MODULE_1__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_10__
|
|
30259
|
+
const { data: results } = await (0, _server_aql__WEBPACK_IMPORTED_MODULE_1__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_10__.q)('transactions').filter({
|
|
30265
30260
|
account: primaryAccount.id,
|
|
30266
30261
|
amount: {
|
|
30267
30262
|
$gt: 0
|
|
@@ -30416,7 +30411,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30416
30411
|
"use strict";
|
|
30417
30412
|
__webpack_require__.r(__webpack_exports__);
|
|
30418
30413
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
30419
|
-
/* harmony export */
|
|
30414
|
+
/* harmony export */ random: () => ( /* binding */random)
|
|
30420
30415
|
/* harmony export */
|
|
30421
30416
|
});
|
|
30422
30417
|
/* harmony import */ var _client_platform__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client/platform */ "./packages/loot-core/src/client/platform.electron.ts");
|
|
@@ -30431,7 +30426,6 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30431
30426
|
return pseudoRandomIterator;
|
|
30432
30427
|
}
|
|
30433
30428
|
const random = _client_platform__WEBPACK_IMPORTED_MODULE_0__.isPlaywright ? pseudoRandom : Math.random;
|
|
30434
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (random);
|
|
30435
30429
|
/***/
|
|
30436
30430
|
}),
|
|
30437
30431
|
/***/ "./packages/loot-core/src/platform/exceptions/index.electron.ts":
|
|
@@ -30449,7 +30443,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30449
30443
|
const captureException = function (exc) {
|
|
30450
30444
|
console.log('[Exception]', exc);
|
|
30451
30445
|
};
|
|
30452
|
-
const captureBreadcrumb = function (
|
|
30446
|
+
const captureBreadcrumb = function () { };
|
|
30453
30447
|
/***/
|
|
30454
30448
|
}),
|
|
30455
30449
|
/***/ "./packages/loot-core/src/platform/server/asyncStorage/index.electron.ts":
|
|
@@ -30474,6 +30468,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30474
30468
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! path */ "path");
|
|
30475
30469
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/ __webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
|
|
30476
30470
|
/* harmony import */ var _fs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../fs */ "./packages/loot-core/src/platform/server/fs/index.electron.ts");
|
|
30471
|
+
// @ts-strict-ignore
|
|
30477
30472
|
const getStorePath = () => (0, path__WEBPACK_IMPORTED_MODULE_1__.join)(_fs__WEBPACK_IMPORTED_MODULE_2__.getDataDir(), 'global-store.json');
|
|
30478
30473
|
let store;
|
|
30479
30474
|
let persisted = true;
|
|
@@ -30551,7 +30546,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30551
30546
|
/* harmony export */
|
|
30552
30547
|
});
|
|
30553
30548
|
const init = function () { };
|
|
30554
|
-
const send = function (
|
|
30549
|
+
const send = function () {
|
|
30555
30550
|
// Nothing
|
|
30556
30551
|
};
|
|
30557
30552
|
const getNumClients = function () {
|
|
@@ -30609,6 +30604,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30609
30604
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! path */ "path");
|
|
30610
30605
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/ __webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
|
|
30611
30606
|
/* harmony import */ var _shared__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shared */ "./packages/loot-core/src/platform/server/fs/shared.ts");
|
|
30607
|
+
// @ts-strict-ignore
|
|
30612
30608
|
let rootPath = path__WEBPACK_IMPORTED_MODULE_1__.join(__dirname, '..', '..', '..', '..');
|
|
30613
30609
|
if (__filename.match('bundle')) {
|
|
30614
30610
|
// The file name is not our filename and indicates that we're in the
|
|
@@ -30751,12 +30747,11 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30751
30747
|
"use strict";
|
|
30752
30748
|
__webpack_require__.r(__webpack_exports__);
|
|
30753
30749
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
30754
|
-
/* harmony export */
|
|
30750
|
+
/* harmony export */ join: () => ( /* reexport safe */path__WEBPACK_IMPORTED_MODULE_0__.join)
|
|
30755
30751
|
/* harmony export */
|
|
30756
30752
|
});
|
|
30757
30753
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! path */ "path");
|
|
30758
30754
|
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
|
|
30759
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (path__WEBPACK_IMPORTED_MODULE_0__.join);
|
|
30760
30755
|
/***/
|
|
30761
30756
|
}),
|
|
30762
30757
|
/***/ "./packages/loot-core/src/platform/server/fs/shared.ts":
|
|
@@ -30773,6 +30768,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30773
30768
|
/* harmony export */
|
|
30774
30769
|
});
|
|
30775
30770
|
/* harmony import */ var _path_join__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./path-join */ "./packages/loot-core/src/platform/server/fs/path-join.electron.ts");
|
|
30771
|
+
// @ts-strict-ignore
|
|
30776
30772
|
let documentDir;
|
|
30777
30773
|
const _setDocumentDir = (dir) => documentDir = dir;
|
|
30778
30774
|
const getDocumentDir = () => {
|
|
@@ -30795,7 +30791,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30795
30791
|
if (id.match(/[^A-Za-z0-9\-_]/)) {
|
|
30796
30792
|
throw new Error(`Invalid budget id “${id}”. Check the id of your budget in the Advanced section of the settings page.`);
|
|
30797
30793
|
}
|
|
30798
|
-
return (0, _path_join__WEBPACK_IMPORTED_MODULE_0__
|
|
30794
|
+
return (0, _path_join__WEBPACK_IMPORTED_MODULE_0__.join)(getDocumentDir(), id);
|
|
30799
30795
|
};
|
|
30800
30796
|
/***/
|
|
30801
30797
|
}),
|
|
@@ -30807,7 +30803,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30807
30803
|
"use strict";
|
|
30808
30804
|
__webpack_require__.r(__webpack_exports__);
|
|
30809
30805
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
30810
|
-
/* harmony export */
|
|
30806
|
+
/* harmony export */ logger: () => ( /* binding */logger)
|
|
30811
30807
|
/* harmony export */
|
|
30812
30808
|
});
|
|
30813
30809
|
const logger = {
|
|
@@ -30818,7 +30814,6 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30818
30814
|
console.warn(...args);
|
|
30819
30815
|
}
|
|
30820
30816
|
};
|
|
30821
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (logger);
|
|
30822
30817
|
/***/
|
|
30823
30818
|
}),
|
|
30824
30819
|
/***/ "./packages/loot-core/src/platform/server/sqlite/index.electron.ts":
|
|
@@ -30844,6 +30839,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30844
30839
|
/* harmony import */ var better_sqlite3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n(better_sqlite3__WEBPACK_IMPORTED_MODULE_0__);
|
|
30845
30840
|
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! uuid */ "./node_modules/uuid/dist/esm-node/v4.js");
|
|
30846
30841
|
/* harmony import */ var _fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../fs */ "./packages/loot-core/src/platform/server/fs/index.electron.ts");
|
|
30842
|
+
// @ts-strict-ignore
|
|
30847
30843
|
function verifyParamTypes(sql, arr) {
|
|
30848
30844
|
arr.forEach((val) => {
|
|
30849
30845
|
if (typeof val !== 'string' && typeof val !== 'number' && val !== null) {
|
|
@@ -30929,9 +30925,11 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30929
30925
|
const db = new (better_sqlite3__WEBPACK_IMPORTED_MODULE_0___default())(pathOrBuffer);
|
|
30930
30926
|
// Define Unicode-aware LOWER and UPPER implementation.
|
|
30931
30927
|
// This is necessary because better-sqlite3 uses SQLite build without ICU support.
|
|
30928
|
+
// @ts-expect-error @types/better-sqlite3 does not support setting strict 3rd argument
|
|
30932
30929
|
db.function('UNICODE_LOWER', {
|
|
30933
30930
|
deterministic: true
|
|
30934
30931
|
}, (arg) => arg?.toLowerCase());
|
|
30932
|
+
// @ts-expect-error @types/better-sqlite3 does not support setting strict 3rd argument
|
|
30935
30933
|
db.function('UNICODE_UPPER', {
|
|
30936
30934
|
deterministic: true
|
|
30937
30935
|
}, (arg) => arg?.toUpperCase());
|
|
@@ -30967,6 +30965,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30967
30965
|
/* harmony import */ var csv_stringify_lib_sync__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n(csv_stringify_lib_sync__WEBPACK_IMPORTED_MODULE_0__);
|
|
30968
30966
|
/* harmony import */ var _shared_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../shared/util */ "./packages/loot-core/src/shared/util.ts");
|
|
30969
30967
|
/* harmony import */ var _aql__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../aql */ "./packages/loot-core/src/server/aql/index.ts");
|
|
30968
|
+
// @ts-strict-ignore
|
|
30970
30969
|
async function exportToCSV(transactions, accounts, categoryGroups, payees) {
|
|
30971
30970
|
const accountNamesById = accounts.reduce((reduced, { id, name }) => {
|
|
30972
30971
|
reduced[id] = name;
|
|
@@ -30980,13 +30979,15 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
30980
30979
|
reduced[id] = name;
|
|
30981
30980
|
return reduced;
|
|
30982
30981
|
}, {});
|
|
30983
|
-
const transactionsForExport = transactions.map(({ account, date, payee, notes, category, amount }) => ({
|
|
30982
|
+
const transactionsForExport = transactions.map(({ account, date, payee, notes, category, amount, cleared, reconciled }) => ({
|
|
30984
30983
|
Account: accountNamesById[account],
|
|
30985
30984
|
Date: date,
|
|
30986
30985
|
Payee: payeeNamesById[payee],
|
|
30987
30986
|
Notes: notes,
|
|
30988
30987
|
Category: categoryNamesById[category],
|
|
30989
|
-
Amount: amount == null ? 0 : (0, _shared_util__WEBPACK_IMPORTED_MODULE_1__.integerToAmount)(amount)
|
|
30988
|
+
Amount: amount == null ? 0 : (0, _shared_util__WEBPACK_IMPORTED_MODULE_1__.integerToAmount)(amount),
|
|
30989
|
+
Cleared: cleared,
|
|
30990
|
+
Reconciled: reconciled
|
|
30990
30991
|
}));
|
|
30991
30992
|
return csv_stringify_lib_sync__WEBPACK_IMPORTED_MODULE_0___default()(transactionsForExport, {
|
|
30992
30993
|
header: true
|
|
@@ -31020,6 +31021,12 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
31020
31021
|
},
|
|
31021
31022
|
{
|
|
31022
31023
|
Amount: 'amount'
|
|
31024
|
+
},
|
|
31025
|
+
{
|
|
31026
|
+
Cleared: 'cleared'
|
|
31027
|
+
},
|
|
31028
|
+
{
|
|
31029
|
+
Reconciled: 'reconciled'
|
|
31023
31030
|
}
|
|
31024
31031
|
]).options({
|
|
31025
31032
|
splits: 'all'
|
|
@@ -31040,7 +31047,8 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
31040
31047
|
Payee: trans.ParentId ? parentsPayees.get(trans.ParentId) : trans.Payee,
|
|
31041
31048
|
Notes: trans.Notes,
|
|
31042
31049
|
Category: trans.Category,
|
|
31043
|
-
Amount: trans.Amount == null ? 0 : (0, _shared_util__WEBPACK_IMPORTED_MODULE_1__.integerToAmount)(trans.Amount)
|
|
31050
|
+
Amount: trans.Amount == null ? 0 : (0, _shared_util__WEBPACK_IMPORTED_MODULE_1__.integerToAmount)(trans.Amount),
|
|
31051
|
+
Cleared: trans.Reconciled === true ? 'Reconciled' : trans.Cleared === true ? 'Cleared' : 'Not cleared'
|
|
31044
31052
|
};
|
|
31045
31053
|
});
|
|
31046
31054
|
return csv_stringify_lib_sync__WEBPACK_IMPORTED_MODULE_0___default()(transactionsForExport, {
|
|
@@ -31071,6 +31079,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
31071
31079
|
/* harmony import */ var _post__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../post */ "./packages/loot-core/src/server/post.ts");
|
|
31072
31080
|
/* harmony import */ var _server_config__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../server-config */ "./packages/loot-core/src/server/server-config.ts");
|
|
31073
31081
|
/* harmony import */ var _sync__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./sync */ "./packages/loot-core/src/server/accounts/sync.ts");
|
|
31082
|
+
// @ts-strict-ignore
|
|
31074
31083
|
async function handoffPublicToken(institution, publicToken) {
|
|
31075
31084
|
const [[, userId], [, key]] = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_0__.multiGet([
|
|
31076
31085
|
'user-id',
|
|
@@ -31170,7 +31179,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
31170
31179
|
return id;
|
|
31171
31180
|
});
|
|
31172
31181
|
// Do an initial sync
|
|
31173
|
-
await _sync__WEBPACK_IMPORTED_MODULE_6__.
|
|
31182
|
+
await _sync__WEBPACK_IMPORTED_MODULE_6__.syncExternalAccount(userId, userKey, id, acct.account_id, bankId);
|
|
31174
31183
|
return id;
|
|
31175
31184
|
}));
|
|
31176
31185
|
}
|
|
@@ -31184,12 +31193,13 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
31184
31193
|
"use strict";
|
|
31185
31194
|
__webpack_require__.r(__webpack_exports__);
|
|
31186
31195
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
31187
|
-
/* harmony export */
|
|
31196
|
+
/* harmony export */ ofx2json: () => ( /* binding */ofx2json)
|
|
31188
31197
|
/* harmony export */
|
|
31189
31198
|
});
|
|
31190
31199
|
/* harmony import */ var xml2js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! xml2js */ "./node_modules/xml2js/lib/xml2js.js");
|
|
31191
31200
|
/* harmony import */ var xml2js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n(xml2js__WEBPACK_IMPORTED_MODULE_0__);
|
|
31192
31201
|
/* harmony import */ var _shared_months__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../shared/months */ "./packages/loot-core/src/shared/months.ts");
|
|
31202
|
+
// @ts-strict-ignore
|
|
31193
31203
|
function sgml2Xml(sgml) {
|
|
31194
31204
|
return sgml.replace(/&/g, '&') // Replace ampersands
|
|
31195
31205
|
.replace(/&/g, '&').replace(/>\s+</g, '><') // remove whitespace inbetween tag close/open
|
|
@@ -31273,7 +31283,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
31273
31283
|
memo: stmtTrn['MEMO']
|
|
31274
31284
|
};
|
|
31275
31285
|
}
|
|
31276
|
-
async function
|
|
31286
|
+
async function ofx2json(ofx) {
|
|
31277
31287
|
// firstly, split into the header attributes and the footer sgml
|
|
31278
31288
|
const contents = ofx.split('<OFX>', 2);
|
|
31279
31289
|
// firstly, parse the headers
|
|
@@ -31318,11 +31328,11 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
31318
31328
|
/* harmony import */ var csv_parse_lib_sync__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! csv-parse/lib/sync */ "./node_modules/csv-parse/lib/sync.js");
|
|
31319
31329
|
/* harmony import */ var csv_parse_lib_sync__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n(csv_parse_lib_sync__WEBPACK_IMPORTED_MODULE_0__);
|
|
31320
31330
|
/* harmony import */ var _platform_server_fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../platform/server/fs */ "./packages/loot-core/src/platform/server/fs/index.electron.ts");
|
|
31321
|
-
/* harmony import */ var
|
|
31322
|
-
/* harmony import */ var
|
|
31323
|
-
/* harmony import */ var
|
|
31324
|
-
|
|
31325
|
-
async function parseFile(filepath, options) {
|
|
31331
|
+
/* harmony import */ var _shared_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../shared/util */ "./packages/loot-core/src/shared/util.ts");
|
|
31332
|
+
/* harmony import */ var _ofx2json__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ofx2json */ "./packages/loot-core/src/server/accounts/ofx2json.ts");
|
|
31333
|
+
/* harmony import */ var _qif2json__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./qif2json */ "./packages/loot-core/src/server/accounts/qif2json.ts");
|
|
31334
|
+
// @ts-strict-ignore
|
|
31335
|
+
async function parseFile(filepath, options = {}) {
|
|
31326
31336
|
const errors = Array();
|
|
31327
31337
|
const m = filepath.match(/\.[^.]*$/);
|
|
31328
31338
|
if (m) {
|
|
@@ -31384,7 +31394,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
31384
31394
|
const contents = await _platform_server_fs__WEBPACK_IMPORTED_MODULE_1__.readFile(filepath);
|
|
31385
31395
|
let data;
|
|
31386
31396
|
try {
|
|
31387
|
-
data = (0,
|
|
31397
|
+
data = (0, _qif2json__WEBPACK_IMPORTED_MODULE_4__.qif2json)(contents);
|
|
31388
31398
|
}
|
|
31389
31399
|
catch (err) {
|
|
31390
31400
|
errors.push({
|
|
@@ -31399,7 +31409,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
31399
31409
|
return {
|
|
31400
31410
|
errors: [],
|
|
31401
31411
|
transactions: data.transactions.map((trans) => ({
|
|
31402
|
-
amount: trans.amount != null ? (0,
|
|
31412
|
+
amount: trans.amount != null ? (0, _shared_util__WEBPACK_IMPORTED_MODULE_2__.looselyParseAmount)(trans.amount) : null,
|
|
31403
31413
|
date: trans.date,
|
|
31404
31414
|
payee_name: trans.payee,
|
|
31405
31415
|
imported_payee: trans.payee,
|
|
@@ -31408,14 +31418,11 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
31408
31418
|
};
|
|
31409
31419
|
}
|
|
31410
31420
|
async function parseOFX(filepath, options) {
|
|
31411
|
-
if (!options?.enableExperimentalOfxParser) {
|
|
31412
|
-
return parseOFXNodeLibOFX(filepath, options);
|
|
31413
|
-
}
|
|
31414
31421
|
const errors = Array();
|
|
31415
31422
|
const contents = await _platform_server_fs__WEBPACK_IMPORTED_MODULE_1__.readFile(filepath);
|
|
31416
31423
|
let data;
|
|
31417
31424
|
try {
|
|
31418
|
-
data = await (0,
|
|
31425
|
+
data = await (0, _ofx2json__WEBPACK_IMPORTED_MODULE_3__.ofx2json)(contents);
|
|
31419
31426
|
}
|
|
31420
31427
|
catch (err) {
|
|
31421
31428
|
errors.push({
|
|
@@ -31443,39 +31450,6 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
31443
31450
|
})
|
|
31444
31451
|
};
|
|
31445
31452
|
}
|
|
31446
|
-
async function parseOFXNodeLibOFX(filepath, options) {
|
|
31447
|
-
const { getOFXTransactions, initModule } = await Promise.resolve( /*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! node-libofx */ "node-libofx", 23));
|
|
31448
|
-
await initModule();
|
|
31449
|
-
const errors = Array();
|
|
31450
|
-
const contents = await _platform_server_fs__WEBPACK_IMPORTED_MODULE_1__.readFile(filepath, 'binary');
|
|
31451
|
-
let data;
|
|
31452
|
-
try {
|
|
31453
|
-
data = getOFXTransactions(contents);
|
|
31454
|
-
}
|
|
31455
|
-
catch (err) {
|
|
31456
|
-
errors.push({
|
|
31457
|
-
message: 'Failed importing file',
|
|
31458
|
-
internal: err.stack
|
|
31459
|
-
});
|
|
31460
|
-
return {
|
|
31461
|
-
errors
|
|
31462
|
-
};
|
|
31463
|
-
}
|
|
31464
|
-
// Banks don't always implement the OFX standard properly
|
|
31465
|
-
// If no payee is available try and fallback to memo
|
|
31466
|
-
const useMemoFallback = options.fallbackMissingPayeeToMemo;
|
|
31467
|
-
return {
|
|
31468
|
-
errors,
|
|
31469
|
-
transactions: data.map((trans) => ({
|
|
31470
|
-
amount: trans.amount,
|
|
31471
|
-
imported_id: trans.fi_id,
|
|
31472
|
-
date: trans.date ? (0, _shared_months__WEBPACK_IMPORTED_MODULE_2__.dayFromDate)(new Date(trans.date * 1000)) : null,
|
|
31473
|
-
payee_name: trans.name || (useMemoFallback ? trans.memo : null),
|
|
31474
|
-
imported_payee: trans.name || (useMemoFallback ? trans.memo : null),
|
|
31475
|
-
notes: !!trans.name || !useMemoFallback ? trans.memo || null : null
|
|
31476
|
-
}))
|
|
31477
|
-
};
|
|
31478
|
-
}
|
|
31479
31453
|
/***/
|
|
31480
31454
|
}),
|
|
31481
31455
|
/***/ "./packages/loot-core/src/server/accounts/payees.ts":
|
|
@@ -31491,6 +31465,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
31491
31465
|
/* harmony export */
|
|
31492
31466
|
});
|
|
31493
31467
|
/* harmony import */ var _db__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../db */ "./packages/loot-core/src/server/db/index.ts");
|
|
31468
|
+
// @ts-strict-ignore
|
|
31494
31469
|
/* eslint-disable import/no-unused-modules */ async function createPayee(description) {
|
|
31495
31470
|
// Check to make sure no payee already exists with exactly the same
|
|
31496
31471
|
// name
|
|
@@ -31532,10 +31507,11 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
31532
31507
|
"use strict";
|
|
31533
31508
|
__webpack_require__.r(__webpack_exports__);
|
|
31534
31509
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
31535
|
-
/* harmony export */
|
|
31510
|
+
/* harmony export */ qif2json: () => ( /* binding */qif2json)
|
|
31536
31511
|
/* harmony export */
|
|
31537
31512
|
});
|
|
31538
|
-
|
|
31513
|
+
// @ts-strict-ignore
|
|
31514
|
+
function qif2json(qif, options = {}) {
|
|
31539
31515
|
const lines = qif.split('\n');
|
|
31540
31516
|
let line = lines.shift();
|
|
31541
31517
|
const type = /!Type:([^$]*)$/.exec(line.trim());
|
|
@@ -31643,6 +31619,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
31643
31619
|
/* harmony import */ var _shared_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../shared/util */ "./packages/loot-core/src/shared/util.ts");
|
|
31644
31620
|
/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../errors */ "./packages/loot-core/src/server/errors.ts");
|
|
31645
31621
|
/* harmony import */ var _util_rschedule__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util/rschedule */ "./packages/loot-core/src/server/util/rschedule.ts");
|
|
31622
|
+
// @ts-strict-ignore
|
|
31646
31623
|
function assert(test, type, msg) {
|
|
31647
31624
|
if (!test) {
|
|
31648
31625
|
throw new _errors__WEBPACK_IMPORTED_MODULE_4__.RuleError(type, msg);
|
|
@@ -32051,14 +32028,14 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
32051
32028
|
return condition.eval(object);
|
|
32052
32029
|
});
|
|
32053
32030
|
}
|
|
32054
|
-
execActions(
|
|
32031
|
+
execActions() {
|
|
32055
32032
|
const changes = {};
|
|
32056
32033
|
this.actions.forEach((action) => action.exec(changes));
|
|
32057
32034
|
return changes;
|
|
32058
32035
|
}
|
|
32059
32036
|
exec(object) {
|
|
32060
32037
|
if (this.evalConditions(object)) {
|
|
32061
|
-
return this.execActions(
|
|
32038
|
+
return this.execActions();
|
|
32062
32039
|
}
|
|
32063
32040
|
return null;
|
|
32064
32041
|
}
|
|
@@ -32338,7 +32315,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
32338
32315
|
/* harmony export */ reconcileGoCardlessTransactions: () => ( /* binding */reconcileGoCardlessTransactions),
|
|
32339
32316
|
/* harmony export */ reconcileTransactions: () => ( /* binding */reconcileTransactions),
|
|
32340
32317
|
/* harmony export */ syncAccount: () => ( /* binding */syncAccount),
|
|
32341
|
-
/* harmony export */
|
|
32318
|
+
/* harmony export */ syncExternalAccount: () => ( /* binding */syncExternalAccount)
|
|
32342
32319
|
/* harmony export */
|
|
32343
32320
|
});
|
|
32344
32321
|
/* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! date-fns */ "./node_modules/date-fns/esm/max/index.js");
|
|
@@ -32358,6 +32335,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
32358
32335
|
/* harmony import */ var _title__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./title */ "./packages/loot-core/src/server/accounts/title/index.ts");
|
|
32359
32336
|
/* harmony import */ var _transaction_rules__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./transaction-rules */ "./packages/loot-core/src/server/accounts/transaction-rules.ts");
|
|
32360
32337
|
/* harmony import */ var _transactions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./transactions */ "./packages/loot-core/src/server/accounts/transactions.ts");
|
|
32338
|
+
// @ts-strict-ignore
|
|
32361
32339
|
// Plaid article about API options:
|
|
32362
32340
|
// https://support.plaid.com/customer/en/portal/articles/2612155-transactions-returned-per-request
|
|
32363
32341
|
function BankSyncError(type, code) {
|
|
@@ -32499,6 +32477,26 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
32499
32477
|
startingBalance
|
|
32500
32478
|
};
|
|
32501
32479
|
}
|
|
32480
|
+
async function downloadSimpleFinTransactions(acctId, since) {
|
|
32481
|
+
const userToken = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_0__.getItem('user-token');
|
|
32482
|
+
if (!userToken)
|
|
32483
|
+
return;
|
|
32484
|
+
const res = await (0, _post__WEBPACK_IMPORTED_MODULE_6__.post)((0, _server_config__WEBPACK_IMPORTED_MODULE_7__.getServer)().SIMPLEFIN_SERVER + '/transactions', {
|
|
32485
|
+
accountId: acctId,
|
|
32486
|
+
startDate: since
|
|
32487
|
+
}, {
|
|
32488
|
+
'X-ACTUAL-TOKEN': userToken
|
|
32489
|
+
});
|
|
32490
|
+
if (res.error_code) {
|
|
32491
|
+
throw BankSyncError(res.error_type, res.error_code);
|
|
32492
|
+
}
|
|
32493
|
+
const { transactions: { all }, balances, startingBalance } = res;
|
|
32494
|
+
return {
|
|
32495
|
+
transactions: all,
|
|
32496
|
+
accountBalance: balances,
|
|
32497
|
+
startingBalance
|
|
32498
|
+
};
|
|
32499
|
+
}
|
|
32502
32500
|
async function resolvePayee(trans, payeeName, payeesToCreate) {
|
|
32503
32501
|
if (trans.payee == null && payeeName) {
|
|
32504
32502
|
// First check our registry of new payees (to avoid a db access)
|
|
@@ -32539,7 +32537,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
32539
32537
|
payee_name = null;
|
|
32540
32538
|
}
|
|
32541
32539
|
else {
|
|
32542
|
-
payee_name = rawPayeeName ? trimmed : (0, _title__WEBPACK_IMPORTED_MODULE_10__
|
|
32540
|
+
payee_name = rawPayeeName ? trimmed : (0, _title__WEBPACK_IMPORTED_MODULE_10__.title)(trimmed);
|
|
32543
32541
|
}
|
|
32544
32542
|
}
|
|
32545
32543
|
trans.imported_payee = trans.imported_payee || payee_name;
|
|
@@ -32583,7 +32581,10 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
32583
32581
|
// that it matters whether the amount is a positive or negative zero.
|
|
32584
32582
|
if (trans.amount > 0 || Object.is(Number(trans.amount), 0)) {
|
|
32585
32583
|
const nameParts = [];
|
|
32586
|
-
|
|
32584
|
+
const name = trans.debtorName || trans.remittanceInformationUnstructured || (trans.remittanceInformationUnstructuredArray || []).join(', ') || trans.additionalInformation;
|
|
32585
|
+
if (name) {
|
|
32586
|
+
nameParts.push((0, _title__WEBPACK_IMPORTED_MODULE_10__.title)(name));
|
|
32587
|
+
}
|
|
32587
32588
|
if (trans.debtorAccount && trans.debtorAccount.iban) {
|
|
32588
32589
|
nameParts.push('(' + trans.debtorAccount.iban.slice(0, 4) + ' XXX ' + trans.debtorAccount.iban.slice(-4) + ')');
|
|
32589
32590
|
}
|
|
@@ -32591,7 +32592,10 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
32591
32592
|
}
|
|
32592
32593
|
else {
|
|
32593
32594
|
const nameParts = [];
|
|
32594
|
-
|
|
32595
|
+
const name = trans.creditorName || trans.remittanceInformationUnstructured || (trans.remittanceInformationUnstructuredArray || []).join(', ') || trans.additionalInformation;
|
|
32596
|
+
if (name) {
|
|
32597
|
+
nameParts.push((0, _title__WEBPACK_IMPORTED_MODULE_10__.title)(name));
|
|
32598
|
+
}
|
|
32595
32599
|
if (trans.creditorAccount && trans.creditorAccount.iban) {
|
|
32596
32600
|
nameParts.push('(' + trans.creditorAccount.iban.slice(0, 4) + ' XXX ' + trans.creditorAccount.iban.slice(-4) + ')');
|
|
32597
32601
|
}
|
|
@@ -32981,7 +32985,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
32981
32985
|
}
|
|
32982
32986
|
return newTransactions;
|
|
32983
32987
|
}
|
|
32984
|
-
async function
|
|
32988
|
+
async function syncExternalAccount(userId, userKey, id, acctId, bankId) {
|
|
32985
32989
|
// TODO: Handle the case where transactions exist in the future
|
|
32986
32990
|
// (that will make start date after end date)
|
|
32987
32991
|
const latestTransaction = await _db__WEBPACK_IMPORTED_MODULE_4__.first('SELECT * FROM v_transactions WHERE account = ? ORDER BY date DESC LIMIT 1', [
|
|
@@ -33000,7 +33004,14 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
33000
33004
|
// Never download transactions before the starting date.
|
|
33001
33005
|
startingDate
|
|
33002
33006
|
]));
|
|
33003
|
-
|
|
33007
|
+
let download;
|
|
33008
|
+
if (acctRow.account_sync_source === 'simpleFin') {
|
|
33009
|
+
download = await downloadSimpleFinTransactions(acctId, startDate);
|
|
33010
|
+
}
|
|
33011
|
+
else if (acctRow.account_sync_source === 'goCardless') {
|
|
33012
|
+
download = await downloadGoCardlessTransactions(userId, userKey, acctId, bankId, startDate);
|
|
33013
|
+
}
|
|
33014
|
+
const { transactions: originalTransactions, accountBalance } = download;
|
|
33004
33015
|
if (originalTransactions.length === 0) {
|
|
33005
33016
|
return {
|
|
33006
33017
|
added: [],
|
|
@@ -33020,19 +33031,29 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
33020
33031
|
else {
|
|
33021
33032
|
// Otherwise, download transaction for the past 90 days
|
|
33022
33033
|
const startingDay = _shared_months__WEBPACK_IMPORTED_MODULE_1__.subDays(_shared_months__WEBPACK_IMPORTED_MODULE_1__.currentDay(), 90);
|
|
33023
|
-
|
|
33024
|
-
|
|
33025
|
-
|
|
33026
|
-
|
|
33027
|
-
|
|
33028
|
-
|
|
33034
|
+
let download;
|
|
33035
|
+
if (acctRow.account_sync_source === 'simpleFin') {
|
|
33036
|
+
download = await downloadSimpleFinTransactions(acctId, startingDay);
|
|
33037
|
+
}
|
|
33038
|
+
else if (acctRow.account_sync_source === 'goCardless') {
|
|
33039
|
+
download = await downloadGoCardlessTransactions(userId, userKey, acctId, bankId, startingDay);
|
|
33040
|
+
}
|
|
33041
|
+
const { transactions, startingBalance } = download;
|
|
33042
|
+
let balanceToUse = startingBalance;
|
|
33043
|
+
if (acctRow.account_sync_source === 'simpleFin') {
|
|
33044
|
+
const currentBalance = startingBalance;
|
|
33045
|
+
const previousBalance = transactions.reduce((total, trans) => {
|
|
33046
|
+
return total - parseInt(trans.transactionAmount.amount.replace('.', ''));
|
|
33047
|
+
}, currentBalance);
|
|
33048
|
+
balanceToUse = previousBalance;
|
|
33049
|
+
}
|
|
33029
33050
|
const oldestTransaction = transactions[transactions.length - 1];
|
|
33030
33051
|
const oldestDate = transactions.length > 0 ? oldestTransaction.date : _shared_months__WEBPACK_IMPORTED_MODULE_1__.currentDay();
|
|
33031
33052
|
const payee = await (0, _payees__WEBPACK_IMPORTED_MODULE_9__.getStartingBalancePayee)();
|
|
33032
33053
|
return (0, _mutators__WEBPACK_IMPORTED_MODULE_5__.runMutator)(async () => {
|
|
33033
33054
|
const initialId = await _db__WEBPACK_IMPORTED_MODULE_4__.insertTransaction({
|
|
33034
33055
|
account: id,
|
|
33035
|
-
amount:
|
|
33056
|
+
amount: balanceToUse,
|
|
33036
33057
|
category: acctRow.offbudget === 0 ? payee.category : null,
|
|
33037
33058
|
payee: payee.id,
|
|
33038
33059
|
date: oldestDate,
|
|
@@ -33139,11 +33160,12 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
33139
33160
|
"use strict";
|
|
33140
33161
|
__webpack_require__.r(__webpack_exports__);
|
|
33141
33162
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
33142
|
-
/* harmony export */
|
|
33163
|
+
/* harmony export */ title: () => ( /* binding */title)
|
|
33143
33164
|
/* harmony export */
|
|
33144
33165
|
});
|
|
33145
33166
|
/* harmony import */ var _lower_case__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lower-case */ "./packages/loot-core/src/server/accounts/title/lower-case.ts");
|
|
33146
33167
|
/* harmony import */ var _specials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./specials */ "./packages/loot-core/src/server/accounts/title/specials.ts");
|
|
33168
|
+
// @ts-strict-ignore
|
|
33147
33169
|
// Utilities
|
|
33148
33170
|
const character = '[0-9\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376-\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0523\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0621-\u064A\u066E-\u066F\u0671-\u06D3\u06D5\u06E5-\u06E6\u06EE-\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4-\u07F5\u07FA\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0972\u097B-\u097F\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC-\u09DD\u09DF-\u09E1\u09F0-\u09F1\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33\u0A35-\u0A36\u0A38-\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0-\u0AE1\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B35-\u0B39\u0B3D\u0B5C-\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58-\u0C59\u0C60-\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0-\u0CE1\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D28\u0D2A-\u0D39\u0D3D\u0D60-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E46\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDD\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8B\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065-\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10D0-\u10FA\u10FC\u1100-\u1159\u115F-\u11A2\u11A8-\u11F9\u1200-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u1676\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19A9\u19C1-\u19C7\u1A00-\u1A16\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE-\u1BAF\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u2094\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2C6F\u2C71-\u2C7D\u2C80-\u2CE4\u2D00-\u2D25\u2D30-\u2D65\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31B7\u31F0-\u31FF\u3400\u4DB5\u4E00\u9FC3\uA000-\uA48C\uA500-\uA60C\uA610-\uA61F\uA62A-\uA62B\uA640-\uA65F\uA662-\uA66E\uA67F-\uA697\uA717-\uA71F\uA722-\uA788\uA78B-\uA78C\uA7FB-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA90A-\uA925\uA930-\uA946\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAC00\uD7A3\uF900-\uFA2D\uFA30-\uFA6A\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40-\uFB41\uFB43-\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]';
|
|
33149
33171
|
const regex = new RegExp(`(?:(?:(\\s?(?:^|[.\\(\\)!?;:"-])\\s*)(${character}))|(${character}))(${character}*[’']*${character}*)`, 'g');
|
|
@@ -33174,7 +33196,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
33174
33196
|
}
|
|
33175
33197
|
if (!forced) {
|
|
33176
33198
|
const fullLower = lower + rest;
|
|
33177
|
-
if (_lower_case__WEBPACK_IMPORTED_MODULE_0__
|
|
33199
|
+
if (_lower_case__WEBPACK_IMPORTED_MODULE_0__.lowerCaseSet.has(fullLower)) {
|
|
33178
33200
|
return parsedMatch;
|
|
33179
33201
|
}
|
|
33180
33202
|
}
|
|
@@ -33182,7 +33204,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
33182
33204
|
});
|
|
33183
33205
|
const customSpecials = options.special || [];
|
|
33184
33206
|
const replace = [
|
|
33185
|
-
..._specials__WEBPACK_IMPORTED_MODULE_1__
|
|
33207
|
+
..._specials__WEBPACK_IMPORTED_MODULE_1__.specials,
|
|
33186
33208
|
...customSpecials
|
|
33187
33209
|
];
|
|
33188
33210
|
const replaceRegExp = convertToRegExp(replace);
|
|
@@ -33201,7 +33223,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
33201
33223
|
"use strict";
|
|
33202
33224
|
__webpack_require__.r(__webpack_exports__);
|
|
33203
33225
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
33204
|
-
/* harmony export */
|
|
33226
|
+
/* harmony export */ lowerCaseSet: () => ( /* binding */lowerCaseSet)
|
|
33205
33227
|
/* harmony export */
|
|
33206
33228
|
});
|
|
33207
33229
|
const conjunctions = [
|
|
@@ -33289,12 +33311,11 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
33289
33311
|
'within',
|
|
33290
33312
|
'without'
|
|
33291
33313
|
];
|
|
33292
|
-
const
|
|
33314
|
+
const lowerCaseSet = new Set([
|
|
33293
33315
|
...conjunctions,
|
|
33294
33316
|
...articles,
|
|
33295
33317
|
...prepositions
|
|
33296
33318
|
]);
|
|
33297
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (dictionary);
|
|
33298
33319
|
/***/
|
|
33299
33320
|
}),
|
|
33300
33321
|
/***/ "./packages/loot-core/src/server/accounts/title/specials.ts":
|
|
@@ -33305,10 +33326,10 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
33305
33326
|
"use strict";
|
|
33306
33327
|
__webpack_require__.r(__webpack_exports__);
|
|
33307
33328
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
33308
|
-
/* harmony export */
|
|
33329
|
+
/* harmony export */ specials: () => ( /* binding */specials)
|
|
33309
33330
|
/* harmony export */
|
|
33310
33331
|
});
|
|
33311
|
-
const
|
|
33332
|
+
const specials = [
|
|
33312
33333
|
'CLI',
|
|
33313
33334
|
'API',
|
|
33314
33335
|
'HTTP',
|
|
@@ -33329,7 +33350,6 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
33329
33350
|
'Next.js',
|
|
33330
33351
|
'Node.js'
|
|
33331
33352
|
];
|
|
33332
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (intended);
|
|
33333
33353
|
/***/
|
|
33334
33354
|
}),
|
|
33335
33355
|
/***/ "./packages/loot-core/src/server/accounts/transaction-rules.ts":
|
|
@@ -33371,6 +33391,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
33371
33391
|
/* harmony import */ var _sync__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sync */ "./packages/loot-core/src/server/sync/index.ts");
|
|
33372
33392
|
/* harmony import */ var _rules__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./rules */ "./packages/loot-core/src/server/accounts/rules.ts");
|
|
33373
33393
|
/* harmony import */ var _transactions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./transactions */ "./packages/loot-core/src/server/accounts/transactions.ts");
|
|
33394
|
+
// @ts-strict-ignore
|
|
33374
33395
|
// TODO: Detect if it looks like the user is creating a rename rule
|
|
33375
33396
|
// and prompt to create it in the pre phase instead
|
|
33376
33397
|
// * We could also make the "create rule" button a dropdown that
|
|
@@ -34129,6 +34150,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
34129
34150
|
/* harmony import */ var _sync__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sync */ "./packages/loot-core/src/server/sync/index.ts");
|
|
34130
34151
|
/* harmony import */ var _transaction_rules__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./transaction-rules */ "./packages/loot-core/src/server/accounts/transaction-rules.ts");
|
|
34131
34152
|
/* harmony import */ var _transfer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./transfer */ "./packages/loot-core/src/server/accounts/transfer.ts");
|
|
34153
|
+
// @ts-strict-ignore
|
|
34132
34154
|
async function idsWithChildren(ids) {
|
|
34133
34155
|
const whereIds = (0, _db_util__WEBPACK_IMPORTED_MODULE_2__.whereIn)(ids, 'parent_id');
|
|
34134
34156
|
const rows = await _db__WEBPACK_IMPORTED_MODULE_1__.all(`SELECT id FROM v_transactions_internal WHERE ${whereIds}`);
|
|
@@ -34268,6 +34290,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
34268
34290
|
/* harmony export */
|
|
34269
34291
|
});
|
|
34270
34292
|
/* harmony import */ var _db__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../db */ "./packages/loot-core/src/server/db/index.ts");
|
|
34293
|
+
// @ts-strict-ignore
|
|
34271
34294
|
async function getPayee(acct) {
|
|
34272
34295
|
return _db__WEBPACK_IMPORTED_MODULE_0__.first('SELECT * FROM payees WHERE transfer_acct = ?', [
|
|
34273
34296
|
acct
|
|
@@ -34455,6 +34478,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
34455
34478
|
/* harmony export */
|
|
34456
34479
|
});
|
|
34457
34480
|
/* harmony import */ var _models__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./models */ "./packages/loot-core/src/server/models.ts");
|
|
34481
|
+
// @ts-strict-ignore
|
|
34458
34482
|
const accountModel = {
|
|
34459
34483
|
..._models__WEBPACK_IMPORTED_MODULE_0__.accountModel,
|
|
34460
34484
|
toExternal(account) {
|
|
@@ -34555,7 +34579,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
34555
34579
|
"use strict";
|
|
34556
34580
|
__webpack_require__.r(__webpack_exports__);
|
|
34557
34581
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
34558
|
-
/* harmony export */
|
|
34582
|
+
/* harmony export */ installAPI: () => ( /* binding */installAPI)
|
|
34559
34583
|
/* harmony export */
|
|
34560
34584
|
});
|
|
34561
34585
|
/* harmony import */ var _actual_app_crdt__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @actual-app/crdt */ "./packages/crdt/index.ts");
|
|
@@ -34570,26 +34594,20 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
34570
34594
|
/* harmony import */ var _aql__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./aql */ "./packages/loot-core/src/server/aql/index.ts");
|
|
34571
34595
|
/* harmony import */ var _cloud_storage__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./cloud-storage */ "./packages/loot-core/src/server/cloud-storage.ts");
|
|
34572
34596
|
/* harmony import */ var _db__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./db */ "./packages/loot-core/src/server/db/index.ts");
|
|
34573
|
-
/* harmony import */ var
|
|
34574
|
-
/* harmony import */ var
|
|
34575
|
-
/* harmony import */ var
|
|
34576
|
-
/* harmony import */ var
|
|
34597
|
+
/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./errors */ "./packages/loot-core/src/server/errors.ts");
|
|
34598
|
+
/* harmony import */ var _mutators__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./mutators */ "./packages/loot-core/src/server/mutators.ts");
|
|
34599
|
+
/* harmony import */ var _prefs__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./prefs */ "./packages/loot-core/src/server/prefs.ts");
|
|
34600
|
+
/* harmony import */ var _sheet__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./sheet */ "./packages/loot-core/src/server/sheet.ts");
|
|
34601
|
+
/* harmony import */ var _sync__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./sync */ "./packages/loot-core/src/server/sync/index.ts");
|
|
34602
|
+
// @ts-strict-ignore
|
|
34577
34603
|
let IMPORT_MODE = false;
|
|
34578
|
-
// This is duplicate from main.js...
|
|
34579
|
-
function APIError(msg, meta) {
|
|
34580
|
-
return {
|
|
34581
|
-
type: 'APIError',
|
|
34582
|
-
message: msg,
|
|
34583
|
-
meta
|
|
34584
|
-
};
|
|
34585
|
-
}
|
|
34586
34604
|
// The API is different in two ways: we never want undo enabled, and
|
|
34587
34605
|
// we also need to notify the UI manually if stuff has changed (if
|
|
34588
34606
|
// they are connecting to an already running instance, the UI should
|
|
34589
34607
|
// update). The wrapper handles that.
|
|
34590
34608
|
function withMutation(handler) {
|
|
34591
34609
|
return (args) => {
|
|
34592
|
-
return (0,
|
|
34610
|
+
return (0, _mutators__WEBPACK_IMPORTED_MODULE_13__.runMutator)(async () => {
|
|
34593
34611
|
const latestTimestamp = (0, _actual_app_crdt__WEBPACK_IMPORTED_MODULE_0__.getClock)().timestamp.toString();
|
|
34594
34612
|
const result = await handler(args);
|
|
34595
34613
|
const rows = await _db__WEBPACK_IMPORTED_MODULE_11__.all('SELECT DISTINCT dataset FROM messages_crdt WHERE timestamp > ?', [
|
|
@@ -34611,39 +34629,39 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
34611
34629
|
let handlers = {};
|
|
34612
34630
|
async function validateMonth(month) {
|
|
34613
34631
|
if (!month.match(/^\d{4}-\d{2}$/)) {
|
|
34614
|
-
throw APIError('Invalid month format, use YYYY-MM: ' + month);
|
|
34632
|
+
throw (0, _errors__WEBPACK_IMPORTED_MODULE_12__.APIError)('Invalid month format, use YYYY-MM: ' + month);
|
|
34615
34633
|
}
|
|
34616
34634
|
if (!IMPORT_MODE) {
|
|
34617
34635
|
const { start, end } = await handlers['get-budget-bounds']();
|
|
34618
34636
|
const range = _shared_months__WEBPACK_IMPORTED_MODULE_3__.range(start, end);
|
|
34619
34637
|
if (!range.includes(month)) {
|
|
34620
|
-
throw APIError('No budget exists for month: ' + month);
|
|
34638
|
+
throw (0, _errors__WEBPACK_IMPORTED_MODULE_12__.APIError)('No budget exists for month: ' + month);
|
|
34621
34639
|
}
|
|
34622
34640
|
}
|
|
34623
34641
|
}
|
|
34624
34642
|
async function validateExpenseCategory(debug, id) {
|
|
34625
34643
|
if (id == null) {
|
|
34626
|
-
throw APIError(`${debug}: category id is required`);
|
|
34644
|
+
throw (0, _errors__WEBPACK_IMPORTED_MODULE_12__.APIError)(`${debug}: category id is required`);
|
|
34627
34645
|
}
|
|
34628
34646
|
const row = await _db__WEBPACK_IMPORTED_MODULE_11__.first('SELECT is_income FROM categories WHERE id = ?', [
|
|
34629
34647
|
id
|
|
34630
34648
|
]);
|
|
34631
34649
|
if (!row) {
|
|
34632
|
-
throw APIError(`${debug}: category “${id}” does not exist`);
|
|
34650
|
+
throw (0, _errors__WEBPACK_IMPORTED_MODULE_12__.APIError)(`${debug}: category “${id}” does not exist`);
|
|
34633
34651
|
}
|
|
34634
34652
|
if (row.is_income !== 0) {
|
|
34635
|
-
throw APIError(`${debug}: category “${id}” is not an expense category`);
|
|
34653
|
+
throw (0, _errors__WEBPACK_IMPORTED_MODULE_12__.APIError)(`${debug}: category “${id}” is not an expense category`);
|
|
34636
34654
|
}
|
|
34637
34655
|
}
|
|
34638
34656
|
function checkFileOpen() {
|
|
34639
|
-
if (!(
|
|
34640
|
-
throw APIError('No budget file is open');
|
|
34657
|
+
if (!(_prefs__WEBPACK_IMPORTED_MODULE_14__.getPrefs() || {}).id) {
|
|
34658
|
+
throw (0, _errors__WEBPACK_IMPORTED_MODULE_12__.APIError)('No budget file is open');
|
|
34641
34659
|
}
|
|
34642
34660
|
}
|
|
34643
34661
|
let batchPromise = null;
|
|
34644
34662
|
handlers['api/batch-budget-start'] = async function () {
|
|
34645
34663
|
if (batchPromise) {
|
|
34646
|
-
throw APIError('Cannot start a batch process: batch already started');
|
|
34664
|
+
throw (0, _errors__WEBPACK_IMPORTED_MODULE_12__.APIError)('Cannot start a batch process: batch already started');
|
|
34647
34665
|
}
|
|
34648
34666
|
// If we are importing, all we need to do is start a raw database
|
|
34649
34667
|
// transaction. Updating spreadsheet cells doesn't go through the
|
|
@@ -34659,7 +34677,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
34659
34677
|
});
|
|
34660
34678
|
}
|
|
34661
34679
|
else {
|
|
34662
|
-
(0,
|
|
34680
|
+
(0, _sync__WEBPACK_IMPORTED_MODULE_16__.batchMessages)(() => {
|
|
34663
34681
|
return new Promise((resolve, reject) => {
|
|
34664
34682
|
batchPromise = {
|
|
34665
34683
|
resolve,
|
|
@@ -34671,13 +34689,13 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
34671
34689
|
};
|
|
34672
34690
|
handlers['api/batch-budget-end'] = async function () {
|
|
34673
34691
|
if (!batchPromise) {
|
|
34674
|
-
throw APIError('Cannot end a batch process: no batch started');
|
|
34692
|
+
throw (0, _errors__WEBPACK_IMPORTED_MODULE_12__.APIError)('Cannot end a batch process: no batch started');
|
|
34675
34693
|
}
|
|
34676
34694
|
batchPromise.resolve();
|
|
34677
34695
|
batchPromise = null;
|
|
34678
34696
|
};
|
|
34679
34697
|
handlers['api/load-budget'] = async function ({ id }) {
|
|
34680
|
-
const { id: currentId } =
|
|
34698
|
+
const { id: currentId } = _prefs__WEBPACK_IMPORTED_MODULE_14__.getPrefs() || {};
|
|
34681
34699
|
if (currentId !== id) {
|
|
34682
34700
|
_platform_server_connection__WEBPACK_IMPORTED_MODULE_1__.send('start-load');
|
|
34683
34701
|
const { error } = await handlers['load-budget']({
|
|
@@ -34693,7 +34711,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
34693
34711
|
}
|
|
34694
34712
|
};
|
|
34695
34713
|
handlers['api/download-budget'] = async function ({ syncId, password }) {
|
|
34696
|
-
const { id: currentId } =
|
|
34714
|
+
const { id: currentId } = _prefs__WEBPACK_IMPORTED_MODULE_14__.getPrefs() || {};
|
|
34697
34715
|
if (currentId) {
|
|
34698
34716
|
await handlers['close-budget']();
|
|
34699
34717
|
}
|
|
@@ -34741,7 +34759,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
34741
34759
|
}
|
|
34742
34760
|
};
|
|
34743
34761
|
handlers['api/sync'] = async function () {
|
|
34744
|
-
const { id } =
|
|
34762
|
+
const { id } = _prefs__WEBPACK_IMPORTED_MODULE_14__.getPrefs();
|
|
34745
34763
|
const result = await handlers['sync-budget']();
|
|
34746
34764
|
if (result.error) {
|
|
34747
34765
|
throw new Error((0, _shared_errors__WEBPACK_IMPORTED_MODULE_2__.getSyncError)(result.error, id));
|
|
@@ -34759,31 +34777,31 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
34759
34777
|
await _db__WEBPACK_IMPORTED_MODULE_11__.runQuery('DELETE FROM categories WHERE is_income = 0');
|
|
34760
34778
|
await _db__WEBPACK_IMPORTED_MODULE_11__.runQuery('DELETE FROM category_groups WHERE is_income = 0');
|
|
34761
34779
|
// Turn syncing off
|
|
34762
|
-
(0,
|
|
34780
|
+
(0, _sync__WEBPACK_IMPORTED_MODULE_16__.setSyncingMode)('import');
|
|
34763
34781
|
_platform_server_connection__WEBPACK_IMPORTED_MODULE_1__.send('start-import');
|
|
34764
34782
|
IMPORT_MODE = true;
|
|
34765
34783
|
};
|
|
34766
34784
|
handlers['api/finish-import'] = async function () {
|
|
34767
34785
|
checkFileOpen();
|
|
34768
|
-
|
|
34786
|
+
_sheet__WEBPACK_IMPORTED_MODULE_15__.get().markCacheDirty();
|
|
34769
34787
|
// We always need to fully reload the app. Importing doesn't touch
|
|
34770
34788
|
// the spreadsheet, but we can't just recreate the spreadsheet
|
|
34771
34789
|
// either; there is other internal state that isn't created
|
|
34772
|
-
const { id } =
|
|
34790
|
+
const { id } = _prefs__WEBPACK_IMPORTED_MODULE_14__.getPrefs();
|
|
34773
34791
|
await handlers['close-budget']();
|
|
34774
34792
|
await handlers['load-budget']({
|
|
34775
34793
|
id
|
|
34776
34794
|
});
|
|
34777
34795
|
await handlers['get-budget-bounds']();
|
|
34778
|
-
await
|
|
34779
|
-
await _cloud_storage__WEBPACK_IMPORTED_MODULE_10__.upload().catch((
|
|
34796
|
+
await _sheet__WEBPACK_IMPORTED_MODULE_15__.waitOnSpreadsheet();
|
|
34797
|
+
await _cloud_storage__WEBPACK_IMPORTED_MODULE_10__.upload().catch(() => { });
|
|
34780
34798
|
_platform_server_connection__WEBPACK_IMPORTED_MODULE_1__.send('finish-import');
|
|
34781
34799
|
IMPORT_MODE = false;
|
|
34782
34800
|
};
|
|
34783
34801
|
handlers['api/abort-import'] = async function () {
|
|
34784
34802
|
if (IMPORT_MODE) {
|
|
34785
34803
|
checkFileOpen();
|
|
34786
|
-
const { id } =
|
|
34804
|
+
const { id } = _prefs__WEBPACK_IMPORTED_MODULE_14__.getPrefs();
|
|
34787
34805
|
await handlers['close-budget']();
|
|
34788
34806
|
await handlers['delete-budget']({
|
|
34789
34807
|
id
|
|
@@ -34807,7 +34825,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
34807
34825
|
const groups = await _db__WEBPACK_IMPORTED_MODULE_11__.getCategoriesGrouped();
|
|
34808
34826
|
const sheetName = _shared_months__WEBPACK_IMPORTED_MODULE_3__.sheetForMonth(month);
|
|
34809
34827
|
function value(name) {
|
|
34810
|
-
const v =
|
|
34828
|
+
const v = _sheet__WEBPACK_IMPORTED_MODULE_15__.get().getCellValue(sheetName, name);
|
|
34811
34829
|
return v === '' ? 0 : v;
|
|
34812
34830
|
}
|
|
34813
34831
|
// This is duplicated from main.js because the return format is
|
|
@@ -34893,7 +34911,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
34893
34911
|
});
|
|
34894
34912
|
handlers['api/transactions-get'] = async function ({ accountId, startDate, endDate }) {
|
|
34895
34913
|
checkFileOpen();
|
|
34896
|
-
const { data } = await (0, _aql__WEBPACK_IMPORTED_MODULE_9__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__
|
|
34914
|
+
const { data } = await (0, _aql__WEBPACK_IMPORTED_MODULE_9__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__.q)('transactions').filter({
|
|
34897
34915
|
$and: [
|
|
34898
34916
|
accountId && {
|
|
34899
34917
|
account: accountId
|
|
@@ -34914,12 +34932,9 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
34914
34932
|
}));
|
|
34915
34933
|
return data;
|
|
34916
34934
|
};
|
|
34917
|
-
handlers['api/transactions-filter'] = async function ({ text, accountId }) {
|
|
34918
|
-
throw new Error('`filterTransactions` is deprecated, use `runQuery` instead');
|
|
34919
|
-
};
|
|
34920
34935
|
handlers['api/transaction-update'] = withMutation(async function ({ id, fields }) {
|
|
34921
34936
|
checkFileOpen();
|
|
34922
|
-
const { data } = await (0, _aql__WEBPACK_IMPORTED_MODULE_9__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__
|
|
34937
|
+
const { data } = await (0, _aql__WEBPACK_IMPORTED_MODULE_9__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__.q)('transactions').filter({
|
|
34923
34938
|
id
|
|
34924
34939
|
}).select('*').options({
|
|
34925
34940
|
splits: 'grouped'
|
|
@@ -34936,7 +34951,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
34936
34951
|
});
|
|
34937
34952
|
handlers['api/transaction-delete'] = withMutation(async function ({ id }) {
|
|
34938
34953
|
checkFileOpen();
|
|
34939
|
-
const { data } = await (0, _aql__WEBPACK_IMPORTED_MODULE_9__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__
|
|
34954
|
+
const { data } = await (0, _aql__WEBPACK_IMPORTED_MODULE_9__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__.q)('transactions').filter({
|
|
34940
34955
|
id
|
|
34941
34956
|
}).select('*').options({
|
|
34942
34957
|
splits: 'grouped'
|
|
@@ -35092,6 +35107,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
35092
35107
|
});
|
|
35093
35108
|
/* harmony import */ var mitt__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! mitt */ "./node_modules/mitt/dist/mitt.mjs");
|
|
35094
35109
|
/* harmony import */ var _platform_exceptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../platform/exceptions */ "./packages/loot-core/src/platform/exceptions/index.electron.ts");
|
|
35110
|
+
// @ts-strict-ignore
|
|
35095
35111
|
// This is a simple helper abstraction for defining methods exposed to
|
|
35096
35112
|
// the client. It doesn't do much, but checks for naming conflicts and
|
|
35097
35113
|
// makes it cleaner to combine methods. We call a group of related
|
|
@@ -35162,6 +35178,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
35162
35178
|
/* harmony export */ quoteAlias: () => ( /* binding */quoteAlias)
|
|
35163
35179
|
/* harmony export */
|
|
35164
35180
|
});
|
|
35181
|
+
// @ts-strict-ignore
|
|
35165
35182
|
let _uid = 0;
|
|
35166
35183
|
function resetUid() {
|
|
35167
35184
|
_uid = 0;
|
|
@@ -36143,7 +36160,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
36143
36160
|
}
|
|
36144
36161
|
function compileQuery(queryState, schema, schemaConfig = {}) {
|
|
36145
36162
|
const { withDead, validateRefs = true, tableOptions, rawMode } = queryState;
|
|
36146
|
-
const { tableViews = {}, tableFilters = (
|
|
36163
|
+
const { tableViews = {}, tableFilters = () => [], customizeQuery = (queryState) => queryState } = schemaConfig;
|
|
36147
36164
|
const internalTableFilters = (name) => {
|
|
36148
36165
|
const filters = tableFilters(name);
|
|
36149
36166
|
// These filters cannot join tables and must be simple strings
|
|
@@ -36273,6 +36290,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
36273
36290
|
/* harmony import */ var _db__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../db */ "./packages/loot-core/src/server/db/index.ts");
|
|
36274
36291
|
/* harmony import */ var _compiler__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./compiler */ "./packages/loot-core/src/server/aql/compiler.ts");
|
|
36275
36292
|
/* harmony import */ var _schema_helpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./schema-helpers */ "./packages/loot-core/src/server/aql/schema-helpers.ts");
|
|
36293
|
+
// @ts-strict-ignore
|
|
36276
36294
|
// TODO (compiler):
|
|
36277
36295
|
// * Properly safeguard all inputs against SQL injection
|
|
36278
36296
|
// * Functions for incr/decr dates
|
|
@@ -36382,6 +36400,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
36382
36400
|
});
|
|
36383
36401
|
/* harmony import */ var _shared_months__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../shared/months */ "./packages/loot-core/src/shared/months.ts");
|
|
36384
36402
|
/* harmony import */ var _models__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../models */ "./packages/loot-core/src/server/models.ts");
|
|
36403
|
+
// @ts-strict-ignore
|
|
36385
36404
|
function isRequired(name, fieldDesc) {
|
|
36386
36405
|
return fieldDesc.required || name === 'id';
|
|
36387
36406
|
}
|
|
@@ -36567,6 +36586,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
36567
36586
|
/* harmony import */ var _compiler__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../compiler */ "./packages/loot-core/src/server/aql/compiler.ts");
|
|
36568
36587
|
/* harmony import */ var _exec__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../exec */ "./packages/loot-core/src/server/aql/exec.ts");
|
|
36569
36588
|
/* harmony import */ var _schema_helpers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../schema-helpers */ "./packages/loot-core/src/server/aql/schema-helpers.ts");
|
|
36589
|
+
// @ts-strict-ignore
|
|
36570
36590
|
// Transactions executor
|
|
36571
36591
|
function toGroup(parents, children, mapper = (x) => x) {
|
|
36572
36592
|
return parents.reduce((list, parent) => {
|
|
@@ -36757,6 +36777,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
36757
36777
|
/* harmony export */ schemaConfig: () => ( /* binding */schemaConfig)
|
|
36758
36778
|
/* harmony export */
|
|
36759
36779
|
});
|
|
36780
|
+
// @ts-strict-ignore
|
|
36760
36781
|
function f(type, opts) {
|
|
36761
36782
|
return {
|
|
36762
36783
|
type,
|
|
@@ -36849,7 +36870,8 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
36849
36870
|
offbudget: f('boolean'),
|
|
36850
36871
|
closed: f('boolean'),
|
|
36851
36872
|
sort_order: f('float'),
|
|
36852
|
-
tombstone: f('boolean')
|
|
36873
|
+
tombstone: f('boolean'),
|
|
36874
|
+
account_sync_source: f('string')
|
|
36853
36875
|
},
|
|
36854
36876
|
categories: {
|
|
36855
36877
|
id: f('id'),
|
|
@@ -36914,6 +36936,46 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
36914
36936
|
conditions: f('json'),
|
|
36915
36937
|
tombstone: f('boolean')
|
|
36916
36938
|
},
|
|
36939
|
+
custom_reports: {
|
|
36940
|
+
id: f('id'),
|
|
36941
|
+
name: f('string'),
|
|
36942
|
+
start_date: f('string', {
|
|
36943
|
+
default: '2023-06'
|
|
36944
|
+
}),
|
|
36945
|
+
end_date: f('string', {
|
|
36946
|
+
default: '2023-09'
|
|
36947
|
+
}),
|
|
36948
|
+
mode: f('string', {
|
|
36949
|
+
default: 'total'
|
|
36950
|
+
}),
|
|
36951
|
+
group_by: f('string', {
|
|
36952
|
+
default: 'Category'
|
|
36953
|
+
}),
|
|
36954
|
+
balance_type: f('string', {
|
|
36955
|
+
default: 'Expense'
|
|
36956
|
+
}),
|
|
36957
|
+
interval: f('string', {
|
|
36958
|
+
default: 'Monthly'
|
|
36959
|
+
}),
|
|
36960
|
+
show_empty: f('integer', {
|
|
36961
|
+
default: 0
|
|
36962
|
+
}),
|
|
36963
|
+
show_offbudgethidden: f('integer', {
|
|
36964
|
+
default: 0
|
|
36965
|
+
}),
|
|
36966
|
+
show_uncategorized: f('integer', {
|
|
36967
|
+
default: 0
|
|
36968
|
+
}),
|
|
36969
|
+
selected_categories: f('json'),
|
|
36970
|
+
graph_type: f('string', {
|
|
36971
|
+
default: 'BarGraph'
|
|
36972
|
+
}),
|
|
36973
|
+
conditions: f('json'),
|
|
36974
|
+
conditions_op: f('string'),
|
|
36975
|
+
metadata: f('json'),
|
|
36976
|
+
color_scheme: f('json'),
|
|
36977
|
+
tombstone: f('boolean')
|
|
36978
|
+
},
|
|
36917
36979
|
reflect_budgets: {
|
|
36918
36980
|
id: f('id'),
|
|
36919
36981
|
month: f('integer'),
|
|
@@ -37150,6 +37212,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
37150
37212
|
/* harmony import */ var _exec__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../exec */ "./packages/loot-core/src/server/aql/exec.ts");
|
|
37151
37213
|
/* harmony import */ var _executors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./executors */ "./packages/loot-core/src/server/aql/schema/executors.ts");
|
|
37152
37214
|
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./index */ "./packages/loot-core/src/server/aql/schema/index.ts");
|
|
37215
|
+
// @ts-strict-ignore
|
|
37153
37216
|
function runCompiledQuery(query, sqlPieces, state, params) {
|
|
37154
37217
|
return (0, _exec__WEBPACK_IMPORTED_MODULE_1__.runCompiledQuery)(query, sqlPieces, state, {
|
|
37155
37218
|
params,
|
|
@@ -37179,6 +37242,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
37179
37242
|
/* harmony export */
|
|
37180
37243
|
});
|
|
37181
37244
|
/* harmony import */ var _compiler__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./compiler */ "./packages/loot-core/src/server/aql/compiler.ts");
|
|
37245
|
+
// @ts-strict-ignore
|
|
37182
37246
|
function selectFields(fields) {
|
|
37183
37247
|
return Object.keys(fields).map((as) => {
|
|
37184
37248
|
let field = fields[as];
|
|
@@ -37261,6 +37325,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
37261
37325
|
/* harmony import */ var _shared_months__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../shared/months */ "./packages/loot-core/src/shared/months.ts");
|
|
37262
37326
|
/* harmony import */ var _cloud_storage__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cloud-storage */ "./packages/loot-core/src/server/cloud-storage.ts");
|
|
37263
37327
|
/* harmony import */ var _prefs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./prefs */ "./packages/loot-core/src/server/prefs.ts");
|
|
37328
|
+
// @ts-strict-ignore
|
|
37264
37329
|
// A special backup that represents the latest version of the db that
|
|
37265
37330
|
// can be reverted to after loading a backup
|
|
37266
37331
|
const LATEST_BACKUP_FILENAME = 'db.latest.sqlite';
|
|
@@ -37458,13 +37523,14 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
37458
37523
|
/* harmony import */ var _prefs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../prefs */ "./packages/loot-core/src/server/prefs.ts");
|
|
37459
37524
|
/* harmony import */ var _sheet__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sheet */ "./packages/loot-core/src/server/sheet.ts");
|
|
37460
37525
|
/* harmony import */ var _sync__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sync */ "./packages/loot-core/src/server/sync/index.ts");
|
|
37526
|
+
// @ts-strict-ignore
|
|
37461
37527
|
async function getSheetValue(sheetName, cell) {
|
|
37462
37528
|
const node = await _sheet__WEBPACK_IMPORTED_MODULE_4__.getCell(sheetName, cell);
|
|
37463
37529
|
return (0, _shared_util__WEBPACK_IMPORTED_MODULE_1__.safeNumber)(typeof node.value === 'number' ? node.value : 0);
|
|
37464
37530
|
}
|
|
37465
37531
|
// We want to only allow the positive movement of money back and
|
|
37466
37532
|
// forth. buffered should never be allowed to go into the negative,
|
|
37467
|
-
// and you shouldn't be allowed to pull non-
|
|
37533
|
+
// and you shouldn't be allowed to pull non-existent money from
|
|
37468
37534
|
// leftover.
|
|
37469
37535
|
function calcBufferedAmount(toBudget, buffered, amount) {
|
|
37470
37536
|
amount = Math.min(Math.max(amount, -buffered), Math.max(toBudget, 0));
|
|
@@ -37542,7 +37608,9 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
37542
37608
|
});
|
|
37543
37609
|
}
|
|
37544
37610
|
return _db__WEBPACK_IMPORTED_MODULE_2__.insert(table, {
|
|
37545
|
-
id: month
|
|
37611
|
+
id: `${dbMonth(month)}-${category}`,
|
|
37612
|
+
month: dbMonth(month),
|
|
37613
|
+
category,
|
|
37546
37614
|
goal
|
|
37547
37615
|
});
|
|
37548
37616
|
}
|
|
@@ -37750,7 +37818,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
37750
37818
|
"use strict";
|
|
37751
37819
|
__webpack_require__.r(__webpack_exports__);
|
|
37752
37820
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
37753
|
-
/* harmony export */
|
|
37821
|
+
/* harmony export */ app: () => ( /* binding */app)
|
|
37754
37822
|
/* harmony export */
|
|
37755
37823
|
});
|
|
37756
37824
|
/* harmony import */ var _app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../app */ "./packages/loot-core/src/server/app.ts");
|
|
@@ -37777,7 +37845,6 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
37777
37845
|
app.method('budget/transfer-available', (0, _mutators__WEBPACK_IMPORTED_MODULE_1__.mutator)((0, _undo__WEBPACK_IMPORTED_MODULE_2__.undoable)(_actions__WEBPACK_IMPORTED_MODULE_3__.transferAvailable)));
|
|
37778
37846
|
app.method('budget/transfer-category', (0, _mutators__WEBPACK_IMPORTED_MODULE_1__.mutator)((0, _undo__WEBPACK_IMPORTED_MODULE_2__.undoable)(_actions__WEBPACK_IMPORTED_MODULE_3__.transferCategory)));
|
|
37779
37847
|
app.method('budget/set-carryover', (0, _mutators__WEBPACK_IMPORTED_MODULE_1__.mutator)((0, _undo__WEBPACK_IMPORTED_MODULE_2__.undoable)(_actions__WEBPACK_IMPORTED_MODULE_3__.setCategoryCarryover)));
|
|
37780
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (app);
|
|
37781
37848
|
/***/
|
|
37782
37849
|
}),
|
|
37783
37850
|
/***/ "./packages/loot-core/src/server/budget/base.ts":
|
|
@@ -37806,6 +37873,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
37806
37873
|
/* harmony import */ var _report__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./report */ "./packages/loot-core/src/server/budget/report.ts");
|
|
37807
37874
|
/* harmony import */ var _rollover__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rollover */ "./packages/loot-core/src/server/budget/rollover.ts");
|
|
37808
37875
|
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./util */ "./packages/loot-core/src/server/budget/util.ts");
|
|
37876
|
+
// @ts-strict-ignore
|
|
37809
37877
|
function getBudgetType() {
|
|
37810
37878
|
const meta = _sheet__WEBPACK_IMPORTED_MODULE_3__.get().meta();
|
|
37811
37879
|
return meta.budgetType || 'rollover';
|
|
@@ -38190,6 +38258,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
38190
38258
|
/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actions */ "./packages/loot-core/src/server/budget/actions.ts");
|
|
38191
38259
|
/* harmony import */ var _cleanup_template_pegjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./cleanup-template.pegjs */ "./packages/loot-core/src/server/budget/cleanup-template.pegjs");
|
|
38192
38260
|
/* harmony import */ var _cleanup_template_pegjs__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/ __webpack_require__.n(_cleanup_template_pegjs__WEBPACK_IMPORTED_MODULE_3__);
|
|
38261
|
+
// @ts-strict-ignore
|
|
38193
38262
|
function cleanupTemplate({ month }) {
|
|
38194
38263
|
return processCleanup(month);
|
|
38195
38264
|
}
|
|
@@ -38209,11 +38278,17 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
38209
38278
|
if (template.filter((t) => t.type === 'source').length > 0) {
|
|
38210
38279
|
const balance = await (0, _actions__WEBPACK_IMPORTED_MODULE_2__.getSheetValue)(sheetName, `leftover-${category.id}`);
|
|
38211
38280
|
const budgeted = await (0, _actions__WEBPACK_IMPORTED_MODULE_2__.getSheetValue)(sheetName, `budget-${category.id}`);
|
|
38281
|
+
const spent = await (0, _actions__WEBPACK_IMPORTED_MODULE_2__.getSheetValue)(sheetName, `sum-amount-${category.id}`);
|
|
38212
38282
|
await (0, _actions__WEBPACK_IMPORTED_MODULE_2__.setBudget)({
|
|
38213
38283
|
category: category.id,
|
|
38214
38284
|
month,
|
|
38215
38285
|
amount: budgeted - balance
|
|
38216
38286
|
});
|
|
38287
|
+
await (0, _actions__WEBPACK_IMPORTED_MODULE_2__.setGoal)({
|
|
38288
|
+
category: category.id,
|
|
38289
|
+
month,
|
|
38290
|
+
goal: -spent
|
|
38291
|
+
});
|
|
38217
38292
|
num_sources += 1;
|
|
38218
38293
|
}
|
|
38219
38294
|
if (template.filter((t) => t.type === 'sink').length > 0) {
|
|
@@ -38352,6 +38427,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
38352
38427
|
/* harmony import */ var _shared_months__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../shared/months */ "./packages/loot-core/src/shared/months.ts");
|
|
38353
38428
|
/* harmony import */ var _shared_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../shared/util */ "./packages/loot-core/src/shared/util.ts");
|
|
38354
38429
|
/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../actions */ "./packages/loot-core/src/server/budget/actions.ts");
|
|
38430
|
+
// @ts-strict-ignore
|
|
38355
38431
|
async function goalsBy(template_lines, current_month, template, l, remainder, last_month_balance, to_budget, errors) {
|
|
38356
38432
|
// by has 'amount' and 'month' params
|
|
38357
38433
|
if (!(0, _actions__WEBPACK_IMPORTED_MODULE_2__.isReflectBudget)()) {
|
|
@@ -38402,6 +38478,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
38402
38478
|
/* harmony import */ var _shared_months__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../shared/months */ "./packages/loot-core/src/shared/months.ts");
|
|
38403
38479
|
/* harmony import */ var _db__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../db */ "./packages/loot-core/src/server/db/index.ts");
|
|
38404
38480
|
/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../actions */ "./packages/loot-core/src/server/budget/actions.ts");
|
|
38481
|
+
// @ts-strict-ignore
|
|
38405
38482
|
async function goalsPercentage(template, month, available_start, sheetName, to_budget, errors) {
|
|
38406
38483
|
const percent = template.percent;
|
|
38407
38484
|
let monthlyIncome = 0;
|
|
@@ -38455,6 +38532,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
38455
38532
|
/* harmony export */ goalsRemainder: () => ( /* binding */goalsRemainder)
|
|
38456
38533
|
/* harmony export */
|
|
38457
38534
|
});
|
|
38535
|
+
// @ts-strict-ignore
|
|
38458
38536
|
async function goalsRemainder(template, budgetAvailable, remainder_scale, to_budget) {
|
|
38459
38537
|
if (remainder_scale >= 0) {
|
|
38460
38538
|
to_budget += remainder_scale === 0 ? Math.round(template.weight) : Math.round(remainder_scale * template.weight);
|
|
@@ -38513,43 +38591,45 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
38513
38591
|
/* harmony import */ var _db__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../db */ "./packages/loot-core/src/server/db/index.ts");
|
|
38514
38592
|
/* harmony import */ var _schedules_app__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../schedules/app */ "./packages/loot-core/src/server/schedules/app.ts");
|
|
38515
38593
|
/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../actions */ "./packages/loot-core/src/server/budget/actions.ts");
|
|
38516
|
-
|
|
38517
|
-
|
|
38518
|
-
|
|
38519
|
-
|
|
38520
|
-
|
|
38521
|
-
|
|
38522
|
-
|
|
38523
|
-
|
|
38524
|
-
|
|
38525
|
-
|
|
38526
|
-
|
|
38527
|
-
|
|
38528
|
-
|
|
38529
|
-
|
|
38530
|
-
|
|
38531
|
-
|
|
38532
|
-
|
|
38533
|
-
|
|
38534
|
-
|
|
38535
|
-
|
|
38536
|
-
|
|
38537
|
-
|
|
38538
|
-
|
|
38594
|
+
// @ts-strict-ignore
|
|
38595
|
+
async function createScheduleList(template, current_month, category) {
|
|
38596
|
+
const t = [];
|
|
38597
|
+
const errors = [];
|
|
38598
|
+
for (let ll = 0; ll < template.length; ll++) {
|
|
38599
|
+
const { id: sid, completed: complete } = await _db__WEBPACK_IMPORTED_MODULE_2__.first('SELECT * FROM schedules WHERE name = ? AND tombstone = 0', [
|
|
38600
|
+
template[ll].name
|
|
38601
|
+
]);
|
|
38602
|
+
const rule = await (0, _schedules_app__WEBPACK_IMPORTED_MODULE_3__.getRuleForSchedule)(sid);
|
|
38603
|
+
const conditions = rule.serialize().conditions;
|
|
38604
|
+
const { date: dateConditions, amount: amountCondition } = (0, _shared_schedules__WEBPACK_IMPORTED_MODULE_1__.extractScheduleConds)(conditions);
|
|
38605
|
+
const sign = category.is_income ? 1 : -1;
|
|
38606
|
+
const target = amountCondition.op === 'isbetween' ? sign * Math.round(amountCondition.value.num1 + amountCondition.value.num2) / 2 : sign * amountCondition.value;
|
|
38607
|
+
const next_date_string = (0, _schedules_app__WEBPACK_IMPORTED_MODULE_3__.getNextDate)(dateConditions, _shared_months__WEBPACK_IMPORTED_MODULE_0__._parse(current_month));
|
|
38608
|
+
const target_interval = dateConditions.value.interval ? dateConditions.value.interval : 1;
|
|
38609
|
+
const target_frequency = dateConditions.value.frequency;
|
|
38610
|
+
const isRepeating = Object(dateConditions.value) === dateConditions.value && 'frequency' in dateConditions.value;
|
|
38611
|
+
const num_months = _shared_months__WEBPACK_IMPORTED_MODULE_0__.differenceInCalendarMonths(next_date_string, current_month);
|
|
38612
|
+
if (num_months < 0) {
|
|
38613
|
+
//non-repeating schedules could be negative
|
|
38614
|
+
errors.push(`Schedule ${template[ll].name} is in the Past.`);
|
|
38615
|
+
}
|
|
38616
|
+
else {
|
|
38539
38617
|
t.push({
|
|
38540
|
-
template: template[ll],
|
|
38541
38618
|
target,
|
|
38542
38619
|
next_date_string,
|
|
38543
38620
|
target_interval,
|
|
38544
38621
|
target_frequency,
|
|
38545
38622
|
num_months,
|
|
38546
38623
|
completed: complete,
|
|
38547
|
-
started
|
|
38624
|
+
//started,
|
|
38625
|
+
full: template[ll].full === null ? false : template[ll].full,
|
|
38626
|
+
repeat: isRepeating,
|
|
38627
|
+
name: template[ll].name
|
|
38548
38628
|
});
|
|
38549
|
-
if (!complete
|
|
38629
|
+
if (!complete) {
|
|
38550
38630
|
if (isRepeating) {
|
|
38551
38631
|
let monthlyTarget = 0;
|
|
38552
|
-
const nextMonth = _shared_months__WEBPACK_IMPORTED_MODULE_0__.addMonths(current_month, t[
|
|
38632
|
+
const nextMonth = _shared_months__WEBPACK_IMPORTED_MODULE_0__.addMonths(current_month, t[t.length - 1].num_months + 1);
|
|
38553
38633
|
let nextBaseDate = (0, _schedules_app__WEBPACK_IMPORTED_MODULE_3__.getNextDate)(dateConditions, _shared_months__WEBPACK_IMPORTED_MODULE_0__._parse(current_month), true);
|
|
38554
38634
|
let nextDate = dateConditions.value.skipWeekend ? _shared_months__WEBPACK_IMPORTED_MODULE_0__.dayFromDate((0, _schedules_app__WEBPACK_IMPORTED_MODULE_3__.getDateWithSkippedWeekend)(_shared_months__WEBPACK_IMPORTED_MODULE_0__._parse(nextBaseDate), dateConditions.value.weekendSolveMode)) : nextBaseDate;
|
|
38555
38635
|
while (nextDate < nextMonth) {
|
|
@@ -38563,82 +38643,81 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
38563
38643
|
break;
|
|
38564
38644
|
}
|
|
38565
38645
|
}
|
|
38566
|
-
t[
|
|
38567
|
-
totalScheduledGoal += target;
|
|
38646
|
+
t[t.length - 1].target = -monthlyTarget;
|
|
38568
38647
|
}
|
|
38569
38648
|
}
|
|
38570
38649
|
else {
|
|
38571
|
-
errors.push(`Schedule ${t[ll].
|
|
38650
|
+
errors.push(`Schedule ${t[ll].name} is not active during the month in question.`);
|
|
38572
38651
|
}
|
|
38573
38652
|
}
|
|
38574
|
-
|
|
38575
|
-
|
|
38576
|
-
|
|
38577
|
-
|
|
38578
|
-
|
|
38579
|
-
|
|
38580
|
-
|
|
38581
|
-
|
|
38582
|
-
|
|
38583
|
-
|
|
38584
|
-
|
|
38585
|
-
|
|
38586
|
-
|
|
38587
|
-
|
|
38588
|
-
|
|
38589
|
-
|
|
38590
|
-
|
|
38591
|
-
|
|
38592
|
-
|
|
38653
|
+
}
|
|
38654
|
+
return {
|
|
38655
|
+
t: t.filter((c) => c.completed === 0),
|
|
38656
|
+
errors
|
|
38657
|
+
};
|
|
38658
|
+
}
|
|
38659
|
+
async function getPayMonthOfTotal(t) {
|
|
38660
|
+
//return the contribution amounts of full or every month type schedules
|
|
38661
|
+
let total = 0;
|
|
38662
|
+
const schedules = t.filter((c) => c.num_months === 0);
|
|
38663
|
+
for (let ll = 0; ll < schedules.length; ll++) {
|
|
38664
|
+
total += schedules[ll].target;
|
|
38665
|
+
}
|
|
38666
|
+
return total;
|
|
38667
|
+
}
|
|
38668
|
+
async function getSinkingContributionTotal(t, remainder, last_month_balance) {
|
|
38669
|
+
//return the contribution amount if there is a balance carried in the category
|
|
38670
|
+
let total = 0;
|
|
38671
|
+
for (let ll = 0; ll < t.length; ll++) {
|
|
38672
|
+
remainder = ll === 0 ? t[ll].target - last_month_balance : t[ll].target - remainder;
|
|
38673
|
+
let tg = 0;
|
|
38674
|
+
if (remainder >= 0) {
|
|
38675
|
+
tg = remainder;
|
|
38676
|
+
remainder = 0;
|
|
38593
38677
|
}
|
|
38594
|
-
else
|
|
38595
|
-
|
|
38596
|
-
|
|
38597
|
-
|
|
38598
|
-
|
|
38599
|
-
|
|
38600
|
-
|
|
38601
|
-
|
|
38602
|
-
|
|
38603
|
-
|
|
38604
|
-
|
|
38605
|
-
|
|
38606
|
-
|
|
38607
|
-
|
|
38608
|
-
|
|
38609
|
-
|
|
38610
|
-
|
|
38611
|
-
|
|
38612
|
-
|
|
38613
|
-
|
|
38614
|
-
|
|
38615
|
-
|
|
38616
|
-
|
|
38617
|
-
|
|
38618
|
-
|
|
38619
|
-
|
|
38620
|
-
|
|
38621
|
-
|
|
38622
|
-
|
|
38623
|
-
|
|
38624
|
-
|
|
38625
|
-
|
|
38626
|
-
|
|
38627
|
-
|
|
38628
|
-
|
|
38629
|
-
|
|
38630
|
-
|
|
38631
|
-
|
|
38632
|
-
|
|
38633
|
-
|
|
38634
|
-
|
|
38635
|
-
|
|
38636
|
-
}
|
|
38637
|
-
}
|
|
38638
|
-
}
|
|
38678
|
+
else {
|
|
38679
|
+
tg = 0;
|
|
38680
|
+
remainder = Math.abs(remainder);
|
|
38681
|
+
}
|
|
38682
|
+
total += tg / (t[ll].num_months + 1);
|
|
38683
|
+
}
|
|
38684
|
+
return total;
|
|
38685
|
+
}
|
|
38686
|
+
async function getSinkingBaseContributionTotal(t) {
|
|
38687
|
+
//return only the base contribution of each schedule
|
|
38688
|
+
let total = 0;
|
|
38689
|
+
for (let ll = 0; ll < t.length; ll++) {
|
|
38690
|
+
total += t[ll].target / t[ll].target_interval;
|
|
38691
|
+
}
|
|
38692
|
+
return total;
|
|
38693
|
+
}
|
|
38694
|
+
async function getSinkingTotal(t) {
|
|
38695
|
+
//sum the total of all upcoming schedules
|
|
38696
|
+
let total = 0;
|
|
38697
|
+
for (let ll = 0; ll < t.length; ll++) {
|
|
38698
|
+
total += t[ll].target;
|
|
38699
|
+
}
|
|
38700
|
+
return total;
|
|
38701
|
+
}
|
|
38702
|
+
async function goalsSchedule(scheduleFlag, template_lines, current_month, balance, remainder, last_month_balance, to_budget, errors, category) {
|
|
38703
|
+
if (!scheduleFlag) {
|
|
38704
|
+
scheduleFlag = true;
|
|
38705
|
+
const template = template_lines.filter((t) => t.type === 'schedule');
|
|
38706
|
+
//in the case of multiple templates per category, schedules may have wrong priority level
|
|
38707
|
+
const t = await createScheduleList(template, current_month, category);
|
|
38708
|
+
errors = errors.concat(t.errors);
|
|
38709
|
+
const t_payMonthOf = t.t.filter((c) => c.full || c.target_frequency === 'monthly' && c.target_interval === 1 && c.num_months === 0 || c.target_frequency === 'weekly' && c.target_interval >= 0 && c.num_months === 0 || c.target_frequency === 'daily' || (0, _actions__WEBPACK_IMPORTED_MODULE_4__.isReflectBudget)());
|
|
38710
|
+
const t_sinking = t.t.filter((c) => !c.full && c.target_frequency === 'monthly' && c.target_interval > 1 || !c.full && c.target_frequency === 'monthly' && c.num_months > 0 && c.target_interval === 1 || !c.full && c.target_frequency === 'yearly' || !c.full && c.target_frequency === undefined).sort((a, b) => a.next_date_string.localeCompare(b.next_date_string));
|
|
38711
|
+
const totalPayMonthOf = await getPayMonthOfTotal(t_payMonthOf);
|
|
38712
|
+
const totalSinking = await getSinkingTotal(t_sinking);
|
|
38713
|
+
const totalSinkingBaseContribution = await getSinkingBaseContributionTotal(t_sinking);
|
|
38714
|
+
if (balance >= totalSinking + totalPayMonthOf) {
|
|
38715
|
+
to_budget += Math.round(totalPayMonthOf + totalSinkingBaseContribution);
|
|
38716
|
+
}
|
|
38717
|
+
else {
|
|
38718
|
+
const totalSinkingContribution = await getSinkingContributionTotal(t_sinking, remainder, last_month_balance);
|
|
38719
|
+
to_budget += Math.round(totalPayMonthOf + totalSinkingContribution);
|
|
38639
38720
|
}
|
|
38640
|
-
increment = Math.round(increment);
|
|
38641
|
-
to_budget += increment;
|
|
38642
38721
|
}
|
|
38643
38722
|
return {
|
|
38644
38723
|
to_budget,
|
|
@@ -38661,6 +38740,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
38661
38740
|
/* harmony export */
|
|
38662
38741
|
});
|
|
38663
38742
|
/* harmony import */ var _shared_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../shared/util */ "./packages/loot-core/src/shared/util.ts");
|
|
38743
|
+
// @ts-strict-ignore
|
|
38664
38744
|
async function goalsSimple(template, limitCheck, errors, limit, hold, to_budget) {
|
|
38665
38745
|
// simple has 'monthly' and/or 'limit' params
|
|
38666
38746
|
if (template.limit != null) {
|
|
@@ -38713,6 +38793,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
38713
38793
|
/* harmony import */ var _shared_months__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../shared/months */ "./packages/loot-core/src/shared/months.ts");
|
|
38714
38794
|
/* harmony import */ var _shared_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../shared/util */ "./packages/loot-core/src/shared/util.ts");
|
|
38715
38795
|
/* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../actions */ "./packages/loot-core/src/server/budget/actions.ts");
|
|
38796
|
+
// @ts-strict-ignore
|
|
38716
38797
|
async function goalsSpend(template, last_month_balance, current_month, to_budget, errors, category) {
|
|
38717
38798
|
// spend has 'amount' and 'from' and 'month' params
|
|
38718
38799
|
const from_month = `${template.from}-01`;
|
|
@@ -38769,6 +38850,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
38769
38850
|
});
|
|
38770
38851
|
/* harmony import */ var _shared_months__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../shared/months */ "./packages/loot-core/src/shared/months.ts");
|
|
38771
38852
|
/* harmony import */ var _shared_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../shared/util */ "./packages/loot-core/src/shared/util.ts");
|
|
38853
|
+
// @ts-strict-ignore
|
|
38772
38854
|
async function goalsWeek(template, limit, limitCheck, hold, current_month, to_budget, errors) {
|
|
38773
38855
|
// week has 'amount', 'starting', 'weeks' and optional 'limit' params
|
|
38774
38856
|
const amount = (0, _shared_util__WEBPACK_IMPORTED_MODULE_1__.amountToInteger)(template.amount);
|
|
@@ -38836,6 +38918,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
38836
38918
|
/* harmony import */ var _goals_goalsSimple__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./goals/goalsSimple */ "./packages/loot-core/src/server/budget/goals/goalsSimple.ts");
|
|
38837
38919
|
/* harmony import */ var _goals_goalsSpend__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./goals/goalsSpend */ "./packages/loot-core/src/server/budget/goals/goalsSpend.ts");
|
|
38838
38920
|
/* harmony import */ var _goals_goalsWeek__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./goals/goalsWeek */ "./packages/loot-core/src/server/budget/goals/goalsWeek.ts");
|
|
38921
|
+
// @ts-strict-ignore
|
|
38839
38922
|
async function applyTemplate({ month }) {
|
|
38840
38923
|
await storeTemplates();
|
|
38841
38924
|
const category_templates = await getTemplates(null);
|
|
@@ -39379,6 +39462,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
39379
39462
|
/* harmony import */ var _sheet__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sheet */ "./packages/loot-core/src/server/sheet.ts");
|
|
39380
39463
|
/* harmony import */ var _spreadsheet_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../spreadsheet/util */ "./packages/loot-core/src/server/spreadsheet/util.ts");
|
|
39381
39464
|
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./util */ "./packages/loot-core/src/server/budget/util.ts");
|
|
39465
|
+
// @ts-strict-ignore
|
|
39382
39466
|
async function createCategory(cat, sheetName, prevSheetName) {
|
|
39383
39467
|
_sheet__WEBPACK_IMPORTED_MODULE_1__.get().createStatic(sheetName, `budget-${cat.id}`, 0);
|
|
39384
39468
|
// This makes the app more robust by "fixing up" null budget values.
|
|
@@ -39497,6 +39581,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
39497
39581
|
/* harmony import */ var _sheet__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../sheet */ "./packages/loot-core/src/server/sheet.ts");
|
|
39498
39582
|
/* harmony import */ var _spreadsheet_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../spreadsheet/util */ "./packages/loot-core/src/server/spreadsheet/util.ts");
|
|
39499
39583
|
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./util */ "./packages/loot-core/src/server/budget/util.ts");
|
|
39584
|
+
// @ts-strict-ignore
|
|
39500
39585
|
function getBlankSheet(months) {
|
|
39501
39586
|
const blankMonth = _shared_months__WEBPACK_IMPORTED_MODULE_0__.prevMonth(months[0]);
|
|
39502
39587
|
return _shared_months__WEBPACK_IMPORTED_MODULE_0__.sheetForMonth(blankMonth);
|
|
@@ -39658,6 +39743,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
39658
39743
|
});
|
|
39659
39744
|
/* harmony import */ var _shared_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../shared/util */ "./packages/loot-core/src/shared/util.ts");
|
|
39660
39745
|
/* harmony import */ var _spreadsheet_globals__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../spreadsheet/globals */ "./packages/loot-core/src/server/spreadsheet/globals.ts");
|
|
39746
|
+
// @ts-strict-ignore
|
|
39661
39747
|
function sumAmounts(...amounts) {
|
|
39662
39748
|
return (0, _shared_util__WEBPACK_IMPORTED_MODULE_0__.safeNumber)(amounts.reduce((total, amount) => {
|
|
39663
39749
|
return total + (0, _spreadsheet_globals__WEBPACK_IMPORTED_MODULE_1__.number)(amount);
|
|
@@ -39711,6 +39797,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
39711
39797
|
/* harmony import */ var _post__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./post */ "./packages/loot-core/src/server/post.ts");
|
|
39712
39798
|
/* harmony import */ var _prefs__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./prefs */ "./packages/loot-core/src/server/prefs.ts");
|
|
39713
39799
|
/* harmony import */ var _server_config__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./server-config */ "./packages/loot-core/src/server/server-config.ts");
|
|
39800
|
+
// @ts-strict-ignore
|
|
39714
39801
|
const UPLOAD_FREQUENCY_IN_DAYS = 7;
|
|
39715
39802
|
async function checkHTTPStatus(res) {
|
|
39716
39803
|
if (res.status !== 200) {
|
|
@@ -39977,7 +40064,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
39977
40064
|
return;
|
|
39978
40065
|
}
|
|
39979
40066
|
// Don't block on uploading
|
|
39980
|
-
upload().catch((
|
|
40067
|
+
upload().catch(() => { });
|
|
39981
40068
|
}
|
|
39982
40069
|
async function removeFile(fileId) {
|
|
39983
40070
|
const userToken = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_1__.getItem('user-token');
|
|
@@ -40105,7 +40192,6 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
40105
40192
|
/* harmony export */ getPayees: () => ( /* binding */getPayees),
|
|
40106
40193
|
/* harmony export */ getTransaction: () => ( /* binding */getTransaction),
|
|
40107
40194
|
/* harmony export */ getTransactions: () => ( /* binding */getTransactions),
|
|
40108
|
-
/* harmony export */ getTransactionsByDate: () => ( /* binding */getTransactionsByDate),
|
|
40109
40195
|
/* harmony export */ insert: () => ( /* binding */insert),
|
|
40110
40196
|
/* harmony export */ insertAccount: () => ( /* binding */insertAccount),
|
|
40111
40197
|
/* harmony export */ insertCategory: () => ( /* binding */insertCategory),
|
|
@@ -40150,6 +40236,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
40150
40236
|
/* harmony import */ var _models__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../models */ "./packages/loot-core/src/server/models.ts");
|
|
40151
40237
|
/* harmony import */ var _sync__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../sync */ "./packages/loot-core/src/server/sync/index.ts");
|
|
40152
40238
|
/* harmony import */ var _sort__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sort */ "./packages/loot-core/src/server/db/sort.ts");
|
|
40239
|
+
// @ts-strict-ignore
|
|
40153
40240
|
let dbPath;
|
|
40154
40241
|
let db;
|
|
40155
40242
|
// Util
|
|
@@ -40532,7 +40619,8 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
40532
40619
|
}
|
|
40533
40620
|
async function mergePayees(target, ids) {
|
|
40534
40621
|
// Load in payees so we can check some stuff
|
|
40535
|
-
const
|
|
40622
|
+
const dbPayees = await all('SELECT * FROM payees');
|
|
40623
|
+
const payees = (0, _shared_util__WEBPACK_IMPORTED_MODULE_4__.groupById)(dbPayees);
|
|
40536
40624
|
// Filter out any transfer payees
|
|
40537
40625
|
if (payees[target].transfer_acct != null) {
|
|
40538
40626
|
return;
|
|
@@ -40644,9 +40732,6 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
40644
40732
|
]);
|
|
40645
40733
|
return rows[0];
|
|
40646
40734
|
}
|
|
40647
|
-
async function getTransactionsByDate(accountId, startDate, endDate, options = {}) {
|
|
40648
|
-
throw new Error('`getTransactionsByDate` is deprecated');
|
|
40649
|
-
}
|
|
40650
40735
|
async function getTransactions(accountId) {
|
|
40651
40736
|
if (arguments.length > 1) {
|
|
40652
40737
|
throw new Error('`getTransactions` was given a second argument, it now only takes a single argument `accountId`');
|
|
@@ -40681,6 +40766,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
40681
40766
|
});
|
|
40682
40767
|
/* harmony import */ var _sync_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sync/index */ "./packages/loot-core/src/server/sync/index.ts");
|
|
40683
40768
|
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./index */ "./packages/loot-core/src/server/db/index.ts");
|
|
40769
|
+
// @ts-strict-ignore
|
|
40684
40770
|
// This file keeps all the mappings in memory so we can access it
|
|
40685
40771
|
// synchronously. This is primarily used in the rules system, but
|
|
40686
40772
|
// there may be other uses in the future. You don't need to worry
|
|
@@ -40817,6 +40903,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
40817
40903
|
/* harmony export */ whereIn: () => ( /* binding */whereIn)
|
|
40818
40904
|
/* harmony export */
|
|
40819
40905
|
});
|
|
40906
|
+
// @ts-strict-ignore
|
|
40820
40907
|
async function incrFetch(runQuery, terms, compare, makeQuery, params = []) {
|
|
40821
40908
|
const pageCount = 500;
|
|
40822
40909
|
let results = [];
|
|
@@ -40864,6 +40951,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
40864
40951
|
});
|
|
40865
40952
|
/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! crypto */ "crypto");
|
|
40866
40953
|
/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_0__);
|
|
40954
|
+
// @ts-strict-ignore
|
|
40867
40955
|
const ENCRYPTION_ALGORITHM = 'aes-256-gcm';
|
|
40868
40956
|
async function sha256String(str) {
|
|
40869
40957
|
return crypto__WEBPACK_IMPORTED_MODULE_0___default().createHash('sha256').update(str).digest('base64');
|
|
@@ -40952,6 +41040,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
40952
41040
|
});
|
|
40953
41041
|
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ "./node_modules/uuid/dist/esm-node/v4.js");
|
|
40954
41042
|
/* harmony import */ var _encryption_internals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./encryption-internals */ "./packages/loot-core/src/server/encryption-internals.ts");
|
|
41043
|
+
// @ts-strict-ignore
|
|
40955
41044
|
// A map of all possible master encryption keys to use, keyed by
|
|
40956
41045
|
// unique id
|
|
40957
41046
|
let keys = {};
|
|
@@ -41079,11 +41168,10 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41079
41168
|
this.type = name;
|
|
41080
41169
|
}
|
|
41081
41170
|
}
|
|
41082
|
-
function APIError(msg
|
|
41171
|
+
function APIError(msg) {
|
|
41083
41172
|
return {
|
|
41084
41173
|
type: 'APIError',
|
|
41085
|
-
message: msg
|
|
41086
|
-
meta
|
|
41174
|
+
message: msg
|
|
41087
41175
|
};
|
|
41088
41176
|
}
|
|
41089
41177
|
function FileDownloadError(reason, meta) {
|
|
@@ -41110,7 +41198,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41110
41198
|
"use strict";
|
|
41111
41199
|
__webpack_require__.r(__webpack_exports__);
|
|
41112
41200
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
41113
|
-
/* harmony export */
|
|
41201
|
+
/* harmony export */ app: () => ( /* binding */app)
|
|
41114
41202
|
/* harmony export */
|
|
41115
41203
|
});
|
|
41116
41204
|
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uuid */ "./node_modules/uuid/dist/esm-node/v4.js");
|
|
@@ -41120,6 +41208,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41120
41208
|
/* harmony import */ var _models__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../models */ "./packages/loot-core/src/server/models.ts");
|
|
41121
41209
|
/* harmony import */ var _mutators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../mutators */ "./packages/loot-core/src/server/mutators.ts");
|
|
41122
41210
|
/* harmony import */ var _undo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../undo */ "./packages/loot-core/src/server/undo.ts");
|
|
41211
|
+
// @ts-strict-ignore
|
|
41123
41212
|
const filterModel = {
|
|
41124
41213
|
validate(filter, { update } = {}) {
|
|
41125
41214
|
(0, _models__WEBPACK_IMPORTED_MODULE_3__.requiredFields)('transaction_filters', filter, [
|
|
@@ -41253,7 +41342,6 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41253
41342
|
app.method('filter-create', (0, _mutators__WEBPACK_IMPORTED_MODULE_4__.mutator)(createFilter));
|
|
41254
41343
|
app.method('filter-update', (0, _mutators__WEBPACK_IMPORTED_MODULE_4__.mutator)(updateFilter));
|
|
41255
41344
|
app.method('filter-delete', (0, _mutators__WEBPACK_IMPORTED_MODULE_4__.mutator)((0, _undo__WEBPACK_IMPORTED_MODULE_5__.undoable)(deleteFilter)));
|
|
41256
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (app);
|
|
41257
41345
|
/***/
|
|
41258
41346
|
}),
|
|
41259
41347
|
/***/ "./packages/loot-core/src/server/importers/actual.ts":
|
|
@@ -41264,7 +41352,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41264
41352
|
"use strict";
|
|
41265
41353
|
__webpack_require__.r(__webpack_exports__);
|
|
41266
41354
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
41267
|
-
/* harmony export */
|
|
41355
|
+
/* harmony export */ importActual: () => ( /* binding */importActual)
|
|
41268
41356
|
/* harmony export */
|
|
41269
41357
|
});
|
|
41270
41358
|
/* harmony import */ var _platform_server_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../platform/server/fs */ "./packages/loot-core/src/platform/server/fs/index.electron.ts");
|
|
@@ -41272,6 +41360,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41272
41360
|
/* harmony import */ var _cloud_storage__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../cloud-storage */ "./packages/loot-core/src/server/cloud-storage.ts");
|
|
41273
41361
|
/* harmony import */ var _main__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../main */ "./packages/loot-core/src/server/main.ts");
|
|
41274
41362
|
/* harmony import */ var _sheet__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sheet */ "./packages/loot-core/src/server/sheet.ts");
|
|
41363
|
+
// @ts-strict-ignore
|
|
41275
41364
|
async function importActual(_filepath, buffer) {
|
|
41276
41365
|
// Importing Actual files is a special case because we can directly
|
|
41277
41366
|
// write down the files, but because it doesn't go through the API
|
|
@@ -41307,7 +41396,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41307
41396
|
});
|
|
41308
41397
|
await _main__WEBPACK_IMPORTED_MODULE_3__.handlers['get-budget-bounds']();
|
|
41309
41398
|
await (0, _sheet__WEBPACK_IMPORTED_MODULE_4__.waitOnSpreadsheet)();
|
|
41310
|
-
await _cloud_storage__WEBPACK_IMPORTED_MODULE_2__.upload().catch((
|
|
41399
|
+
await _cloud_storage__WEBPACK_IMPORTED_MODULE_2__.upload().catch(() => { });
|
|
41311
41400
|
}
|
|
41312
41401
|
/***/
|
|
41313
41402
|
}),
|
|
@@ -41326,13 +41415,14 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41326
41415
|
/* harmony import */ var _actual__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actual */ "./packages/loot-core/src/server/importers/actual.ts");
|
|
41327
41416
|
/* harmony import */ var _ynab4__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ynab4 */ "./packages/loot-core/src/server/importers/ynab4.ts");
|
|
41328
41417
|
/* harmony import */ var _ynab5__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ynab5 */ "./packages/loot-core/src/server/importers/ynab5.ts");
|
|
41418
|
+
// @ts-strict-ignore
|
|
41329
41419
|
const importers = {
|
|
41330
41420
|
ynab4: _ynab4__WEBPACK_IMPORTED_MODULE_2__,
|
|
41331
41421
|
ynab5: _ynab5__WEBPACK_IMPORTED_MODULE_3__
|
|
41332
41422
|
};
|
|
41333
41423
|
async function handleBudgetImport(type, filepath, buffer) {
|
|
41334
41424
|
if (type === 'actual') {
|
|
41335
|
-
return (0, _actual__WEBPACK_IMPORTED_MODULE_1__
|
|
41425
|
+
return (0, _actual__WEBPACK_IMPORTED_MODULE_1__.importActual)(filepath, buffer);
|
|
41336
41426
|
}
|
|
41337
41427
|
const importer = importers[type];
|
|
41338
41428
|
try {
|
|
@@ -41388,7 +41478,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41388
41478
|
/* harmony export */
|
|
41389
41479
|
});
|
|
41390
41480
|
/* harmony import */ var _actual_app_api_injected__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @actual-app/api/injected */ "./packages/api/injected.js");
|
|
41391
|
-
/* harmony import */ var _actual_app_api_methods__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @actual-app/api/methods */ "./packages/api/methods.
|
|
41481
|
+
/* harmony import */ var _actual_app_api_methods__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @actual-app/api/methods */ "./packages/api/methods.ts");
|
|
41392
41482
|
/* harmony import */ var _actual_app_api_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @actual-app/api/utils */ "./packages/api/utils.js");
|
|
41393
41483
|
/* harmony import */ var adm_zip__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! adm-zip */ "./node_modules/adm-zip/adm-zip.js");
|
|
41394
41484
|
/* harmony import */ var adm_zip__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/ __webpack_require__.n(adm_zip__WEBPACK_IMPORTED_MODULE_3__);
|
|
@@ -41397,6 +41487,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41397
41487
|
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! uuid */ "./node_modules/uuid/dist/esm-node/v4.js");
|
|
41398
41488
|
/* harmony import */ var _shared_months__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../shared/months */ "./packages/loot-core/src/shared/months.ts");
|
|
41399
41489
|
/* harmony import */ var _shared_util__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../shared/util */ "./packages/loot-core/src/shared/util.ts");
|
|
41490
|
+
// @ts-strict-ignore
|
|
41400
41491
|
// This is a special usage of the API because this package is embedded
|
|
41401
41492
|
// into Actual itself. We only want to pull in the methods in that
|
|
41402
41493
|
// case and ignore everything else; otherwise we'd be pulling in the
|
|
@@ -41533,7 +41624,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41533
41624
|
notes: transaction.memo || null,
|
|
41534
41625
|
cleared: transaction.cleared === 'Cleared',
|
|
41535
41626
|
...transferProperties(transaction),
|
|
41536
|
-
subtransactions: transaction.subTransactions && transaction.subTransactions.map((t
|
|
41627
|
+
subtransactions: transaction.subTransactions && transaction.subTransactions.map((t) => {
|
|
41537
41628
|
return {
|
|
41538
41629
|
id: entityIdMap.get(t.entityId),
|
|
41539
41630
|
amount: (0, _actual_app_api_utils__WEBPACK_IMPORTED_MODULE_2__.amountToInteger)(t.amount),
|
|
@@ -41643,7 +41734,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41643
41734
|
await importBudgets(data, entityIdMap);
|
|
41644
41735
|
console.log('Setting up...');
|
|
41645
41736
|
}
|
|
41646
|
-
function getBudgetName(filepath
|
|
41737
|
+
function getBudgetName(filepath) {
|
|
41647
41738
|
let unixFilepath = slash__WEBPACK_IMPORTED_MODULE_4___default()(filepath);
|
|
41648
41739
|
if (!/\.zip/.test(unixFilepath)) {
|
|
41649
41740
|
return null;
|
|
@@ -41717,10 +41808,11 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41717
41808
|
/* harmony export */ parseFile: () => ( /* binding */parseFile)
|
|
41718
41809
|
/* harmony export */
|
|
41719
41810
|
});
|
|
41720
|
-
/* harmony import */ var _actual_app_api_methods__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @actual-app/api/methods */ "./packages/api/methods.
|
|
41811
|
+
/* harmony import */ var _actual_app_api_methods__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @actual-app/api/methods */ "./packages/api/methods.ts");
|
|
41721
41812
|
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! uuid */ "./node_modules/uuid/dist/esm-node/v4.js");
|
|
41722
41813
|
/* harmony import */ var _shared_months__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../shared/months */ "./packages/loot-core/src/shared/months.ts");
|
|
41723
41814
|
/* harmony import */ var _shared_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../shared/util */ "./packages/loot-core/src/shared/util.ts");
|
|
41815
|
+
// @ts-strict-ignore
|
|
41724
41816
|
// This is a special usage of the API because this package is embedded
|
|
41725
41817
|
// into Actual itself. We only want to pull in the methods in that
|
|
41726
41818
|
// case and ignore everything else; otherwise we'd be pulling in the
|
|
@@ -41746,21 +41838,21 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41746
41838
|
// Hidden categories are put in its own group by YNAB,
|
|
41747
41839
|
// so it's already handled.
|
|
41748
41840
|
const categories = await _actual_app_api_methods__WEBPACK_IMPORTED_MODULE_0__.getCategories();
|
|
41749
|
-
const incomeCatId = categories
|
|
41841
|
+
const incomeCatId = findIdByName(categories, 'Income');
|
|
41750
41842
|
const ynabIncomeCategories = [
|
|
41751
41843
|
'To be Budgeted',
|
|
41752
41844
|
'Inflow: Ready to Assign'
|
|
41753
41845
|
];
|
|
41754
41846
|
function checkSpecialCat(cat) {
|
|
41755
|
-
if (cat.category_group_id === data.category_groups
|
|
41756
|
-
if (ynabIncomeCategories.
|
|
41847
|
+
if (cat.category_group_id === findIdByName(data.category_groups, 'Internal Master Category')) {
|
|
41848
|
+
if (ynabIncomeCategories.some((ynabIncomeCategory) => equalsIgnoreCase(cat.name, ynabIncomeCategory))) {
|
|
41757
41849
|
return 'income';
|
|
41758
41850
|
}
|
|
41759
41851
|
else {
|
|
41760
41852
|
return 'internal';
|
|
41761
41853
|
}
|
|
41762
41854
|
}
|
|
41763
|
-
else if (cat.category_group_id === data.category_groups
|
|
41855
|
+
else if (cat.category_group_id === findIdByName(data.category_groups, 'Credit Card Payments')) {
|
|
41764
41856
|
return 'creditCard';
|
|
41765
41857
|
}
|
|
41766
41858
|
}
|
|
@@ -41770,7 +41862,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41770
41862
|
if (!group.deleted) {
|
|
41771
41863
|
let groupId;
|
|
41772
41864
|
// Ignores internal category and credit cards
|
|
41773
|
-
if (group.name
|
|
41865
|
+
if (!equalsIgnoreCase(group.name, 'Internal Master Category') && !equalsIgnoreCase(group.name, 'Credit Card Payments')) {
|
|
41774
41866
|
groupId = await _actual_app_api_methods__WEBPACK_IMPORTED_MODULE_0__.createCategoryGroup({
|
|
41775
41867
|
name: group.name,
|
|
41776
41868
|
is_income: false
|
|
@@ -41821,9 +41913,9 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41821
41913
|
async function importTransactions(data, entityIdMap) {
|
|
41822
41914
|
const payees = await _actual_app_api_methods__WEBPACK_IMPORTED_MODULE_0__.getPayees();
|
|
41823
41915
|
const categories = await _actual_app_api_methods__WEBPACK_IMPORTED_MODULE_0__.getCategories();
|
|
41824
|
-
const incomeCatId = categories
|
|
41825
|
-
const startingBalanceCatId = categories
|
|
41826
|
-
const startingPayeeYNAB = data.payees
|
|
41916
|
+
const incomeCatId = findIdByName(categories, 'Income');
|
|
41917
|
+
const startingBalanceCatId = findIdByName(categories, 'Starting Balances'); //better way to do it?
|
|
41918
|
+
const startingPayeeYNAB = findIdByName(data.payees, 'Starting Balance');
|
|
41827
41919
|
const transactionsGrouped = (0, _shared_util__WEBPACK_IMPORTED_MODULE_2__.groupBy)(data.transactions, 'account_id');
|
|
41828
41920
|
const subtransactionsGrouped = (0, _shared_util__WEBPACK_IMPORTED_MODULE_2__.groupBy)(data.subtransactions, 'transaction_id');
|
|
41829
41921
|
const payeesByTransferAcct = payees.filter((payee) => payee?.transfer_acct).map((payee) => [
|
|
@@ -41908,8 +42000,8 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41908
42000
|
// Also, there could be a way to set rollover using
|
|
41909
42001
|
// Deferred Income Subcat and Immediate Income Subcat
|
|
41910
42002
|
const budgets = (0, _shared_util__WEBPACK_IMPORTED_MODULE_2__.sortByKey)(data.months, 'month');
|
|
41911
|
-
const internalCatIdYnab = data.category_groups
|
|
41912
|
-
const creditcardCatIdYnab = data.category_groups
|
|
42003
|
+
const internalCatIdYnab = findIdByName(data.category_groups, 'Internal Master Category');
|
|
42004
|
+
const creditcardCatIdYnab = findIdByName(data.category_groups, 'Credit Card Payments');
|
|
41913
42005
|
await _actual_app_api_methods__WEBPACK_IMPORTED_MODULE_0__.batchBudgetUpdates(async () => {
|
|
41914
42006
|
for (const budget of budgets) {
|
|
41915
42007
|
const month = _shared_months__WEBPACK_IMPORTED_MODULE_1__.monthFromDate(budget.month);
|
|
@@ -41952,6 +42044,17 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41952
42044
|
function getBudgetName(_filepath, data) {
|
|
41953
42045
|
return data.budget_name || data.name;
|
|
41954
42046
|
}
|
|
42047
|
+
function equalsIgnoreCase(stringa, stringb) {
|
|
42048
|
+
return stringa.localeCompare(stringb, undefined, {
|
|
42049
|
+
sensitivity: 'base'
|
|
42050
|
+
}) === 0;
|
|
42051
|
+
}
|
|
42052
|
+
function findByNameIgnoreCase(categories, name) {
|
|
42053
|
+
return categories.find((cat) => equalsIgnoreCase(cat.name, name));
|
|
42054
|
+
}
|
|
42055
|
+
function findIdByName(categories, name) {
|
|
42056
|
+
return findByNameIgnoreCase(categories, name)?.id;
|
|
42057
|
+
}
|
|
41955
42058
|
/***/
|
|
41956
42059
|
}),
|
|
41957
42060
|
/***/ "./packages/loot-core/src/server/main-app.ts":
|
|
@@ -41962,7 +42065,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41962
42065
|
"use strict";
|
|
41963
42066
|
__webpack_require__.r(__webpack_exports__);
|
|
41964
42067
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
41965
|
-
/* harmony export */
|
|
42068
|
+
/* harmony export */ app: () => ( /* binding */app)
|
|
41966
42069
|
/* harmony export */
|
|
41967
42070
|
});
|
|
41968
42071
|
/* harmony import */ var _platform_server_connection__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../platform/server/connection */ "./packages/loot-core/src/platform/server/connection/index.api.ts");
|
|
@@ -41972,7 +42075,6 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41972
42075
|
app.events.on('sync', (info) => {
|
|
41973
42076
|
_platform_server_connection__WEBPACK_IMPORTED_MODULE_0__.send('sync-event', info);
|
|
41974
42077
|
});
|
|
41975
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (app);
|
|
41976
42078
|
/***/
|
|
41977
42079
|
}),
|
|
41978
42080
|
/***/ "./packages/loot-core/src/server/main.ts":
|
|
@@ -41993,7 +42095,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
41993
42095
|
/* harmony import */ var _polyfills__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/ __webpack_require__.n(_polyfills__WEBPACK_IMPORTED_MODULE_0__);
|
|
41994
42096
|
/* harmony import */ var _actual_app_api_injected__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @actual-app/api/injected */ "./packages/api/injected.js");
|
|
41995
42097
|
/* harmony import */ var _actual_app_crdt__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @actual-app/crdt */ "./packages/crdt/index.ts");
|
|
41996
|
-
/* harmony import */ var
|
|
42098
|
+
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_51__ = __webpack_require__(/*! uuid */ "./node_modules/uuid/dist/esm-node/v4.js");
|
|
41997
42099
|
/* harmony import */ var _mocks_budget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mocks/budget */ "./packages/loot-core/src/mocks/budget.ts");
|
|
41998
42100
|
/* harmony import */ var _platform_exceptions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../platform/exceptions */ "./packages/loot-core/src/platform/exceptions/index.electron.ts");
|
|
41999
42101
|
/* harmony import */ var _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../platform/server/asyncStorage */ "./packages/loot-core/src/platform/server/asyncStorage/index.electron.ts");
|
|
@@ -42030,23 +42132,25 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42030
42132
|
/* harmony import */ var _platform__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./platform */ "./packages/loot-core/src/server/platform.ts");
|
|
42031
42133
|
/* harmony import */ var _post__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./post */ "./packages/loot-core/src/server/post.ts");
|
|
42032
42134
|
/* harmony import */ var _prefs__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ./prefs */ "./packages/loot-core/src/server/prefs.ts");
|
|
42033
|
-
/* harmony import */ var
|
|
42034
|
-
/* harmony import */ var
|
|
42035
|
-
/* harmony import */ var
|
|
42036
|
-
/* harmony import */ var
|
|
42037
|
-
/* harmony import */ var
|
|
42038
|
-
/* harmony import */ var
|
|
42039
|
-
/* harmony import */ var
|
|
42040
|
-
/* harmony import */ var
|
|
42041
|
-
/* harmony import */ var
|
|
42042
|
-
/* harmony import */ var
|
|
42043
|
-
/* harmony import */ var
|
|
42135
|
+
/* harmony import */ var _reports_app__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./reports/app */ "./packages/loot-core/src/server/reports/app.ts");
|
|
42136
|
+
/* harmony import */ var _rules_app__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ./rules/app */ "./packages/loot-core/src/server/rules/app.ts");
|
|
42137
|
+
/* harmony import */ var _schedules_app__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ./schedules/app */ "./packages/loot-core/src/server/schedules/app.ts");
|
|
42138
|
+
/* harmony import */ var _server_config__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ./server-config */ "./packages/loot-core/src/server/server-config.ts");
|
|
42139
|
+
/* harmony import */ var _sheet__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(/*! ./sheet */ "./packages/loot-core/src/server/sheet.ts");
|
|
42140
|
+
/* harmony import */ var _spreadsheet_util__WEBPACK_IMPORTED_MODULE_44__ = __webpack_require__(/*! ./spreadsheet/util */ "./packages/loot-core/src/server/spreadsheet/util.ts");
|
|
42141
|
+
/* harmony import */ var _sync__WEBPACK_IMPORTED_MODULE_45__ = __webpack_require__(/*! ./sync */ "./packages/loot-core/src/server/sync/index.ts");
|
|
42142
|
+
/* harmony import */ var _sync_migrate__WEBPACK_IMPORTED_MODULE_46__ = __webpack_require__(/*! ./sync/migrate */ "./packages/loot-core/src/server/sync/migrate.ts");
|
|
42143
|
+
/* harmony import */ var _tools_app__WEBPACK_IMPORTED_MODULE_47__ = __webpack_require__(/*! ./tools/app */ "./packages/loot-core/src/server/tools/app.ts");
|
|
42144
|
+
/* harmony import */ var _undo__WEBPACK_IMPORTED_MODULE_48__ = __webpack_require__(/*! ./undo */ "./packages/loot-core/src/server/undo.ts");
|
|
42145
|
+
/* harmony import */ var _update__WEBPACK_IMPORTED_MODULE_49__ = __webpack_require__(/*! ./update */ "./packages/loot-core/src/server/update.ts");
|
|
42146
|
+
/* harmony import */ var _util_budget_name__WEBPACK_IMPORTED_MODULE_50__ = __webpack_require__(/*! ./util/budget-name */ "./packages/loot-core/src/server/util/budget-name.ts");
|
|
42147
|
+
// @ts-strict-ignore
|
|
42044
42148
|
const DEMO_BUDGET_ID = '_demo-budget';
|
|
42045
42149
|
const TEST_BUDGET_ID = '_test-budget';
|
|
42046
42150
|
// util
|
|
42047
42151
|
function onSheetChange({ names }) {
|
|
42048
42152
|
const nodes = names.map((name) => {
|
|
42049
|
-
const node =
|
|
42153
|
+
const node = _sheet__WEBPACK_IMPORTED_MODULE_43__.get()._getNode(name);
|
|
42050
42154
|
return {
|
|
42051
42155
|
name: node.name,
|
|
42052
42156
|
value: node.value
|
|
@@ -42059,13 +42163,13 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42059
42163
|
// is /currently/ empty but we promise to fill it in later
|
|
42060
42164
|
let handlers = {};
|
|
42061
42165
|
handlers['undo'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function () {
|
|
42062
|
-
return (0,
|
|
42166
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.undo)();
|
|
42063
42167
|
});
|
|
42064
42168
|
handlers['redo'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(function () {
|
|
42065
|
-
return (0,
|
|
42169
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.redo)();
|
|
42066
42170
|
});
|
|
42067
42171
|
handlers['transactions-batch-update'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function ({ added, deleted, updated, learnCategories }) {
|
|
42068
|
-
return (0,
|
|
42172
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
42069
42173
|
const result = await (0, _accounts_transactions__WEBPACK_IMPORTED_MODULE_20__.batchUpdateTransactions)({
|
|
42070
42174
|
added,
|
|
42071
42175
|
updated,
|
|
@@ -42116,7 +42220,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42116
42220
|
};
|
|
42117
42221
|
};
|
|
42118
42222
|
handlers['get-earliest-transaction'] = async function () {
|
|
42119
|
-
const { data } = await (0, _aql__WEBPACK_IMPORTED_MODULE_22__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_12__
|
|
42223
|
+
const { data } = await (0, _aql__WEBPACK_IMPORTED_MODULE_22__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_12__.q)('transactions').options({
|
|
42120
42224
|
splits: 'none'
|
|
42121
42225
|
}).orderBy({
|
|
42122
42226
|
date: 'asc'
|
|
@@ -42130,10 +42234,10 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42130
42234
|
const groups = await _db__WEBPACK_IMPORTED_MODULE_27__.getCategoriesGrouped();
|
|
42131
42235
|
const sheetName = _shared_months__WEBPACK_IMPORTED_MODULE_11__.sheetForMonth(month);
|
|
42132
42236
|
function value(name) {
|
|
42133
|
-
const v =
|
|
42237
|
+
const v = _sheet__WEBPACK_IMPORTED_MODULE_43__.getCellValue(sheetName, name);
|
|
42134
42238
|
return {
|
|
42135
42239
|
value: v === '' ? 0 : v,
|
|
42136
|
-
name: (0,
|
|
42240
|
+
name: (0, _spreadsheet_util__WEBPACK_IMPORTED_MODULE_44__.resolveName)(sheetName, name)
|
|
42137
42241
|
};
|
|
42138
42242
|
}
|
|
42139
42243
|
let values = [
|
|
@@ -42176,10 +42280,10 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42176
42280
|
const groups = await _db__WEBPACK_IMPORTED_MODULE_27__.getCategoriesGrouped();
|
|
42177
42281
|
const sheetName = _shared_months__WEBPACK_IMPORTED_MODULE_11__.sheetForMonth(month);
|
|
42178
42282
|
function value(name) {
|
|
42179
|
-
const v =
|
|
42283
|
+
const v = _sheet__WEBPACK_IMPORTED_MODULE_43__.getCellValue(sheetName, name);
|
|
42180
42284
|
return {
|
|
42181
42285
|
value: v === '' ? 0 : v,
|
|
42182
|
-
name: (0,
|
|
42286
|
+
name: (0, _spreadsheet_util__WEBPACK_IMPORTED_MODULE_44__.resolveName)(sheetName, name)
|
|
42183
42287
|
};
|
|
42184
42288
|
}
|
|
42185
42289
|
let values = [
|
|
@@ -42224,7 +42328,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42224
42328
|
});
|
|
42225
42329
|
};
|
|
42226
42330
|
handlers['category-create'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function ({ name, groupId, isIncome, hidden }) {
|
|
42227
|
-
return (0,
|
|
42331
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
42228
42332
|
if (!groupId) {
|
|
42229
42333
|
throw (0, _errors__WEBPACK_IMPORTED_MODULE_30__.APIError)('Creating a category: groupId is required');
|
|
42230
42334
|
}
|
|
@@ -42237,7 +42341,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42237
42341
|
});
|
|
42238
42342
|
});
|
|
42239
42343
|
handlers['category-update'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function (category) {
|
|
42240
|
-
return (0,
|
|
42344
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
42241
42345
|
try {
|
|
42242
42346
|
await _db__WEBPACK_IMPORTED_MODULE_27__.updateCategory(category);
|
|
42243
42347
|
}
|
|
@@ -42255,17 +42359,17 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42255
42359
|
});
|
|
42256
42360
|
});
|
|
42257
42361
|
handlers['category-move'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function ({ id, groupId, targetId }) {
|
|
42258
|
-
return (0,
|
|
42259
|
-
await (0,
|
|
42362
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
42363
|
+
await (0, _sync__WEBPACK_IMPORTED_MODULE_45__.batchMessages)(async () => {
|
|
42260
42364
|
await _db__WEBPACK_IMPORTED_MODULE_27__.moveCategory(id, groupId, targetId);
|
|
42261
42365
|
});
|
|
42262
42366
|
return 'ok';
|
|
42263
42367
|
});
|
|
42264
42368
|
});
|
|
42265
42369
|
handlers['category-delete'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function ({ id, transferId }) {
|
|
42266
|
-
return (0,
|
|
42370
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
42267
42371
|
let result = {};
|
|
42268
|
-
await (0,
|
|
42372
|
+
await (0, _sync__WEBPACK_IMPORTED_MODULE_45__.batchMessages)(async () => {
|
|
42269
42373
|
const row = await _db__WEBPACK_IMPORTED_MODULE_27__.first('SELECT is_income FROM categories WHERE id = ?', [
|
|
42270
42374
|
id
|
|
42271
42375
|
]);
|
|
@@ -42307,7 +42411,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42307
42411
|
});
|
|
42308
42412
|
});
|
|
42309
42413
|
handlers['category-group-create'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function ({ name, isIncome }) {
|
|
42310
|
-
return (0,
|
|
42414
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
42311
42415
|
return _db__WEBPACK_IMPORTED_MODULE_27__.insertCategoryGroup({
|
|
42312
42416
|
name,
|
|
42313
42417
|
is_income: isIncome ? 1 : 0
|
|
@@ -42315,24 +42419,24 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42315
42419
|
});
|
|
42316
42420
|
});
|
|
42317
42421
|
handlers['category-group-update'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function (group) {
|
|
42318
|
-
return (0,
|
|
42422
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
42319
42423
|
return _db__WEBPACK_IMPORTED_MODULE_27__.updateCategoryGroup(group);
|
|
42320
42424
|
});
|
|
42321
42425
|
});
|
|
42322
42426
|
handlers['category-group-move'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function ({ id, targetId }) {
|
|
42323
|
-
return (0,
|
|
42324
|
-
await (0,
|
|
42427
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
42428
|
+
await (0, _sync__WEBPACK_IMPORTED_MODULE_45__.batchMessages)(async () => {
|
|
42325
42429
|
await _db__WEBPACK_IMPORTED_MODULE_27__.moveCategoryGroup(id, targetId);
|
|
42326
42430
|
});
|
|
42327
42431
|
return 'ok';
|
|
42328
42432
|
});
|
|
42329
42433
|
});
|
|
42330
42434
|
handlers['category-group-delete'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function ({ id, transferId }) {
|
|
42331
|
-
return (0,
|
|
42435
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
42332
42436
|
const groupCategories = await _db__WEBPACK_IMPORTED_MODULE_27__.all('SELECT id FROM categories WHERE cat_group = ? AND tombstone = 0', [
|
|
42333
42437
|
id
|
|
42334
42438
|
]);
|
|
42335
|
-
return (0,
|
|
42439
|
+
return (0, _sync__WEBPACK_IMPORTED_MODULE_45__.batchMessages)(async () => {
|
|
42336
42440
|
if (transferId) {
|
|
42337
42441
|
await _budget_base__WEBPACK_IMPORTED_MODULE_25__.doTransfer(groupCategories.map((c) => c.id), transferId);
|
|
42338
42442
|
}
|
|
@@ -42356,15 +42460,15 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42356
42460
|
// If there are any non-zero budget values, also force the user to
|
|
42357
42461
|
// transfer the category.
|
|
42358
42462
|
return [
|
|
42359
|
-
...
|
|
42463
|
+
..._sheet__WEBPACK_IMPORTED_MODULE_43__.get().meta().createdMonths
|
|
42360
42464
|
].some((month) => {
|
|
42361
42465
|
const sheetName = _shared_months__WEBPACK_IMPORTED_MODULE_11__.sheetForMonth(month);
|
|
42362
|
-
const value =
|
|
42466
|
+
const value = _sheet__WEBPACK_IMPORTED_MODULE_43__.get().getCellValue(sheetName, 'budget-' + id);
|
|
42363
42467
|
return value != null && value !== 0;
|
|
42364
42468
|
});
|
|
42365
42469
|
};
|
|
42366
42470
|
handlers['payee-create'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function ({ name }) {
|
|
42367
|
-
return (0,
|
|
42471
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
42368
42472
|
return _db__WEBPACK_IMPORTED_MODULE_27__.insertPayee({
|
|
42369
42473
|
name
|
|
42370
42474
|
});
|
|
@@ -42387,7 +42491,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42387
42491
|
return payeeCounts;
|
|
42388
42492
|
};
|
|
42389
42493
|
handlers['payees-merge'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function ({ targetId, mergeIds }) {
|
|
42390
|
-
return (0,
|
|
42494
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
42391
42495
|
return _db__WEBPACK_IMPORTED_MODULE_27__.mergePayees(targetId, mergeIds);
|
|
42392
42496
|
}, {
|
|
42393
42497
|
targetId,
|
|
@@ -42395,8 +42499,8 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42395
42499
|
});
|
|
42396
42500
|
});
|
|
42397
42501
|
handlers['payees-batch-change'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function ({ added, deleted, updated }) {
|
|
42398
|
-
return (0,
|
|
42399
|
-
return (0,
|
|
42502
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
42503
|
+
return (0, _sync__WEBPACK_IMPORTED_MODULE_45__.batchMessages)(async () => {
|
|
42400
42504
|
if (deleted) {
|
|
42401
42505
|
await Promise.all(deleted.map((p) => _db__WEBPACK_IMPORTED_MODULE_27__.deletePayee(p)));
|
|
42402
42506
|
}
|
|
@@ -42425,7 +42529,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42425
42529
|
'name',
|
|
42426
42530
|
'value'
|
|
42427
42531
|
];
|
|
42428
|
-
const node =
|
|
42532
|
+
const node = _sheet__WEBPACK_IMPORTED_MODULE_43__.get()._getNode((0, _spreadsheet_util__WEBPACK_IMPORTED_MODULE_44__.resolveName)(sheetName, name));
|
|
42429
42533
|
if (fields) {
|
|
42430
42534
|
const res = {};
|
|
42431
42535
|
fields.forEach((field) => {
|
|
@@ -42444,13 +42548,13 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42444
42548
|
};
|
|
42445
42549
|
handlers['getCells'] = async function ({ names }) {
|
|
42446
42550
|
return names.map((name) => ({
|
|
42447
|
-
value:
|
|
42551
|
+
value: _sheet__WEBPACK_IMPORTED_MODULE_43__.get()._getNode(name).value
|
|
42448
42552
|
}));
|
|
42449
42553
|
};
|
|
42450
42554
|
handlers['getCellNamesInSheet'] = async function ({ sheetName }) {
|
|
42451
42555
|
const names = [];
|
|
42452
|
-
for (const name of
|
|
42453
|
-
const { sheet: nodeSheet, name: nodeName } = (0,
|
|
42556
|
+
for (const name of _sheet__WEBPACK_IMPORTED_MODULE_43__.get().getNodes().keys()) {
|
|
42557
|
+
const { sheet: nodeSheet, name: nodeName } = (0, _spreadsheet_util__WEBPACK_IMPORTED_MODULE_44__.unresolveName)(name);
|
|
42454
42558
|
if (nodeSheet === sheetName) {
|
|
42455
42559
|
names.push(nodeName);
|
|
42456
42560
|
}
|
|
@@ -42458,7 +42562,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42458
42562
|
return names;
|
|
42459
42563
|
};
|
|
42460
42564
|
handlers['debugCell'] = async function ({ sheetName, name }) {
|
|
42461
|
-
const node =
|
|
42565
|
+
const node = _sheet__WEBPACK_IMPORTED_MODULE_43__.get().getNode((0, _spreadsheet_util__WEBPACK_IMPORTED_MODULE_44__.resolveName)(sheetName, name));
|
|
42462
42566
|
return {
|
|
42463
42567
|
...node,
|
|
42464
42568
|
_run: node._run && node._run.toString()
|
|
@@ -42467,7 +42571,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42467
42571
|
handlers['create-query'] = async function ({ sheetName, name, query }) {
|
|
42468
42572
|
// Always run it regardless of cache. We don't know anything has changed
|
|
42469
42573
|
// between the cache value being saved and now
|
|
42470
|
-
|
|
42574
|
+
_sheet__WEBPACK_IMPORTED_MODULE_43__.get().createQuery(sheetName, name, query);
|
|
42471
42575
|
return 'ok';
|
|
42472
42576
|
};
|
|
42473
42577
|
handlers['query'] = async function (query) {
|
|
@@ -42492,7 +42596,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42492
42596
|
return 'ok';
|
|
42493
42597
|
};
|
|
42494
42598
|
handlers['account-update'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function ({ id, name }) {
|
|
42495
|
-
return (0,
|
|
42599
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
42496
42600
|
await _db__WEBPACK_IMPORTED_MODULE_27__.update('accounts', {
|
|
42497
42601
|
id,
|
|
42498
42602
|
name
|
|
@@ -42554,25 +42658,27 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42554
42658
|
await _db__WEBPACK_IMPORTED_MODULE_27__.update('accounts', {
|
|
42555
42659
|
id,
|
|
42556
42660
|
account_id: account.account_id,
|
|
42557
|
-
bank: bank.id
|
|
42661
|
+
bank: bank.id,
|
|
42662
|
+
account_sync_source: 'goCardless'
|
|
42558
42663
|
});
|
|
42559
42664
|
}
|
|
42560
42665
|
else {
|
|
42561
|
-
id = (0,
|
|
42666
|
+
id = (0, uuid__WEBPACK_IMPORTED_MODULE_51__["default"])();
|
|
42562
42667
|
await _db__WEBPACK_IMPORTED_MODULE_27__.insertWithUUID('accounts', {
|
|
42563
42668
|
id,
|
|
42564
42669
|
account_id: account.account_id,
|
|
42565
42670
|
mask: account.mask,
|
|
42566
42671
|
name: account.name,
|
|
42567
42672
|
official_name: account.official_name,
|
|
42568
|
-
bank: bank.id
|
|
42673
|
+
bank: bank.id,
|
|
42674
|
+
account_sync_source: 'goCardless'
|
|
42569
42675
|
});
|
|
42570
42676
|
await _db__WEBPACK_IMPORTED_MODULE_27__.insertPayee({
|
|
42571
42677
|
name: '',
|
|
42572
42678
|
transfer_acct: id
|
|
42573
42679
|
});
|
|
42574
42680
|
}
|
|
42575
|
-
await _accounts_sync__WEBPACK_IMPORTED_MODULE_18__.
|
|
42681
|
+
await _accounts_sync__WEBPACK_IMPORTED_MODULE_18__.syncExternalAccount(undefined, undefined, id, account.account_id, bank.bank_id);
|
|
42576
42682
|
_platform_server_connection__WEBPACK_IMPORTED_MODULE_6__.send('sync-event', {
|
|
42577
42683
|
type: 'success',
|
|
42578
42684
|
tables: [
|
|
@@ -42581,6 +42687,48 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42581
42687
|
});
|
|
42582
42688
|
return 'ok';
|
|
42583
42689
|
};
|
|
42690
|
+
handlers['simplefin-accounts-link'] = async function ({ externalAccount, upgradingId }) {
|
|
42691
|
+
let id;
|
|
42692
|
+
const institution = {
|
|
42693
|
+
name: externalAccount.institution ?? 'Unknown'
|
|
42694
|
+
};
|
|
42695
|
+
const bank = await _accounts_link__WEBPACK_IMPORTED_MODULE_15__.findOrCreateBank(institution, externalAccount.orgDomain);
|
|
42696
|
+
if (upgradingId) {
|
|
42697
|
+
const accRow = await _db__WEBPACK_IMPORTED_MODULE_27__.first('SELECT * FROM accounts WHERE id = ?', [
|
|
42698
|
+
upgradingId
|
|
42699
|
+
]);
|
|
42700
|
+
id = accRow.id;
|
|
42701
|
+
await _db__WEBPACK_IMPORTED_MODULE_27__.update('accounts', {
|
|
42702
|
+
id,
|
|
42703
|
+
account_id: externalAccount.account_id,
|
|
42704
|
+
bank: bank.id,
|
|
42705
|
+
account_sync_source: 'simpleFin'
|
|
42706
|
+
});
|
|
42707
|
+
}
|
|
42708
|
+
else {
|
|
42709
|
+
id = (0, uuid__WEBPACK_IMPORTED_MODULE_51__["default"])();
|
|
42710
|
+
await _db__WEBPACK_IMPORTED_MODULE_27__.insertWithUUID('accounts', {
|
|
42711
|
+
id,
|
|
42712
|
+
account_id: externalAccount.account_id,
|
|
42713
|
+
name: externalAccount.name,
|
|
42714
|
+
official_name: externalAccount.name,
|
|
42715
|
+
bank: bank.id,
|
|
42716
|
+
account_sync_source: 'simpleFin'
|
|
42717
|
+
});
|
|
42718
|
+
await _db__WEBPACK_IMPORTED_MODULE_27__.insertPayee({
|
|
42719
|
+
name: '',
|
|
42720
|
+
transfer_acct: id
|
|
42721
|
+
});
|
|
42722
|
+
}
|
|
42723
|
+
await _accounts_sync__WEBPACK_IMPORTED_MODULE_18__.syncExternalAccount(undefined, undefined, id, externalAccount.account_id, bank.bank_id);
|
|
42724
|
+
await _platform_server_connection__WEBPACK_IMPORTED_MODULE_6__.send('sync-event', {
|
|
42725
|
+
type: 'success',
|
|
42726
|
+
tables: [
|
|
42727
|
+
'transactions'
|
|
42728
|
+
]
|
|
42729
|
+
});
|
|
42730
|
+
return 'ok';
|
|
42731
|
+
};
|
|
42584
42732
|
handlers['accounts-connect'] = async function ({ institution, publicToken, accountIds, offbudgetIds }) {
|
|
42585
42733
|
const bankId = await _accounts_link__WEBPACK_IMPORTED_MODULE_15__.handoffPublicToken(institution, publicToken);
|
|
42586
42734
|
const ids = await _accounts_link__WEBPACK_IMPORTED_MODULE_15__.addAccounts(bankId, accountIds, offbudgetIds);
|
|
@@ -42592,7 +42740,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42592
42740
|
return ids;
|
|
42593
42741
|
};
|
|
42594
42742
|
handlers['account-create'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function ({ name, balance, offBudget, closed }) {
|
|
42595
|
-
return (0,
|
|
42743
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
42596
42744
|
const id = await _db__WEBPACK_IMPORTED_MODULE_27__.insertAccount({
|
|
42597
42745
|
name,
|
|
42598
42746
|
offbudget: offBudget ? 1 : 0,
|
|
@@ -42624,7 +42772,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42624
42772
|
await handlers['account-unlink']({
|
|
42625
42773
|
id
|
|
42626
42774
|
});
|
|
42627
|
-
return (0,
|
|
42775
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
42628
42776
|
const account = await _db__WEBPACK_IMPORTED_MODULE_27__.first('SELECT * FROM accounts WHERE id = ? AND tombstone = 0', [
|
|
42629
42777
|
id
|
|
42630
42778
|
]);
|
|
@@ -42649,7 +42797,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42649
42797
|
const { id: payeeId } = await _db__WEBPACK_IMPORTED_MODULE_27__.first('SELECT id FROM payees WHERE transfer_acct = ?', [
|
|
42650
42798
|
id
|
|
42651
42799
|
]);
|
|
42652
|
-
await (0,
|
|
42800
|
+
await (0, _sync__WEBPACK_IMPORTED_MODULE_45__.batchMessages)(async () => {
|
|
42653
42801
|
// TODO: what this should really do is send a special message that
|
|
42654
42802
|
// automatically marks the tombstone value for all transactions
|
|
42655
42803
|
// within an account... or something? This is problematic
|
|
@@ -42690,7 +42838,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42690
42838
|
transferAccountId
|
|
42691
42839
|
]);
|
|
42692
42840
|
await handlers['transaction-add']({
|
|
42693
|
-
id: (0,
|
|
42841
|
+
id: (0, uuid__WEBPACK_IMPORTED_MODULE_51__["default"])(),
|
|
42694
42842
|
payee: payeeId,
|
|
42695
42843
|
amount: -balance,
|
|
42696
42844
|
account: id,
|
|
@@ -42703,7 +42851,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42703
42851
|
});
|
|
42704
42852
|
});
|
|
42705
42853
|
handlers['account-reopen'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function ({ id }) {
|
|
42706
|
-
return (0,
|
|
42854
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
42707
42855
|
await _db__WEBPACK_IMPORTED_MODULE_27__.update('accounts', {
|
|
42708
42856
|
id,
|
|
42709
42857
|
closed: 0
|
|
@@ -42711,7 +42859,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42711
42859
|
});
|
|
42712
42860
|
});
|
|
42713
42861
|
handlers['account-move'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function ({ id, targetId }) {
|
|
42714
|
-
return (0,
|
|
42862
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
42715
42863
|
await _db__WEBPACK_IMPORTED_MODULE_27__.moveAccount(id, targetId);
|
|
42716
42864
|
});
|
|
42717
42865
|
});
|
|
@@ -42731,7 +42879,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42731
42879
|
cb('timeout');
|
|
42732
42880
|
return;
|
|
42733
42881
|
}
|
|
42734
|
-
const data = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0,
|
|
42882
|
+
const data = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().PLAID_SERVER + '/get-web-token-contents', {
|
|
42735
42883
|
userId,
|
|
42736
42884
|
key,
|
|
42737
42885
|
token
|
|
@@ -42845,7 +42993,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42845
42993
|
};
|
|
42846
42994
|
}
|
|
42847
42995
|
try {
|
|
42848
|
-
return await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0,
|
|
42996
|
+
return await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().BASE_SERVER + '/secret', {
|
|
42849
42997
|
name,
|
|
42850
42998
|
value
|
|
42851
42999
|
}, {
|
|
@@ -42867,7 +43015,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42867
43015
|
};
|
|
42868
43016
|
}
|
|
42869
43017
|
try {
|
|
42870
|
-
return await (0, _post__WEBPACK_IMPORTED_MODULE_37__.get)((0,
|
|
43018
|
+
return await (0, _post__WEBPACK_IMPORTED_MODULE_37__.get)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().BASE_SERVER + '/secret/' + name, {
|
|
42871
43019
|
'X-ACTUAL-TOKEN': userToken
|
|
42872
43020
|
});
|
|
42873
43021
|
}
|
|
@@ -42894,7 +43042,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42894
43042
|
cb('timeout');
|
|
42895
43043
|
return;
|
|
42896
43044
|
}
|
|
42897
|
-
const data = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0,
|
|
43045
|
+
const data = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().GOCARDLESS_SERVER + '/get-accounts', {
|
|
42898
43046
|
upgradingAccountId,
|
|
42899
43047
|
requisitionId
|
|
42900
43048
|
}, {
|
|
@@ -42934,7 +43082,29 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42934
43082
|
error: 'unauthorized'
|
|
42935
43083
|
};
|
|
42936
43084
|
}
|
|
42937
|
-
return (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0,
|
|
43085
|
+
return (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().GOCARDLESS_SERVER + '/status', {}, {
|
|
43086
|
+
'X-ACTUAL-TOKEN': userToken
|
|
43087
|
+
});
|
|
43088
|
+
};
|
|
43089
|
+
handlers['simplefin-status'] = async function () {
|
|
43090
|
+
const userToken = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_5__.getItem('user-token');
|
|
43091
|
+
if (!userToken) {
|
|
43092
|
+
return {
|
|
43093
|
+
error: 'unauthorized'
|
|
43094
|
+
};
|
|
43095
|
+
}
|
|
43096
|
+
return (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().SIMPLEFIN_SERVER + '/status', {}, {
|
|
43097
|
+
'X-ACTUAL-TOKEN': userToken
|
|
43098
|
+
});
|
|
43099
|
+
};
|
|
43100
|
+
handlers['simplefin-accounts'] = async function () {
|
|
43101
|
+
const userToken = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_5__.getItem('user-token');
|
|
43102
|
+
if (!userToken) {
|
|
43103
|
+
return {
|
|
43104
|
+
error: 'unauthorized'
|
|
43105
|
+
};
|
|
43106
|
+
}
|
|
43107
|
+
return (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().SIMPLEFIN_SERVER + '/accounts', {}, {
|
|
42938
43108
|
'X-ACTUAL-TOKEN': userToken
|
|
42939
43109
|
});
|
|
42940
43110
|
};
|
|
@@ -42945,7 +43115,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42945
43115
|
error: 'unauthorized'
|
|
42946
43116
|
};
|
|
42947
43117
|
}
|
|
42948
|
-
return (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0,
|
|
43118
|
+
return (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().GOCARDLESS_SERVER + '/get-banks', {
|
|
42949
43119
|
country,
|
|
42950
43120
|
showDemo: (0, _shared_environment__WEBPACK_IMPORTED_MODULE_10__.isNonProductionEnvironment)()
|
|
42951
43121
|
}, {
|
|
@@ -42964,7 +43134,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42964
43134
|
};
|
|
42965
43135
|
}
|
|
42966
43136
|
try {
|
|
42967
|
-
return await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0,
|
|
43137
|
+
return await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().GOCARDLESS_SERVER + '/create-web-token', {
|
|
42968
43138
|
upgradingAccountId,
|
|
42969
43139
|
institutionId,
|
|
42970
43140
|
accessValidForDays
|
|
@@ -42998,7 +43168,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
42998
43168
|
const acct = accounts[i];
|
|
42999
43169
|
if (acct.bankId) {
|
|
43000
43170
|
try {
|
|
43001
|
-
const res = await _accounts_sync__WEBPACK_IMPORTED_MODULE_18__.
|
|
43171
|
+
const res = await _accounts_sync__WEBPACK_IMPORTED_MODULE_18__.syncExternalAccount(userId, userKey, acct.id, acct.account_id, acct.bankId);
|
|
43002
43172
|
const { added, updated } = res;
|
|
43003
43173
|
newTransactions = newTransactions.concat(added);
|
|
43004
43174
|
matchedTransactions = matchedTransactions.concat(updated);
|
|
@@ -43050,7 +43220,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43050
43220
|
};
|
|
43051
43221
|
};
|
|
43052
43222
|
handlers['transactions-import'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(function ({ accountId, transactions }) {
|
|
43053
|
-
return (0,
|
|
43223
|
+
return (0, _undo__WEBPACK_IMPORTED_MODULE_48__.withUndo)(async () => {
|
|
43054
43224
|
if (typeof accountId !== 'string') {
|
|
43055
43225
|
throw (0, _errors__WEBPACK_IMPORTED_MODULE_30__.APIError)('transactions-import: accountId must be an id');
|
|
43056
43226
|
}
|
|
@@ -43080,14 +43250,22 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43080
43250
|
if (!bankId) {
|
|
43081
43251
|
return 'ok';
|
|
43082
43252
|
}
|
|
43253
|
+
const accRow = await _db__WEBPACK_IMPORTED_MODULE_27__.first('SELECT * FROM accounts WHERE id = ?', [
|
|
43254
|
+
id
|
|
43255
|
+
]);
|
|
43256
|
+
const isGoCardless = accRow.account_sync_source === 'goCardless';
|
|
43083
43257
|
await _db__WEBPACK_IMPORTED_MODULE_27__.updateAccount({
|
|
43084
43258
|
id,
|
|
43085
43259
|
account_id: null,
|
|
43086
43260
|
bank: null,
|
|
43087
43261
|
balance_current: null,
|
|
43088
43262
|
balance_available: null,
|
|
43089
|
-
balance_limit: null
|
|
43263
|
+
balance_limit: null,
|
|
43264
|
+
account_sync_source: null
|
|
43090
43265
|
});
|
|
43266
|
+
if (isGoCardless === false) {
|
|
43267
|
+
return;
|
|
43268
|
+
}
|
|
43091
43269
|
const { count } = await _db__WEBPACK_IMPORTED_MODULE_27__.first('SELECT COUNT(*) as count FROM accounts WHERE bank = ?', [
|
|
43092
43270
|
bankId
|
|
43093
43271
|
]);
|
|
@@ -43102,7 +43280,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43102
43280
|
bankId
|
|
43103
43281
|
]);
|
|
43104
43282
|
try {
|
|
43105
|
-
await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0,
|
|
43283
|
+
await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().GOCARDLESS_SERVER + '/remove-account', {
|
|
43106
43284
|
requisitionId
|
|
43107
43285
|
}, {
|
|
43108
43286
|
'X-ACTUAL-TOKEN': userToken
|
|
@@ -43121,7 +43299,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43121
43299
|
'user-id',
|
|
43122
43300
|
'user-key'
|
|
43123
43301
|
]);
|
|
43124
|
-
const data = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0,
|
|
43302
|
+
const data = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().PLAID_SERVER + '/make-public-token', {
|
|
43125
43303
|
userId,
|
|
43126
43304
|
key: userKey,
|
|
43127
43305
|
item_id: '' + bankId
|
|
@@ -43143,7 +43321,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43143
43321
|
}
|
|
43144
43322
|
if ('autoUpdate' in prefs) {
|
|
43145
43323
|
await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_5__.setItem('auto-update', '' + prefs.autoUpdate);
|
|
43146
|
-
process.
|
|
43324
|
+
process.parentPort.postMessage({
|
|
43147
43325
|
type: 'shouldAutoUpdate',
|
|
43148
43326
|
flag: prefs.autoUpdate
|
|
43149
43327
|
});
|
|
@@ -43184,7 +43362,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43184
43362
|
// Need to sync the budget name on the server as well
|
|
43185
43363
|
if (prefsToSet.budgetName && cloudFileId) {
|
|
43186
43364
|
const userToken = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_5__.getItem('user-token');
|
|
43187
|
-
await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0,
|
|
43365
|
+
await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().SYNC_SERVER + '/update-user-filename', {
|
|
43188
43366
|
token: userToken,
|
|
43189
43367
|
fileId: cloudFileId,
|
|
43190
43368
|
name: prefsToSet.budgetName
|
|
@@ -43197,10 +43375,10 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43197
43375
|
return _prefs__WEBPACK_IMPORTED_MODULE_38__.getPrefs();
|
|
43198
43376
|
};
|
|
43199
43377
|
handlers['sync-reset'] = async function () {
|
|
43200
|
-
return await (0,
|
|
43378
|
+
return await (0, _sync__WEBPACK_IMPORTED_MODULE_45__.resetSync)();
|
|
43201
43379
|
};
|
|
43202
43380
|
handlers['sync-repair'] = async function () {
|
|
43203
|
-
await (0,
|
|
43381
|
+
await (0, _sync__WEBPACK_IMPORTED_MODULE_45__.repairSync)();
|
|
43204
43382
|
};
|
|
43205
43383
|
// A user can only enable/change their key with the file loaded. This
|
|
43206
43384
|
// will change in the future: during onboarding the user should be
|
|
@@ -43211,7 +43389,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43211
43389
|
throw new Error('user-set-key must be called with file loaded');
|
|
43212
43390
|
}
|
|
43213
43391
|
const salt = _encryption__WEBPACK_IMPORTED_MODULE_29__.randomBytes(32).toString('base64');
|
|
43214
|
-
const id = (0,
|
|
43392
|
+
const id = (0, uuid__WEBPACK_IMPORTED_MODULE_51__["default"])();
|
|
43215
43393
|
const key = await _encryption__WEBPACK_IMPORTED_MODULE_29__.createKey({
|
|
43216
43394
|
id,
|
|
43217
43395
|
password,
|
|
@@ -43220,11 +43398,11 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43220
43398
|
// Load the key
|
|
43221
43399
|
await _encryption__WEBPACK_IMPORTED_MODULE_29__.loadKey(key);
|
|
43222
43400
|
// Make some test data to use if the key is valid or not
|
|
43223
|
-
const testContent = await (0,
|
|
43401
|
+
const testContent = await (0, _sync__WEBPACK_IMPORTED_MODULE_45__.makeTestMessage)(key.getId());
|
|
43224
43402
|
// Changing your key necessitates a sync reset as well. This will
|
|
43225
43403
|
// clear all existing encrypted data from the server so you won't
|
|
43226
43404
|
// have a mix of data encrypted with different keys.
|
|
43227
|
-
return await (0,
|
|
43405
|
+
return await (0, _sync__WEBPACK_IMPORTED_MODULE_45__.resetSync)({
|
|
43228
43406
|
key,
|
|
43229
43407
|
salt,
|
|
43230
43408
|
testContent: JSON.stringify({
|
|
@@ -43242,7 +43420,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43242
43420
|
}
|
|
43243
43421
|
let res;
|
|
43244
43422
|
try {
|
|
43245
|
-
res = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0,
|
|
43423
|
+
res = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().SYNC_SERVER + '/user-get-key', {
|
|
43246
43424
|
token: userToken,
|
|
43247
43425
|
fileId
|
|
43248
43426
|
});
|
|
@@ -43303,7 +43481,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43303
43481
|
};
|
|
43304
43482
|
handlers['subscribe-needs-bootstrap'] = async function ({ url } = {}) {
|
|
43305
43483
|
try {
|
|
43306
|
-
if (!(0,
|
|
43484
|
+
if (!(0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)(url)) {
|
|
43307
43485
|
return {
|
|
43308
43486
|
bootstrapped: true,
|
|
43309
43487
|
hasServer: false
|
|
@@ -43317,7 +43495,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43317
43495
|
}
|
|
43318
43496
|
let res;
|
|
43319
43497
|
try {
|
|
43320
|
-
res = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.get)((0,
|
|
43498
|
+
res = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.get)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)(url).SIGNUP_SERVER + '/needs-bootstrap');
|
|
43321
43499
|
}
|
|
43322
43500
|
catch (err) {
|
|
43323
43501
|
return {
|
|
@@ -43345,7 +43523,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43345
43523
|
handlers['subscribe-bootstrap'] = async function ({ password }) {
|
|
43346
43524
|
let res;
|
|
43347
43525
|
try {
|
|
43348
|
-
res = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0,
|
|
43526
|
+
res = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().SIGNUP_SERVER + '/bootstrap', {
|
|
43349
43527
|
password
|
|
43350
43528
|
});
|
|
43351
43529
|
}
|
|
@@ -43363,7 +43541,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43363
43541
|
};
|
|
43364
43542
|
};
|
|
43365
43543
|
handlers['subscribe-get-user'] = async function () {
|
|
43366
|
-
if (!(0,
|
|
43544
|
+
if (!(0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)()) {
|
|
43367
43545
|
if (!await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_5__.getItem('did-bootstrap')) {
|
|
43368
43546
|
return null;
|
|
43369
43547
|
}
|
|
@@ -43376,7 +43554,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43376
43554
|
return null;
|
|
43377
43555
|
}
|
|
43378
43556
|
try {
|
|
43379
|
-
const res = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.get)((0,
|
|
43557
|
+
const res = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.get)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().SIGNUP_SERVER + '/validate', {
|
|
43380
43558
|
headers: {
|
|
43381
43559
|
'X-ACTUAL-TOKEN': userToken
|
|
43382
43560
|
}
|
|
@@ -43409,7 +43587,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43409
43587
|
};
|
|
43410
43588
|
}
|
|
43411
43589
|
try {
|
|
43412
|
-
await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0,
|
|
43590
|
+
await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().SIGNUP_SERVER + '/change-password', {
|
|
43413
43591
|
token: userToken,
|
|
43414
43592
|
password
|
|
43415
43593
|
});
|
|
@@ -43422,7 +43600,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43422
43600
|
return {};
|
|
43423
43601
|
};
|
|
43424
43602
|
handlers['subscribe-sign-in'] = async function ({ password }) {
|
|
43425
|
-
const res = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0,
|
|
43603
|
+
const res = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.post)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().SIGNUP_SERVER + '/login', {
|
|
43426
43604
|
password
|
|
43427
43605
|
});
|
|
43428
43606
|
if (res.token) {
|
|
@@ -43444,14 +43622,14 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43444
43622
|
return 'ok';
|
|
43445
43623
|
};
|
|
43446
43624
|
handlers['get-server-version'] = async function () {
|
|
43447
|
-
if (!(0,
|
|
43625
|
+
if (!(0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)()) {
|
|
43448
43626
|
return {
|
|
43449
43627
|
error: 'no-server'
|
|
43450
43628
|
};
|
|
43451
43629
|
}
|
|
43452
43630
|
let version;
|
|
43453
43631
|
try {
|
|
43454
|
-
const res = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.get)((0,
|
|
43632
|
+
const res = await (0, _post__WEBPACK_IMPORTED_MODULE_37__.get)((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().BASE_SERVER + '/info');
|
|
43455
43633
|
const info = JSON.parse(res);
|
|
43456
43634
|
version = info.build.version;
|
|
43457
43635
|
}
|
|
@@ -43465,7 +43643,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43465
43643
|
};
|
|
43466
43644
|
};
|
|
43467
43645
|
handlers['get-server-url'] = async function () {
|
|
43468
|
-
return (0,
|
|
43646
|
+
return (0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)() && (0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)().BASE_SERVER;
|
|
43469
43647
|
};
|
|
43470
43648
|
handlers['set-server-url'] = async function ({ url, validate = true }) {
|
|
43471
43649
|
if (url == null) {
|
|
@@ -43475,23 +43653,23 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43475
43653
|
url = url.replace(/\/+$/, '');
|
|
43476
43654
|
if (validate) {
|
|
43477
43655
|
// Validate the server is running
|
|
43478
|
-
const
|
|
43656
|
+
const result = await (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.runHandler)(handlers['subscribe-needs-bootstrap'], {
|
|
43479
43657
|
url
|
|
43480
43658
|
});
|
|
43481
|
-
if (error) {
|
|
43659
|
+
if ('error' in result) {
|
|
43482
43660
|
return {
|
|
43483
|
-
error
|
|
43661
|
+
error: result.error
|
|
43484
43662
|
};
|
|
43485
43663
|
}
|
|
43486
43664
|
}
|
|
43487
43665
|
}
|
|
43488
43666
|
await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_5__.setItem('server-url', url);
|
|
43489
43667
|
await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_5__.setItem('did-bootstrap', true);
|
|
43490
|
-
(0,
|
|
43668
|
+
(0, _server_config__WEBPACK_IMPORTED_MODULE_42__.setServer)(url);
|
|
43491
43669
|
return {};
|
|
43492
43670
|
};
|
|
43493
43671
|
handlers['sync'] = async function () {
|
|
43494
|
-
return (0,
|
|
43672
|
+
return (0, _sync__WEBPACK_IMPORTED_MODULE_45__.fullSync)();
|
|
43495
43673
|
};
|
|
43496
43674
|
handlers['get-budgets'] = async function () {
|
|
43497
43675
|
const paths = await _platform_server_fs__WEBPACK_IMPORTED_MODULE_7__.listDir(_platform_server_fs__WEBPACK_IMPORTED_MODULE_7__.getDocumentDir());
|
|
@@ -43528,9 +43706,9 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43528
43706
|
};
|
|
43529
43707
|
handlers['reset-budget-cache'] = (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.mutator)(async function () {
|
|
43530
43708
|
// Recomputing everything will update the cache
|
|
43531
|
-
await
|
|
43532
|
-
|
|
43533
|
-
await
|
|
43709
|
+
await _sheet__WEBPACK_IMPORTED_MODULE_43__.loadUserBudgets(_db__WEBPACK_IMPORTED_MODULE_27__);
|
|
43710
|
+
_sheet__WEBPACK_IMPORTED_MODULE_43__.get().recomputeAll();
|
|
43711
|
+
await _sheet__WEBPACK_IMPORTED_MODULE_43__.waitOnSpreadsheet();
|
|
43534
43712
|
});
|
|
43535
43713
|
handlers['upload-budget'] = async function ({ id } = {}) {
|
|
43536
43714
|
if (id) {
|
|
@@ -43607,8 +43785,8 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43607
43785
|
};
|
|
43608
43786
|
// open and sync, but don’t close
|
|
43609
43787
|
handlers['sync-budget'] = async function () {
|
|
43610
|
-
(0,
|
|
43611
|
-
const result = await (0,
|
|
43788
|
+
(0, _sync__WEBPACK_IMPORTED_MODULE_45__.setSyncingMode)('enabled');
|
|
43789
|
+
const result = await (0, _sync__WEBPACK_IMPORTED_MODULE_45__.initialFullSync)();
|
|
43612
43790
|
return result;
|
|
43613
43791
|
};
|
|
43614
43792
|
handlers['load-budget'] = async function ({ id }) {
|
|
@@ -43642,10 +43820,10 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43642
43820
|
message: 'Closing budget'
|
|
43643
43821
|
});
|
|
43644
43822
|
// The spreadsheet may be running, wait for it to complete
|
|
43645
|
-
await
|
|
43646
|
-
|
|
43647
|
-
(0,
|
|
43648
|
-
await _main_app__WEBPACK_IMPORTED_MODULE_33__
|
|
43823
|
+
await _sheet__WEBPACK_IMPORTED_MODULE_43__.waitOnSpreadsheet();
|
|
43824
|
+
_sheet__WEBPACK_IMPORTED_MODULE_43__.unloadSpreadsheet();
|
|
43825
|
+
(0, _sync__WEBPACK_IMPORTED_MODULE_45__.clearFullSyncTimeout)();
|
|
43826
|
+
await _main_app__WEBPACK_IMPORTED_MODULE_33__.app.stopServices();
|
|
43649
43827
|
await _db__WEBPACK_IMPORTED_MODULE_27__.closeDatabase();
|
|
43650
43828
|
try {
|
|
43651
43829
|
await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_5__.setItem('lastBudget', '');
|
|
@@ -43663,7 +43841,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43663
43841
|
// If it's a cloud file, you can delete it from the server by
|
|
43664
43842
|
// passing its cloud id
|
|
43665
43843
|
if (cloudFileId) {
|
|
43666
|
-
await _cloud_storage__WEBPACK_IMPORTED_MODULE_26__.removeFile(cloudFileId).catch((
|
|
43844
|
+
await _cloud_storage__WEBPACK_IMPORTED_MODULE_26__.removeFile(cloudFileId).catch(() => { });
|
|
43667
43845
|
}
|
|
43668
43846
|
// If a local file exists, you can delete it by passing its local id
|
|
43669
43847
|
if (id) {
|
|
@@ -43687,9 +43865,9 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43687
43865
|
// Unfortunately we need to load all of the existing files first
|
|
43688
43866
|
// so we can detect conflicting names.
|
|
43689
43867
|
const files = await handlers['get-budgets']();
|
|
43690
|
-
budgetName = await (0,
|
|
43868
|
+
budgetName = await (0, _util_budget_name__WEBPACK_IMPORTED_MODULE_50__.uniqueFileName)(files);
|
|
43691
43869
|
}
|
|
43692
|
-
id = await (0,
|
|
43870
|
+
id = await (0, _util_budget_name__WEBPACK_IMPORTED_MODULE_50__.idFromFileName)(budgetName);
|
|
43693
43871
|
}
|
|
43694
43872
|
const budgetDir = _platform_server_fs__WEBPACK_IMPORTED_MODULE_7__.getBudgetDir(id);
|
|
43695
43873
|
await _platform_server_fs__WEBPACK_IMPORTED_MODULE_7__.mkdir(budgetDir);
|
|
@@ -43793,7 +43971,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43793
43971
|
});
|
|
43794
43972
|
}
|
|
43795
43973
|
try {
|
|
43796
|
-
await (0,
|
|
43974
|
+
await (0, _update__WEBPACK_IMPORTED_MODULE_49__.updateVersion)();
|
|
43797
43975
|
}
|
|
43798
43976
|
catch (e) {
|
|
43799
43977
|
console.warn('Error updating', e);
|
|
@@ -43810,7 +43988,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43810
43988
|
}
|
|
43811
43989
|
else {
|
|
43812
43990
|
(0, _platform_exceptions__WEBPACK_IMPORTED_MODULE_4__.captureException)(e);
|
|
43813
|
-
_platform_server_log__WEBPACK_IMPORTED_MODULE_8__
|
|
43991
|
+
_platform_server_log__WEBPACK_IMPORTED_MODULE_8__.logger.info('Error updating budget ' + id, e);
|
|
43814
43992
|
console.log('Error updating budget', e);
|
|
43815
43993
|
result = {
|
|
43816
43994
|
error: 'loading-budget'
|
|
@@ -43839,7 +44017,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43839
44017
|
(0, _backups__WEBPACK_IMPORTED_MODULE_23__.startBackupService)(id);
|
|
43840
44018
|
}
|
|
43841
44019
|
try {
|
|
43842
|
-
await
|
|
44020
|
+
await _sheet__WEBPACK_IMPORTED_MODULE_43__.loadSpreadsheet(_db__WEBPACK_IMPORTED_MODULE_27__, onSheetChange);
|
|
43843
44021
|
}
|
|
43844
44022
|
catch (e) {
|
|
43845
44023
|
(0, _platform_exceptions__WEBPACK_IMPORTED_MODULE_4__.captureException)(e);
|
|
@@ -43849,25 +44027,25 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43849
44027
|
};
|
|
43850
44028
|
}
|
|
43851
44029
|
// This is a bit leaky, but we need to set the initial budget type
|
|
43852
|
-
|
|
44030
|
+
_sheet__WEBPACK_IMPORTED_MODULE_43__.get().meta().budgetType = _prefs__WEBPACK_IMPORTED_MODULE_38__.getPrefs().budgetType;
|
|
43853
44031
|
await _budget_base__WEBPACK_IMPORTED_MODULE_25__.createAllBudgets();
|
|
43854
44032
|
// Load all the in-memory state
|
|
43855
44033
|
await _db_mappings__WEBPACK_IMPORTED_MODULE_28__.loadMappings();
|
|
43856
44034
|
await _accounts_transaction_rules__WEBPACK_IMPORTED_MODULE_19__.loadRules();
|
|
43857
|
-
await
|
|
43858
|
-
await _main_app__WEBPACK_IMPORTED_MODULE_33__
|
|
43859
|
-
(0,
|
|
44035
|
+
await _sync_migrate__WEBPACK_IMPORTED_MODULE_46__.listen();
|
|
44036
|
+
await _main_app__WEBPACK_IMPORTED_MODULE_33__.app.startServices();
|
|
44037
|
+
(0, _undo__WEBPACK_IMPORTED_MODULE_48__.clearUndo)();
|
|
43860
44038
|
// Ensure that syncing is enabled
|
|
43861
44039
|
if (true) {
|
|
43862
44040
|
if (id === DEMO_BUDGET_ID) {
|
|
43863
|
-
(0,
|
|
44041
|
+
(0, _sync__WEBPACK_IMPORTED_MODULE_45__.setSyncingMode)('disabled');
|
|
43864
44042
|
}
|
|
43865
44043
|
else {
|
|
43866
|
-
if ((0,
|
|
43867
|
-
(0,
|
|
44044
|
+
if ((0, _server_config__WEBPACK_IMPORTED_MODULE_42__.getServer)()) {
|
|
44045
|
+
(0, _sync__WEBPACK_IMPORTED_MODULE_45__.setSyncingMode)('enabled');
|
|
43868
44046
|
}
|
|
43869
44047
|
else {
|
|
43870
|
-
(0,
|
|
44048
|
+
(0, _sync__WEBPACK_IMPORTED_MODULE_45__.setSyncingMode)('disabled');
|
|
43871
44049
|
}
|
|
43872
44050
|
await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_5__.setItem('lastBudget', id);
|
|
43873
44051
|
// Only upload periodically on desktop
|
|
@@ -43876,7 +44054,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43876
44054
|
}
|
|
43877
44055
|
}
|
|
43878
44056
|
}
|
|
43879
|
-
_main_app__WEBPACK_IMPORTED_MODULE_33__
|
|
44057
|
+
_main_app__WEBPACK_IMPORTED_MODULE_33__.app.events.emit('load-budget', {
|
|
43880
44058
|
id
|
|
43881
44059
|
});
|
|
43882
44060
|
return {};
|
|
@@ -43912,14 +44090,14 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43912
44090
|
handlers['app-focused'] = async function () {
|
|
43913
44091
|
if (_prefs__WEBPACK_IMPORTED_MODULE_38__.getPrefs() && _prefs__WEBPACK_IMPORTED_MODULE_38__.getPrefs().id) {
|
|
43914
44092
|
// First we sync
|
|
43915
|
-
(0,
|
|
44093
|
+
(0, _sync__WEBPACK_IMPORTED_MODULE_45__.fullSync)();
|
|
43916
44094
|
}
|
|
43917
44095
|
};
|
|
43918
|
-
handlers = (0, _api__WEBPACK_IMPORTED_MODULE_21__
|
|
43919
|
-
_actual_app_api_injected__WEBPACK_IMPORTED_MODULE_1__.override((name, args) => (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.runHandler)(_main_app__WEBPACK_IMPORTED_MODULE_33__
|
|
44096
|
+
handlers = (0, _api__WEBPACK_IMPORTED_MODULE_21__.installAPI)(handlers);
|
|
44097
|
+
_actual_app_api_injected__WEBPACK_IMPORTED_MODULE_1__.override((name, args) => (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.runHandler)(_main_app__WEBPACK_IMPORTED_MODULE_33__.app.handlers[name], args));
|
|
43920
44098
|
// A hack for now until we clean up everything
|
|
43921
|
-
_main_app__WEBPACK_IMPORTED_MODULE_33__
|
|
43922
|
-
_main_app__WEBPACK_IMPORTED_MODULE_33__
|
|
44099
|
+
_main_app__WEBPACK_IMPORTED_MODULE_33__.app.handlers = handlers;
|
|
44100
|
+
_main_app__WEBPACK_IMPORTED_MODULE_33__.app.combine(_schedules_app__WEBPACK_IMPORTED_MODULE_41__.app, _budget_app__WEBPACK_IMPORTED_MODULE_24__.app, _notes_app__WEBPACK_IMPORTED_MODULE_35__.app, _tools_app__WEBPACK_IMPORTED_MODULE_47__.app, _filters_app__WEBPACK_IMPORTED_MODULE_31__.app, _reports_app__WEBPACK_IMPORTED_MODULE_39__.app, _rules_app__WEBPACK_IMPORTED_MODULE_40__.app);
|
|
43923
44101
|
function getDefaultDocumentDir() {
|
|
43924
44102
|
if (_platform__WEBPACK_IMPORTED_MODULE_36__.isMobile) {
|
|
43925
44103
|
// On mobile, unfortunately we need to be backwards compatible
|
|
@@ -43992,21 +44170,21 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
43992
44170
|
if (!url) {
|
|
43993
44171
|
await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_5__.removeItem('user-token');
|
|
43994
44172
|
}
|
|
43995
|
-
(0,
|
|
43996
|
-
_platform_server_connection__WEBPACK_IMPORTED_MODULE_6__.init(socketName, _main_app__WEBPACK_IMPORTED_MODULE_33__
|
|
44173
|
+
(0, _server_config__WEBPACK_IMPORTED_MODULE_42__.setServer)(url);
|
|
44174
|
+
_platform_server_connection__WEBPACK_IMPORTED_MODULE_6__.init(socketName, _main_app__WEBPACK_IMPORTED_MODULE_33__.app.handlers);
|
|
43997
44175
|
if (!isDev && !_platform__WEBPACK_IMPORTED_MODULE_36__.isMobile && !_platform__WEBPACK_IMPORTED_MODULE_36__.isWeb) {
|
|
43998
44176
|
const autoUpdate = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_5__.getItem('auto-update');
|
|
43999
|
-
process.
|
|
44177
|
+
process.parentPort.postMessage({
|
|
44000
44178
|
type: 'shouldAutoUpdate',
|
|
44001
44179
|
flag: autoUpdate == null || autoUpdate === 'true'
|
|
44002
44180
|
});
|
|
44003
44181
|
}
|
|
44004
44182
|
if (isDev) {
|
|
44005
|
-
global.$send = (name, args) => (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.runHandler)(_main_app__WEBPACK_IMPORTED_MODULE_33__
|
|
44183
|
+
global.$send = (name, args) => (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.runHandler)(_main_app__WEBPACK_IMPORTED_MODULE_33__.app.handlers[name], args);
|
|
44006
44184
|
global.$query = _aql__WEBPACK_IMPORTED_MODULE_22__.runQuery;
|
|
44007
|
-
global.$q = _shared_query__WEBPACK_IMPORTED_MODULE_12__
|
|
44185
|
+
global.$q = _shared_query__WEBPACK_IMPORTED_MODULE_12__.q;
|
|
44008
44186
|
global.$db = _db__WEBPACK_IMPORTED_MODULE_27__;
|
|
44009
|
-
global.$setSyncingMode =
|
|
44187
|
+
global.$setSyncingMode = _sync__WEBPACK_IMPORTED_MODULE_45__.setSyncingMode;
|
|
44010
44188
|
}
|
|
44011
44189
|
}
|
|
44012
44190
|
// eslint-disable-next-line import/no-unused-modules
|
|
@@ -44030,7 +44208,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44030
44208
|
]);
|
|
44031
44209
|
_platform_server_fs__WEBPACK_IMPORTED_MODULE_7__._setDocumentDir(dataDir || process.cwd());
|
|
44032
44210
|
if (serverURL) {
|
|
44033
|
-
(0,
|
|
44211
|
+
(0, _server_config__WEBPACK_IMPORTED_MODULE_42__.setServer)(serverURL);
|
|
44034
44212
|
if (config.password) {
|
|
44035
44213
|
await (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.runHandler)(handlers['subscribe-sign-in'], {
|
|
44036
44214
|
password: config.password
|
|
@@ -44040,9 +44218,9 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44040
44218
|
else {
|
|
44041
44219
|
// This turns off all server URLs. In this mode we don't want any
|
|
44042
44220
|
// access to the server, we are doing things locally
|
|
44043
|
-
(0,
|
|
44044
|
-
_main_app__WEBPACK_IMPORTED_MODULE_33__
|
|
44045
|
-
(0,
|
|
44221
|
+
(0, _server_config__WEBPACK_IMPORTED_MODULE_42__.setServer)(null);
|
|
44222
|
+
_main_app__WEBPACK_IMPORTED_MODULE_33__.app.events.on('load-budget', () => {
|
|
44223
|
+
(0, _sync__WEBPACK_IMPORTED_MODULE_45__.setSyncingMode)('offline');
|
|
44046
44224
|
});
|
|
44047
44225
|
}
|
|
44048
44226
|
return lib;
|
|
@@ -44053,11 +44231,11 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44053
44231
|
getDataDir: _platform_server_fs__WEBPACK_IMPORTED_MODULE_7__.getDataDir,
|
|
44054
44232
|
sendMessage: (msg, args) => _platform_server_connection__WEBPACK_IMPORTED_MODULE_6__.send(msg, args),
|
|
44055
44233
|
send: async (name, args) => {
|
|
44056
|
-
const res = await (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.runHandler)(_main_app__WEBPACK_IMPORTED_MODULE_33__
|
|
44234
|
+
const res = await (0, _mutators__WEBPACK_IMPORTED_MODULE_34__.runHandler)(_main_app__WEBPACK_IMPORTED_MODULE_33__.app.handlers[name], args);
|
|
44057
44235
|
return res;
|
|
44058
44236
|
},
|
|
44059
|
-
on: (name, func) => _main_app__WEBPACK_IMPORTED_MODULE_33__
|
|
44060
|
-
q: _shared_query__WEBPACK_IMPORTED_MODULE_12__
|
|
44237
|
+
on: (name, func) => _main_app__WEBPACK_IMPORTED_MODULE_33__.app.events.on(name, func),
|
|
44238
|
+
q: _shared_query__WEBPACK_IMPORTED_MODULE_12__.q,
|
|
44061
44239
|
db: _db__WEBPACK_IMPORTED_MODULE_27__
|
|
44062
44240
|
};
|
|
44063
44241
|
/***/
|
|
@@ -44084,6 +44262,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44084
44262
|
/* harmony import */ var _migrations_1632571489012_remove_cache__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../migrations/1632571489012_remove_cache */ "./packages/loot-core/migrations/1632571489012_remove_cache.js");
|
|
44085
44263
|
/* harmony import */ var _platform_server_fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../platform/server/fs */ "./packages/loot-core/src/platform/server/fs/index.electron.ts");
|
|
44086
44264
|
/* harmony import */ var _platform_server_sqlite__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../platform/server/sqlite */ "./packages/loot-core/src/platform/server/sqlite/index.electron.ts");
|
|
44265
|
+
// @ts-strict-ignore
|
|
44087
44266
|
// We have to bundle in JS migrations manually to avoid having to `eval`
|
|
44088
44267
|
// them which doesn't play well with CSP. There isn't great, and eventually
|
|
44089
44268
|
// we can remove this migration.
|
|
@@ -44218,20 +44397,19 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44218
44397
|
/* harmony export */ fromDateRepr: () => ( /* binding */fromDateRepr),
|
|
44219
44398
|
/* harmony export */ payeeModel: () => ( /* binding */payeeModel),
|
|
44220
44399
|
/* harmony export */ requiredFields: () => ( /* binding */requiredFields),
|
|
44221
|
-
/* harmony export */ toDateRepr: () => ( /* binding */toDateRepr)
|
|
44222
|
-
/* harmony export */ transactionModel: () => ( /* binding */transactionModel)
|
|
44400
|
+
/* harmony export */ toDateRepr: () => ( /* binding */toDateRepr)
|
|
44223
44401
|
/* harmony export */
|
|
44224
44402
|
});
|
|
44225
44403
|
function requiredFields(name, row, fields, update) {
|
|
44226
44404
|
fields.forEach((field) => {
|
|
44227
44405
|
if (update) {
|
|
44228
44406
|
if (row.hasOwnProperty(field) && row[field] == null) {
|
|
44229
|
-
throw new Error(`${name} is missing field ${field}`);
|
|
44407
|
+
throw new Error(`${name} is missing field ${String(field)}`);
|
|
44230
44408
|
}
|
|
44231
44409
|
}
|
|
44232
44410
|
else {
|
|
44233
44411
|
if (!row.hasOwnProperty(field) || row[field] == null) {
|
|
44234
|
-
throw new Error(`${name} is missing field ${field}`);
|
|
44412
|
+
throw new Error(`${name} is missing field ${String(field)}`);
|
|
44235
44413
|
}
|
|
44236
44414
|
}
|
|
44237
44415
|
});
|
|
@@ -44301,69 +44479,6 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44301
44479
|
return payee;
|
|
44302
44480
|
}
|
|
44303
44481
|
};
|
|
44304
|
-
const transactionModel = {
|
|
44305
|
-
validate(trans, { update } = {}) {
|
|
44306
|
-
requiredFields('transaction', trans, [
|
|
44307
|
-
'date',
|
|
44308
|
-
'acct'
|
|
44309
|
-
], update);
|
|
44310
|
-
if ('date' in trans) {
|
|
44311
|
-
// Make sure it's the right format, and also do a sanity check.
|
|
44312
|
-
// Really old dates can mess up the system and can happen by
|
|
44313
|
-
// accident
|
|
44314
|
-
if (trans.date.match(/^\d{4}-\d{2}-\d{2}$/) == null || trans.date < '2000-01-01') {
|
|
44315
|
-
throw new Error('Invalid transaction date: ' + trans.date);
|
|
44316
|
-
}
|
|
44317
|
-
}
|
|
44318
|
-
return trans;
|
|
44319
|
-
},
|
|
44320
|
-
toJS(row) {
|
|
44321
|
-
// Check a non-important field that typically wouldn't be passed in
|
|
44322
|
-
// manually, and use it as a smoke test to see if this is a
|
|
44323
|
-
// fully-formed transaction or not.
|
|
44324
|
-
if (!('location' in row)) {
|
|
44325
|
-
throw new Error('A full transaction is required to be passed to `toJS`. Instead got: ' + JSON.stringify(row));
|
|
44326
|
-
}
|
|
44327
|
-
const trans = {
|
|
44328
|
-
...row
|
|
44329
|
-
};
|
|
44330
|
-
trans.error = row.error ? JSON.parse(row.error) : null;
|
|
44331
|
-
trans.isParent = row.isParent === 1 ? true : false;
|
|
44332
|
-
trans.isChild = row.isChild === 1 ? true : false;
|
|
44333
|
-
trans.starting_balance_flag = row.starting_balance_flag === 1 ? true : false;
|
|
44334
|
-
trans.cleared = row.cleared === 1 ? true : false;
|
|
44335
|
-
trans.pending = row.pending === 1 ? true : false;
|
|
44336
|
-
trans.date = trans.date && fromDateRepr(trans.date);
|
|
44337
|
-
return trans;
|
|
44338
|
-
},
|
|
44339
|
-
fromJS(trans) {
|
|
44340
|
-
const row = {
|
|
44341
|
-
...trans
|
|
44342
|
-
};
|
|
44343
|
-
if ('error' in row) {
|
|
44344
|
-
row.error = trans.error ? JSON.stringify(trans.error) : null;
|
|
44345
|
-
}
|
|
44346
|
-
if ('isParent' in row) {
|
|
44347
|
-
row.isParent = trans.isParent ? 1 : 0;
|
|
44348
|
-
}
|
|
44349
|
-
if ('isChild' in row) {
|
|
44350
|
-
row.isChild = trans.isChild ? 1 : 0;
|
|
44351
|
-
}
|
|
44352
|
-
if ('cleared' in row) {
|
|
44353
|
-
row.cleared = trans.cleared ? 1 : 0;
|
|
44354
|
-
}
|
|
44355
|
-
if ('pending' in row) {
|
|
44356
|
-
row.pending = trans.pending ? 1 : 0;
|
|
44357
|
-
}
|
|
44358
|
-
if ('starting_balance_flag' in row) {
|
|
44359
|
-
row.starting_balance_flag = trans.starting_balance_flag ? 1 : 0;
|
|
44360
|
-
}
|
|
44361
|
-
if ('date' in row) {
|
|
44362
|
-
row.date = toDateRepr(trans.date);
|
|
44363
|
-
}
|
|
44364
|
-
return row;
|
|
44365
|
-
}
|
|
44366
|
-
};
|
|
44367
44482
|
/***/
|
|
44368
44483
|
}),
|
|
44369
44484
|
/***/ "./packages/loot-core/src/server/mutators.ts":
|
|
@@ -44386,6 +44501,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44386
44501
|
});
|
|
44387
44502
|
/* harmony import */ var _platform_exceptions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../platform/exceptions */ "./packages/loot-core/src/platform/exceptions/index.electron.ts");
|
|
44388
44503
|
/* harmony import */ var _shared_async__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../shared/async */ "./packages/loot-core/src/shared/async.ts");
|
|
44504
|
+
// @ts-strict-ignore
|
|
44389
44505
|
const runningMethods = new Set();
|
|
44390
44506
|
let currentContext = null;
|
|
44391
44507
|
const mutatingMethods = new WeakMap();
|
|
@@ -44500,7 +44616,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44500
44616
|
"use strict";
|
|
44501
44617
|
__webpack_require__.r(__webpack_exports__);
|
|
44502
44618
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
44503
|
-
/* harmony export */
|
|
44619
|
+
/* harmony export */ app: () => ( /* binding */app)
|
|
44504
44620
|
/* harmony export */
|
|
44505
44621
|
});
|
|
44506
44622
|
/* harmony import */ var _app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../app */ "./packages/loot-core/src/server/app.ts");
|
|
@@ -44512,7 +44628,6 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44512
44628
|
note
|
|
44513
44629
|
});
|
|
44514
44630
|
});
|
|
44515
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (app);
|
|
44516
44631
|
/***/
|
|
44517
44632
|
}),
|
|
44518
44633
|
/***/ "./packages/loot-core/src/server/platform.ts":
|
|
@@ -44557,6 +44672,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44557
44672
|
/* harmony import */ var _platform_server_fetch__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../platform/server/fetch */ "./packages/loot-core/src/platform/server/fetch/index.api.ts");
|
|
44558
44673
|
/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./errors */ "./packages/loot-core/src/server/errors.ts");
|
|
44559
44674
|
/* harmony import */ var _platform__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./platform */ "./packages/loot-core/src/server/platform.ts");
|
|
44675
|
+
// @ts-strict-ignore
|
|
44560
44676
|
function throwIfNot200(res, text) {
|
|
44561
44677
|
if (res.status !== 200) {
|
|
44562
44678
|
if (res.status === 500) {
|
|
@@ -44653,6 +44769,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44653
44769
|
/* harmony import */ var _actual_app_crdt__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @actual-app/crdt */ "./packages/crdt/index.ts");
|
|
44654
44770
|
/* harmony import */ var _platform_server_fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../platform/server/fs */ "./packages/loot-core/src/platform/server/fs/index.electron.ts");
|
|
44655
44771
|
/* harmony import */ var _sync__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sync */ "./packages/loot-core/src/server/sync/index.ts");
|
|
44772
|
+
// @ts-strict-ignore
|
|
44656
44773
|
const BUDGET_TYPES = [
|
|
44657
44774
|
'report',
|
|
44658
44775
|
'rollover'
|
|
@@ -44730,6 +44847,94 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44730
44847
|
}
|
|
44731
44848
|
/***/
|
|
44732
44849
|
}),
|
|
44850
|
+
/***/ "./packages/loot-core/src/server/reports/app.ts":
|
|
44851
|
+
/*!******************************************************!*\
|
|
44852
|
+
!*** ./packages/loot-core/src/server/reports/app.ts ***!
|
|
44853
|
+
\******************************************************/
|
|
44854
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
44855
|
+
"use strict";
|
|
44856
|
+
__webpack_require__.r(__webpack_exports__);
|
|
44857
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
44858
|
+
/* harmony export */ app: () => ( /* binding */app)
|
|
44859
|
+
/* harmony export */
|
|
44860
|
+
});
|
|
44861
|
+
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! uuid */ "./node_modules/uuid/dist/esm-node/v4.js");
|
|
44862
|
+
/* harmony import */ var _accounts_transaction_rules__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../accounts/transaction-rules */ "./packages/loot-core/src/server/accounts/transaction-rules.ts");
|
|
44863
|
+
/* harmony import */ var _app__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../app */ "./packages/loot-core/src/server/app.ts");
|
|
44864
|
+
/* harmony import */ var _db__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../db */ "./packages/loot-core/src/server/db/index.ts");
|
|
44865
|
+
/* harmony import */ var _models__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../models */ "./packages/loot-core/src/server/models.ts");
|
|
44866
|
+
/* harmony import */ var _mutators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../mutators */ "./packages/loot-core/src/server/mutators.ts");
|
|
44867
|
+
/* harmony import */ var _undo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../undo */ "./packages/loot-core/src/server/undo.ts");
|
|
44868
|
+
const reportModel = {
|
|
44869
|
+
validate(report, { update } = {}) {
|
|
44870
|
+
(0, _models__WEBPACK_IMPORTED_MODULE_3__.requiredFields)('reports', report, [
|
|
44871
|
+
'conditionsOp'
|
|
44872
|
+
], update);
|
|
44873
|
+
if (!update || 'conditionsOp' in report) {
|
|
44874
|
+
if (![
|
|
44875
|
+
'and',
|
|
44876
|
+
'or'
|
|
44877
|
+
].includes(report.conditionsOp)) {
|
|
44878
|
+
throw new Error('Invalid filter conditionsOp: ' + report.conditionsOp);
|
|
44879
|
+
}
|
|
44880
|
+
}
|
|
44881
|
+
return report;
|
|
44882
|
+
},
|
|
44883
|
+
toJS(row) {
|
|
44884
|
+
return {
|
|
44885
|
+
...row,
|
|
44886
|
+
conditionsOp: row.conditions_op,
|
|
44887
|
+
filters: (0, _accounts_transaction_rules__WEBPACK_IMPORTED_MODULE_0__.parseConditionsOrActions)(row.conditions)
|
|
44888
|
+
};
|
|
44889
|
+
},
|
|
44890
|
+
fromJS(report) {
|
|
44891
|
+
const { filters, conditionsOp, ...row } = report;
|
|
44892
|
+
if (conditionsOp) {
|
|
44893
|
+
row.conditions_op = conditionsOp;
|
|
44894
|
+
row.conditions = filters;
|
|
44895
|
+
}
|
|
44896
|
+
return row;
|
|
44897
|
+
}
|
|
44898
|
+
};
|
|
44899
|
+
async function reportNameExists(name, reportId, newItem) {
|
|
44900
|
+
if (!name) {
|
|
44901
|
+
throw new Error('Report name is required');
|
|
44902
|
+
}
|
|
44903
|
+
if (!reportId) {
|
|
44904
|
+
throw new Error('Report recall error');
|
|
44905
|
+
}
|
|
44906
|
+
const idForName = await _db__WEBPACK_IMPORTED_MODULE_2__.first('SELECT id from reports WHERE tombstone = 0 AND name = ?', [
|
|
44907
|
+
name
|
|
44908
|
+
]);
|
|
44909
|
+
if (!newItem && idForName.id !== reportId) {
|
|
44910
|
+
throw new Error('There is already a report named ' + name);
|
|
44911
|
+
}
|
|
44912
|
+
}
|
|
44913
|
+
async function createReport(report) {
|
|
44914
|
+
const reportId = (0, uuid__WEBPACK_IMPORTED_MODULE_6__["default"])();
|
|
44915
|
+
const item = {
|
|
44916
|
+
...report,
|
|
44917
|
+
id: reportId
|
|
44918
|
+
};
|
|
44919
|
+
reportNameExists(item.name, item.id, true);
|
|
44920
|
+
// Create the report here based on the info
|
|
44921
|
+
await _db__WEBPACK_IMPORTED_MODULE_2__.insertWithSchema('reports', reportModel.fromJS(item));
|
|
44922
|
+
return reportId;
|
|
44923
|
+
}
|
|
44924
|
+
async function updateReport(item) {
|
|
44925
|
+
reportNameExists(item.name, item.id, false);
|
|
44926
|
+
await _db__WEBPACK_IMPORTED_MODULE_2__.insertWithSchema('reports', reportModel.fromJS(item));
|
|
44927
|
+
}
|
|
44928
|
+
async function deleteReport(id) {
|
|
44929
|
+
await _db__WEBPACK_IMPORTED_MODULE_2__.delete_('reports', id);
|
|
44930
|
+
}
|
|
44931
|
+
// Expose functions to the client
|
|
44932
|
+
const app = (0, _app__WEBPACK_IMPORTED_MODULE_1__.createApp)();
|
|
44933
|
+
app.method('report/create', (0, _mutators__WEBPACK_IMPORTED_MODULE_4__.mutator)((0, _undo__WEBPACK_IMPORTED_MODULE_5__.undoable)(createReport)));
|
|
44934
|
+
app.method('report/update', (0, _mutators__WEBPACK_IMPORTED_MODULE_4__.mutator)((0, _undo__WEBPACK_IMPORTED_MODULE_5__.undoable)(updateReport)));
|
|
44935
|
+
app.method('report/delete', (0, _mutators__WEBPACK_IMPORTED_MODULE_4__.mutator)((0, _undo__WEBPACK_IMPORTED_MODULE_5__.undoable)(deleteReport)));
|
|
44936
|
+
/***/
|
|
44937
|
+
}),
|
|
44733
44938
|
/***/ "./packages/loot-core/src/server/rules/app.ts":
|
|
44734
44939
|
/*!****************************************************!*\
|
|
44735
44940
|
!*** ./packages/loot-core/src/server/rules/app.ts ***!
|
|
@@ -44738,7 +44943,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44738
44943
|
"use strict";
|
|
44739
44944
|
__webpack_require__.r(__webpack_exports__);
|
|
44740
44945
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
44741
|
-
/* harmony export */
|
|
44946
|
+
/* harmony export */ app: () => ( /* binding */app)
|
|
44742
44947
|
/* harmony export */
|
|
44743
44948
|
});
|
|
44744
44949
|
/* harmony import */ var _shared_rules__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../shared/rules */ "./packages/loot-core/src/shared/rules.ts");
|
|
@@ -44749,6 +44954,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44749
44954
|
/* harmony import */ var _mutators__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../mutators */ "./packages/loot-core/src/server/mutators.ts");
|
|
44750
44955
|
/* harmony import */ var _sync__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sync */ "./packages/loot-core/src/server/sync/index.ts");
|
|
44751
44956
|
/* harmony import */ var _undo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../undo */ "./packages/loot-core/src/server/undo.ts");
|
|
44957
|
+
// @ts-strict-ignore
|
|
44752
44958
|
function validateRule(rule) {
|
|
44753
44959
|
// Returns an array of errors, the array is the same link as the
|
|
44754
44960
|
// passed-in `array`, or null if there are no errors
|
|
@@ -44843,7 +45049,6 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44843
45049
|
app.method('rules-run', async function ({ transaction }) {
|
|
44844
45050
|
return _accounts_transaction_rules__WEBPACK_IMPORTED_MODULE_2__.runRules(transaction);
|
|
44845
45051
|
});
|
|
44846
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (app);
|
|
44847
45052
|
/***/
|
|
44848
45053
|
}),
|
|
44849
45054
|
/***/ "./packages/loot-core/src/server/schedules/app.ts":
|
|
@@ -44854,8 +45059,8 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44854
45059
|
"use strict";
|
|
44855
45060
|
__webpack_require__.r(__webpack_exports__);
|
|
44856
45061
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
45062
|
+
/* harmony export */ app: () => ( /* binding */app),
|
|
44857
45063
|
/* harmony export */ createSchedule: () => ( /* binding */createSchedule),
|
|
44858
|
-
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
|
|
44859
45064
|
/* harmony export */ deleteSchedule: () => ( /* binding */deleteSchedule),
|
|
44860
45065
|
/* harmony export */ getDateWithSkippedWeekend: () => ( /* binding */getDateWithSkippedWeekend),
|
|
44861
45066
|
/* harmony export */ getNextDate: () => ( /* binding */getNextDate),
|
|
@@ -44891,6 +45096,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44891
45096
|
/* harmony import */ var _undo__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../undo */ "./packages/loot-core/src/server/undo.ts");
|
|
44892
45097
|
/* harmony import */ var _util_rschedule__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../util/rschedule */ "./packages/loot-core/src/server/util/rschedule.ts");
|
|
44893
45098
|
/* harmony import */ var _find_schedules__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./find-schedules */ "./packages/loot-core/src/server/schedules/find-schedules.ts");
|
|
45099
|
+
// @ts-strict-ignore
|
|
44894
45100
|
// Utilities
|
|
44895
45101
|
function zip(arr1, arr2) {
|
|
44896
45102
|
const result = [];
|
|
@@ -44949,13 +45155,13 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
44949
45155
|
if (id == null) {
|
|
44950
45156
|
throw new Error('Schedule not attached to a rule');
|
|
44951
45157
|
}
|
|
44952
|
-
const { data: ruleId } = await (0, _aql__WEBPACK_IMPORTED_MODULE_10__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__
|
|
45158
|
+
const { data: ruleId } = await (0, _aql__WEBPACK_IMPORTED_MODULE_10__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__.q)('schedules').filter({
|
|
44953
45159
|
id
|
|
44954
45160
|
}).calculate('rule'));
|
|
44955
45161
|
return (0, _accounts_transaction_rules__WEBPACK_IMPORTED_MODULE_8__.getRules)().find((rule) => rule.id === ruleId);
|
|
44956
45162
|
}
|
|
44957
45163
|
async function fixRuleForSchedule(id) {
|
|
44958
|
-
const { data: ruleId } = await (0, _aql__WEBPACK_IMPORTED_MODULE_10__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__
|
|
45164
|
+
const { data: ruleId } = await (0, _aql__WEBPACK_IMPORTED_MODULE_10__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__.q)('schedules').filter({
|
|
44959
45165
|
id
|
|
44960
45166
|
}).calculate('rule'));
|
|
44961
45167
|
if (ruleId) {
|
|
@@ -45000,7 +45206,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45000
45206
|
conditions = rule.serialize().conditions;
|
|
45001
45207
|
}
|
|
45002
45208
|
const { date: dateCond } = (0, _shared_schedules__WEBPACK_IMPORTED_MODULE_5__.extractScheduleConds)(conditions);
|
|
45003
|
-
const { data: nextDate } = await (0, _aql__WEBPACK_IMPORTED_MODULE_10__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__
|
|
45209
|
+
const { data: nextDate } = await (0, _aql__WEBPACK_IMPORTED_MODULE_10__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__.q)('schedules').filter({
|
|
45004
45210
|
id
|
|
45005
45211
|
}).calculate('next_date'));
|
|
45006
45212
|
// Only do this if a date condition exists
|
|
@@ -45141,7 +45347,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45141
45347
|
});
|
|
45142
45348
|
}
|
|
45143
45349
|
async function deleteSchedule({ id }) {
|
|
45144
|
-
const { data: ruleId } = await (0, _aql__WEBPACK_IMPORTED_MODULE_10__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__
|
|
45350
|
+
const { data: ruleId } = await (0, _aql__WEBPACK_IMPORTED_MODULE_10__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__.q)('schedules').filter({
|
|
45145
45351
|
id
|
|
45146
45352
|
}).calculate('rule'));
|
|
45147
45353
|
await (0, _sync__WEBPACK_IMPORTED_MODULE_15__.batchMessages)(async () => {
|
|
@@ -45218,7 +45424,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45218
45424
|
// This is the service that move schedules forward automatically and
|
|
45219
45425
|
// posts transactions
|
|
45220
45426
|
async function postTransactionForSchedule({ id }) {
|
|
45221
|
-
const { data } = await (0, _aql__WEBPACK_IMPORTED_MODULE_10__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__
|
|
45427
|
+
const { data } = await (0, _aql__WEBPACK_IMPORTED_MODULE_10__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__.q)('schedules').filter({
|
|
45222
45428
|
id
|
|
45223
45429
|
}).select('*'));
|
|
45224
45430
|
const schedule = data[0];
|
|
@@ -45242,7 +45448,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45242
45448
|
// TODO: make this sequential
|
|
45243
45449
|
async function advanceSchedulesService(syncSuccess) {
|
|
45244
45450
|
// Move all paid schedules
|
|
45245
|
-
const { data: schedules } = await (0, _aql__WEBPACK_IMPORTED_MODULE_10__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__
|
|
45451
|
+
const { data: schedules } = await (0, _aql__WEBPACK_IMPORTED_MODULE_10__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_4__.q)('schedules').filter({
|
|
45246
45452
|
completed: false,
|
|
45247
45453
|
'_account.closed': false
|
|
45248
45454
|
}).select('*'));
|
|
@@ -45322,7 +45528,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45322
45528
|
app.method('schedule/discover', discoverSchedules);
|
|
45323
45529
|
app.method('schedule/get-upcoming-dates', getUpcomingDates);
|
|
45324
45530
|
app.service(trackJSONPaths);
|
|
45325
|
-
app.events.on('sync', ({ type
|
|
45531
|
+
app.events.on('sync', ({ type }) => {
|
|
45326
45532
|
const completeEvent = type === 'success' || type === 'error' || type === 'unauthorized';
|
|
45327
45533
|
if (completeEvent && _prefs__WEBPACK_IMPORTED_MODULE_14__.getPrefs()) {
|
|
45328
45534
|
const { lastScheduleRun } = _prefs__WEBPACK_IMPORTED_MODULE_14__.getPrefs();
|
|
@@ -45348,7 +45554,6 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45348
45554
|
}
|
|
45349
45555
|
return date;
|
|
45350
45556
|
}
|
|
45351
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (app);
|
|
45352
45557
|
/***/
|
|
45353
45558
|
}),
|
|
45354
45559
|
/***/ "./packages/loot-core/src/server/schedules/find-schedules.ts":
|
|
@@ -45381,6 +45586,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45381
45586
|
/* harmony import */ var _db__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../db */ "./packages/loot-core/src/server/db/index.ts");
|
|
45382
45587
|
/* harmony import */ var _models__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../models */ "./packages/loot-core/src/server/models.ts");
|
|
45383
45588
|
/* harmony import */ var _util_rschedule__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../util/rschedule */ "./packages/loot-core/src/server/util/rschedule.ts");
|
|
45589
|
+
// @ts-strict-ignore
|
|
45384
45590
|
function takeDates(config) {
|
|
45385
45591
|
const schedule = new _util_rschedule__WEBPACK_IMPORTED_MODULE_9__.Schedule({
|
|
45386
45592
|
rrules: (0, _shared_schedules__WEBPACK_IMPORTED_MODULE_3__.recurConfigToRSchedule)(config)
|
|
@@ -45390,7 +45596,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45390
45596
|
}).toArray().map((d) => d.date);
|
|
45391
45597
|
}
|
|
45392
45598
|
async function getTransactions(date, account) {
|
|
45393
|
-
const { data } = await (0, _aql__WEBPACK_IMPORTED_MODULE_6__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_1__
|
|
45599
|
+
const { data } = await (0, _aql__WEBPACK_IMPORTED_MODULE_6__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_1__.q)('transactions').filter({
|
|
45394
45600
|
account,
|
|
45395
45601
|
schedule: null,
|
|
45396
45602
|
// Don't match transfers
|
|
@@ -45419,7 +45625,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45419
45625
|
// best start date that matches all the dates the closest
|
|
45420
45626
|
return 1 / (dayDiff + 1);
|
|
45421
45627
|
}
|
|
45422
|
-
function matchSchedules(allOccurs, config
|
|
45628
|
+
function matchSchedules(allOccurs, config) {
|
|
45423
45629
|
allOccurs = [
|
|
45424
45630
|
...allOccurs
|
|
45425
45631
|
].reverse();
|
|
@@ -45459,7 +45665,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45459
45665
|
}
|
|
45460
45666
|
return schedules;
|
|
45461
45667
|
}
|
|
45462
|
-
async function schedulesForPattern(baseStart, numDays, baseConfig, accountId
|
|
45668
|
+
async function schedulesForPattern(baseStart, numDays, baseConfig, accountId) {
|
|
45463
45669
|
let schedules = [];
|
|
45464
45670
|
for (let i = 0; i < numDays; i++) {
|
|
45465
45671
|
const start = date_fns__WEBPACK_IMPORTED_MODULE_11__["default"](baseStart, i);
|
|
@@ -45486,7 +45692,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45486
45692
|
transactions: await getTransactions(date, accountId)
|
|
45487
45693
|
});
|
|
45488
45694
|
}
|
|
45489
|
-
schedules = schedules.concat(matchSchedules(data, config
|
|
45695
|
+
schedules = schedules.concat(matchSchedules(data, config));
|
|
45490
45696
|
}
|
|
45491
45697
|
return schedules;
|
|
45492
45698
|
}
|
|
@@ -45530,9 +45736,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45530
45736
|
value: -1
|
|
45531
45737
|
}
|
|
45532
45738
|
]
|
|
45533
|
-
}, accountId
|
|
45534
|
-
// happen to match
|
|
45535
|
-
0.75);
|
|
45739
|
+
}, accountId);
|
|
45536
45740
|
const s2 = await schedulesForPattern(date_fns__WEBPACK_IMPORTED_MODULE_14__["default"]((0, _shared_months__WEBPACK_IMPORTED_MODULE_0__.parseDate)(startDate), 4), 1, {
|
|
45537
45741
|
frequency: 'monthly',
|
|
45538
45742
|
patterns: [
|
|
@@ -45541,7 +45745,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45541
45745
|
value: -1
|
|
45542
45746
|
}
|
|
45543
45747
|
]
|
|
45544
|
-
}, accountId
|
|
45748
|
+
}, accountId);
|
|
45545
45749
|
return s1.concat(s2);
|
|
45546
45750
|
}
|
|
45547
45751
|
async function monthly1stor3rd(startDate, accountId) {
|
|
@@ -45619,7 +45823,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45619
45823
|
currentConfig = null;
|
|
45620
45824
|
break;
|
|
45621
45825
|
}
|
|
45622
|
-
const { data } = await (0, _aql__WEBPACK_IMPORTED_MODULE_6__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_1__
|
|
45826
|
+
const { data } = await (0, _aql__WEBPACK_IMPORTED_MODULE_6__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_1__.q)('transactions').filter({
|
|
45623
45827
|
$and: filters
|
|
45624
45828
|
}).select('*'));
|
|
45625
45829
|
if (data.length === 0) {
|
|
@@ -45650,7 +45854,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45650
45854
|
//
|
|
45651
45855
|
// Search for them approx (+- 2 days) but track which transactions
|
|
45652
45856
|
// and find the best one...
|
|
45653
|
-
const { data: accounts } = await (0, _aql__WEBPACK_IMPORTED_MODULE_6__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_1__
|
|
45857
|
+
const { data: accounts } = await (0, _aql__WEBPACK_IMPORTED_MODULE_6__.runQuery)((0, _shared_query__WEBPACK_IMPORTED_MODULE_1__.q)('accounts').filter({
|
|
45654
45858
|
closed: false
|
|
45655
45859
|
}).select('*'));
|
|
45656
45860
|
let allSchedules = [];
|
|
@@ -45666,7 +45870,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45666
45870
|
}
|
|
45667
45871
|
const schedules = [
|
|
45668
45872
|
...(0, _shared_util__WEBPACK_IMPORTED_MODULE_4__.groupBy)(allSchedules, 'payee').entries()
|
|
45669
|
-
].map(([
|
|
45873
|
+
].map(([, schedules]) => {
|
|
45670
45874
|
schedules.sort((s1, s2) => s2.rank - s1.rank);
|
|
45671
45875
|
const winner = schedules[0];
|
|
45672
45876
|
// Convert to schedule and return it
|
|
@@ -45743,7 +45947,8 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45743
45947
|
SYNC_SERVER: joinURL(url, '/sync'),
|
|
45744
45948
|
SIGNUP_SERVER: joinURL(url, '/account'),
|
|
45745
45949
|
PLAID_SERVER: joinURL(url, '/plaid'),
|
|
45746
|
-
GOCARDLESS_SERVER: joinURL(url, '/gocardless')
|
|
45950
|
+
GOCARDLESS_SERVER: joinURL(url, '/gocardless'),
|
|
45951
|
+
SIMPLEFIN_SERVER: joinURL(url, '/simplefin')
|
|
45747
45952
|
};
|
|
45748
45953
|
}
|
|
45749
45954
|
return config;
|
|
@@ -45777,6 +45982,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45777
45982
|
/* harmony import */ var _prefs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./prefs */ "./packages/loot-core/src/server/prefs.ts");
|
|
45778
45983
|
/* harmony import */ var _spreadsheet_spreadsheet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./spreadsheet/spreadsheet */ "./packages/loot-core/src/server/spreadsheet/spreadsheet.ts");
|
|
45779
45984
|
/* harmony import */ var _spreadsheet_util__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spreadsheet/util */ "./packages/loot-core/src/server/spreadsheet/util.ts");
|
|
45985
|
+
// @ts-strict-ignore
|
|
45780
45986
|
let globalSheet;
|
|
45781
45987
|
let globalOnChange;
|
|
45782
45988
|
let globalCacheDb;
|
|
@@ -45853,10 +46059,10 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45853
46059
|
}
|
|
45854
46060
|
let sheet;
|
|
45855
46061
|
if (cacheEnabled) {
|
|
45856
|
-
sheet = new _spreadsheet_spreadsheet__WEBPACK_IMPORTED_MODULE_5__
|
|
46062
|
+
sheet = new _spreadsheet_spreadsheet__WEBPACK_IMPORTED_MODULE_5__.Spreadsheet(updateSpreadsheetCache.bind(null, cacheDb), setCacheStatus.bind(null, mainDb, cacheDb));
|
|
45857
46063
|
}
|
|
45858
46064
|
else {
|
|
45859
|
-
sheet = new _spreadsheet_spreadsheet__WEBPACK_IMPORTED_MODULE_5__
|
|
46065
|
+
sheet = new _spreadsheet_spreadsheet__WEBPACK_IMPORTED_MODULE_5__.Spreadsheet();
|
|
45860
46066
|
}
|
|
45861
46067
|
(0, _platform_exceptions__WEBPACK_IMPORTED_MODULE_0__.captureBreadcrumb)({
|
|
45862
46068
|
message: 'loading spreaadsheet',
|
|
@@ -45995,9 +46201,10 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
45995
46201
|
"use strict";
|
|
45996
46202
|
__webpack_require__.r(__webpack_exports__);
|
|
45997
46203
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
45998
|
-
/* harmony export */
|
|
46204
|
+
/* harmony export */ Graph: () => ( /* binding */Graph)
|
|
45999
46205
|
/* harmony export */
|
|
46000
46206
|
});
|
|
46207
|
+
// @ts-strict-ignore
|
|
46001
46208
|
function Graph() {
|
|
46002
46209
|
const graph = {
|
|
46003
46210
|
addNode,
|
|
@@ -46104,7 +46311,6 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
46104
46311
|
}
|
|
46105
46312
|
return graph;
|
|
46106
46313
|
}
|
|
46107
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Graph);
|
|
46108
46314
|
/***/
|
|
46109
46315
|
}),
|
|
46110
46316
|
/***/ "./packages/loot-core/src/server/spreadsheet/spreadsheet.ts":
|
|
@@ -46115,17 +46321,18 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
46115
46321
|
"use strict";
|
|
46116
46322
|
__webpack_require__.r(__webpack_exports__);
|
|
46117
46323
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
46118
|
-
/* harmony export */
|
|
46324
|
+
/* harmony export */ Spreadsheet: () => ( /* binding */Spreadsheet)
|
|
46119
46325
|
/* harmony export */
|
|
46120
46326
|
});
|
|
46121
46327
|
/* harmony import */ var mitt__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! mitt */ "./node_modules/mitt/dist/mitt.mjs");
|
|
46122
46328
|
/* harmony import */ var _aql__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../aql */ "./packages/loot-core/src/server/aql/index.ts");
|
|
46123
46329
|
/* harmony import */ var _graph_data_structure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./graph-data-structure */ "./packages/loot-core/src/server/spreadsheet/graph-data-structure.ts");
|
|
46124
46330
|
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./util */ "./packages/loot-core/src/server/spreadsheet/util.ts");
|
|
46331
|
+
// @ts-strict-ignore
|
|
46125
46332
|
class Spreadsheet {
|
|
46126
46333
|
constructor(saveCache, setCacheStatus) {
|
|
46127
46334
|
// @ts-expect-error Graph should be converted to class
|
|
46128
|
-
this.graph = new _graph_data_structure__WEBPACK_IMPORTED_MODULE_2__
|
|
46335
|
+
this.graph = new _graph_data_structure__WEBPACK_IMPORTED_MODULE_2__.Graph();
|
|
46129
46336
|
this.nodes = new Map();
|
|
46130
46337
|
this.transactionDepth = 0;
|
|
46131
46338
|
this.saveCache = saveCache;
|
|
@@ -46162,7 +46369,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
46162
46369
|
hasCell(name) {
|
|
46163
46370
|
return this.nodes.has(name);
|
|
46164
46371
|
}
|
|
46165
|
-
add(name, expr
|
|
46372
|
+
add(name, expr) {
|
|
46166
46373
|
this.set(name, expr);
|
|
46167
46374
|
}
|
|
46168
46375
|
getNodes() {
|
|
@@ -46518,6 +46725,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
46518
46725
|
/* harmony export */ unresolveName: () => ( /* binding */unresolveName)
|
|
46519
46726
|
/* harmony export */
|
|
46520
46727
|
});
|
|
46728
|
+
// @ts-strict-ignore
|
|
46521
46729
|
function unresolveName(name) {
|
|
46522
46730
|
const idx = name.indexOf('!');
|
|
46523
46731
|
if (idx !== -1) {
|
|
@@ -46552,6 +46760,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
46552
46760
|
/* harmony import */ var _encryption__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../encryption */ "./packages/loot-core/src/server/encryption.ts");
|
|
46553
46761
|
/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../errors */ "./packages/loot-core/src/server/errors.ts");
|
|
46554
46762
|
/* harmony import */ var _prefs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../prefs */ "./packages/loot-core/src/server/prefs.ts");
|
|
46763
|
+
// @ts-strict-ignore
|
|
46555
46764
|
function coerceBuffer(value) {
|
|
46556
46765
|
// The web encryption APIs give us back raw Uint8Array... but our
|
|
46557
46766
|
// encryption code assumes we can work with it as a buffer. This is
|
|
@@ -46668,10 +46877,10 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
46668
46877
|
/* harmony export */ fullSync: () => ( /* binding */fullSync),
|
|
46669
46878
|
/* harmony export */ getMessagesSince: () => ( /* binding */getMessagesSince),
|
|
46670
46879
|
/* harmony export */ initialFullSync: () => ( /* binding */initialFullSync),
|
|
46671
|
-
/* harmony export */ makeTestMessage: () => ( /* reexport safe */_make_test_message__WEBPACK_IMPORTED_MODULE_20__
|
|
46880
|
+
/* harmony export */ makeTestMessage: () => ( /* reexport safe */_make_test_message__WEBPACK_IMPORTED_MODULE_20__.makeTestMessage),
|
|
46672
46881
|
/* harmony export */ receiveMessages: () => ( /* binding */receiveMessages),
|
|
46673
|
-
/* harmony export */ repairSync: () => ( /* reexport safe */_repair__WEBPACK_IMPORTED_MODULE_18__
|
|
46674
|
-
/* harmony export */ resetSync: () => ( /* reexport safe */_reset__WEBPACK_IMPORTED_MODULE_21__
|
|
46882
|
+
/* harmony export */ repairSync: () => ( /* reexport safe */_repair__WEBPACK_IMPORTED_MODULE_18__.repairSync),
|
|
46883
|
+
/* harmony export */ resetSync: () => ( /* reexport safe */_reset__WEBPACK_IMPORTED_MODULE_21__.resetSync),
|
|
46675
46884
|
/* harmony export */ scheduleFullSync: () => ( /* binding */scheduleFullSync),
|
|
46676
46885
|
/* harmony export */ sendMessages: () => ( /* binding */sendMessages),
|
|
46677
46886
|
/* harmony export */ serializeValue: () => ( /* binding */serializeValue),
|
|
@@ -46700,6 +46909,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
46700
46909
|
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./utils */ "./packages/loot-core/src/server/sync/utils.ts");
|
|
46701
46910
|
/* harmony import */ var _make_test_message__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./make-test-message */ "./packages/loot-core/src/server/sync/make-test-message.ts");
|
|
46702
46911
|
/* harmony import */ var _reset__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./reset */ "./packages/loot-core/src/server/sync/reset.ts");
|
|
46912
|
+
// @ts-strict-ignore
|
|
46703
46913
|
const FULL_SYNC_DELAY = 1000;
|
|
46704
46914
|
let SYNCING_MODE = 'enabled';
|
|
46705
46915
|
function setSyncingMode(mode) {
|
|
@@ -46800,7 +47010,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
46800
47010
|
sql = `SELECT * FROM ${table}`;
|
|
46801
47011
|
}
|
|
46802
47012
|
sql += ` WHERE `;
|
|
46803
|
-
sql += partIds.map((
|
|
47013
|
+
sql += partIds.map(() => `${column} = ?`).join(' OR ');
|
|
46804
47014
|
try {
|
|
46805
47015
|
const rows = await _db__WEBPACK_IMPORTED_MODULE_8__.runQuery(sql, partIds, true);
|
|
46806
47016
|
results = results.concat(rows);
|
|
@@ -46811,8 +47021,10 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
46811
47021
|
message: error.message,
|
|
46812
47022
|
stack: error.stack
|
|
46813
47023
|
},
|
|
46814
|
-
|
|
46815
|
-
|
|
47024
|
+
query: {
|
|
47025
|
+
sql,
|
|
47026
|
+
params: partIds
|
|
47027
|
+
}
|
|
46816
47028
|
});
|
|
46817
47029
|
}
|
|
46818
47030
|
}
|
|
@@ -47045,7 +47257,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47045
47257
|
}
|
|
47046
47258
|
_syncListeners.forEach((func) => func(oldData, newData));
|
|
47047
47259
|
const tables = getTablesFromMessages(messages.filter((msg) => !msg.old));
|
|
47048
|
-
_main_app__WEBPACK_IMPORTED_MODULE_10__
|
|
47260
|
+
_main_app__WEBPACK_IMPORTED_MODULE_10__.app.events.emit('sync', {
|
|
47049
47261
|
type: 'applied',
|
|
47050
47262
|
tables,
|
|
47051
47263
|
data: newData,
|
|
@@ -47070,14 +47282,14 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47070
47282
|
// couldn't apply, which doesn't make any sense. Must be a bug
|
|
47071
47283
|
// in the code. Send a specific error type for it for a custom
|
|
47072
47284
|
// message.
|
|
47073
|
-
_main_app__WEBPACK_IMPORTED_MODULE_10__
|
|
47285
|
+
_main_app__WEBPACK_IMPORTED_MODULE_10__.app.events.emit('sync', {
|
|
47074
47286
|
type: 'error',
|
|
47075
47287
|
subtype: 'apply-failure',
|
|
47076
47288
|
meta: e.meta
|
|
47077
47289
|
});
|
|
47078
47290
|
}
|
|
47079
47291
|
else {
|
|
47080
|
-
_main_app__WEBPACK_IMPORTED_MODULE_10__
|
|
47292
|
+
_main_app__WEBPACK_IMPORTED_MODULE_10__.app.events.emit('sync', {
|
|
47081
47293
|
type: 'error',
|
|
47082
47294
|
meta: e.meta
|
|
47083
47295
|
});
|
|
@@ -47161,7 +47373,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47161
47373
|
return {};
|
|
47162
47374
|
}
|
|
47163
47375
|
const fullSync = (0, _shared_async__WEBPACK_IMPORTED_MODULE_5__.once)(async function () {
|
|
47164
|
-
_main_app__WEBPACK_IMPORTED_MODULE_10__
|
|
47376
|
+
_main_app__WEBPACK_IMPORTED_MODULE_10__.app.events.emit('sync', {
|
|
47165
47377
|
type: 'start'
|
|
47166
47378
|
});
|
|
47167
47379
|
let messages;
|
|
@@ -47173,28 +47385,28 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47173
47385
|
if (e instanceof _errors__WEBPACK_IMPORTED_MODULE_9__.SyncError) {
|
|
47174
47386
|
if (e.reason === 'out-of-sync') {
|
|
47175
47387
|
(0, _platform_exceptions__WEBPACK_IMPORTED_MODULE_1__.captureException)(e);
|
|
47176
|
-
_main_app__WEBPACK_IMPORTED_MODULE_10__
|
|
47388
|
+
_main_app__WEBPACK_IMPORTED_MODULE_10__.app.events.emit('sync', {
|
|
47177
47389
|
type: 'error',
|
|
47178
47390
|
subtype: 'out-of-sync',
|
|
47179
47391
|
meta: e.meta
|
|
47180
47392
|
});
|
|
47181
47393
|
}
|
|
47182
47394
|
else if (e.reason === 'invalid-schema') {
|
|
47183
|
-
_main_app__WEBPACK_IMPORTED_MODULE_10__
|
|
47395
|
+
_main_app__WEBPACK_IMPORTED_MODULE_10__.app.events.emit('sync', {
|
|
47184
47396
|
type: 'error',
|
|
47185
47397
|
subtype: 'invalid-schema',
|
|
47186
47398
|
meta: e.meta
|
|
47187
47399
|
});
|
|
47188
47400
|
}
|
|
47189
47401
|
else if (e.reason === 'decrypt-failure' || e.reason === 'encrypt-failure') {
|
|
47190
|
-
_main_app__WEBPACK_IMPORTED_MODULE_10__
|
|
47402
|
+
_main_app__WEBPACK_IMPORTED_MODULE_10__.app.events.emit('sync', {
|
|
47191
47403
|
type: 'error',
|
|
47192
47404
|
subtype: e.reason,
|
|
47193
47405
|
meta: e.meta
|
|
47194
47406
|
});
|
|
47195
47407
|
}
|
|
47196
47408
|
else {
|
|
47197
|
-
_main_app__WEBPACK_IMPORTED_MODULE_10__
|
|
47409
|
+
_main_app__WEBPACK_IMPORTED_MODULE_10__.app.events.emit('sync', {
|
|
47198
47410
|
type: 'error',
|
|
47199
47411
|
meta: e.meta
|
|
47200
47412
|
});
|
|
@@ -47203,20 +47415,20 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47203
47415
|
else if (e instanceof _errors__WEBPACK_IMPORTED_MODULE_9__.PostError) {
|
|
47204
47416
|
console.log(e);
|
|
47205
47417
|
if (e.reason === 'unauthorized') {
|
|
47206
|
-
_main_app__WEBPACK_IMPORTED_MODULE_10__
|
|
47418
|
+
_main_app__WEBPACK_IMPORTED_MODULE_10__.app.events.emit('sync', {
|
|
47207
47419
|
type: 'unauthorized'
|
|
47208
47420
|
});
|
|
47209
47421
|
// Set the user into read-only mode
|
|
47210
47422
|
_platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_2__.setItem('readOnly', 'true');
|
|
47211
47423
|
}
|
|
47212
47424
|
else if (e.reason === 'network-failure') {
|
|
47213
|
-
_main_app__WEBPACK_IMPORTED_MODULE_10__
|
|
47425
|
+
_main_app__WEBPACK_IMPORTED_MODULE_10__.app.events.emit('sync', {
|
|
47214
47426
|
type: 'error',
|
|
47215
47427
|
subtype: 'network'
|
|
47216
47428
|
});
|
|
47217
47429
|
}
|
|
47218
47430
|
else {
|
|
47219
|
-
_main_app__WEBPACK_IMPORTED_MODULE_10__
|
|
47431
|
+
_main_app__WEBPACK_IMPORTED_MODULE_10__.app.events.emit('sync', {
|
|
47220
47432
|
type: 'error',
|
|
47221
47433
|
subtype: e.reason
|
|
47222
47434
|
});
|
|
@@ -47225,7 +47437,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47225
47437
|
else {
|
|
47226
47438
|
(0, _platform_exceptions__WEBPACK_IMPORTED_MODULE_1__.captureException)(e);
|
|
47227
47439
|
// TODO: Send the message to the client and allow them to expand & view it
|
|
47228
|
-
_main_app__WEBPACK_IMPORTED_MODULE_10__
|
|
47440
|
+
_main_app__WEBPACK_IMPORTED_MODULE_10__.app.events.emit('sync', {
|
|
47229
47441
|
type: 'error'
|
|
47230
47442
|
});
|
|
47231
47443
|
}
|
|
@@ -47238,7 +47450,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47238
47450
|
};
|
|
47239
47451
|
}
|
|
47240
47452
|
const tables = getTablesFromMessages(messages);
|
|
47241
|
-
_main_app__WEBPACK_IMPORTED_MODULE_10__
|
|
47453
|
+
_main_app__WEBPACK_IMPORTED_MODULE_10__.app.events.emit('sync', {
|
|
47242
47454
|
type: 'success',
|
|
47243
47455
|
tables,
|
|
47244
47456
|
syncDisabled: checkSyncingMode('disabled')
|
|
@@ -47259,7 +47471,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47259
47471
|
new _actual_app_crdt__WEBPACK_IMPORTED_MODULE_0__.Timestamp(Date.now() - 5 * 60 * 1000, 0, '0').toString();
|
|
47260
47472
|
const messages = getMessagesSince(since);
|
|
47261
47473
|
const userToken = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_2__.getItem('user-token');
|
|
47262
|
-
_platform_server_log__WEBPACK_IMPORTED_MODULE_4__
|
|
47474
|
+
_platform_server_log__WEBPACK_IMPORTED_MODULE_4__.logger.info('Syncing since', since, messages.length, '(attempt: ' + count + ')');
|
|
47263
47475
|
const buffer = await _encoder__WEBPACK_IMPORTED_MODULE_17__.encode(groupId, cloudFileId, since, messages);
|
|
47264
47476
|
// TODO: There a limit on how many messages we can send because of
|
|
47265
47477
|
// the payload size. Right now it's at 20MB on the server. We should
|
|
@@ -47274,7 +47486,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47274
47486
|
return [];
|
|
47275
47487
|
}
|
|
47276
47488
|
const res = await _encoder__WEBPACK_IMPORTED_MODULE_17__.decode(resBuffer);
|
|
47277
|
-
_platform_server_log__WEBPACK_IMPORTED_MODULE_4__
|
|
47489
|
+
_platform_server_log__WEBPACK_IMPORTED_MODULE_4__.logger.info('Got messages from server', res.messages.length);
|
|
47278
47490
|
const localTimeChanged = (0, _actual_app_crdt__WEBPACK_IMPORTED_MODULE_0__.getClock)().timestamp.toString() !== currentTime;
|
|
47279
47491
|
// Apply the new messages
|
|
47280
47492
|
let receivedMessages = [];
|
|
@@ -47300,10 +47512,10 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47300
47512
|
// false. In that case, we don't reset the counter but it should be
|
|
47301
47513
|
// very unlikely that this happens enough to hit the loop limit.
|
|
47302
47514
|
if (count >= 10 && diffTime === prevDiffTime || count >= 100) {
|
|
47303
|
-
_platform_server_log__WEBPACK_IMPORTED_MODULE_4__
|
|
47304
|
-
_platform_server_log__WEBPACK_IMPORTED_MODULE_4__
|
|
47305
|
-
_platform_server_log__WEBPACK_IMPORTED_MODULE_4__
|
|
47306
|
-
_platform_server_log__WEBPACK_IMPORTED_MODULE_4__
|
|
47515
|
+
_platform_server_log__WEBPACK_IMPORTED_MODULE_4__.logger.info('SENT -------');
|
|
47516
|
+
_platform_server_log__WEBPACK_IMPORTED_MODULE_4__.logger.info(JSON.stringify(messages));
|
|
47517
|
+
_platform_server_log__WEBPACK_IMPORTED_MODULE_4__.logger.info('RECEIVED -------');
|
|
47518
|
+
_platform_server_log__WEBPACK_IMPORTED_MODULE_4__.logger.info(JSON.stringify(res.messages));
|
|
47307
47519
|
const rebuiltMerkle = (0, _repair__WEBPACK_IMPORTED_MODULE_18__.rebuildMerkleHash)();
|
|
47308
47520
|
console.log(count, 'messages:', messages.length, messages.length > 0 ? messages[0] : null, 'res.messages:', res.messages.length, res.messages.length > 0 ? res.messages[0] : null, 'clientId', (0, _actual_app_crdt__WEBPACK_IMPORTED_MODULE_0__.getClock)().timestamp.node(), 'groupId', groupId, 'diffTime:', diffTime, diffTime === prevDiffTime, 'local clock:', (0, _actual_app_crdt__WEBPACK_IMPORTED_MODULE_0__.getClock)().timestamp.toString(), (0, _actual_app_crdt__WEBPACK_IMPORTED_MODULE_0__.getClock)().merkle.hash, 'rebuilt hash:', rebuiltMerkle.numMessages, rebuiltMerkle.trie.hash, 'server hash:', res.merkle.hash, 'localTimeChanged:', localTimeChanged);
|
|
47309
47521
|
if (rebuiltMerkle.trie.hash === res.merkle.hash) {
|
|
@@ -47343,11 +47555,12 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47343
47555
|
"use strict";
|
|
47344
47556
|
__webpack_require__.r(__webpack_exports__);
|
|
47345
47557
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
47346
|
-
/* harmony export */
|
|
47558
|
+
/* harmony export */ makeTestMessage: () => ( /* binding */makeTestMessage)
|
|
47347
47559
|
/* harmony export */
|
|
47348
47560
|
});
|
|
47349
47561
|
/* harmony import */ var _actual_app_crdt__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @actual-app/crdt */ "./packages/crdt/index.ts");
|
|
47350
47562
|
/* harmony import */ var _encryption__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../encryption */ "./packages/loot-core/src/server/encryption.ts");
|
|
47563
|
+
// @ts-strict-ignore
|
|
47351
47564
|
async function randomString() {
|
|
47352
47565
|
return (await _encryption__WEBPACK_IMPORTED_MODULE_1__.randomBytes(12)).toString();
|
|
47353
47566
|
}
|
|
@@ -47376,6 +47589,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47376
47589
|
});
|
|
47377
47590
|
/* harmony import */ var _actual_app_crdt__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @actual-app/crdt */ "./packages/crdt/index.ts");
|
|
47378
47591
|
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./index */ "./packages/loot-core/src/server/sync/index.ts");
|
|
47592
|
+
// @ts-strict-ignore
|
|
47379
47593
|
function migrateParentIds(_oldValues, newValues) {
|
|
47380
47594
|
newValues.forEach((items, table) => {
|
|
47381
47595
|
if (table === 'transactions') {
|
|
@@ -47419,12 +47633,13 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47419
47633
|
"use strict";
|
|
47420
47634
|
__webpack_require__.r(__webpack_exports__);
|
|
47421
47635
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
47422
|
-
/* harmony export */
|
|
47423
|
-
/* harmony export */
|
|
47636
|
+
/* harmony export */ rebuildMerkleHash: () => ( /* binding */rebuildMerkleHash),
|
|
47637
|
+
/* harmony export */ repairSync: () => ( /* binding */repairSync)
|
|
47424
47638
|
/* harmony export */
|
|
47425
47639
|
});
|
|
47426
47640
|
/* harmony import */ var _actual_app_crdt__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @actual-app/crdt */ "./packages/crdt/index.ts");
|
|
47427
47641
|
/* harmony import */ var _db__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../db */ "./packages/loot-core/src/server/db/index.ts");
|
|
47642
|
+
// @ts-strict-ignore
|
|
47428
47643
|
function rebuildMerkleHash() {
|
|
47429
47644
|
const rows = _db__WEBPACK_IMPORTED_MODULE_1__.runQuery('SELECT timestamp FROM messages_crdt', [], true);
|
|
47430
47645
|
let trie = _actual_app_crdt__WEBPACK_IMPORTED_MODULE_0__.merkle.emptyTrie();
|
|
@@ -47456,7 +47671,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47456
47671
|
"use strict";
|
|
47457
47672
|
__webpack_require__.r(__webpack_exports__);
|
|
47458
47673
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
47459
|
-
/* harmony export */
|
|
47674
|
+
/* harmony export */ resetSync: () => ( /* binding */resetSync)
|
|
47460
47675
|
/* harmony export */
|
|
47461
47676
|
});
|
|
47462
47677
|
/* harmony import */ var _platform_exceptions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../platform/exceptions */ "./packages/loot-core/src/platform/exceptions/index.electron.ts");
|
|
@@ -47466,6 +47681,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47466
47681
|
/* harmony import */ var _db__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../db */ "./packages/loot-core/src/server/db/index.ts");
|
|
47467
47682
|
/* harmony import */ var _mutators__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../mutators */ "./packages/loot-core/src/server/mutators.ts");
|
|
47468
47683
|
/* harmony import */ var _prefs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../prefs */ "./packages/loot-core/src/server/prefs.ts");
|
|
47684
|
+
// @ts-strict-ignore
|
|
47469
47685
|
async function resetSync(keyState) {
|
|
47470
47686
|
if (!keyState) {
|
|
47471
47687
|
// If we aren't resetting the key, make sure our key is up-to-date
|
|
@@ -47580,13 +47796,14 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47580
47796
|
"use strict";
|
|
47581
47797
|
__webpack_require__.r(__webpack_exports__);
|
|
47582
47798
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
47583
|
-
/* harmony export */
|
|
47799
|
+
/* harmony export */ app: () => ( /* binding */app)
|
|
47584
47800
|
/* harmony export */
|
|
47585
47801
|
});
|
|
47586
47802
|
/* harmony import */ var _accounts_transactions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../accounts/transactions */ "./packages/loot-core/src/server/accounts/transactions.ts");
|
|
47587
47803
|
/* harmony import */ var _app__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../app */ "./packages/loot-core/src/server/app.ts");
|
|
47588
47804
|
/* harmony import */ var _db__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../db */ "./packages/loot-core/src/server/db/index.ts");
|
|
47589
47805
|
/* harmony import */ var _mutators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mutators */ "./packages/loot-core/src/server/mutators.ts");
|
|
47806
|
+
// @ts-strict-ignore
|
|
47590
47807
|
const app = (0, _app__WEBPACK_IMPORTED_MODULE_1__.createApp)();
|
|
47591
47808
|
app.method('tools/fix-split-transactions', async () => {
|
|
47592
47809
|
// 1. Check for child transactions that have a blank payee, and set
|
|
@@ -47643,7 +47860,6 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47643
47860
|
numDeleted: deletedRows.length
|
|
47644
47861
|
};
|
|
47645
47862
|
});
|
|
47646
|
-
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (app);
|
|
47647
47863
|
/***/
|
|
47648
47864
|
}),
|
|
47649
47865
|
/***/ "./packages/loot-core/src/server/undo.ts":
|
|
@@ -47667,6 +47883,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47667
47883
|
/* harmony import */ var _shared_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../shared/util */ "./packages/loot-core/src/shared/util.ts");
|
|
47668
47884
|
/* harmony import */ var _mutators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./mutators */ "./packages/loot-core/src/server/mutators.ts");
|
|
47669
47885
|
/* harmony import */ var _sync__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sync */ "./packages/loot-core/src/server/sync/index.ts");
|
|
47886
|
+
// @ts-strict-ignore
|
|
47670
47887
|
let MESSAGE_HISTORY = [
|
|
47671
47888
|
{
|
|
47672
47889
|
type: 'marker'
|
|
@@ -47903,6 +48120,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47903
48120
|
/* harmony import */ var _aql__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./aql */ "./packages/loot-core/src/server/aql/index.ts");
|
|
47904
48121
|
/* harmony import */ var _db__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./db */ "./packages/loot-core/src/server/db/index.ts");
|
|
47905
48122
|
/* harmony import */ var _migrate_migrations__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./migrate/migrations */ "./packages/loot-core/src/server/migrate/migrations.ts");
|
|
48123
|
+
// @ts-strict-ignore
|
|
47906
48124
|
// Managing the init/update process
|
|
47907
48125
|
async function runMigrations() {
|
|
47908
48126
|
await _migrate_migrations__WEBPACK_IMPORTED_MODULE_3__.migrate(_db__WEBPACK_IMPORTED_MODULE_2__.getDatabase());
|
|
@@ -47943,6 +48161,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
47943
48161
|
});
|
|
47944
48162
|
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ "./node_modules/uuid/dist/esm-node/v4.js");
|
|
47945
48163
|
/* harmony import */ var _platform_server_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../platform/server/fs */ "./packages/loot-core/src/platform/server/fs/index.electron.ts");
|
|
48164
|
+
// @ts-strict-ignore
|
|
47946
48165
|
async function uniqueFileName(existingFiles) {
|
|
47947
48166
|
const initialName = 'My Finances';
|
|
47948
48167
|
let idx = 1;
|
|
@@ -48056,14 +48275,15 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
48056
48275
|
/* harmony export */ sequential: () => ( /* binding */sequential)
|
|
48057
48276
|
/* harmony export */
|
|
48058
48277
|
});
|
|
48278
|
+
// @ts-strict-ignore
|
|
48059
48279
|
function sequential(fn) {
|
|
48060
48280
|
const sequenceState = {
|
|
48061
48281
|
running: null,
|
|
48062
48282
|
queue: []
|
|
48063
48283
|
};
|
|
48064
48284
|
function pump() {
|
|
48065
|
-
|
|
48066
|
-
|
|
48285
|
+
const next = sequenceState.queue.shift();
|
|
48286
|
+
if (next !== undefined) {
|
|
48067
48287
|
run(next.args, next.resolve, next.reject);
|
|
48068
48288
|
}
|
|
48069
48289
|
else {
|
|
@@ -48071,8 +48291,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
48071
48291
|
}
|
|
48072
48292
|
}
|
|
48073
48293
|
function run(args, resolve, reject) {
|
|
48074
|
-
sequenceState.running = fn.apply(null, args)
|
|
48075
|
-
sequenceState.running.then((val) => {
|
|
48294
|
+
sequenceState.running = fn.apply(null, args).then((val) => {
|
|
48076
48295
|
pump();
|
|
48077
48296
|
resolve(val);
|
|
48078
48297
|
}, (err) => {
|
|
@@ -48157,6 +48376,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
48157
48376
|
/* harmony export */ getUploadError: () => ( /* binding */getUploadError)
|
|
48158
48377
|
/* harmony export */
|
|
48159
48378
|
});
|
|
48379
|
+
// @ts-strict-ignore
|
|
48160
48380
|
function getUploadError({ reason, meta }) {
|
|
48161
48381
|
switch (reason) {
|
|
48162
48382
|
case 'unauthorized':
|
|
@@ -48293,6 +48513,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
48293
48513
|
/* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! date-fns */ "./node_modules/date-fns/esm/endOfMonth/index.js");
|
|
48294
48514
|
/* harmony import */ var memoize_one__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! memoize-one */ "./node_modules/memoize-one/dist/memoize-one.esm.js");
|
|
48295
48515
|
/* harmony import */ var _client_platform__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../client/platform */ "./packages/loot-core/src/client/platform.electron.ts");
|
|
48516
|
+
// @ts-strict-ignore
|
|
48296
48517
|
function _parse(value) {
|
|
48297
48518
|
if (typeof value === 'string') {
|
|
48298
48519
|
// Dates are hard. We just want to deal with months in the format
|
|
@@ -48462,11 +48683,11 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
48462
48683
|
const days = [];
|
|
48463
48684
|
let day = start;
|
|
48464
48685
|
while (date_fns__WEBPACK_IMPORTED_MODULE_10__["default"](_parse(day), _parse(end))) {
|
|
48465
|
-
days.push(day);
|
|
48686
|
+
days.push(dayFromDate(day));
|
|
48466
48687
|
day = addDays(day, 1);
|
|
48467
48688
|
}
|
|
48468
48689
|
if (inclusive) {
|
|
48469
|
-
days.push(day);
|
|
48690
|
+
days.push(dayFromDate(day));
|
|
48470
48691
|
}
|
|
48471
48692
|
return days;
|
|
48472
48693
|
}
|
|
@@ -48540,10 +48761,11 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
48540
48761
|
__webpack_require__.r(__webpack_exports__);
|
|
48541
48762
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
48542
48763
|
/* harmony export */ Query: () => ( /* binding */Query),
|
|
48543
|
-
/* harmony export */
|
|
48544
|
-
/* harmony export */
|
|
48764
|
+
/* harmony export */ getPrimaryOrderBy: () => ( /* binding */getPrimaryOrderBy),
|
|
48765
|
+
/* harmony export */ q: () => ( /* binding */q)
|
|
48545
48766
|
/* harmony export */
|
|
48546
48767
|
});
|
|
48768
|
+
// @ts-strict-ignore
|
|
48547
48769
|
class Query {
|
|
48548
48770
|
constructor(state) {
|
|
48549
48771
|
this.state = {
|
|
@@ -48718,6 +48940,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
48718
48940
|
/* harmony export */
|
|
48719
48941
|
});
|
|
48720
48942
|
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util */ "./packages/loot-core/src/shared/util.ts");
|
|
48943
|
+
// @ts-strict-ignore
|
|
48721
48944
|
// For now, this info is duplicated from the backend. Figure out how
|
|
48722
48945
|
// to share it later.
|
|
48723
48946
|
const TYPE_INFO = {
|
|
@@ -48788,6 +49011,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
48788
49011
|
category: 'id',
|
|
48789
49012
|
account: 'id',
|
|
48790
49013
|
cleared: 'boolean',
|
|
49014
|
+
reconciled: 'boolean',
|
|
48791
49015
|
saved: 'saved'
|
|
48792
49016
|
}));
|
|
48793
49017
|
function mapField(field, opts) {
|
|
@@ -49030,6 +49254,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
49030
49254
|
});
|
|
49031
49255
|
/* harmony import */ var _months__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./months */ "./packages/loot-core/src/shared/months.ts");
|
|
49032
49256
|
/* harmony import */ var _query__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./query */ "./packages/loot-core/src/shared/query.ts");
|
|
49257
|
+
// @ts-strict-ignore
|
|
49033
49258
|
function getStatus(nextDate, completed, hasTrans) {
|
|
49034
49259
|
const today = _months__WEBPACK_IMPORTED_MODULE_0__.currentDay();
|
|
49035
49260
|
if (completed) {
|
|
@@ -49063,7 +49288,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
49063
49288
|
}
|
|
49064
49289
|
};
|
|
49065
49290
|
});
|
|
49066
|
-
return (0, _query__WEBPACK_IMPORTED_MODULE_1__
|
|
49291
|
+
return (0, _query__WEBPACK_IMPORTED_MODULE_1__.q)('transactions').filter({
|
|
49067
49292
|
$or: filters
|
|
49068
49293
|
}).orderBy({
|
|
49069
49294
|
date: 'desc'
|
|
@@ -49199,12 +49424,14 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
49199
49424
|
function recurConfigToRSchedule(config) {
|
|
49200
49425
|
const base = {
|
|
49201
49426
|
start: _months__WEBPACK_IMPORTED_MODULE_0__.parseDate(config.start),
|
|
49427
|
+
// @ts-ignore: issues with https://gitlab.com/john.carroll.p/rschedule/-/issues/86
|
|
49202
49428
|
frequency: config.frequency.toUpperCase(),
|
|
49203
49429
|
byHourOfDay: [
|
|
49204
49430
|
12
|
|
49205
49431
|
]
|
|
49206
49432
|
};
|
|
49207
49433
|
if (config.interval) {
|
|
49434
|
+
// @ts-ignore: issues with https://gitlab.com/john.carroll.p/rschedule/-/issues/86
|
|
49208
49435
|
base.interval = config.interval;
|
|
49209
49436
|
}
|
|
49210
49437
|
switch (config.endMode) {
|
|
@@ -49307,6 +49534,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
49307
49534
|
});
|
|
49308
49535
|
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! uuid */ "./node_modules/uuid/dist/esm-node/v4.js");
|
|
49309
49536
|
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util */ "./packages/loot-core/src/shared/util.ts");
|
|
49537
|
+
// @ts-strict-ignore
|
|
49310
49538
|
function isPreviewId(id) {
|
|
49311
49539
|
return id.indexOf('preview/') !== -1;
|
|
49312
49540
|
}
|
|
@@ -49397,7 +49625,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
49397
49625
|
]);
|
|
49398
49626
|
}
|
|
49399
49627
|
function applyTransactionDiff(groupedTrans, diff) {
|
|
49400
|
-
return groupTransaction((0, _util__WEBPACK_IMPORTED_MODULE_0__.applyChanges)(diff, ungroupTransaction(groupedTrans)));
|
|
49628
|
+
return groupTransaction((0, _util__WEBPACK_IMPORTED_MODULE_0__.applyChanges)(diff, ungroupTransaction(groupedTrans) || []));
|
|
49401
49629
|
}
|
|
49402
49630
|
function replaceTransactions(transactions, id, func) {
|
|
49403
49631
|
const idx = transactions.findIndex((t) => t.id === id);
|
|
@@ -49413,6 +49641,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
49413
49641
|
if (parentIndex == null) {
|
|
49414
49642
|
console.log('Cannot find parent index');
|
|
49415
49643
|
return {
|
|
49644
|
+
data: [],
|
|
49416
49645
|
diff: {
|
|
49417
49646
|
deleted: [],
|
|
49418
49647
|
updated: []
|
|
@@ -49474,8 +49703,8 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
49474
49703
|
if (!trans.is_parent) {
|
|
49475
49704
|
return trans;
|
|
49476
49705
|
}
|
|
49477
|
-
const prevSub = (0, _util__WEBPACK_IMPORTED_MODULE_0__.last)(trans.subtransactions);
|
|
49478
|
-
trans.subtransactions
|
|
49706
|
+
const prevSub = (0, _util__WEBPACK_IMPORTED_MODULE_0__.last)(trans.subtransactions || []);
|
|
49707
|
+
trans.subtransactions?.push(makeChild(trans, {
|
|
49479
49708
|
amount: 0,
|
|
49480
49709
|
sort_order: num(prevSub && prevSub.sort_order) - 1
|
|
49481
49710
|
}));
|
|
@@ -49486,7 +49715,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
49486
49715
|
return replaceTransactions(transactions, transaction.id, (trans) => {
|
|
49487
49716
|
if (trans.is_parent) {
|
|
49488
49717
|
const parent = trans.id === transaction.id ? transaction : trans;
|
|
49489
|
-
const sub = trans.subtransactions
|
|
49718
|
+
const sub = trans.subtransactions?.map((t) => {
|
|
49490
49719
|
// Make sure to update the children to reflect the updated
|
|
49491
49720
|
// properties (if the parent updated)
|
|
49492
49721
|
let child = t;
|
|
@@ -49517,7 +49746,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
49517
49746
|
if (trans.id === id) {
|
|
49518
49747
|
return null;
|
|
49519
49748
|
}
|
|
49520
|
-
else if (trans.subtransactions
|
|
49749
|
+
else if (trans.subtransactions?.length === 1) {
|
|
49521
49750
|
return {
|
|
49522
49751
|
...trans,
|
|
49523
49752
|
subtransactions: null,
|
|
@@ -49526,7 +49755,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
49526
49755
|
};
|
|
49527
49756
|
}
|
|
49528
49757
|
else {
|
|
49529
|
-
const sub = trans.subtransactions
|
|
49758
|
+
const sub = trans.subtransactions?.filter((t) => t.id !== id);
|
|
49530
49759
|
return recalculateSplit({
|
|
49531
49760
|
...trans,
|
|
49532
49761
|
subtransactions: sub
|
|
@@ -49583,6 +49812,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
49583
49812
|
__webpack_require__.r(__webpack_exports__);
|
|
49584
49813
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
49585
49814
|
/* harmony export */ amountToCurrency: () => ( /* binding */amountToCurrency),
|
|
49815
|
+
/* harmony export */ amountToCurrencyNoDecimal: () => ( /* binding */amountToCurrencyNoDecimal),
|
|
49586
49816
|
/* harmony export */ amountToInteger: () => ( /* binding */amountToInteger),
|
|
49587
49817
|
/* harmony export */ applyChanges: () => ( /* binding */applyChanges),
|
|
49588
49818
|
/* harmony export */ currencyToAmount: () => ( /* binding */currencyToAmount),
|
|
@@ -49610,17 +49840,19 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
49610
49840
|
/* harmony export */ toRelaxedNumber: () => ( /* binding */toRelaxedNumber)
|
|
49611
49841
|
/* harmony export */
|
|
49612
49842
|
});
|
|
49843
|
+
// @ts-strict-ignore
|
|
49613
49844
|
function last(arr) {
|
|
49614
49845
|
return arr[arr.length - 1];
|
|
49615
49846
|
}
|
|
49616
49847
|
function getChangedValues(obj1, obj2) {
|
|
49617
|
-
|
|
49618
|
-
// objects
|
|
49619
|
-
const diff = obj1.id ? {
|
|
49620
|
-
id: obj1.id
|
|
49621
|
-
} : {};
|
|
49848
|
+
const diff = {};
|
|
49622
49849
|
const keys = Object.keys(obj2);
|
|
49623
49850
|
let hasChanged = false;
|
|
49851
|
+
// Keep the id field because this is mostly used to diff database
|
|
49852
|
+
// objects
|
|
49853
|
+
if (obj1.id) {
|
|
49854
|
+
diff.id = obj1.id;
|
|
49855
|
+
}
|
|
49624
49856
|
for (let i = 0; i < keys.length; i++) {
|
|
49625
49857
|
const key = keys[i];
|
|
49626
49858
|
if (obj1[key] !== obj2[key]) {
|
|
@@ -49876,6 +50108,11 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
49876
50108
|
function amountToCurrency(n) {
|
|
49877
50109
|
return getNumberFormat().formatter.format(n);
|
|
49878
50110
|
}
|
|
50111
|
+
function amountToCurrencyNoDecimal(n) {
|
|
50112
|
+
return getNumberFormat({
|
|
50113
|
+
hideFraction: true
|
|
50114
|
+
}).formatter.format(n);
|
|
50115
|
+
}
|
|
49879
50116
|
function currencyToAmount(str) {
|
|
49880
50117
|
const amount = parseFloat(str.replace(getNumberFormat().regex, '').replace(getNumberFormat().separator, '.'));
|
|
49881
50118
|
return isNaN(amount) ? null : amount;
|
|
@@ -49912,7 +50149,7 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
49912
50149
|
amount = amount.replace('(', '-').replace(')', '');
|
|
49913
50150
|
}
|
|
49914
50151
|
const m = amount.match(/[.,][^.,]*$/);
|
|
49915
|
-
if (!m || m.index === 0) {
|
|
50152
|
+
if (!m || m.index === undefined || m.index === 0) {
|
|
49916
50153
|
return safeNumber(parseFloat(extractNumbers(amount)));
|
|
49917
50154
|
}
|
|
49918
50155
|
const left = extractNumbers(amount.slice(0, m.index));
|
|
@@ -57159,24 +57396,6 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
57159
57396
|
module.exports = require("better-sqlite3");
|
|
57160
57397
|
/***/
|
|
57161
57398
|
}),
|
|
57162
|
-
/***/ "fs":
|
|
57163
|
-
/*!*********************!*\
|
|
57164
|
-
!*** external "fs" ***!
|
|
57165
|
-
\*********************/
|
|
57166
|
-
/***/ ((module) => {
|
|
57167
|
-
"use strict";
|
|
57168
|
-
module.exports = require("fs");
|
|
57169
|
-
/***/
|
|
57170
|
-
}),
|
|
57171
|
-
/***/ "node-libofx":
|
|
57172
|
-
/*!******************************!*\
|
|
57173
|
-
!*** external "node-libofx" ***!
|
|
57174
|
-
\******************************/
|
|
57175
|
-
/***/ ((module) => {
|
|
57176
|
-
"use strict";
|
|
57177
|
-
module.exports = require("node-libofx");
|
|
57178
|
-
/***/
|
|
57179
|
-
}),
|
|
57180
57399
|
/***/ "crypto":
|
|
57181
57400
|
/*!*************************!*\
|
|
57182
57401
|
!*** external "crypto" ***!
|
|
@@ -57195,6 +57414,15 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
57195
57414
|
module.exports = require("events");
|
|
57196
57415
|
/***/
|
|
57197
57416
|
}),
|
|
57417
|
+
/***/ "fs":
|
|
57418
|
+
/*!*********************!*\
|
|
57419
|
+
!*** external "fs" ***!
|
|
57420
|
+
\*********************/
|
|
57421
|
+
/***/ ((module) => {
|
|
57422
|
+
"use strict";
|
|
57423
|
+
module.exports = require("fs");
|
|
57424
|
+
/***/
|
|
57425
|
+
}),
|
|
57198
57426
|
/***/ "os":
|
|
57199
57427
|
/*!*********************!*\
|
|
57200
57428
|
!*** external "os" ***!
|
|
@@ -57827,42 +58055,6 @@ CREATE TABLE kvcache_key (id INTEGER PRIMARY KEY, key REAL);
|
|
|
57827
58055
|
/******/
|
|
57828
58056
|
})();
|
|
57829
58057
|
/******/
|
|
57830
|
-
/******/ /* webpack/runtime/create fake namespace object */
|
|
57831
|
-
/******/ (() => {
|
|
57832
|
-
/******/ var getProto = Object.getPrototypeOf ? (obj) => (Object.getPrototypeOf(obj)) : (obj) => (obj.__proto__);
|
|
57833
|
-
/******/ var leafPrototypes;
|
|
57834
|
-
/******/ // create a fake namespace object
|
|
57835
|
-
/******/ // mode & 1: value is a module id, require it
|
|
57836
|
-
/******/ // mode & 2: merge all properties of value into the ns
|
|
57837
|
-
/******/ // mode & 4: return value when already ns object
|
|
57838
|
-
/******/ // mode & 16: return value when it's Promise-like
|
|
57839
|
-
/******/ // mode & 8|1: behave like require
|
|
57840
|
-
/******/ __webpack_require__.t = function (value, mode) {
|
|
57841
|
-
/******/ if (mode & 1)
|
|
57842
|
-
value = this(value);
|
|
57843
|
-
/******/ if (mode & 8)
|
|
57844
|
-
return value;
|
|
57845
|
-
/******/ if (typeof value === 'object' && value) {
|
|
57846
|
-
/******/ if ((mode & 4) && value.__esModule)
|
|
57847
|
-
return value;
|
|
57848
|
-
/******/ if ((mode & 16) && typeof value.then === 'function')
|
|
57849
|
-
return value;
|
|
57850
|
-
/******/ }
|
|
57851
|
-
/******/ var ns = Object.create(null);
|
|
57852
|
-
/******/ __webpack_require__.r(ns);
|
|
57853
|
-
/******/ var def = {};
|
|
57854
|
-
/******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];
|
|
57855
|
-
/******/ for (var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) {
|
|
57856
|
-
/******/ Object.getOwnPropertyNames(current).forEach((key) => (def[key] = () => (value[key])));
|
|
57857
|
-
/******/ }
|
|
57858
|
-
/******/ def['default'] = () => (value);
|
|
57859
|
-
/******/ __webpack_require__.d(ns, def);
|
|
57860
|
-
/******/ return ns;
|
|
57861
|
-
/******/
|
|
57862
|
-
};
|
|
57863
|
-
/******/
|
|
57864
|
-
})();
|
|
57865
|
-
/******/
|
|
57866
58058
|
/******/ /* webpack/runtime/define property getters */
|
|
57867
58059
|
/******/ (() => {
|
|
57868
58060
|
/******/ // define getter functions for harmony exports
|