@actual-app/api 4.1.5 → 5.0.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/app/bundle.api.js CHANGED
@@ -11582,86 +11582,6 @@ module.exports = function (records, options = {}) {
11582
11582
 
11583
11583
  /***/ }),
11584
11584
 
11585
- /***/ "./node_modules/damerau-levenshtein/index.js":
11586
- /*!***************************************************!*\
11587
- !*** ./node_modules/damerau-levenshtein/index.js ***!
11588
- \***************************************************/
11589
- /*! no static exports found */
11590
- /***/ (function(module, exports) {
11591
-
11592
- // TheSpanishInquisition
11593
- // Cache the matrix. Note that if you not pass a limit this implementation will use a dynamically calculate one.
11594
- module.exports = function (__this, that, limit) {
11595
- var thisLength = __this.length,
11596
- thatLength = that.length,
11597
- matrix = []; // If the limit is not defined it will be calculate from this and that args.
11598
-
11599
- limit = (limit || (thatLength > thisLength ? thatLength : thisLength)) + 1;
11600
-
11601
- for (var i = 0; i < limit; i++) {
11602
- matrix[i] = [i];
11603
- matrix[i].length = limit;
11604
- }
11605
-
11606
- for (i = 0; i < limit; i++) {
11607
- matrix[0][i] = i;
11608
- }
11609
-
11610
- if (Math.abs(thisLength - thatLength) > (limit || 100)) {
11611
- return prepare(limit || 100);
11612
- }
11613
-
11614
- if (thisLength === 0) {
11615
- return prepare(thatLength);
11616
- }
11617
-
11618
- if (thatLength === 0) {
11619
- return prepare(thisLength);
11620
- } // Calculate matrix.
11621
-
11622
-
11623
- var j, this_i, that_j, cost, min, t;
11624
-
11625
- for (i = 1; i <= thisLength; ++i) {
11626
- this_i = __this[i - 1]; // Step 4
11627
-
11628
- for (j = 1; j <= thatLength; ++j) {
11629
- // Check the jagged ld total so far
11630
- if (i === j && matrix[i][j] > 4) return prepare(thisLength);
11631
- that_j = that[j - 1];
11632
- cost = this_i === that_j ? 0 : 1; // Step 5
11633
- // Calculate the minimum (much faster than Math.min(...)).
11634
-
11635
- min = matrix[i - 1][j] + 1; // Deletion.
11636
-
11637
- if ((t = matrix[i][j - 1] + 1) < min) min = t; // Insertion.
11638
-
11639
- if ((t = matrix[i - 1][j - 1] + cost) < min) min = t; // Substitution.
11640
- // Update matrix.
11641
-
11642
- matrix[i][j] = i > 1 && j > 1 && this_i === that[j - 2] && __this[i - 2] === that_j && (t = matrix[i - 2][j - 2] + cost) < min ? t : min; // Transposition.
11643
- }
11644
- }
11645
-
11646
- return prepare(matrix[thisLength][thatLength]);
11647
- /**
11648
- *
11649
- */
11650
-
11651
- function prepare(steps) {
11652
- var length = Math.max(thisLength, thatLength);
11653
- var relative = length === 0 ? 0 : steps / length;
11654
- var similarity = 1 - relative;
11655
- return {
11656
- steps: steps,
11657
- relative: relative,
11658
- similarity: similarity
11659
- };
11660
- }
11661
- };
11662
-
11663
- /***/ }),
11664
-
11665
11585
  /***/ "./node_modules/date-fns/esm/_lib/addLeadingZeros/index.js":
11666
11586
  /*!*****************************************************************!*\
11667
11587
  !*** ./node_modules/date-fns/esm/_lib/addLeadingZeros/index.js ***!
@@ -26399,7 +26319,7 @@ var is = __webpack_require__(/*! object-is */ "./node_modules/object-is/index.js
26399
26319
 
26400
26320
  var isRegex = __webpack_require__(/*! is-regex */ "./node_modules/is-regex/index.js");
26401
26321
 
26402
- var flags = __webpack_require__(/*! regexp.prototype.flags */ "./node_modules/regexp.prototype.flags/index.js");
26322
+ var flags = __webpack_require__(/*! regexp.prototype.flags */ "./node_modules/deep-equal/node_modules/regexp.prototype.flags/index.js");
26403
26323
 
26404
26324
  var isArray = __webpack_require__(/*! isarray */ "./node_modules/deep-equal/node_modules/isarray/index.js");
26405
26325
 
@@ -26417,7 +26337,7 @@ var getIterator = __webpack_require__(/*! es-get-iterator */ "./node_modules/es-
26417
26337
 
26418
26338
  var getSideChannel = __webpack_require__(/*! side-channel */ "./node_modules/side-channel/index.js");
26419
26339
 
26420
- var whichTypedArray = __webpack_require__(/*! which-typed-array */ "./node_modules/which-typed-array/index.js");
26340
+ var whichTypedArray = __webpack_require__(/*! which-typed-array */ "./node_modules/deep-equal/node_modules/which-typed-array/index.js");
26421
26341
 
26422
26342
  var assign = __webpack_require__(/*! object.assign */ "./node_modules/object.assign/index.js");
26423
26343
 
@@ -26867,6 +26787,97 @@ module.exports = function deepEqual(a, b, opts) {
26867
26787
 
26868
26788
  /***/ }),
26869
26789
 
26790
+ /***/ "./node_modules/deep-equal/node_modules/is-typed-array/index.js":
26791
+ /*!**********************************************************************!*\
26792
+ !*** ./node_modules/deep-equal/node_modules/is-typed-array/index.js ***!
26793
+ \**********************************************************************/
26794
+ /*! no static exports found */
26795
+ /***/ (function(module, exports, __webpack_require__) {
26796
+
26797
+ "use strict";
26798
+
26799
+
26800
+ var forEach = __webpack_require__(/*! foreach */ "./node_modules/foreach/index.js");
26801
+
26802
+ var availableTypedArrays = __webpack_require__(/*! available-typed-arrays */ "./node_modules/available-typed-arrays/index.js");
26803
+
26804
+ var callBound = __webpack_require__(/*! call-bind/callBound */ "./node_modules/call-bind/callBound.js");
26805
+
26806
+ var $toString = callBound('Object.prototype.toString');
26807
+
26808
+ var hasToStringTag = __webpack_require__(/*! has-tostringtag/shams */ "./node_modules/has-tostringtag/shams.js")();
26809
+
26810
+ var g = typeof globalThis === 'undefined' ? global : globalThis;
26811
+ var typedArrays = availableTypedArrays();
26812
+
26813
+ var $indexOf = callBound('Array.prototype.indexOf', true) || function indexOf(array, value) {
26814
+ for (var i = 0; i < array.length; i += 1) {
26815
+ if (array[i] === value) {
26816
+ return i;
26817
+ }
26818
+ }
26819
+
26820
+ return -1;
26821
+ };
26822
+
26823
+ var $slice = callBound('String.prototype.slice');
26824
+ var toStrTags = {};
26825
+
26826
+ var gOPD = __webpack_require__(/*! es-abstract/helpers/getOwnPropertyDescriptor */ "./node_modules/es-abstract/helpers/getOwnPropertyDescriptor.js");
26827
+
26828
+ var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof');
26829
+
26830
+ if (hasToStringTag && gOPD && getPrototypeOf) {
26831
+ forEach(typedArrays, function (typedArray) {
26832
+ var arr = new g[typedArray]();
26833
+
26834
+ if (Symbol.toStringTag in arr) {
26835
+ var proto = getPrototypeOf(arr);
26836
+ var descriptor = gOPD(proto, Symbol.toStringTag);
26837
+
26838
+ if (!descriptor) {
26839
+ var superProto = getPrototypeOf(proto);
26840
+ descriptor = gOPD(superProto, Symbol.toStringTag);
26841
+ }
26842
+
26843
+ toStrTags[typedArray] = descriptor.get;
26844
+ }
26845
+ });
26846
+ }
26847
+
26848
+ var tryTypedArrays = function tryAllTypedArrays(value) {
26849
+ var anyTrue = false;
26850
+ forEach(toStrTags, function (getter, typedArray) {
26851
+ if (!anyTrue) {
26852
+ try {
26853
+ anyTrue = getter.call(value) === typedArray;
26854
+ } catch (e) {
26855
+ /**/
26856
+ }
26857
+ }
26858
+ });
26859
+ return anyTrue;
26860
+ };
26861
+
26862
+ module.exports = function isTypedArray(value) {
26863
+ if (!value || typeof value !== 'object') {
26864
+ return false;
26865
+ }
26866
+
26867
+ if (!hasToStringTag || !(Symbol.toStringTag in value)) {
26868
+ var tag = $slice($toString(value), 8, -1);
26869
+ return $indexOf(typedArrays, tag) > -1;
26870
+ }
26871
+
26872
+ if (!gOPD) {
26873
+ return false;
26874
+ }
26875
+
26876
+ return tryTypedArrays(value);
26877
+ };
26878
+
26879
+ /***/ }),
26880
+
26870
26881
  /***/ "./node_modules/deep-equal/node_modules/isarray/index.js":
26871
26882
  /*!***************************************************************!*\
26872
26883
  !*** ./node_modules/deep-equal/node_modules/isarray/index.js ***!
@@ -26882,6 +26893,242 @@ module.exports = Array.isArray || function (arr) {
26882
26893
 
26883
26894
  /***/ }),
26884
26895
 
26896
+ /***/ "./node_modules/deep-equal/node_modules/regexp.prototype.flags/implementation.js":
26897
+ /*!***************************************************************************************!*\
26898
+ !*** ./node_modules/deep-equal/node_modules/regexp.prototype.flags/implementation.js ***!
26899
+ \***************************************************************************************/
26900
+ /*! no static exports found */
26901
+ /***/ (function(module, exports, __webpack_require__) {
26902
+
26903
+ "use strict";
26904
+
26905
+
26906
+ var $Object = Object;
26907
+ var $TypeError = TypeError;
26908
+
26909
+ module.exports = function flags() {
26910
+ if (this != null && this !== $Object(this)) {
26911
+ throw new $TypeError('RegExp.prototype.flags getter called on non-object');
26912
+ }
26913
+
26914
+ var result = '';
26915
+
26916
+ if (this.hasIndices) {
26917
+ result += 'd';
26918
+ }
26919
+
26920
+ if (this.global) {
26921
+ result += 'g';
26922
+ }
26923
+
26924
+ if (this.ignoreCase) {
26925
+ result += 'i';
26926
+ }
26927
+
26928
+ if (this.multiline) {
26929
+ result += 'm';
26930
+ }
26931
+
26932
+ if (this.dotAll) {
26933
+ result += 's';
26934
+ }
26935
+
26936
+ if (this.unicode) {
26937
+ result += 'u';
26938
+ }
26939
+
26940
+ if (this.sticky) {
26941
+ result += 'y';
26942
+ }
26943
+
26944
+ return result;
26945
+ };
26946
+
26947
+ /***/ }),
26948
+
26949
+ /***/ "./node_modules/deep-equal/node_modules/regexp.prototype.flags/index.js":
26950
+ /*!******************************************************************************!*\
26951
+ !*** ./node_modules/deep-equal/node_modules/regexp.prototype.flags/index.js ***!
26952
+ \******************************************************************************/
26953
+ /*! no static exports found */
26954
+ /***/ (function(module, exports, __webpack_require__) {
26955
+
26956
+ "use strict";
26957
+
26958
+
26959
+ var define = __webpack_require__(/*! define-properties */ "./node_modules/define-properties/index.js");
26960
+
26961
+ var callBind = __webpack_require__(/*! call-bind */ "./node_modules/call-bind/index.js");
26962
+
26963
+ var implementation = __webpack_require__(/*! ./implementation */ "./node_modules/deep-equal/node_modules/regexp.prototype.flags/implementation.js");
26964
+
26965
+ var getPolyfill = __webpack_require__(/*! ./polyfill */ "./node_modules/deep-equal/node_modules/regexp.prototype.flags/polyfill.js");
26966
+
26967
+ var shim = __webpack_require__(/*! ./shim */ "./node_modules/deep-equal/node_modules/regexp.prototype.flags/shim.js");
26968
+
26969
+ var flagsBound = callBind(getPolyfill());
26970
+ define(flagsBound, {
26971
+ getPolyfill: getPolyfill,
26972
+ implementation: implementation,
26973
+ shim: shim
26974
+ });
26975
+ module.exports = flagsBound;
26976
+
26977
+ /***/ }),
26978
+
26979
+ /***/ "./node_modules/deep-equal/node_modules/regexp.prototype.flags/polyfill.js":
26980
+ /*!*********************************************************************************!*\
26981
+ !*** ./node_modules/deep-equal/node_modules/regexp.prototype.flags/polyfill.js ***!
26982
+ \*********************************************************************************/
26983
+ /*! no static exports found */
26984
+ /***/ (function(module, exports, __webpack_require__) {
26985
+
26986
+ "use strict";
26987
+
26988
+
26989
+ var implementation = __webpack_require__(/*! ./implementation */ "./node_modules/deep-equal/node_modules/regexp.prototype.flags/implementation.js");
26990
+
26991
+ var supportsDescriptors = __webpack_require__(/*! define-properties */ "./node_modules/define-properties/index.js").supportsDescriptors;
26992
+
26993
+ var $gOPD = Object.getOwnPropertyDescriptor;
26994
+
26995
+ module.exports = function getPolyfill() {
26996
+ if (supportsDescriptors && /a/mig.flags === 'gim') {
26997
+ var descriptor = $gOPD(RegExp.prototype, 'flags');
26998
+
26999
+ if (descriptor && typeof descriptor.get === 'function' && typeof /a/.dotAll === 'boolean') {
27000
+ return descriptor.get;
27001
+ }
27002
+ }
27003
+
27004
+ return implementation;
27005
+ };
27006
+
27007
+ /***/ }),
27008
+
27009
+ /***/ "./node_modules/deep-equal/node_modules/regexp.prototype.flags/shim.js":
27010
+ /*!*****************************************************************************!*\
27011
+ !*** ./node_modules/deep-equal/node_modules/regexp.prototype.flags/shim.js ***!
27012
+ \*****************************************************************************/
27013
+ /*! no static exports found */
27014
+ /***/ (function(module, exports, __webpack_require__) {
27015
+
27016
+ "use strict";
27017
+
27018
+
27019
+ var supportsDescriptors = __webpack_require__(/*! define-properties */ "./node_modules/define-properties/index.js").supportsDescriptors;
27020
+
27021
+ var getPolyfill = __webpack_require__(/*! ./polyfill */ "./node_modules/deep-equal/node_modules/regexp.prototype.flags/polyfill.js");
27022
+
27023
+ var gOPD = Object.getOwnPropertyDescriptor;
27024
+ var defineProperty = Object.defineProperty;
27025
+ var TypeErr = TypeError;
27026
+ var getProto = Object.getPrototypeOf;
27027
+ var regex = /a/;
27028
+
27029
+ module.exports = function shimFlags() {
27030
+ if (!supportsDescriptors || !getProto) {
27031
+ throw new TypeErr('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors');
27032
+ }
27033
+
27034
+ var polyfill = getPolyfill();
27035
+ var proto = getProto(regex);
27036
+ var descriptor = gOPD(proto, 'flags');
27037
+
27038
+ if (!descriptor || descriptor.get !== polyfill) {
27039
+ defineProperty(proto, 'flags', {
27040
+ configurable: true,
27041
+ enumerable: false,
27042
+ get: polyfill
27043
+ });
27044
+ }
27045
+
27046
+ return polyfill;
27047
+ };
27048
+
27049
+ /***/ }),
27050
+
27051
+ /***/ "./node_modules/deep-equal/node_modules/which-typed-array/index.js":
27052
+ /*!*************************************************************************!*\
27053
+ !*** ./node_modules/deep-equal/node_modules/which-typed-array/index.js ***!
27054
+ \*************************************************************************/
27055
+ /*! no static exports found */
27056
+ /***/ (function(module, exports, __webpack_require__) {
27057
+
27058
+ "use strict";
27059
+
27060
+
27061
+ var forEach = __webpack_require__(/*! foreach */ "./node_modules/foreach/index.js");
27062
+
27063
+ var availableTypedArrays = __webpack_require__(/*! available-typed-arrays */ "./node_modules/available-typed-arrays/index.js");
27064
+
27065
+ var callBound = __webpack_require__(/*! call-bind/callBound */ "./node_modules/call-bind/callBound.js");
27066
+
27067
+ var $toString = callBound('Object.prototype.toString');
27068
+
27069
+ var hasToStringTag = __webpack_require__(/*! has-tostringtag/shams */ "./node_modules/has-tostringtag/shams.js")();
27070
+
27071
+ var g = typeof globalThis === 'undefined' ? global : globalThis;
27072
+ var typedArrays = availableTypedArrays();
27073
+ var $slice = callBound('String.prototype.slice');
27074
+ var toStrTags = {};
27075
+
27076
+ var gOPD = __webpack_require__(/*! es-abstract/helpers/getOwnPropertyDescriptor */ "./node_modules/es-abstract/helpers/getOwnPropertyDescriptor.js");
27077
+
27078
+ var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof');
27079
+
27080
+ if (hasToStringTag && gOPD && getPrototypeOf) {
27081
+ forEach(typedArrays, function (typedArray) {
27082
+ if (typeof g[typedArray] === 'function') {
27083
+ var arr = new g[typedArray]();
27084
+
27085
+ if (Symbol.toStringTag in arr) {
27086
+ var proto = getPrototypeOf(arr);
27087
+ var descriptor = gOPD(proto, Symbol.toStringTag);
27088
+
27089
+ if (!descriptor) {
27090
+ var superProto = getPrototypeOf(proto);
27091
+ descriptor = gOPD(superProto, Symbol.toStringTag);
27092
+ }
27093
+
27094
+ toStrTags[typedArray] = descriptor.get;
27095
+ }
27096
+ }
27097
+ });
27098
+ }
27099
+
27100
+ var tryTypedArrays = function tryAllTypedArrays(value) {
27101
+ var foundName = false;
27102
+ forEach(toStrTags, function (getter, typedArray) {
27103
+ if (!foundName) {
27104
+ try {
27105
+ var name = getter.call(value);
27106
+
27107
+ if (name === typedArray) {
27108
+ foundName = name;
27109
+ }
27110
+ } catch (e) {}
27111
+ }
27112
+ });
27113
+ return foundName;
27114
+ };
27115
+
27116
+ var isTypedArray = __webpack_require__(/*! is-typed-array */ "./node_modules/deep-equal/node_modules/is-typed-array/index.js");
27117
+
27118
+ module.exports = function whichTypedArray(value) {
27119
+ if (!isTypedArray(value)) {
27120
+ return false;
27121
+ }
27122
+
27123
+ if (!hasToStringTag || !(Symbol.toStringTag in value)) {
27124
+ return $slice($toString(value), 8, -1);
27125
+ }
27126
+
27127
+ return tryTypedArrays(value);
27128
+ };
27129
+
27130
+ /***/ }),
27131
+
26885
27132
  /***/ "./node_modules/define-properties/index.js":
26886
27133
  /*!*************************************************!*\
26887
27134
  !*** ./node_modules/define-properties/index.js ***!
@@ -36420,97 +36667,6 @@ if (hasSymbols) {
36420
36667
 
36421
36668
  /***/ }),
36422
36669
 
36423
- /***/ "./node_modules/is-typed-array/index.js":
36424
- /*!**********************************************!*\
36425
- !*** ./node_modules/is-typed-array/index.js ***!
36426
- \**********************************************/
36427
- /*! no static exports found */
36428
- /***/ (function(module, exports, __webpack_require__) {
36429
-
36430
- "use strict";
36431
-
36432
-
36433
- var forEach = __webpack_require__(/*! foreach */ "./node_modules/foreach/index.js");
36434
-
36435
- var availableTypedArrays = __webpack_require__(/*! available-typed-arrays */ "./node_modules/available-typed-arrays/index.js");
36436
-
36437
- var callBound = __webpack_require__(/*! call-bind/callBound */ "./node_modules/call-bind/callBound.js");
36438
-
36439
- var $toString = callBound('Object.prototype.toString');
36440
-
36441
- var hasToStringTag = __webpack_require__(/*! has-tostringtag/shams */ "./node_modules/has-tostringtag/shams.js")();
36442
-
36443
- var g = typeof globalThis === 'undefined' ? global : globalThis;
36444
- var typedArrays = availableTypedArrays();
36445
-
36446
- var $indexOf = callBound('Array.prototype.indexOf', true) || function indexOf(array, value) {
36447
- for (var i = 0; i < array.length; i += 1) {
36448
- if (array[i] === value) {
36449
- return i;
36450
- }
36451
- }
36452
-
36453
- return -1;
36454
- };
36455
-
36456
- var $slice = callBound('String.prototype.slice');
36457
- var toStrTags = {};
36458
-
36459
- var gOPD = __webpack_require__(/*! es-abstract/helpers/getOwnPropertyDescriptor */ "./node_modules/es-abstract/helpers/getOwnPropertyDescriptor.js");
36460
-
36461
- var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof');
36462
-
36463
- if (hasToStringTag && gOPD && getPrototypeOf) {
36464
- forEach(typedArrays, function (typedArray) {
36465
- var arr = new g[typedArray]();
36466
-
36467
- if (Symbol.toStringTag in arr) {
36468
- var proto = getPrototypeOf(arr);
36469
- var descriptor = gOPD(proto, Symbol.toStringTag);
36470
-
36471
- if (!descriptor) {
36472
- var superProto = getPrototypeOf(proto);
36473
- descriptor = gOPD(superProto, Symbol.toStringTag);
36474
- }
36475
-
36476
- toStrTags[typedArray] = descriptor.get;
36477
- }
36478
- });
36479
- }
36480
-
36481
- var tryTypedArrays = function tryAllTypedArrays(value) {
36482
- var anyTrue = false;
36483
- forEach(toStrTags, function (getter, typedArray) {
36484
- if (!anyTrue) {
36485
- try {
36486
- anyTrue = getter.call(value) === typedArray;
36487
- } catch (e) {
36488
- /**/
36489
- }
36490
- }
36491
- });
36492
- return anyTrue;
36493
- };
36494
-
36495
- module.exports = function isTypedArray(value) {
36496
- if (!value || typeof value !== 'object') {
36497
- return false;
36498
- }
36499
-
36500
- if (!hasToStringTag || !(Symbol.toStringTag in value)) {
36501
- var tag = $slice($toString(value), 8, -1);
36502
- return $indexOf(typedArrays, tag) > -1;
36503
- }
36504
-
36505
- if (!gOPD) {
36506
- return false;
36507
- }
36508
-
36509
- return tryTypedArrays(value);
36510
- };
36511
-
36512
- /***/ }),
36513
-
36514
36670
  /***/ "./node_modules/is-weakmap/index.js":
36515
36671
  /*!******************************************!*\
36516
36672
  !*** ./node_modules/is-weakmap/index.js ***!
@@ -38990,161 +39146,6 @@ module.exports = function shimAssign() {
38990
39146
 
38991
39147
  /***/ }),
38992
39148
 
38993
- /***/ "./node_modules/regexp.prototype.flags/implementation.js":
38994
- /*!***************************************************************!*\
38995
- !*** ./node_modules/regexp.prototype.flags/implementation.js ***!
38996
- \***************************************************************/
38997
- /*! no static exports found */
38998
- /***/ (function(module, exports, __webpack_require__) {
38999
-
39000
- "use strict";
39001
-
39002
-
39003
- var $Object = Object;
39004
- var $TypeError = TypeError;
39005
-
39006
- module.exports = function flags() {
39007
- if (this != null && this !== $Object(this)) {
39008
- throw new $TypeError('RegExp.prototype.flags getter called on non-object');
39009
- }
39010
-
39011
- var result = '';
39012
-
39013
- if (this.hasIndices) {
39014
- result += 'd';
39015
- }
39016
-
39017
- if (this.global) {
39018
- result += 'g';
39019
- }
39020
-
39021
- if (this.ignoreCase) {
39022
- result += 'i';
39023
- }
39024
-
39025
- if (this.multiline) {
39026
- result += 'm';
39027
- }
39028
-
39029
- if (this.dotAll) {
39030
- result += 's';
39031
- }
39032
-
39033
- if (this.unicode) {
39034
- result += 'u';
39035
- }
39036
-
39037
- if (this.sticky) {
39038
- result += 'y';
39039
- }
39040
-
39041
- return result;
39042
- };
39043
-
39044
- /***/ }),
39045
-
39046
- /***/ "./node_modules/regexp.prototype.flags/index.js":
39047
- /*!******************************************************!*\
39048
- !*** ./node_modules/regexp.prototype.flags/index.js ***!
39049
- \******************************************************/
39050
- /*! no static exports found */
39051
- /***/ (function(module, exports, __webpack_require__) {
39052
-
39053
- "use strict";
39054
-
39055
-
39056
- var define = __webpack_require__(/*! define-properties */ "./node_modules/define-properties/index.js");
39057
-
39058
- var callBind = __webpack_require__(/*! call-bind */ "./node_modules/call-bind/index.js");
39059
-
39060
- var implementation = __webpack_require__(/*! ./implementation */ "./node_modules/regexp.prototype.flags/implementation.js");
39061
-
39062
- var getPolyfill = __webpack_require__(/*! ./polyfill */ "./node_modules/regexp.prototype.flags/polyfill.js");
39063
-
39064
- var shim = __webpack_require__(/*! ./shim */ "./node_modules/regexp.prototype.flags/shim.js");
39065
-
39066
- var flagsBound = callBind(getPolyfill());
39067
- define(flagsBound, {
39068
- getPolyfill: getPolyfill,
39069
- implementation: implementation,
39070
- shim: shim
39071
- });
39072
- module.exports = flagsBound;
39073
-
39074
- /***/ }),
39075
-
39076
- /***/ "./node_modules/regexp.prototype.flags/polyfill.js":
39077
- /*!*********************************************************!*\
39078
- !*** ./node_modules/regexp.prototype.flags/polyfill.js ***!
39079
- \*********************************************************/
39080
- /*! no static exports found */
39081
- /***/ (function(module, exports, __webpack_require__) {
39082
-
39083
- "use strict";
39084
-
39085
-
39086
- var implementation = __webpack_require__(/*! ./implementation */ "./node_modules/regexp.prototype.flags/implementation.js");
39087
-
39088
- var supportsDescriptors = __webpack_require__(/*! define-properties */ "./node_modules/define-properties/index.js").supportsDescriptors;
39089
-
39090
- var $gOPD = Object.getOwnPropertyDescriptor;
39091
-
39092
- module.exports = function getPolyfill() {
39093
- if (supportsDescriptors && /a/mig.flags === 'gim') {
39094
- var descriptor = $gOPD(RegExp.prototype, 'flags');
39095
-
39096
- if (descriptor && typeof descriptor.get === 'function' && typeof /a/.dotAll === 'boolean') {
39097
- return descriptor.get;
39098
- }
39099
- }
39100
-
39101
- return implementation;
39102
- };
39103
-
39104
- /***/ }),
39105
-
39106
- /***/ "./node_modules/regexp.prototype.flags/shim.js":
39107
- /*!*****************************************************!*\
39108
- !*** ./node_modules/regexp.prototype.flags/shim.js ***!
39109
- \*****************************************************/
39110
- /*! no static exports found */
39111
- /***/ (function(module, exports, __webpack_require__) {
39112
-
39113
- "use strict";
39114
-
39115
-
39116
- var supportsDescriptors = __webpack_require__(/*! define-properties */ "./node_modules/define-properties/index.js").supportsDescriptors;
39117
-
39118
- var getPolyfill = __webpack_require__(/*! ./polyfill */ "./node_modules/regexp.prototype.flags/polyfill.js");
39119
-
39120
- var gOPD = Object.getOwnPropertyDescriptor;
39121
- var defineProperty = Object.defineProperty;
39122
- var TypeErr = TypeError;
39123
- var getProto = Object.getPrototypeOf;
39124
- var regex = /a/;
39125
-
39126
- module.exports = function shimFlags() {
39127
- if (!supportsDescriptors || !getProto) {
39128
- throw new TypeErr('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors');
39129
- }
39130
-
39131
- var polyfill = getPolyfill();
39132
- var proto = getProto(regex);
39133
- var descriptor = gOPD(proto, 'flags');
39134
-
39135
- if (!descriptor || descriptor.get !== polyfill) {
39136
- defineProperty(proto, 'flags', {
39137
- configurable: true,
39138
- enumerable: false,
39139
- get: polyfill
39140
- });
39141
- }
39142
-
39143
- return polyfill;
39144
- };
39145
-
39146
- /***/ }),
39147
-
39148
39149
  /***/ "./node_modules/side-channel/index.js":
39149
39150
  /*!********************************************!*\
39150
39151
  !*** ./node_modules/side-channel/index.js ***!
@@ -39620,87 +39621,6 @@ module.exports = function whichCollection(value) {
39620
39621
 
39621
39622
  /***/ }),
39622
39623
 
39623
- /***/ "./node_modules/which-typed-array/index.js":
39624
- /*!*************************************************!*\
39625
- !*** ./node_modules/which-typed-array/index.js ***!
39626
- \*************************************************/
39627
- /*! no static exports found */
39628
- /***/ (function(module, exports, __webpack_require__) {
39629
-
39630
- "use strict";
39631
-
39632
-
39633
- var forEach = __webpack_require__(/*! foreach */ "./node_modules/foreach/index.js");
39634
-
39635
- var availableTypedArrays = __webpack_require__(/*! available-typed-arrays */ "./node_modules/available-typed-arrays/index.js");
39636
-
39637
- var callBound = __webpack_require__(/*! call-bind/callBound */ "./node_modules/call-bind/callBound.js");
39638
-
39639
- var $toString = callBound('Object.prototype.toString');
39640
-
39641
- var hasToStringTag = __webpack_require__(/*! has-tostringtag/shams */ "./node_modules/has-tostringtag/shams.js")();
39642
-
39643
- var g = typeof globalThis === 'undefined' ? global : globalThis;
39644
- var typedArrays = availableTypedArrays();
39645
- var $slice = callBound('String.prototype.slice');
39646
- var toStrTags = {};
39647
-
39648
- var gOPD = __webpack_require__(/*! es-abstract/helpers/getOwnPropertyDescriptor */ "./node_modules/es-abstract/helpers/getOwnPropertyDescriptor.js");
39649
-
39650
- var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof');
39651
-
39652
- if (hasToStringTag && gOPD && getPrototypeOf) {
39653
- forEach(typedArrays, function (typedArray) {
39654
- if (typeof g[typedArray] === 'function') {
39655
- var arr = new g[typedArray]();
39656
-
39657
- if (Symbol.toStringTag in arr) {
39658
- var proto = getPrototypeOf(arr);
39659
- var descriptor = gOPD(proto, Symbol.toStringTag);
39660
-
39661
- if (!descriptor) {
39662
- var superProto = getPrototypeOf(proto);
39663
- descriptor = gOPD(superProto, Symbol.toStringTag);
39664
- }
39665
-
39666
- toStrTags[typedArray] = descriptor.get;
39667
- }
39668
- }
39669
- });
39670
- }
39671
-
39672
- var tryTypedArrays = function tryAllTypedArrays(value) {
39673
- var foundName = false;
39674
- forEach(toStrTags, function (getter, typedArray) {
39675
- if (!foundName) {
39676
- try {
39677
- var name = getter.call(value);
39678
-
39679
- if (name === typedArray) {
39680
- foundName = name;
39681
- }
39682
- } catch (e) {}
39683
- }
39684
- });
39685
- return foundName;
39686
- };
39687
-
39688
- var isTypedArray = __webpack_require__(/*! is-typed-array */ "./node_modules/is-typed-array/index.js");
39689
-
39690
- module.exports = function whichTypedArray(value) {
39691
- if (!isTypedArray(value)) {
39692
- return false;
39693
- }
39694
-
39695
- if (!hasToStringTag || !(Symbol.toStringTag in value)) {
39696
- return $slice($toString(value), 8, -1);
39697
- }
39698
-
39699
- return tryTypedArrays(value);
39700
- };
39701
-
39702
- /***/ }),
39703
-
39704
39624
  /***/ "./packages/api/app/query.js":
39705
39625
  /*!***********************************!*\
39706
39626
  !*** ./packages/api/app/query.js ***!
@@ -39929,6 +39849,15 @@ async function loadBudget(budgetId) {
39929
39849
  });
39930
39850
  }
39931
39851
 
39852
+ async function downloadBudget(syncId, {
39853
+ password
39854
+ } = {}) {
39855
+ return send('api/download-budget', {
39856
+ syncId,
39857
+ password
39858
+ });
39859
+ }
39860
+
39932
39861
  async function batchBudgetUpdates(func) {
39933
39862
  await send('api/batch-budget-start');
39934
39863
 
@@ -40157,6 +40086,7 @@ module.exports = {
40157
40086
  runQuery,
40158
40087
  q,
40159
40088
  loadBudget,
40089
+ downloadBudget,
40160
40090
  batchBudgetUpdates,
40161
40091
  getBudgetMonths,
40162
40092
  getBudgetMonth,
@@ -40222,6 +40152,12 @@ module.exports = {
40222
40152
  /*! no static exports found */
40223
40153
  /***/ (function(module, exports, __webpack_require__) {
40224
40154
 
40155
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
40156
+
40157
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
40158
+
40159
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
40160
+
40225
40161
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
40226
40162
 
40227
40163
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -40333,7 +40269,8 @@ function getCurrentMonth() {
40333
40269
 
40334
40270
 
40335
40271
  async function importAccounts(data, entityIdMap) {
40336
- return Promise.all(data.accounts.map(async account => {
40272
+ const accounts = sortByKey(data.accounts, 'sortableIndex');
40273
+ return Promise.all(accounts.map(async account => {
40337
40274
  if (!account.isTombstone) {
40338
40275
  const id = await actual.createAccount({
40339
40276
  type: mapAccountType(account.accountType),
@@ -40419,6 +40356,12 @@ async function importTransactions(data, entityIdMap) {
40419
40356
 
40420
40357
  for (let transaction of data.transactions) {
40421
40358
  entityIdMap.set(transaction.entityId, uuid.v4());
40359
+
40360
+ if (transaction.subTransactions) {
40361
+ for (let subTransaction of transaction.subTransactions) {
40362
+ entityIdMap.set(subTransaction.entityId, uuid.v4());
40363
+ }
40364
+ }
40422
40365
  }
40423
40366
 
40424
40367
  let sortOrder = 1;
@@ -40431,29 +40374,38 @@ async function importTransactions(data, entityIdMap) {
40431
40374
  }
40432
40375
 
40433
40376
  let id = entityIdMap.get(transaction.entityId);
40434
- let transferId = entityIdMap.get(transaction.transferTransactionId) || null;
40435
- let payee = null;
40436
40377
 
40437
- if (transferId) {
40438
- payee = payees.find(p => p.transfer_acct === entityIdMap.get(transaction.targetAccountId)).id;
40439
- } else {
40440
- payee = entityIdMap.get(transaction.payeeId);
40378
+ function transferProperties(t) {
40379
+ let transferId = entityIdMap.get(t.transferTransactionId) || null;
40380
+ let payee = null;
40381
+
40382
+ if (transferId) {
40383
+ payee = payees.find(p => p.transfer_acct === entityIdMap.get(t.targetAccountId)).id;
40384
+ } else {
40385
+ payee = entityIdMap.get(t.payeeId);
40386
+ }
40387
+
40388
+ return {
40389
+ transfer_id: transferId,
40390
+ payee
40391
+ };
40441
40392
  }
40442
40393
 
40443
- let newTransaction = {
40394
+ let newTransaction = _objectSpread({
40444
40395
  id,
40445
40396
  amount: amountToInteger(transaction.amount),
40446
40397
  category: isOffBudget(entityIdMap.get(accountId)) ? null : getCategory(transaction.categoryId),
40447
40398
  date: transaction.date,
40448
40399
  notes: transaction.memo || null,
40449
- payee,
40450
- transfer_id: transferId
40451
- };
40400
+ cleared: transaction.cleared === 'Cleared'
40401
+ }, transferProperties(transaction));
40402
+
40452
40403
  newTransaction.subtransactions = transaction.subTransactions && transaction.subTransactions.map((t, i) => {
40453
- return {
40404
+ return _objectSpread({
40454
40405
  amount: amountToInteger(t.amount),
40455
- category: getCategory(t.categoryId)
40456
- };
40406
+ category: getCategory(t.categoryId),
40407
+ notes: t.memo || null
40408
+ }, transferProperties(t));
40457
40409
  });
40458
40410
  return newTransaction;
40459
40411
  }).filter(x => x);
@@ -40486,11 +40438,7 @@ function fillInBudgets(data, categoryBudgets) {
40486
40438
 
40487
40439
  async function importBudgets(data, entityIdMap) {
40488
40440
  let budgets = sortByKey(data.monthlyBudgets, 'month');
40489
- let earliestMonth = monthFromDate(budgets[0].month);
40490
- let currentMonth = getCurrentMonth();
40491
40441
  await actual.batchBudgetUpdates(async () => {
40492
- const carryoverFlags = {};
40493
-
40494
40442
  for (let budget of budgets) {
40495
40443
  let filled = fillInBudgets(data, budget.monthlySubCategoryBudgets.filter(b => !b.isTombstone));
40496
40444
  await Promise.all(filled.map(async catBudget => {
@@ -40505,13 +40453,8 @@ async function importBudgets(data, entityIdMap) {
40505
40453
  await actual.setBudgetAmount(month, catId, amount);
40506
40454
 
40507
40455
  if (catBudget.overspendingHandling === 'AffectsBuffer') {
40508
- // Turn off the carryover flag so it doesn't propagate
40509
- // to future months
40510
- carryoverFlags[catId] = false;
40511
- } else if (catBudget.overspendingHandling === 'Confined' || carryoverFlags[catId]) {
40512
- // Overspending has switched to carryover, set the
40513
- // flag so it propagates to future months
40514
- carryoverFlags[catId] = true;
40456
+ await actual.setBudgetCarryover(month, catId, false);
40457
+ } else if (catBudget.overspendingHandling === 'Confined') {
40515
40458
  await actual.setBudgetCarryover(month, catId, true);
40516
40459
  }
40517
40460
  }));
@@ -41406,9 +41349,7 @@ async function fillChecking(handlers, account, payees, groups) {
41406
41349
  async function fillInvestment(handlers, account, payees, groups) {
41407
41350
  let _extractCommonThings3 = extractCommonThings(payees, groups),
41408
41351
  incomePayee = _extractCommonThings3.incomePayee,
41409
- expensePayees = _extractCommonThings3.expensePayees,
41410
- incomeGroup = _extractCommonThings3.incomeGroup,
41411
- expenseCategories = _extractCommonThings3.expenseCategories;
41352
+ incomeGroup = _extractCommonThings3.incomeGroup;
41412
41353
 
41413
41354
  let numTransactions = integer(10, 30);
41414
41355
  let transactions = [];
@@ -41487,9 +41428,7 @@ async function fillSavings(handlers, account, payees, groups) {
41487
41428
  async function fillMortgage(handlers, account, payees, groups) {
41488
41429
  let _extractCommonThings5 = extractCommonThings(payees, groups),
41489
41430
  incomePayee = _extractCommonThings5.incomePayee,
41490
- expensePayees = _extractCommonThings5.expensePayees,
41491
- incomeGroup = _extractCommonThings5.incomeGroup,
41492
- expenseCategories = _extractCommonThings5.expenseCategories;
41431
+ incomeGroup = _extractCommonThings5.incomeGroup;
41493
41432
 
41494
41433
  let numTransactions = integer(7, 10);
41495
41434
  let amount = integer(100000, 200000);
@@ -41524,9 +41463,7 @@ async function fillMortgage(handlers, account, payees, groups) {
41524
41463
  async function fillOther(handlers, account, payees, groups) {
41525
41464
  let _extractCommonThings6 = extractCommonThings(payees, groups),
41526
41465
  incomePayee = _extractCommonThings6.incomePayee,
41527
- expensePayees = _extractCommonThings6.expensePayees,
41528
- incomeGroup = _extractCommonThings6.incomeGroup,
41529
- expenseCategories = _extractCommonThings6.expenseCategories;
41466
+ incomeGroup = _extractCommonThings6.incomeGroup;
41530
41467
 
41531
41468
  let numTransactions = integer(3, 6);
41532
41469
  let category = incomeGroup.categories.find(c => c.name === 'Income');
@@ -41897,16 +41834,8 @@ __webpack_require__.r(__webpack_exports__);
41897
41834
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "captureBreadcrumb", function() { return captureBreadcrumb; });
41898
41835
  function captureException(exc) {
41899
41836
  console.log('[Exception]', exc);
41900
-
41901
- if (global.SentryClient) {
41902
- global.SentryClient.captureException(exc);
41903
- }
41904
- }
41905
- function captureBreadcrumb(breadcrumb) {
41906
- if (global.SentryClient) {
41907
- global.SentryClient.addBreadcrumb(breadcrumb);
41908
- }
41909
41837
  }
41838
+ function captureBreadcrumb(breadcrumb) {}
41910
41839
 
41911
41840
  /***/ }),
41912
41841
 
@@ -42725,7 +42654,7 @@ async function parseOFX(filepath) {
42725
42654
 
42726
42655
  await initModule();
42727
42656
  let errors = [];
42728
- let contents = await _platform_server_fs__WEBPACK_IMPORTED_MODULE_1___default.a.readFile(filepath);
42657
+ let contents = await _platform_server_fs__WEBPACK_IMPORTED_MODULE_1___default.a.readFile(filepath, 'binary');
42729
42658
  let data;
42730
42659
 
42731
42660
  try {
@@ -42968,14 +42897,6 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
42968
42897
 
42969
42898
 
42970
42899
 
42971
- function safeNumber(n) {
42972
- return isNaN(n) ? null : n;
42973
- }
42974
-
42975
- function safeParseInt(n) {
42976
- return safeNumber(parseInt(n));
42977
- }
42978
-
42979
42900
  function assert(test, type, msg) {
42980
42901
  if (!test) {
42981
42902
  throw new _errors__WEBPACK_IMPORTED_MODULE_5__["RuleError"](type, msg);
@@ -43637,7 +43558,6 @@ function migrateIds(rule, mappings) {
43637
43558
  } // This finds all the rules that reference the `id`
43638
43559
 
43639
43560
  function iterateIds(rules, fieldName, func) {
43640
- let counts = {};
43641
43561
  let i;
43642
43562
 
43643
43563
  ruleiter: for (i = 0; i < rules.length; i++) {
@@ -43738,8 +43658,6 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
43738
43658
 
43739
43659
 
43740
43660
 
43741
- const levenshtein = __webpack_require__(/*! damerau-levenshtein */ "./node_modules/damerau-levenshtein/index.js");
43742
-
43743
43661
  const dateFns = __webpack_require__(/*! date-fns */ "./node_modules/date-fns/esm/index.js");
43744
43662
 
43745
43663
  const uuid = __webpack_require__(/*! ../../platform/uuid */ "./packages/loot-core/src/platform/uuid/index.electron.js");
@@ -44039,7 +43957,6 @@ async function reconcileTransactions(acctId, transactions) {
44039
43957
  }); // Finally, generate & commit the changes
44040
43958
 
44041
43959
  for (let _ref2 of transactionsStep3) {
44042
- let payee_name = _ref2.payee_name;
44043
43960
  let trans = _ref2.trans;
44044
43961
  let subtransactions = _ref2.subtransactions;
44045
43962
  let match = _ref2.match;
@@ -44107,7 +44024,6 @@ async function addTransactions(acctId, transactions, {
44107
44024
  payeesToCreate = _await$normalizeTrans2.payeesToCreate;
44108
44025
 
44109
44026
  for (let _ref3 of normalized) {
44110
- let payee_name = _ref3.payee_name;
44111
44027
  let trans = _ref3.trans;
44112
44028
  let subtransactions = _ref3.subtransactions;
44113
44029
  // Run the rules
@@ -44602,7 +44518,6 @@ function onApplySync(oldValues, newValues) {
44602
44518
  function runRules(trans) {
44603
44519
  let finalTrans = _objectSpread({}, trans);
44604
44520
 
44605
- let allChanges = {};
44606
44521
  let rules = Object(_rules__WEBPACK_IMPORTED_MODULE_9__["rankRules"])(Object(_shared_util__WEBPACK_IMPORTED_MODULE_2__["fastSetMerge"])(firstcharIndexer.getApplicableRules(trans), payeeIndexer.getApplicableRules(trans)));
44607
44522
 
44608
44523
  for (let i = 0; i < rules.length; i++) {
@@ -44711,11 +44626,6 @@ function conditionsToAQL(conditions, {
44711
44626
  let dates = value.schedule.occurrences({
44712
44627
  take: recurDateBounds
44713
44628
  }).toArray().map(d => Object(_shared_months__WEBPACK_IMPORTED_MODULE_0__["dayFromDate"])(d.date));
44714
-
44715
- let compare = d => ({
44716
- $eq: d
44717
- });
44718
-
44719
44629
  return {
44720
44630
  $or: dates.map(d => {
44721
44631
  if (op === 'isapprox') {
@@ -44738,8 +44648,6 @@ function conditionsToAQL(conditions, {
44738
44648
  })
44739
44649
  };
44740
44650
  } else {
44741
- let date = value.date;
44742
-
44743
44651
  if (op === 'isapprox') {
44744
44652
  let fullDate = Object(_shared_months__WEBPACK_IMPORTED_MODULE_0__["parseDate"])(value.date);
44745
44653
  let high = Object(_shared_months__WEBPACK_IMPORTED_MODULE_0__["addDays"])(fullDate, 2);
@@ -45413,8 +45321,7 @@ async function getPayee(acct) {
45413
45321
  async function getTransferredAccount(transaction) {
45414
45322
  if (transaction.payee) {
45415
45323
  let _await$db$first = await _db__WEBPACK_IMPORTED_MODULE_0__["first"]('SELECT id, transfer_acct FROM v_payees WHERE id = ?', [transaction.payee]),
45416
- transfer_acct = _await$db$first.transfer_acct,
45417
- id = _await$db$first.id;
45324
+ transfer_acct = _await$db$first.transfer_acct;
45418
45325
 
45419
45326
  return transfer_acct;
45420
45327
  }
@@ -45499,21 +45406,26 @@ async function addTransfer(transaction, transferredAccount) {
45499
45406
  } : {});
45500
45407
  }
45501
45408
  async function removeTransfer(transaction) {
45502
- let transferTrans = await _db__WEBPACK_IMPORTED_MODULE_0__["getTransaction"](transaction.transfer_id);
45503
-
45504
- if (transferTrans.is_child) {
45505
- // If it's a child transaction, we don't delete it because that
45506
- // would invalidate the whole split transaction. Instead of turn
45507
- // it into a normal transaction
45508
- await _db__WEBPACK_IMPORTED_MODULE_0__["updateTransaction"]({
45509
- id: transaction.transfer_id,
45510
- transfer_id: null,
45511
- payee: null
45512
- });
45513
- } else {
45514
- await _db__WEBPACK_IMPORTED_MODULE_0__["deleteTransaction"]({
45515
- id: transaction.transfer_id
45516
- });
45409
+ let transferTrans = await _db__WEBPACK_IMPORTED_MODULE_0__["getTransaction"](transaction.transfer_id); // Perform operations on the transfer transaction only
45410
+ // if it is found. For example: when users delete both
45411
+ // (in & out) transfer transactions at the same time -
45412
+ // transfer transaction will not be found.
45413
+
45414
+ if (transferTrans) {
45415
+ if (transferTrans.is_child) {
45416
+ // If it's a child transaction, we don't delete it because that
45417
+ // would invalidate the whole split transaction. Instead of turn
45418
+ // it into a normal transaction
45419
+ await _db__WEBPACK_IMPORTED_MODULE_0__["updateTransaction"]({
45420
+ id: transaction.transfer_id,
45421
+ transfer_id: null,
45422
+ payee: null
45423
+ });
45424
+ } else {
45425
+ await _db__WEBPACK_IMPORTED_MODULE_0__["deleteTransaction"]({
45426
+ id: transaction.transfer_id
45427
+ });
45428
+ }
45517
45429
  }
45518
45430
 
45519
45431
  await _db__WEBPACK_IMPORTED_MODULE_0__["updateTransaction"]({
@@ -45807,20 +45719,21 @@ const payeeRuleModel = _objectSpread(_objectSpread({}, _models__WEBPACK_IMPORTED
45807
45719
 
45808
45720
  "use strict";
45809
45721
  __webpack_require__.r(__webpack_exports__);
45810
- /* harmony import */ var _shared_months__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../shared/months */ "./packages/loot-core/src/shared/months.js");
45811
- /* harmony import */ var _shared_query__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../shared/query */ "./packages/loot-core/src/shared/query.js");
45812
- /* harmony import */ var _shared_transactions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../shared/transactions */ "./packages/loot-core/src/shared/transactions.js");
45813
- /* harmony import */ var _shared_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../shared/util */ "./packages/loot-core/src/shared/util.js");
45814
- /* harmony import */ var _accounts_sync__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./accounts/sync */ "./packages/loot-core/src/server/accounts/sync.js");
45815
- /* harmony import */ var _api_models__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./api-models */ "./packages/loot-core/src/server/api-models.js");
45816
- /* harmony import */ var _aql__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./aql */ "./packages/loot-core/src/server/aql/index.js");
45817
- /* harmony import */ var _cloud_storage__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./cloud-storage */ "./packages/loot-core/src/server/cloud-storage.js");
45818
- /* harmony import */ var _crdt__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./crdt */ "./packages/loot-core/src/server/crdt/index.js");
45819
- /* harmony import */ var _db__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./db */ "./packages/loot-core/src/server/db/index.js");
45820
- /* harmony import */ var _mutators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./mutators */ "./packages/loot-core/src/server/mutators.js");
45821
- /* harmony import */ var _prefs__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./prefs */ "./packages/loot-core/src/server/prefs.js");
45822
- /* harmony import */ var _sheet__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./sheet */ "./packages/loot-core/src/server/sheet.js");
45823
- /* harmony import */ var _sync__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sync */ "./packages/loot-core/src/server/sync/index.js");
45722
+ /* harmony import */ var _shared_errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../shared/errors */ "./packages/loot-core/src/shared/errors.js");
45723
+ /* harmony import */ var _shared_months__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../shared/months */ "./packages/loot-core/src/shared/months.js");
45724
+ /* harmony import */ var _shared_query__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../shared/query */ "./packages/loot-core/src/shared/query.js");
45725
+ /* harmony import */ var _shared_transactions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../shared/transactions */ "./packages/loot-core/src/shared/transactions.js");
45726
+ /* harmony import */ var _shared_util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../shared/util */ "./packages/loot-core/src/shared/util.js");
45727
+ /* harmony import */ var _accounts_sync__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./accounts/sync */ "./packages/loot-core/src/server/accounts/sync.js");
45728
+ /* harmony import */ var _api_models__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./api-models */ "./packages/loot-core/src/server/api-models.js");
45729
+ /* harmony import */ var _aql__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./aql */ "./packages/loot-core/src/server/aql/index.js");
45730
+ /* harmony import */ var _cloud_storage__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./cloud-storage */ "./packages/loot-core/src/server/cloud-storage.js");
45731
+ /* harmony import */ var _crdt__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./crdt */ "./packages/loot-core/src/server/crdt/index.js");
45732
+ /* harmony import */ var _db__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./db */ "./packages/loot-core/src/server/db/index.js");
45733
+ /* harmony import */ var _mutators__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./mutators */ "./packages/loot-core/src/server/mutators.js");
45734
+ /* harmony import */ var _prefs__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./prefs */ "./packages/loot-core/src/server/prefs.js");
45735
+ /* harmony import */ var _sheet__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sheet */ "./packages/loot-core/src/server/sheet.js");
45736
+ /* harmony import */ var _sync__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./sync */ "./packages/loot-core/src/server/sync/index.js");
45824
45737
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
45825
45738
 
45826
45739
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -45842,6 +45755,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
45842
45755
 
45843
45756
 
45844
45757
 
45758
+
45845
45759
  const connection = __webpack_require__(/*! ../platform/server/connection */ "./packages/loot-core/src/platform/server/connection/index.api.js");
45846
45760
 
45847
45761
  let IMPORT_MODE = false; // This is duplicate from main.js...
@@ -45860,10 +45774,10 @@ function APIError(msg, meta) {
45860
45774
 
45861
45775
  function withMutation(handler) {
45862
45776
  return args => {
45863
- return Object(_mutators__WEBPACK_IMPORTED_MODULE_10__["runMutator"])(async () => {
45864
- let latestTimestamp = Object(_crdt__WEBPACK_IMPORTED_MODULE_8__["getClock"])().timestamp.toString();
45777
+ return Object(_mutators__WEBPACK_IMPORTED_MODULE_11__["runMutator"])(async () => {
45778
+ let latestTimestamp = Object(_crdt__WEBPACK_IMPORTED_MODULE_9__["getClock"])().timestamp.toString();
45865
45779
  let result = await handler(args);
45866
- let rows = await _db__WEBPACK_IMPORTED_MODULE_9__["all"]('SELECT DISTINCT dataset FROM messages_crdt WHERE timestamp > ?', [latestTimestamp]); // Only send the sync event if anybody else is connected
45780
+ let rows = await _db__WEBPACK_IMPORTED_MODULE_10__["all"]('SELECT DISTINCT dataset FROM messages_crdt WHERE timestamp > ?', [latestTimestamp]); // Only send the sync event if anybody else is connected
45867
45781
 
45868
45782
  if (connection.getNumClients() > 1) {
45869
45783
  connection.send('sync-event', {
@@ -45891,7 +45805,7 @@ async function validateMonth(month) {
45891
45805
  start = _await$handlers$getB.start,
45892
45806
  end = _await$handlers$getB.end;
45893
45807
 
45894
- let range = _shared_months__WEBPACK_IMPORTED_MODULE_0__["range"](start, end);
45808
+ let range = _shared_months__WEBPACK_IMPORTED_MODULE_1__["range"](start, end);
45895
45809
 
45896
45810
  if (!range.includes(month)) {
45897
45811
  throw APIError('No budget exists for month: ' + month);
@@ -45904,7 +45818,7 @@ async function validateExpenseCategory(debug, id) {
45904
45818
  throw APIError(`${debug}: category id is required`);
45905
45819
  }
45906
45820
 
45907
- let row = await _db__WEBPACK_IMPORTED_MODULE_9__["first"]('SELECT is_income FROM categories WHERE id = ?', [id]);
45821
+ let row = await _db__WEBPACK_IMPORTED_MODULE_10__["first"]('SELECT is_income FROM categories WHERE id = ?', [id]);
45908
45822
 
45909
45823
  if (!row) {
45910
45824
  throw APIError(`${debug}: category "${id}" does not exist`);
@@ -45926,7 +45840,7 @@ handlers['api/batch-budget-start'] = async function () {
45926
45840
 
45927
45841
 
45928
45842
  if (IMPORT_MODE) {
45929
- _db__WEBPACK_IMPORTED_MODULE_9__["asyncTransaction"](() => {
45843
+ _db__WEBPACK_IMPORTED_MODULE_10__["asyncTransaction"](() => {
45930
45844
  return new Promise((resolve, reject) => {
45931
45845
  batchPromise = {
45932
45846
  resolve,
@@ -45935,7 +45849,7 @@ handlers['api/batch-budget-start'] = async function () {
45935
45849
  });
45936
45850
  });
45937
45851
  } else {
45938
- Object(_sync__WEBPACK_IMPORTED_MODULE_13__["batchMessages"])(() => {
45852
+ Object(_sync__WEBPACK_IMPORTED_MODULE_14__["batchMessages"])(() => {
45939
45853
  return new Promise((resolve, reject) => {
45940
45854
  batchPromise = {
45941
45855
  resolve,
@@ -45958,7 +45872,7 @@ handlers['api/batch-budget-end'] = async function () {
45958
45872
  handlers['api/load-budget'] = async function ({
45959
45873
  id
45960
45874
  }) {
45961
- let _ref = _prefs__WEBPACK_IMPORTED_MODULE_11__["getPrefs"]() || {},
45875
+ let _ref = _prefs__WEBPACK_IMPORTED_MODULE_12__["getPrefs"]() || {},
45962
45876
  currentId = _ref.id;
45963
45877
 
45964
45878
  if (currentId !== id) {
@@ -45973,15 +45887,69 @@ handlers['api/load-budget'] = async function ({
45973
45887
  connection.send('finish-load');
45974
45888
  } else {
45975
45889
  connection.send('show-budgets');
45890
+ throw new Error(Object(_shared_errors__WEBPACK_IMPORTED_MODULE_0__["getSyncError"])(error, id));
45891
+ }
45892
+ }
45893
+ };
45976
45894
 
45977
- if (error === 'out-of-sync-migrations' || error === 'out-of-sync-data') {
45978
- throw new Error('This budget cannot be loaded with this version of the app.');
45979
- } else if (error === 'budget-not-found') {
45980
- throw new Error('Budget "' + id + '" not found. Check the id of your budget in the "Advanced" section of the settings page.');
45981
- } else {
45982
- throw new Error('We had an unknown problem opening "' + id + '".');
45895
+ handlers['api/download-budget'] = async function ({
45896
+ syncId,
45897
+ password
45898
+ }) {
45899
+ let _ref2 = _prefs__WEBPACK_IMPORTED_MODULE_12__["getPrefs"]() || {},
45900
+ currentId = _ref2.id;
45901
+
45902
+ if (currentId) {
45903
+ await handlers['close-budget']();
45904
+ }
45905
+
45906
+ let localBudget = (await handlers['get-budgets']()).find(b => b.groupId === syncId);
45907
+
45908
+ if (localBudget) {
45909
+ await handlers['load-budget']({
45910
+ id: localBudget.id
45911
+ });
45912
+ let result = await handlers['sync-budget']({
45913
+ id: localBudget.id
45914
+ });
45915
+
45916
+ if (result.error) {
45917
+ throw new Error(Object(_shared_errors__WEBPACK_IMPORTED_MODULE_0__["getSyncError"])(result.error, localBudget.id));
45918
+ }
45919
+ } else {
45920
+ let files = await handlers['get-remote-files']();
45921
+ let file = files.find(f => f.groupId === syncId);
45922
+
45923
+ if (!file) {
45924
+ throw new Error(`Budget "${syncId}" not found. Check the sync id of your budget in the "Advanced" section of the settings page.`);
45925
+ }
45926
+
45927
+ if (file.encryptKeyId && !password) {
45928
+ throw new Error(`File ${file.name} is encrypted. Please provide a password.`);
45929
+ }
45930
+
45931
+ if (password) {
45932
+ let result = await handlers['key-test']({
45933
+ fileId: file.fileId,
45934
+ password
45935
+ });
45936
+
45937
+ if (result.error) {
45938
+ throw new Error(Object(_shared_errors__WEBPACK_IMPORTED_MODULE_0__["getTestKeyError"])(result.error));
45983
45939
  }
45984
45940
  }
45941
+
45942
+ let result = await handlers['download-budget']({
45943
+ fileId: file.fileId
45944
+ });
45945
+
45946
+ if (result.error) {
45947
+ throw new Error(Object(_shared_errors__WEBPACK_IMPORTED_MODULE_0__["getDownloadError"])(result.error, result.id));
45948
+ }
45949
+
45950
+ await handlers['load-budget']({
45951
+ id: result.id
45952
+ });
45985
45953
  }
45986
45954
  };
45987
45955
 
@@ -45996,20 +45964,20 @@ handlers['api/start-import'] = async function ({
45996
45964
  avoidUpload: true
45997
45965
  }); // Clear out the default expense categories
45998
45966
 
45999
- await _db__WEBPACK_IMPORTED_MODULE_9__["runQuery"]('DELETE FROM categories WHERE is_income = 0');
46000
- await _db__WEBPACK_IMPORTED_MODULE_9__["runQuery"]('DELETE FROM category_groups WHERE is_income = 0'); // Turn syncing off
45967
+ await _db__WEBPACK_IMPORTED_MODULE_10__["runQuery"]('DELETE FROM categories WHERE is_income = 0');
45968
+ await _db__WEBPACK_IMPORTED_MODULE_10__["runQuery"]('DELETE FROM category_groups WHERE is_income = 0'); // Turn syncing off
46001
45969
 
46002
- Object(_sync__WEBPACK_IMPORTED_MODULE_13__["setSyncingMode"])('import');
45970
+ Object(_sync__WEBPACK_IMPORTED_MODULE_14__["setSyncingMode"])('import');
46003
45971
  connection.send('start-import');
46004
45972
  IMPORT_MODE = true;
46005
45973
  };
46006
45974
 
46007
45975
  handlers['api/finish-import'] = async function () {
46008
- _sheet__WEBPACK_IMPORTED_MODULE_12__["get"]().markCacheDirty(); // We always need to fully reload the app. Importing doesn't touch
45976
+ _sheet__WEBPACK_IMPORTED_MODULE_13__["get"]().markCacheDirty(); // We always need to fully reload the app. Importing doesn't touch
46009
45977
  // the spreadsheet, but we can't just recreate the spreadsheet
46010
45978
  // either; there is other internal state that isn't created
46011
45979
 
46012
- let _prefs$getPrefs = _prefs__WEBPACK_IMPORTED_MODULE_11__["getPrefs"](),
45980
+ let _prefs$getPrefs = _prefs__WEBPACK_IMPORTED_MODULE_12__["getPrefs"](),
46013
45981
  id = _prefs$getPrefs.id;
46014
45982
 
46015
45983
  await handlers['close-budget']();
@@ -46017,15 +45985,15 @@ handlers['api/finish-import'] = async function () {
46017
45985
  id
46018
45986
  });
46019
45987
  await handlers['get-budget-bounds']();
46020
- await _sheet__WEBPACK_IMPORTED_MODULE_12__["waitOnSpreadsheet"]();
46021
- await _cloud_storage__WEBPACK_IMPORTED_MODULE_7__["upload"]().catch(err => {});
45988
+ await _sheet__WEBPACK_IMPORTED_MODULE_13__["waitOnSpreadsheet"]();
45989
+ await _cloud_storage__WEBPACK_IMPORTED_MODULE_8__["upload"]().catch(err => {});
46022
45990
  connection.send('finish-import');
46023
45991
  IMPORT_MODE = false;
46024
45992
  };
46025
45993
 
46026
45994
  handlers['api/abort-import'] = async function () {
46027
45995
  if (IMPORT_MODE) {
46028
- let _prefs$getPrefs2 = _prefs__WEBPACK_IMPORTED_MODULE_11__["getPrefs"](),
45996
+ let _prefs$getPrefs2 = _prefs__WEBPACK_IMPORTED_MODULE_12__["getPrefs"](),
46029
45997
  id = _prefs$getPrefs2.id;
46030
45998
 
46031
45999
  await handlers['close-budget']();
@@ -46041,7 +46009,7 @@ handlers['api/abort-import'] = async function () {
46041
46009
  handlers['api/query'] = async function ({
46042
46010
  query
46043
46011
  }) {
46044
- return Object(_aql__WEBPACK_IMPORTED_MODULE_6__["runQuery"])(query);
46012
+ return Object(_aql__WEBPACK_IMPORTED_MODULE_7__["runQuery"])(query);
46045
46013
  };
46046
46014
 
46047
46015
  handlers['api/budget-months'] = async function () {
@@ -46049,18 +46017,18 @@ handlers['api/budget-months'] = async function () {
46049
46017
  start = _await$handlers$getB2.start,
46050
46018
  end = _await$handlers$getB2.end;
46051
46019
 
46052
- return _shared_months__WEBPACK_IMPORTED_MODULE_0__["range"](start, end);
46020
+ return _shared_months__WEBPACK_IMPORTED_MODULE_1__["range"](start, end);
46053
46021
  };
46054
46022
 
46055
46023
  handlers['api/budget-month'] = async function ({
46056
46024
  month
46057
46025
  }) {
46058
46026
  await validateMonth(month);
46059
- let groups = await _db__WEBPACK_IMPORTED_MODULE_9__["getCategoriesGrouped"]();
46060
- let sheetName = _shared_months__WEBPACK_IMPORTED_MODULE_0__["sheetForMonth"](month);
46027
+ let groups = await _db__WEBPACK_IMPORTED_MODULE_10__["getCategoriesGrouped"]();
46028
+ let sheetName = _shared_months__WEBPACK_IMPORTED_MODULE_1__["sheetForMonth"](month);
46061
46029
 
46062
46030
  function value(name) {
46063
- let v = _sheet__WEBPACK_IMPORTED_MODULE_12__["get"]().getCellValue(sheetName, name);
46031
+ let v = _sheet__WEBPACK_IMPORTED_MODULE_13__["get"]().getCellValue(sheetName, name);
46064
46032
  return v === '' ? 0 : v;
46065
46033
  } // This is duplicated from main.js because the return format is
46066
46034
  // different (for now)
@@ -46079,19 +46047,19 @@ handlers['api/budget-month'] = async function ({
46079
46047
  totalBalance: value('total-leftover'),
46080
46048
  categoryGroups: groups.map(group => {
46081
46049
  if (group.is_income) {
46082
- return _objectSpread(_objectSpread({}, _api_models__WEBPACK_IMPORTED_MODULE_5__["categoryGroupModel"].toExternal(group)), {}, {
46050
+ return _objectSpread(_objectSpread({}, _api_models__WEBPACK_IMPORTED_MODULE_6__["categoryGroupModel"].toExternal(group)), {}, {
46083
46051
  received: value('total-income'),
46084
- categories: group.categories.map(cat => _objectSpread(_objectSpread({}, _api_models__WEBPACK_IMPORTED_MODULE_5__["categoryModel"].toExternal(cat)), {}, {
46052
+ categories: group.categories.map(cat => _objectSpread(_objectSpread({}, _api_models__WEBPACK_IMPORTED_MODULE_6__["categoryModel"].toExternal(cat)), {}, {
46085
46053
  received: value(`sum-amount-${cat.id}`)
46086
46054
  }))
46087
46055
  });
46088
46056
  }
46089
46057
 
46090
- return _objectSpread(_objectSpread({}, _api_models__WEBPACK_IMPORTED_MODULE_5__["categoryGroupModel"].toExternal(group)), {}, {
46058
+ return _objectSpread(_objectSpread({}, _api_models__WEBPACK_IMPORTED_MODULE_6__["categoryGroupModel"].toExternal(group)), {}, {
46091
46059
  budgeted: value(`group-budget-${group.id}`),
46092
46060
  spent: value(`group-sum-amount-${group.id}`),
46093
46061
  balance: value(`group-leftover-${group.id}`),
46094
- categories: group.categories.map(cat => _objectSpread(_objectSpread({}, _api_models__WEBPACK_IMPORTED_MODULE_5__["categoryModel"].toExternal(cat)), {}, {
46062
+ categories: group.categories.map(cat => _objectSpread(_objectSpread({}, _api_models__WEBPACK_IMPORTED_MODULE_6__["categoryModel"].toExternal(cat)), {}, {
46095
46063
  budgeted: value(`budget-${cat.id}`),
46096
46064
  spent: value(`sum-amount-${cat.id}`),
46097
46065
  balance: value(`leftover-${cat.id}`),
@@ -46152,7 +46120,7 @@ handlers['api/transactions-add'] = withMutation(async function ({
46152
46120
  accountId,
46153
46121
  transactions
46154
46122
  }) {
46155
- await Object(_accounts_sync__WEBPACK_IMPORTED_MODULE_4__["addTransactions"])(accountId, transactions, {
46123
+ await Object(_accounts_sync__WEBPACK_IMPORTED_MODULE_5__["addTransactions"])(accountId, transactions, {
46156
46124
  runTransfers: false
46157
46125
  });
46158
46126
  return 'ok';
@@ -46163,7 +46131,7 @@ handlers['api/transactions-get'] = async function ({
46163
46131
  startDate,
46164
46132
  endDate
46165
46133
  }) {
46166
- let _await$aqlQuery = await Object(_aql__WEBPACK_IMPORTED_MODULE_6__["runQuery"])(Object(_shared_query__WEBPACK_IMPORTED_MODULE_1__["default"])('transactions').filter({
46134
+ let _await$aqlQuery = await Object(_aql__WEBPACK_IMPORTED_MODULE_7__["runQuery"])(Object(_shared_query__WEBPACK_IMPORTED_MODULE_2__["default"])('transactions').filter({
46167
46135
  $and: [accountId && {
46168
46136
  account: accountId
46169
46137
  }, startDate && {
@@ -46194,20 +46162,20 @@ handlers['api/transaction-update'] = withMutation(async function ({
46194
46162
  id,
46195
46163
  fields
46196
46164
  }) {
46197
- let _await$aqlQuery2 = await Object(_aql__WEBPACK_IMPORTED_MODULE_6__["runQuery"])(Object(_shared_query__WEBPACK_IMPORTED_MODULE_1__["default"])('transactions').filter({
46165
+ let _await$aqlQuery2 = await Object(_aql__WEBPACK_IMPORTED_MODULE_7__["runQuery"])(Object(_shared_query__WEBPACK_IMPORTED_MODULE_2__["default"])('transactions').filter({
46198
46166
  id
46199
46167
  }).select('*').options({
46200
46168
  splits: 'grouped'
46201
46169
  })),
46202
46170
  data = _await$aqlQuery2.data;
46203
46171
 
46204
- let transactions = Object(_shared_transactions__WEBPACK_IMPORTED_MODULE_2__["ungroupTransactions"])(data);
46172
+ let transactions = Object(_shared_transactions__WEBPACK_IMPORTED_MODULE_3__["ungroupTransactions"])(data);
46205
46173
 
46206
46174
  if (transactions.length === 0) {
46207
46175
  return [];
46208
46176
  }
46209
46177
 
46210
- let _updateTransaction = Object(_shared_transactions__WEBPACK_IMPORTED_MODULE_2__["updateTransaction"])(transactions, fields),
46178
+ let _updateTransaction = Object(_shared_transactions__WEBPACK_IMPORTED_MODULE_3__["updateTransaction"])(transactions, fields),
46211
46179
  diff = _updateTransaction.diff;
46212
46180
 
46213
46181
  return handlers['transactions-batch-update'](diff);
@@ -46215,28 +46183,28 @@ handlers['api/transaction-update'] = withMutation(async function ({
46215
46183
  handlers['api/transaction-delete'] = withMutation(async function ({
46216
46184
  id
46217
46185
  }) {
46218
- let _await$aqlQuery3 = await Object(_aql__WEBPACK_IMPORTED_MODULE_6__["runQuery"])(Object(_shared_query__WEBPACK_IMPORTED_MODULE_1__["default"])('transactions').filter({
46186
+ let _await$aqlQuery3 = await Object(_aql__WEBPACK_IMPORTED_MODULE_7__["runQuery"])(Object(_shared_query__WEBPACK_IMPORTED_MODULE_2__["default"])('transactions').filter({
46219
46187
  id
46220
46188
  }).select('*').options({
46221
46189
  splits: 'grouped'
46222
46190
  })),
46223
46191
  data = _await$aqlQuery3.data;
46224
46192
 
46225
- let transactions = Object(_shared_transactions__WEBPACK_IMPORTED_MODULE_2__["ungroupTransactions"])(data);
46193
+ let transactions = Object(_shared_transactions__WEBPACK_IMPORTED_MODULE_3__["ungroupTransactions"])(data);
46226
46194
 
46227
46195
  if (transactions.length === 0) {
46228
46196
  return [];
46229
46197
  }
46230
46198
 
46231
- let _deleteTransaction = Object(_shared_transactions__WEBPACK_IMPORTED_MODULE_2__["deleteTransaction"])(transactions, id),
46199
+ let _deleteTransaction = Object(_shared_transactions__WEBPACK_IMPORTED_MODULE_3__["deleteTransaction"])(transactions, id),
46232
46200
  diff = _deleteTransaction.diff;
46233
46201
 
46234
46202
  return handlers['transactions-batch-update'](diff);
46235
46203
  });
46236
46204
 
46237
46205
  handlers['api/accounts-get'] = async function () {
46238
- let accounts = await _db__WEBPACK_IMPORTED_MODULE_9__["getAccounts"]();
46239
- return accounts.map(account => _api_models__WEBPACK_IMPORTED_MODULE_5__["accountModel"].toExternal(account));
46206
+ let accounts = await _db__WEBPACK_IMPORTED_MODULE_10__["getAccounts"]();
46207
+ return accounts.map(account => _api_models__WEBPACK_IMPORTED_MODULE_6__["accountModel"].toExternal(account));
46240
46208
  };
46241
46209
 
46242
46210
  handlers['api/account-create'] = withMutation(async function ({
@@ -46250,16 +46218,16 @@ handlers['api/account-create'] = withMutation(async function ({
46250
46218
  closed: account.closed,
46251
46219
  // Current the API expects an amount but it really should expect
46252
46220
  // an integer
46253
- balance: initialBalance != null ? Object(_shared_util__WEBPACK_IMPORTED_MODULE_3__["integerToAmount"])(initialBalance) : null
46221
+ balance: initialBalance != null ? Object(_shared_util__WEBPACK_IMPORTED_MODULE_4__["integerToAmount"])(initialBalance) : null
46254
46222
  });
46255
46223
  });
46256
46224
  handlers['api/account-update'] = withMutation(async function ({
46257
46225
  id,
46258
46226
  fields
46259
46227
  }) {
46260
- return _db__WEBPACK_IMPORTED_MODULE_9__["updateAccount"](_objectSpread({
46228
+ return _db__WEBPACK_IMPORTED_MODULE_10__["updateAccount"](_objectSpread({
46261
46229
  id
46262
- }, _api_models__WEBPACK_IMPORTED_MODULE_5__["accountModel"].fromExternal(fields)));
46230
+ }, _api_models__WEBPACK_IMPORTED_MODULE_6__["accountModel"].fromExternal(fields)));
46263
46231
  });
46264
46232
  handlers['api/account-close'] = withMutation(async function ({
46265
46233
  id,
@@ -46292,7 +46260,7 @@ handlers['api/categories-get'] = async function ({
46292
46260
  grouped
46293
46261
  } = {}) {
46294
46262
  let result = await handlers['get-categories']();
46295
- return grouped ? result.grouped.map(_api_models__WEBPACK_IMPORTED_MODULE_5__["categoryGroupModel"].toExternal) : result.list.map(_api_models__WEBPACK_IMPORTED_MODULE_5__["categoryModel"].toExternal);
46263
+ return grouped ? result.grouped.map(_api_models__WEBPACK_IMPORTED_MODULE_6__["categoryGroupModel"].toExternal) : result.list.map(_api_models__WEBPACK_IMPORTED_MODULE_6__["categoryModel"].toExternal);
46296
46264
  };
46297
46265
 
46298
46266
  handlers['api/category-group-create'] = withMutation(async function ({
@@ -46308,7 +46276,7 @@ handlers['api/category-group-update'] = withMutation(async function ({
46308
46276
  }) {
46309
46277
  return handlers['category-group-update'](_objectSpread({
46310
46278
  id
46311
- }, _api_models__WEBPACK_IMPORTED_MODULE_5__["categoryGroupModel"].fromExternal(fields)));
46279
+ }, _api_models__WEBPACK_IMPORTED_MODULE_6__["categoryGroupModel"].fromExternal(fields)));
46312
46280
  });
46313
46281
  handlers['api/category-group-delete'] = withMutation(async function ({
46314
46282
  id,
@@ -46334,7 +46302,7 @@ handlers['api/category-update'] = withMutation(async function ({
46334
46302
  }) {
46335
46303
  return handlers['category-update'](_objectSpread({
46336
46304
  id
46337
- }, _api_models__WEBPACK_IMPORTED_MODULE_5__["categoryModel"].fromExternal(fields)));
46305
+ }, _api_models__WEBPACK_IMPORTED_MODULE_6__["categoryModel"].fromExternal(fields)));
46338
46306
  });
46339
46307
  handlers['api/category-delete'] = withMutation(async function ({
46340
46308
  id,
@@ -46348,7 +46316,7 @@ handlers['api/category-delete'] = withMutation(async function ({
46348
46316
 
46349
46317
  handlers['api/payees-get'] = async function () {
46350
46318
  let payees = await handlers['payees-get']();
46351
- return payees.map(_api_models__WEBPACK_IMPORTED_MODULE_5__["payeeModel"].toExternal);
46319
+ return payees.map(_api_models__WEBPACK_IMPORTED_MODULE_6__["payeeModel"].toExternal);
46352
46320
  };
46353
46321
 
46354
46322
  handlers['api/payee-create'] = withMutation(async function ({
@@ -46365,7 +46333,7 @@ handlers['api/payee-update'] = withMutation(async function ({
46365
46333
  return handlers['payees-batch-change']({
46366
46334
  updated: [_objectSpread({
46367
46335
  id
46368
- }, _api_models__WEBPACK_IMPORTED_MODULE_5__["payeeModel"].fromExternal(fields))]
46336
+ }, _api_models__WEBPACK_IMPORTED_MODULE_6__["payeeModel"].fromExternal(fields))]
46369
46337
  });
46370
46338
  });
46371
46339
  handlers['api/payee-delete'] = withMutation(async function ({
@@ -46384,7 +46352,7 @@ handlers['api/payee-rules-get'] = async function ({
46384
46352
  let rules = await handlers['payees-get-rules']({
46385
46353
  id: payeeId
46386
46354
  });
46387
- return rules.map(_api_models__WEBPACK_IMPORTED_MODULE_5__["payeeRuleModel"].toExternal);
46355
+ return rules.map(_api_models__WEBPACK_IMPORTED_MODULE_6__["payeeRuleModel"].toExternal);
46388
46356
  };
46389
46357
 
46390
46358
  handlers['api/payee-rule-create'] = withMutation(async function ({
@@ -46403,7 +46371,7 @@ handlers['api/payee-rule-update'] = withMutation(async function ({
46403
46371
  }) {
46404
46372
  return handlers['payees-update-rule'](_objectSpread({
46405
46373
  id
46406
- }, _api_models__WEBPACK_IMPORTED_MODULE_5__["payeeRuleModel"].fromExternal(fields)));
46374
+ }, _api_models__WEBPACK_IMPORTED_MODULE_6__["payeeRuleModel"].fromExternal(fields)));
46407
46375
  });
46408
46376
  handlers['api/payee-rule-delete'] = withMutation(async function ({
46409
46377
  id
@@ -46674,7 +46642,6 @@ function makePath(state, path) {
46674
46642
 
46675
46643
  function resolvePath(state, path) {
46676
46644
  let paths = path.split('.');
46677
- let tableId;
46678
46645
  paths = paths.reduce((acc, name) => {
46679
46646
  let fullName = acc.context + '.' + name;
46680
46647
  return {
@@ -47073,19 +47040,6 @@ const compileExpr = saveStack('expr', (state, expr) => {
47073
47040
 
47074
47041
  return compileLiteral(expr);
47075
47042
  });
47076
-
47077
- function assertType(name, data, acceptedTypes) {
47078
- if (acceptedTypes.indexOf(data.type) === -1) {
47079
- throw new CompileError(`Invalid type of expression to ${name}, must be one of ${JSON.stringify(acceptedTypes)}: ${JSON.stringify(data.value)}`);
47080
- }
47081
- }
47082
-
47083
- function assertArgLength(name, args, len) {
47084
- if (args.length !== len) {
47085
- throw new CompileError(`Invalid number of args to ${name}: expected ${len} but received ${args.length}`)();
47086
- }
47087
- }
47088
-
47089
47043
  const compileFunction = saveStack('function', (state, func) => {
47090
47044
  let _Object$keys = Object.keys(func),
47091
47045
  _Object$keys2 = _slicedToArray(_Object$keys, 1),
@@ -47170,34 +47124,21 @@ const compileFunction = saveStack('function', (state, func) => {
47170
47124
  case '$neg':
47171
47125
  {
47172
47126
  validateArgLength(args, 1);
47173
-
47174
- let _valArray11 = valArray(state, args, ['float']),
47175
- _valArray12 = _slicedToArray(_valArray11, 1),
47176
- arg1 = _valArray12[0];
47177
-
47127
+ valArray(state, args, ['float']);
47178
47128
  return typed(`(-${val(state, args[0])})`, args[0].type);
47179
47129
  }
47180
47130
 
47181
47131
  case '$abs':
47182
47132
  {
47183
47133
  validateArgLength(args, 1);
47184
-
47185
- let _valArray13 = valArray(state, args, ['float']),
47186
- _valArray14 = _slicedToArray(_valArray13, 1),
47187
- arg1 = _valArray14[0];
47188
-
47134
+ valArray(state, args, ['float']);
47189
47135
  return typed(`ABS(${val(state, args[0])})`, args[0].type);
47190
47136
  }
47191
47137
 
47192
47138
  case '$idiv':
47193
47139
  {
47194
47140
  validateArgLength(args, 2);
47195
-
47196
- let _valArray15 = valArray(state, args, ['integer', 'integer']),
47197
- _valArray16 = _slicedToArray(_valArray15, 2),
47198
- arg1 = _valArray16[0],
47199
- arg2 = _valArray16[1];
47200
-
47141
+ valArray(state, args, ['integer', 'integer']);
47201
47142
  return typed(`(${val(state, args[0])} / ${val(state, args[1])})`, args[0].type);
47202
47143
  }
47203
47144
  // date functions
@@ -47223,9 +47164,9 @@ const compileFunction = saveStack('function', (state, func) => {
47223
47164
  case '$nocase':
47224
47165
  validateArgLength(args, 1);
47225
47166
 
47226
- let _valArray17 = valArray(state, args, ['string']),
47227
- _valArray18 = _slicedToArray(_valArray17, 1),
47228
- arg1 = _valArray18[0];
47167
+ let _valArray11 = valArray(state, args, ['string']),
47168
+ _valArray12 = _slicedToArray(_valArray11, 1),
47169
+ arg1 = _valArray12[0];
47229
47170
 
47230
47171
  return typed(`${arg1} COLLATE NOCASE`, args[0].type);
47231
47172
 
@@ -47268,40 +47209,40 @@ const compileOp = saveStack('op', (state, fieldRef, opData) => {
47268
47209
  switch (op) {
47269
47210
  case '$gte':
47270
47211
  {
47271
- let _valArray19 = valArray(state, [lhs, rhs], [null, lhs.type]),
47272
- _valArray20 = _slicedToArray(_valArray19, 2),
47273
- left = _valArray20[0],
47274
- right = _valArray20[1];
47212
+ let _valArray13 = valArray(state, [lhs, rhs], [null, lhs.type]),
47213
+ _valArray14 = _slicedToArray(_valArray13, 2),
47214
+ left = _valArray14[0],
47215
+ right = _valArray14[1];
47275
47216
 
47276
47217
  return `${left} >= ${right}`;
47277
47218
  }
47278
47219
 
47279
47220
  case '$lte':
47280
47221
  {
47281
- let _valArray21 = valArray(state, [lhs, rhs], [null, lhs.type]),
47282
- _valArray22 = _slicedToArray(_valArray21, 2),
47283
- left = _valArray22[0],
47284
- right = _valArray22[1];
47222
+ let _valArray15 = valArray(state, [lhs, rhs], [null, lhs.type]),
47223
+ _valArray16 = _slicedToArray(_valArray15, 2),
47224
+ left = _valArray16[0],
47225
+ right = _valArray16[1];
47285
47226
 
47286
47227
  return `${left} <= ${right}`;
47287
47228
  }
47288
47229
 
47289
47230
  case '$gt':
47290
47231
  {
47291
- let _valArray23 = valArray(state, [lhs, rhs], [null, lhs.type]),
47292
- _valArray24 = _slicedToArray(_valArray23, 2),
47293
- left = _valArray24[0],
47294
- right = _valArray24[1];
47232
+ let _valArray17 = valArray(state, [lhs, rhs], [null, lhs.type]),
47233
+ _valArray18 = _slicedToArray(_valArray17, 2),
47234
+ left = _valArray18[0],
47235
+ right = _valArray18[1];
47295
47236
 
47296
47237
  return `${left} > ${right}`;
47297
47238
  }
47298
47239
 
47299
47240
  case '$lt':
47300
47241
  {
47301
- let _valArray25 = valArray(state, [lhs, rhs], [null, lhs.type]),
47302
- _valArray26 = _slicedToArray(_valArray25, 2),
47303
- left = _valArray26[0],
47304
- right = _valArray26[1];
47242
+ let _valArray19 = valArray(state, [lhs, rhs], [null, lhs.type]),
47243
+ _valArray20 = _slicedToArray(_valArray19, 2),
47244
+ left = _valArray20[0],
47245
+ right = _valArray20[1];
47305
47246
 
47306
47247
  return `${left} < ${right}`;
47307
47248
  }
@@ -47312,10 +47253,10 @@ const compileOp = saveStack('op', (state, fieldRef, opData) => {
47312
47253
  return `${val(state, lhs)} IS NULL`;
47313
47254
  }
47314
47255
 
47315
- let _valArray27 = valArray(state, [lhs, rhs], [null, lhs.type]),
47316
- _valArray28 = _slicedToArray(_valArray27, 2),
47317
- left = _valArray28[0],
47318
- right = _valArray28[1];
47256
+ let _valArray21 = valArray(state, [lhs, rhs], [null, lhs.type]),
47257
+ _valArray22 = _slicedToArray(_valArray21, 2),
47258
+ left = _valArray22[0],
47259
+ right = _valArray22[1];
47319
47260
 
47320
47261
  if (rhs.type === 'param') {
47321
47262
  let orders = state.namedParameters.map(param => {
@@ -47333,10 +47274,10 @@ const compileOp = saveStack('op', (state, fieldRef, opData) => {
47333
47274
 
47334
47275
  case '$oneof':
47335
47276
  {
47336
- let _valArray29 = valArray(state, [lhs, rhs], [null, 'array']),
47337
- _valArray30 = _slicedToArray(_valArray29, 2),
47338
- left = _valArray30[0],
47339
- right = _valArray30[1]; // Dedupe the ids
47277
+ let _valArray23 = valArray(state, [lhs, rhs], [null, 'array']),
47278
+ _valArray24 = _slicedToArray(_valArray23, 2),
47279
+ left = _valArray24[0],
47280
+ right = _valArray24[1]; // Dedupe the ids
47340
47281
 
47341
47282
 
47342
47283
  let ids = [...new Set(right)];
@@ -47345,10 +47286,10 @@ const compileOp = saveStack('op', (state, fieldRef, opData) => {
47345
47286
 
47346
47287
  case '$like':
47347
47288
  {
47348
- let _valArray31 = valArray(state, [lhs, rhs], ['string', 'string']),
47349
- _valArray32 = _slicedToArray(_valArray31, 2),
47350
- left = _valArray32[0],
47351
- right = _valArray32[1];
47289
+ let _valArray25 = valArray(state, [lhs, rhs], ['string', 'string']),
47290
+ _valArray26 = _slicedToArray(_valArray25, 2),
47291
+ left = _valArray26[0],
47292
+ right = _valArray26[1];
47352
47293
 
47353
47294
  return `${left} LIKE ${right}`;
47354
47295
  }
@@ -47618,7 +47559,7 @@ function isAggregateQuery(queryState) {
47618
47559
  return queryState.selectExpressions.find(expr => {
47619
47560
  if (typeof expr !== 'string') {
47620
47561
  let _Object$entries$3 = _slicedToArray(Object.entries(expr)[0], 2),
47621
- name = _Object$entries$3[0],
47562
+ _ = _Object$entries$3[0],
47622
47563
  value = _Object$entries$3[1];
47623
47564
 
47624
47565
  return isAggregateFunction(value);
@@ -47673,15 +47614,13 @@ function compileQuery(queryState, schema, schemaConfig = {}) {
47673
47614
  groupExpressions = _customizeQuery.groupExpressions,
47674
47615
  orderExpressions = _customizeQuery.orderExpressions,
47675
47616
  limit = _customizeQuery.limit,
47676
- offset = _customizeQuery.offset,
47677
- calculation = _customizeQuery.calculation;
47617
+ offset = _customizeQuery.offset;
47678
47618
 
47679
47619
  let select = '';
47680
47620
  let where = '';
47681
47621
  let joins = '';
47682
47622
  let groupBy = '';
47683
47623
  let orderBy = '';
47684
- let dependences = [];
47685
47624
  let state = {
47686
47625
  schema,
47687
47626
  implicitTableName: tableName,
@@ -48221,8 +48160,7 @@ function isHappyPathQuery(queryState) {
48221
48160
  }
48222
48161
 
48223
48162
  async function execTransactionsGrouped(state, queryState, sql, params, splitType, outputTypes) {
48224
- let tableName = queryState.table,
48225
- withDead = queryState.withDead;
48163
+ let withDead = queryState.withDead;
48226
48164
  let whereDead = withDead ? '' : `AND ${sql.from}.tombstone = 0`;
48227
48165
 
48228
48166
  if (Object(_compiler__WEBPACK_IMPORTED_MODULE_2__["isAggregateQuery"])(queryState)) {
@@ -48290,7 +48228,6 @@ async function execTransactionsGrouped(state, queryState, sql, params, splitType
48290
48228
  WHERE ${where} ${whereDead}
48291
48229
  ${sql.orderBy}
48292
48230
  `;
48293
- let start = Date.now();
48294
48231
  let allRows = await _db__WEBPACK_IMPORTED_MODULE_0__["all"](finalSql); // Group the parents and children up
48295
48232
 
48296
48233
  let _allRows$reduce = allRows.reduce((acc, trans) => {
@@ -48558,9 +48495,7 @@ const schemaConfig = {
48558
48495
  },
48559
48496
 
48560
48497
  customizeQuery(queryState) {
48561
- let tableName = queryState.table,
48562
- _queryState$tableOpti = queryState.tableOptions,
48563
- tableOptions = _queryState$tableOpti === void 0 ? {} : _queryState$tableOpti;
48498
+ let tableName = queryState.table;
48564
48499
 
48565
48500
  function orderBy(orders) {
48566
48501
  // If order was specified, always add id as the last sort to make
@@ -49068,11 +49003,12 @@ function stopBackupService() {
49068
49003
  /*!*********************************************************!*\
49069
49004
  !*** ./packages/loot-core/src/server/budget/actions.js ***!
49070
49005
  \*********************************************************/
49071
- /*! exports provided: getBudget, setBudget, setBuffer, copyPreviousMonth, setZero, set3MonthAvg, holdForNextMonth, resetHold, coverOverspending, transferAvailable, transferCategory, setCategoryCarryover */
49006
+ /*! exports provided: getSheetValue, getBudget, setBudget, setBuffer, copyPreviousMonth, setZero, set3MonthAvg, holdForNextMonth, resetHold, coverOverspending, transferAvailable, transferCategory, setCategoryCarryover */
49072
49007
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
49073
49008
 
49074
49009
  "use strict";
49075
49010
  __webpack_require__.r(__webpack_exports__);
49011
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getSheetValue", function() { return getSheetValue; });
49076
49012
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getBudget", function() { return getBudget; });
49077
49013
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setBudget", function() { return setBudget; });
49078
49014
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setBuffer", function() { return setBuffer; });
@@ -49097,7 +49033,6 @@ __webpack_require__.r(__webpack_exports__);
49097
49033
 
49098
49034
 
49099
49035
 
49100
-
49101
49036
  async function getSheetValue(sheetName, cell) {
49102
49037
  const node = await _sheet__WEBPACK_IMPORTED_MODULE_4__["getCell"](sheetName, cell);
49103
49038
  return Object(_shared_util__WEBPACK_IMPORTED_MODULE_1__["safeNumber"])(typeof node.value === 'number' ? node.value : 0);
@@ -49106,7 +49041,6 @@ async function getSheetValue(sheetName, cell) {
49106
49041
  // and you shouldn't be allowed to pull non-existant money from
49107
49042
  // leftover.
49108
49043
 
49109
-
49110
49044
  function calcBufferedAmount(toBudget, buffered, amount) {
49111
49045
  amount = Math.min(Math.max(amount, -buffered), Math.max(toBudget, 0));
49112
49046
  return buffered + amount;
@@ -49126,13 +49060,6 @@ function isReflectBudget() {
49126
49060
  return budgetType === 'report';
49127
49061
  }
49128
49062
 
49129
- function isZeroBudget() {
49130
- let _prefs$getPrefs2 = _prefs__WEBPACK_IMPORTED_MODULE_3__["getPrefs"](),
49131
- budgetType = _prefs$getPrefs2.budgetType;
49132
-
49133
- return budgetType === 'rollover';
49134
- }
49135
-
49136
49063
  function dbMonth(month) {
49137
49064
  return parseInt(month.replace('-', ''));
49138
49065
  }
@@ -49410,6 +49337,8 @@ __webpack_require__.r(__webpack_exports__);
49410
49337
  /* harmony import */ var _mutators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mutators */ "./packages/loot-core/src/server/mutators.js");
49411
49338
  /* harmony import */ var _undo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../undo */ "./packages/loot-core/src/server/undo.js");
49412
49339
  /* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./actions */ "./packages/loot-core/src/server/budget/actions.js");
49340
+ /* harmony import */ var _goaltemplates__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./goaltemplates */ "./packages/loot-core/src/server/budget/goaltemplates.js");
49341
+
49413
49342
 
49414
49343
 
49415
49344
 
@@ -49419,6 +49348,8 @@ app.method('budget/budget-amount', Object(_mutators__WEBPACK_IMPORTED_MODULE_1__
49419
49348
  app.method('budget/copy-previous-month', Object(_mutators__WEBPACK_IMPORTED_MODULE_1__["mutator"])(Object(_undo__WEBPACK_IMPORTED_MODULE_2__["undoable"])(_actions__WEBPACK_IMPORTED_MODULE_3__["copyPreviousMonth"])));
49420
49349
  app.method('budget/set-zero', Object(_mutators__WEBPACK_IMPORTED_MODULE_1__["mutator"])(Object(_undo__WEBPACK_IMPORTED_MODULE_2__["undoable"])(_actions__WEBPACK_IMPORTED_MODULE_3__["setZero"])));
49421
49350
  app.method('budget/set-3month-avg', Object(_mutators__WEBPACK_IMPORTED_MODULE_1__["mutator"])(Object(_undo__WEBPACK_IMPORTED_MODULE_2__["undoable"])(_actions__WEBPACK_IMPORTED_MODULE_3__["set3MonthAvg"])));
49351
+ app.method('budget/apply-goal-template', Object(_mutators__WEBPACK_IMPORTED_MODULE_1__["mutator"])(Object(_undo__WEBPACK_IMPORTED_MODULE_2__["undoable"])(_goaltemplates__WEBPACK_IMPORTED_MODULE_4__["applyTemplate"])));
49352
+ app.method('budget/overwrite-goal-template', Object(_mutators__WEBPACK_IMPORTED_MODULE_1__["mutator"])(Object(_undo__WEBPACK_IMPORTED_MODULE_2__["undoable"])(_goaltemplates__WEBPACK_IMPORTED_MODULE_4__["overwriteTemplate"])));
49422
49353
  app.method('budget/hold-for-next-month', Object(_mutators__WEBPACK_IMPORTED_MODULE_1__["mutator"])(Object(_undo__WEBPACK_IMPORTED_MODULE_2__["undoable"])(_actions__WEBPACK_IMPORTED_MODULE_3__["holdForNextMonth"])));
49423
49354
  app.method('budget/reset-hold', Object(_mutators__WEBPACK_IMPORTED_MODULE_1__["mutator"])(Object(_undo__WEBPACK_IMPORTED_MODULE_2__["undoable"])(_actions__WEBPACK_IMPORTED_MODULE_3__["resetHold"])));
49424
49355
  app.method('budget/cover-overspending', Object(_mutators__WEBPACK_IMPORTED_MODULE_1__["mutator"])(Object(_undo__WEBPACK_IMPORTED_MODULE_2__["undoable"])(_actions__WEBPACK_IMPORTED_MODULE_3__["coverOverspending"])));
@@ -49482,21 +49413,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
49482
49413
 
49483
49414
 
49484
49415
 
49485
-
49486
- function mergeUpdates(updates) {
49487
- const merged = {};
49488
- updates.forEach(update => {
49489
- Object.keys(update).forEach(sheet => {
49490
- if (merged[sheet]) {
49491
- merged[sheet] = _objectSpread(_objectSpread({}, merged[sheet]), update[sheet]);
49492
- } else {
49493
- merged[sheet] = update[sheet];
49494
- }
49495
- });
49496
- });
49497
- return merged;
49498
- }
49499
-
49500
49416
  function getBudgetType() {
49501
49417
  let meta = _sheet__WEBPACK_IMPORTED_MODULE_3__["get"]().meta();
49502
49418
  return meta.budgetType || 'rollover';
@@ -49877,6 +49793,1864 @@ async function setType(type) {
49877
49793
 
49878
49794
  /***/ }),
49879
49795
 
49796
+ /***/ "./packages/loot-core/src/server/budget/goal-template.pegjs":
49797
+ /*!******************************************************************!*\
49798
+ !*** ./packages/loot-core/src/server/budget/goal-template.pegjs ***!
49799
+ \******************************************************************/
49800
+ /*! no static exports found */
49801
+ /***/ (function(module, exports, __webpack_require__) {
49802
+
49803
+ "use strict";
49804
+ /*
49805
+ * Generated by PEG.js 0.10.0.
49806
+ *
49807
+ * http://pegjs.org/
49808
+ */
49809
+
49810
+
49811
+
49812
+ function peg$subclass(child, parent) {
49813
+ function ctor() { this.constructor = child; }
49814
+ ctor.prototype = parent.prototype;
49815
+ child.prototype = new ctor();
49816
+ }
49817
+
49818
+ function peg$SyntaxError(message, expected, found, location) {
49819
+ this.message = message;
49820
+ this.expected = expected;
49821
+ this.found = found;
49822
+ this.location = location;
49823
+ this.name = "SyntaxError";
49824
+
49825
+ if (typeof Error.captureStackTrace === "function") {
49826
+ Error.captureStackTrace(this, peg$SyntaxError);
49827
+ }
49828
+ }
49829
+
49830
+ peg$subclass(peg$SyntaxError, Error);
49831
+
49832
+ peg$SyntaxError.buildMessage = function(expected, found) {
49833
+ var DESCRIBE_EXPECTATION_FNS = {
49834
+ literal: function(expectation) {
49835
+ return "\"" + literalEscape(expectation.text) + "\"";
49836
+ },
49837
+
49838
+ "class": function(expectation) {
49839
+ var escapedParts = "",
49840
+ i;
49841
+
49842
+ for (i = 0; i < expectation.parts.length; i++) {
49843
+ escapedParts += expectation.parts[i] instanceof Array
49844
+ ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
49845
+ : classEscape(expectation.parts[i]);
49846
+ }
49847
+
49848
+ return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
49849
+ },
49850
+
49851
+ any: function(expectation) {
49852
+ return "any character";
49853
+ },
49854
+
49855
+ end: function(expectation) {
49856
+ return "end of input";
49857
+ },
49858
+
49859
+ other: function(expectation) {
49860
+ return expectation.description;
49861
+ }
49862
+ };
49863
+
49864
+ function hex(ch) {
49865
+ return ch.charCodeAt(0).toString(16).toUpperCase();
49866
+ }
49867
+
49868
+ function literalEscape(s) {
49869
+ return s
49870
+ .replace(/\\/g, '\\\\')
49871
+ .replace(/"/g, '\\"')
49872
+ .replace(/\0/g, '\\0')
49873
+ .replace(/\t/g, '\\t')
49874
+ .replace(/\n/g, '\\n')
49875
+ .replace(/\r/g, '\\r')
49876
+ .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
49877
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
49878
+ }
49879
+
49880
+ function classEscape(s) {
49881
+ return s
49882
+ .replace(/\\/g, '\\\\')
49883
+ .replace(/\]/g, '\\]')
49884
+ .replace(/\^/g, '\\^')
49885
+ .replace(/-/g, '\\-')
49886
+ .replace(/\0/g, '\\0')
49887
+ .replace(/\t/g, '\\t')
49888
+ .replace(/\n/g, '\\n')
49889
+ .replace(/\r/g, '\\r')
49890
+ .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
49891
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
49892
+ }
49893
+
49894
+ function describeExpectation(expectation) {
49895
+ return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
49896
+ }
49897
+
49898
+ function describeExpected(expected) {
49899
+ var descriptions = new Array(expected.length),
49900
+ i, j;
49901
+
49902
+ for (i = 0; i < expected.length; i++) {
49903
+ descriptions[i] = describeExpectation(expected[i]);
49904
+ }
49905
+
49906
+ descriptions.sort();
49907
+
49908
+ if (descriptions.length > 0) {
49909
+ for (i = 1, j = 1; i < descriptions.length; i++) {
49910
+ if (descriptions[i - 1] !== descriptions[i]) {
49911
+ descriptions[j] = descriptions[i];
49912
+ j++;
49913
+ }
49914
+ }
49915
+ descriptions.length = j;
49916
+ }
49917
+
49918
+ switch (descriptions.length) {
49919
+ case 1:
49920
+ return descriptions[0];
49921
+
49922
+ case 2:
49923
+ return descriptions[0] + " or " + descriptions[1];
49924
+
49925
+ default:
49926
+ return descriptions.slice(0, -1).join(", ")
49927
+ + ", or "
49928
+ + descriptions[descriptions.length - 1];
49929
+ }
49930
+ }
49931
+
49932
+ function describeFound(found) {
49933
+ return found ? "\"" + literalEscape(found) + "\"" : "end of input";
49934
+ }
49935
+
49936
+ return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
49937
+ };
49938
+
49939
+ function peg$parse(input, options) {
49940
+ options = options !== void 0 ? options : {};
49941
+
49942
+ var peg$FAILED = {},
49943
+
49944
+ peg$startRuleFunctions = { expr: peg$parseexpr },
49945
+ peg$startRuleFunction = peg$parseexpr,
49946
+
49947
+ peg$c0 = /^[^\n]/,
49948
+ peg$c1 = peg$classExpectation(["\n"], true, false),
49949
+ peg$c2 = function(percent, category) { return { type: 'percentage', percent: +percent, category } },
49950
+ peg$c3 = function(amount, weeks, starting, limit) { return { type: 'week', amount, weeks, starting, limit } },
49951
+ peg$c4 = function(amount, month, from, repeat) { return {
49952
+ type: from ? 'spend' : 'by',
49953
+ amount,
49954
+ month,
49955
+ ...(repeat ? repeat[3] : {}),
49956
+ from
49957
+ } },
49958
+ peg$c5 = function(monthly, limit) { return { type: 'simple', monthly, limit } },
49959
+ peg$c6 = function(limit) { return { type: 'simple', limit } },
49960
+ peg$c7 = peg$otherExpectation("repeat interval"),
49961
+ peg$c8 = "month",
49962
+ peg$c9 = peg$literalExpectation("month", false),
49963
+ peg$c10 = function() { return { annual: false } },
49964
+ peg$c11 = "months",
49965
+ peg$c12 = peg$literalExpectation("months", false),
49966
+ peg$c13 = function(months) { return { annual: false, repeat: +months } },
49967
+ peg$c14 = "year",
49968
+ peg$c15 = peg$literalExpectation("year", false),
49969
+ peg$c16 = function() { return { annual: true } },
49970
+ peg$c17 = "years",
49971
+ peg$c18 = peg$literalExpectation("years", false),
49972
+ peg$c19 = function(years) { return { annual: true, repeat: +years } },
49973
+ peg$c20 = function(amount) { return amount },
49974
+ peg$c21 = function() { return null },
49975
+ peg$c22 = function(n) { return +n },
49976
+ peg$c23 = "spend",
49977
+ peg$c24 = peg$literalExpectation("spend", false),
49978
+ peg$c25 = "from",
49979
+ peg$c26 = peg$literalExpectation("from", false),
49980
+ peg$c27 = function(month) { return month },
49981
+ peg$c28 = "week",
49982
+ peg$c29 = peg$literalExpectation("week", false),
49983
+ peg$c30 = "weeks",
49984
+ peg$c31 = peg$literalExpectation("weeks", false),
49985
+ peg$c32 = "by",
49986
+ peg$c33 = peg$literalExpectation("by", false),
49987
+ peg$c34 = "of",
49988
+ peg$c35 = peg$literalExpectation("of", false),
49989
+ peg$c36 = "repeat",
49990
+ peg$c37 = peg$literalExpectation("repeat", false),
49991
+ peg$c38 = "every",
49992
+ peg$c39 = peg$literalExpectation("every", false),
49993
+ peg$c40 = "starting",
49994
+ peg$c41 = peg$literalExpectation("starting", false),
49995
+ peg$c42 = "up",
49996
+ peg$c43 = peg$literalExpectation("up", false),
49997
+ peg$c44 = "to",
49998
+ peg$c45 = peg$literalExpectation("to", false),
49999
+ peg$c46 = peg$otherExpectation("space"),
50000
+ peg$c47 = " ",
50001
+ peg$c48 = peg$literalExpectation(" ", false),
50002
+ peg$c49 = peg$otherExpectation("digit"),
50003
+ peg$c50 = /^[0-9]/,
50004
+ peg$c51 = peg$classExpectation([["0", "9"]], false, false),
50005
+ peg$c52 = peg$otherExpectation("number"),
50006
+ peg$c53 = peg$otherExpectation("amount"),
50007
+ peg$c54 = ".",
50008
+ peg$c55 = peg$literalExpectation(".", false),
50009
+ peg$c56 = function(amount) { return +amount },
50010
+ peg$c57 = peg$otherExpectation("percentage"),
50011
+ peg$c58 = "%",
50012
+ peg$c59 = peg$literalExpectation("%", false),
50013
+ peg$c60 = function(percent) { return +percent },
50014
+ peg$c61 = peg$otherExpectation("year"),
50015
+ peg$c62 = peg$otherExpectation("month"),
50016
+ peg$c63 = "-",
50017
+ peg$c64 = peg$literalExpectation("-", false),
50018
+ peg$c65 = peg$otherExpectation("day"),
50019
+ peg$c66 = peg$otherExpectation("currency symbol"),
50020
+ peg$c67 = peg$anyExpectation(),
50021
+ peg$c68 = function(symbol) { return /\p{Sc}/u.test(symbol) },
50022
+
50023
+ peg$currPos = 0,
50024
+ peg$savedPos = 0,
50025
+ peg$posDetailsCache = [{ line: 1, column: 1 }],
50026
+ peg$maxFailPos = 0,
50027
+ peg$maxFailExpected = [],
50028
+ peg$silentFails = 0,
50029
+
50030
+ peg$result;
50031
+
50032
+ if ("startRule" in options) {
50033
+ if (!(options.startRule in peg$startRuleFunctions)) {
50034
+ throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
50035
+ }
50036
+
50037
+ peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
50038
+ }
50039
+
50040
+ function text() {
50041
+ return input.substring(peg$savedPos, peg$currPos);
50042
+ }
50043
+
50044
+ function location() {
50045
+ return peg$computeLocation(peg$savedPos, peg$currPos);
50046
+ }
50047
+
50048
+ function expected(description, location) {
50049
+ location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
50050
+
50051
+ throw peg$buildStructuredError(
50052
+ [peg$otherExpectation(description)],
50053
+ input.substring(peg$savedPos, peg$currPos),
50054
+ location
50055
+ );
50056
+ }
50057
+
50058
+ function error(message, location) {
50059
+ location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
50060
+
50061
+ throw peg$buildSimpleError(message, location);
50062
+ }
50063
+
50064
+ function peg$literalExpectation(text, ignoreCase) {
50065
+ return { type: "literal", text: text, ignoreCase: ignoreCase };
50066
+ }
50067
+
50068
+ function peg$classExpectation(parts, inverted, ignoreCase) {
50069
+ return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
50070
+ }
50071
+
50072
+ function peg$anyExpectation() {
50073
+ return { type: "any" };
50074
+ }
50075
+
50076
+ function peg$endExpectation() {
50077
+ return { type: "end" };
50078
+ }
50079
+
50080
+ function peg$otherExpectation(description) {
50081
+ return { type: "other", description: description };
50082
+ }
50083
+
50084
+ function peg$computePosDetails(pos) {
50085
+ var details = peg$posDetailsCache[pos], p;
50086
+
50087
+ if (details) {
50088
+ return details;
50089
+ } else {
50090
+ p = pos - 1;
50091
+ while (!peg$posDetailsCache[p]) {
50092
+ p--;
50093
+ }
50094
+
50095
+ details = peg$posDetailsCache[p];
50096
+ details = {
50097
+ line: details.line,
50098
+ column: details.column
50099
+ };
50100
+
50101
+ while (p < pos) {
50102
+ if (input.charCodeAt(p) === 10) {
50103
+ details.line++;
50104
+ details.column = 1;
50105
+ } else {
50106
+ details.column++;
50107
+ }
50108
+
50109
+ p++;
50110
+ }
50111
+
50112
+ peg$posDetailsCache[pos] = details;
50113
+ return details;
50114
+ }
50115
+ }
50116
+
50117
+ function peg$computeLocation(startPos, endPos) {
50118
+ var startPosDetails = peg$computePosDetails(startPos),
50119
+ endPosDetails = peg$computePosDetails(endPos);
50120
+
50121
+ return {
50122
+ start: {
50123
+ offset: startPos,
50124
+ line: startPosDetails.line,
50125
+ column: startPosDetails.column
50126
+ },
50127
+ end: {
50128
+ offset: endPos,
50129
+ line: endPosDetails.line,
50130
+ column: endPosDetails.column
50131
+ }
50132
+ };
50133
+ }
50134
+
50135
+ function peg$fail(expected) {
50136
+ if (peg$currPos < peg$maxFailPos) { return; }
50137
+
50138
+ if (peg$currPos > peg$maxFailPos) {
50139
+ peg$maxFailPos = peg$currPos;
50140
+ peg$maxFailExpected = [];
50141
+ }
50142
+
50143
+ peg$maxFailExpected.push(expected);
50144
+ }
50145
+
50146
+ function peg$buildSimpleError(message, location) {
50147
+ return new peg$SyntaxError(message, null, null, location);
50148
+ }
50149
+
50150
+ function peg$buildStructuredError(expected, found, location) {
50151
+ return new peg$SyntaxError(
50152
+ peg$SyntaxError.buildMessage(expected, found),
50153
+ expected,
50154
+ found,
50155
+ location
50156
+ );
50157
+ }
50158
+
50159
+ function peg$parseexpr() {
50160
+ var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11;
50161
+
50162
+ s0 = peg$currPos;
50163
+ s1 = peg$parsepercent();
50164
+ if (s1 !== peg$FAILED) {
50165
+ s2 = peg$parse_();
50166
+ if (s2 !== peg$FAILED) {
50167
+ s3 = peg$parseof();
50168
+ if (s3 !== peg$FAILED) {
50169
+ s4 = peg$parse_();
50170
+ if (s4 !== peg$FAILED) {
50171
+ s5 = peg$currPos;
50172
+ s6 = [];
50173
+ if (peg$c0.test(input.charAt(peg$currPos))) {
50174
+ s7 = input.charAt(peg$currPos);
50175
+ peg$currPos++;
50176
+ } else {
50177
+ s7 = peg$FAILED;
50178
+ if (peg$silentFails === 0) { peg$fail(peg$c1); }
50179
+ }
50180
+ while (s7 !== peg$FAILED) {
50181
+ s6.push(s7);
50182
+ if (peg$c0.test(input.charAt(peg$currPos))) {
50183
+ s7 = input.charAt(peg$currPos);
50184
+ peg$currPos++;
50185
+ } else {
50186
+ s7 = peg$FAILED;
50187
+ if (peg$silentFails === 0) { peg$fail(peg$c1); }
50188
+ }
50189
+ }
50190
+ if (s6 !== peg$FAILED) {
50191
+ s5 = input.substring(s5, peg$currPos);
50192
+ } else {
50193
+ s5 = s6;
50194
+ }
50195
+ if (s5 !== peg$FAILED) {
50196
+ peg$savedPos = s0;
50197
+ s1 = peg$c2(s1, s5);
50198
+ s0 = s1;
50199
+ } else {
50200
+ peg$currPos = s0;
50201
+ s0 = peg$FAILED;
50202
+ }
50203
+ } else {
50204
+ peg$currPos = s0;
50205
+ s0 = peg$FAILED;
50206
+ }
50207
+ } else {
50208
+ peg$currPos = s0;
50209
+ s0 = peg$FAILED;
50210
+ }
50211
+ } else {
50212
+ peg$currPos = s0;
50213
+ s0 = peg$FAILED;
50214
+ }
50215
+ } else {
50216
+ peg$currPos = s0;
50217
+ s0 = peg$FAILED;
50218
+ }
50219
+ if (s0 === peg$FAILED) {
50220
+ s0 = peg$currPos;
50221
+ s1 = peg$parseamount();
50222
+ if (s1 !== peg$FAILED) {
50223
+ s2 = peg$parse_();
50224
+ if (s2 !== peg$FAILED) {
50225
+ s3 = peg$parserepeatEvery();
50226
+ if (s3 !== peg$FAILED) {
50227
+ s4 = peg$parse_();
50228
+ if (s4 !== peg$FAILED) {
50229
+ s5 = peg$parseweekCount();
50230
+ if (s5 !== peg$FAILED) {
50231
+ s6 = peg$parse_();
50232
+ if (s6 !== peg$FAILED) {
50233
+ s7 = peg$parsestarting();
50234
+ if (s7 !== peg$FAILED) {
50235
+ s8 = peg$parse_();
50236
+ if (s8 !== peg$FAILED) {
50237
+ s9 = peg$parsedate();
50238
+ if (s9 !== peg$FAILED) {
50239
+ s10 = peg$parselimit();
50240
+ if (s10 === peg$FAILED) {
50241
+ s10 = null;
50242
+ }
50243
+ if (s10 !== peg$FAILED) {
50244
+ peg$savedPos = s0;
50245
+ s1 = peg$c3(s1, s5, s9, s10);
50246
+ s0 = s1;
50247
+ } else {
50248
+ peg$currPos = s0;
50249
+ s0 = peg$FAILED;
50250
+ }
50251
+ } else {
50252
+ peg$currPos = s0;
50253
+ s0 = peg$FAILED;
50254
+ }
50255
+ } else {
50256
+ peg$currPos = s0;
50257
+ s0 = peg$FAILED;
50258
+ }
50259
+ } else {
50260
+ peg$currPos = s0;
50261
+ s0 = peg$FAILED;
50262
+ }
50263
+ } else {
50264
+ peg$currPos = s0;
50265
+ s0 = peg$FAILED;
50266
+ }
50267
+ } else {
50268
+ peg$currPos = s0;
50269
+ s0 = peg$FAILED;
50270
+ }
50271
+ } else {
50272
+ peg$currPos = s0;
50273
+ s0 = peg$FAILED;
50274
+ }
50275
+ } else {
50276
+ peg$currPos = s0;
50277
+ s0 = peg$FAILED;
50278
+ }
50279
+ } else {
50280
+ peg$currPos = s0;
50281
+ s0 = peg$FAILED;
50282
+ }
50283
+ } else {
50284
+ peg$currPos = s0;
50285
+ s0 = peg$FAILED;
50286
+ }
50287
+ if (s0 === peg$FAILED) {
50288
+ s0 = peg$currPos;
50289
+ s1 = peg$parseamount();
50290
+ if (s1 !== peg$FAILED) {
50291
+ s2 = peg$parse_();
50292
+ if (s2 !== peg$FAILED) {
50293
+ s3 = peg$parseby();
50294
+ if (s3 !== peg$FAILED) {
50295
+ s4 = peg$parse_();
50296
+ if (s4 !== peg$FAILED) {
50297
+ s5 = peg$parsemonth();
50298
+ if (s5 !== peg$FAILED) {
50299
+ s6 = peg$parsespendFrom();
50300
+ if (s6 === peg$FAILED) {
50301
+ s6 = null;
50302
+ }
50303
+ if (s6 !== peg$FAILED) {
50304
+ s7 = peg$currPos;
50305
+ s8 = peg$parse_();
50306
+ if (s8 !== peg$FAILED) {
50307
+ s9 = peg$parserepeatEvery();
50308
+ if (s9 !== peg$FAILED) {
50309
+ s10 = peg$parse_();
50310
+ if (s10 !== peg$FAILED) {
50311
+ s11 = peg$parserepeat();
50312
+ if (s11 !== peg$FAILED) {
50313
+ s8 = [s8, s9, s10, s11];
50314
+ s7 = s8;
50315
+ } else {
50316
+ peg$currPos = s7;
50317
+ s7 = peg$FAILED;
50318
+ }
50319
+ } else {
50320
+ peg$currPos = s7;
50321
+ s7 = peg$FAILED;
50322
+ }
50323
+ } else {
50324
+ peg$currPos = s7;
50325
+ s7 = peg$FAILED;
50326
+ }
50327
+ } else {
50328
+ peg$currPos = s7;
50329
+ s7 = peg$FAILED;
50330
+ }
50331
+ if (s7 === peg$FAILED) {
50332
+ s7 = null;
50333
+ }
50334
+ if (s7 !== peg$FAILED) {
50335
+ peg$savedPos = s0;
50336
+ s1 = peg$c4(s1, s5, s6, s7);
50337
+ s0 = s1;
50338
+ } else {
50339
+ peg$currPos = s0;
50340
+ s0 = peg$FAILED;
50341
+ }
50342
+ } else {
50343
+ peg$currPos = s0;
50344
+ s0 = peg$FAILED;
50345
+ }
50346
+ } else {
50347
+ peg$currPos = s0;
50348
+ s0 = peg$FAILED;
50349
+ }
50350
+ } else {
50351
+ peg$currPos = s0;
50352
+ s0 = peg$FAILED;
50353
+ }
50354
+ } else {
50355
+ peg$currPos = s0;
50356
+ s0 = peg$FAILED;
50357
+ }
50358
+ } else {
50359
+ peg$currPos = s0;
50360
+ s0 = peg$FAILED;
50361
+ }
50362
+ } else {
50363
+ peg$currPos = s0;
50364
+ s0 = peg$FAILED;
50365
+ }
50366
+ if (s0 === peg$FAILED) {
50367
+ s0 = peg$currPos;
50368
+ s1 = peg$parseamount();
50369
+ if (s1 !== peg$FAILED) {
50370
+ s2 = peg$parselimit();
50371
+ if (s2 === peg$FAILED) {
50372
+ s2 = null;
50373
+ }
50374
+ if (s2 !== peg$FAILED) {
50375
+ peg$savedPos = s0;
50376
+ s1 = peg$c5(s1, s2);
50377
+ s0 = s1;
50378
+ } else {
50379
+ peg$currPos = s0;
50380
+ s0 = peg$FAILED;
50381
+ }
50382
+ } else {
50383
+ peg$currPos = s0;
50384
+ s0 = peg$FAILED;
50385
+ }
50386
+ if (s0 === peg$FAILED) {
50387
+ s0 = peg$currPos;
50388
+ s1 = peg$parseupTo();
50389
+ if (s1 !== peg$FAILED) {
50390
+ s2 = peg$parse_();
50391
+ if (s2 !== peg$FAILED) {
50392
+ s3 = peg$parseamount();
50393
+ if (s3 !== peg$FAILED) {
50394
+ peg$savedPos = s0;
50395
+ s1 = peg$c6(s3);
50396
+ s0 = s1;
50397
+ } else {
50398
+ peg$currPos = s0;
50399
+ s0 = peg$FAILED;
50400
+ }
50401
+ } else {
50402
+ peg$currPos = s0;
50403
+ s0 = peg$FAILED;
50404
+ }
50405
+ } else {
50406
+ peg$currPos = s0;
50407
+ s0 = peg$FAILED;
50408
+ }
50409
+ }
50410
+ }
50411
+ }
50412
+ }
50413
+
50414
+ return s0;
50415
+ }
50416
+
50417
+ function peg$parserepeat() {
50418
+ var s0, s1, s2, s3;
50419
+
50420
+ peg$silentFails++;
50421
+ s0 = peg$currPos;
50422
+ if (input.substr(peg$currPos, 5) === peg$c8) {
50423
+ s1 = peg$c8;
50424
+ peg$currPos += 5;
50425
+ } else {
50426
+ s1 = peg$FAILED;
50427
+ if (peg$silentFails === 0) { peg$fail(peg$c9); }
50428
+ }
50429
+ if (s1 !== peg$FAILED) {
50430
+ peg$savedPos = s0;
50431
+ s1 = peg$c10();
50432
+ }
50433
+ s0 = s1;
50434
+ if (s0 === peg$FAILED) {
50435
+ s0 = peg$currPos;
50436
+ s1 = peg$parsed();
50437
+ if (s1 !== peg$FAILED) {
50438
+ s2 = peg$parse_();
50439
+ if (s2 !== peg$FAILED) {
50440
+ if (input.substr(peg$currPos, 6) === peg$c11) {
50441
+ s3 = peg$c11;
50442
+ peg$currPos += 6;
50443
+ } else {
50444
+ s3 = peg$FAILED;
50445
+ if (peg$silentFails === 0) { peg$fail(peg$c12); }
50446
+ }
50447
+ if (s3 !== peg$FAILED) {
50448
+ peg$savedPos = s0;
50449
+ s1 = peg$c13(s1);
50450
+ s0 = s1;
50451
+ } else {
50452
+ peg$currPos = s0;
50453
+ s0 = peg$FAILED;
50454
+ }
50455
+ } else {
50456
+ peg$currPos = s0;
50457
+ s0 = peg$FAILED;
50458
+ }
50459
+ } else {
50460
+ peg$currPos = s0;
50461
+ s0 = peg$FAILED;
50462
+ }
50463
+ if (s0 === peg$FAILED) {
50464
+ s0 = peg$currPos;
50465
+ if (input.substr(peg$currPos, 4) === peg$c14) {
50466
+ s1 = peg$c14;
50467
+ peg$currPos += 4;
50468
+ } else {
50469
+ s1 = peg$FAILED;
50470
+ if (peg$silentFails === 0) { peg$fail(peg$c15); }
50471
+ }
50472
+ if (s1 !== peg$FAILED) {
50473
+ peg$savedPos = s0;
50474
+ s1 = peg$c16();
50475
+ }
50476
+ s0 = s1;
50477
+ if (s0 === peg$FAILED) {
50478
+ s0 = peg$currPos;
50479
+ s1 = peg$parsed();
50480
+ if (s1 !== peg$FAILED) {
50481
+ s2 = peg$parse_();
50482
+ if (s2 !== peg$FAILED) {
50483
+ if (input.substr(peg$currPos, 5) === peg$c17) {
50484
+ s3 = peg$c17;
50485
+ peg$currPos += 5;
50486
+ } else {
50487
+ s3 = peg$FAILED;
50488
+ if (peg$silentFails === 0) { peg$fail(peg$c18); }
50489
+ }
50490
+ if (s3 !== peg$FAILED) {
50491
+ peg$savedPos = s0;
50492
+ s1 = peg$c19(s1);
50493
+ s0 = s1;
50494
+ } else {
50495
+ peg$currPos = s0;
50496
+ s0 = peg$FAILED;
50497
+ }
50498
+ } else {
50499
+ peg$currPos = s0;
50500
+ s0 = peg$FAILED;
50501
+ }
50502
+ } else {
50503
+ peg$currPos = s0;
50504
+ s0 = peg$FAILED;
50505
+ }
50506
+ }
50507
+ }
50508
+ }
50509
+ peg$silentFails--;
50510
+ if (s0 === peg$FAILED) {
50511
+ s1 = peg$FAILED;
50512
+ if (peg$silentFails === 0) { peg$fail(peg$c7); }
50513
+ }
50514
+
50515
+ return s0;
50516
+ }
50517
+
50518
+ function peg$parselimit() {
50519
+ var s0, s1, s2, s3, s4;
50520
+
50521
+ s0 = peg$currPos;
50522
+ s1 = peg$parse_();
50523
+ if (s1 !== peg$FAILED) {
50524
+ s2 = peg$parseupTo();
50525
+ if (s2 === peg$FAILED) {
50526
+ s2 = null;
50527
+ }
50528
+ if (s2 !== peg$FAILED) {
50529
+ s3 = peg$parse_();
50530
+ if (s3 !== peg$FAILED) {
50531
+ s4 = peg$parseamount();
50532
+ if (s4 !== peg$FAILED) {
50533
+ peg$savedPos = s0;
50534
+ s1 = peg$c20(s4);
50535
+ s0 = s1;
50536
+ } else {
50537
+ peg$currPos = s0;
50538
+ s0 = peg$FAILED;
50539
+ }
50540
+ } else {
50541
+ peg$currPos = s0;
50542
+ s0 = peg$FAILED;
50543
+ }
50544
+ } else {
50545
+ peg$currPos = s0;
50546
+ s0 = peg$FAILED;
50547
+ }
50548
+ } else {
50549
+ peg$currPos = s0;
50550
+ s0 = peg$FAILED;
50551
+ }
50552
+
50553
+ return s0;
50554
+ }
50555
+
50556
+ function peg$parseweekCount() {
50557
+ var s0, s1, s2, s3;
50558
+
50559
+ s0 = peg$currPos;
50560
+ s1 = peg$parseweek();
50561
+ if (s1 !== peg$FAILED) {
50562
+ peg$savedPos = s0;
50563
+ s1 = peg$c21();
50564
+ }
50565
+ s0 = s1;
50566
+ if (s0 === peg$FAILED) {
50567
+ s0 = peg$currPos;
50568
+ s1 = peg$parsenumber();
50569
+ if (s1 !== peg$FAILED) {
50570
+ s2 = peg$parse_();
50571
+ if (s2 !== peg$FAILED) {
50572
+ s3 = peg$parseweeks();
50573
+ if (s3 !== peg$FAILED) {
50574
+ peg$savedPos = s0;
50575
+ s1 = peg$c22(s1);
50576
+ s0 = s1;
50577
+ } else {
50578
+ peg$currPos = s0;
50579
+ s0 = peg$FAILED;
50580
+ }
50581
+ } else {
50582
+ peg$currPos = s0;
50583
+ s0 = peg$FAILED;
50584
+ }
50585
+ } else {
50586
+ peg$currPos = s0;
50587
+ s0 = peg$FAILED;
50588
+ }
50589
+ }
50590
+
50591
+ return s0;
50592
+ }
50593
+
50594
+ function peg$parsespendFrom() {
50595
+ var s0, s1, s2, s3, s4, s5, s6;
50596
+
50597
+ s0 = peg$currPos;
50598
+ s1 = peg$parse_();
50599
+ if (s1 !== peg$FAILED) {
50600
+ if (input.substr(peg$currPos, 5) === peg$c23) {
50601
+ s2 = peg$c23;
50602
+ peg$currPos += 5;
50603
+ } else {
50604
+ s2 = peg$FAILED;
50605
+ if (peg$silentFails === 0) { peg$fail(peg$c24); }
50606
+ }
50607
+ if (s2 !== peg$FAILED) {
50608
+ s3 = peg$parse_();
50609
+ if (s3 !== peg$FAILED) {
50610
+ if (input.substr(peg$currPos, 4) === peg$c25) {
50611
+ s4 = peg$c25;
50612
+ peg$currPos += 4;
50613
+ } else {
50614
+ s4 = peg$FAILED;
50615
+ if (peg$silentFails === 0) { peg$fail(peg$c26); }
50616
+ }
50617
+ if (s4 !== peg$FAILED) {
50618
+ s5 = peg$parse_();
50619
+ if (s5 !== peg$FAILED) {
50620
+ s6 = peg$parsemonth();
50621
+ if (s6 !== peg$FAILED) {
50622
+ peg$savedPos = s0;
50623
+ s1 = peg$c27(s6);
50624
+ s0 = s1;
50625
+ } else {
50626
+ peg$currPos = s0;
50627
+ s0 = peg$FAILED;
50628
+ }
50629
+ } else {
50630
+ peg$currPos = s0;
50631
+ s0 = peg$FAILED;
50632
+ }
50633
+ } else {
50634
+ peg$currPos = s0;
50635
+ s0 = peg$FAILED;
50636
+ }
50637
+ } else {
50638
+ peg$currPos = s0;
50639
+ s0 = peg$FAILED;
50640
+ }
50641
+ } else {
50642
+ peg$currPos = s0;
50643
+ s0 = peg$FAILED;
50644
+ }
50645
+ } else {
50646
+ peg$currPos = s0;
50647
+ s0 = peg$FAILED;
50648
+ }
50649
+
50650
+ return s0;
50651
+ }
50652
+
50653
+ function peg$parseweek() {
50654
+ var s0;
50655
+
50656
+ if (input.substr(peg$currPos, 4) === peg$c28) {
50657
+ s0 = peg$c28;
50658
+ peg$currPos += 4;
50659
+ } else {
50660
+ s0 = peg$FAILED;
50661
+ if (peg$silentFails === 0) { peg$fail(peg$c29); }
50662
+ }
50663
+
50664
+ return s0;
50665
+ }
50666
+
50667
+ function peg$parseweeks() {
50668
+ var s0;
50669
+
50670
+ if (input.substr(peg$currPos, 5) === peg$c30) {
50671
+ s0 = peg$c30;
50672
+ peg$currPos += 5;
50673
+ } else {
50674
+ s0 = peg$FAILED;
50675
+ if (peg$silentFails === 0) { peg$fail(peg$c31); }
50676
+ }
50677
+
50678
+ return s0;
50679
+ }
50680
+
50681
+ function peg$parseby() {
50682
+ var s0;
50683
+
50684
+ if (input.substr(peg$currPos, 2) === peg$c32) {
50685
+ s0 = peg$c32;
50686
+ peg$currPos += 2;
50687
+ } else {
50688
+ s0 = peg$FAILED;
50689
+ if (peg$silentFails === 0) { peg$fail(peg$c33); }
50690
+ }
50691
+
50692
+ return s0;
50693
+ }
50694
+
50695
+ function peg$parseof() {
50696
+ var s0;
50697
+
50698
+ if (input.substr(peg$currPos, 2) === peg$c34) {
50699
+ s0 = peg$c34;
50700
+ peg$currPos += 2;
50701
+ } else {
50702
+ s0 = peg$FAILED;
50703
+ if (peg$silentFails === 0) { peg$fail(peg$c35); }
50704
+ }
50705
+
50706
+ return s0;
50707
+ }
50708
+
50709
+ function peg$parserepeatEvery() {
50710
+ var s0, s1, s2, s3;
50711
+
50712
+ s0 = peg$currPos;
50713
+ if (input.substr(peg$currPos, 6) === peg$c36) {
50714
+ s1 = peg$c36;
50715
+ peg$currPos += 6;
50716
+ } else {
50717
+ s1 = peg$FAILED;
50718
+ if (peg$silentFails === 0) { peg$fail(peg$c37); }
50719
+ }
50720
+ if (s1 !== peg$FAILED) {
50721
+ s2 = peg$parse_();
50722
+ if (s2 !== peg$FAILED) {
50723
+ if (input.substr(peg$currPos, 5) === peg$c38) {
50724
+ s3 = peg$c38;
50725
+ peg$currPos += 5;
50726
+ } else {
50727
+ s3 = peg$FAILED;
50728
+ if (peg$silentFails === 0) { peg$fail(peg$c39); }
50729
+ }
50730
+ if (s3 !== peg$FAILED) {
50731
+ s1 = [s1, s2, s3];
50732
+ s0 = s1;
50733
+ } else {
50734
+ peg$currPos = s0;
50735
+ s0 = peg$FAILED;
50736
+ }
50737
+ } else {
50738
+ peg$currPos = s0;
50739
+ s0 = peg$FAILED;
50740
+ }
50741
+ } else {
50742
+ peg$currPos = s0;
50743
+ s0 = peg$FAILED;
50744
+ }
50745
+
50746
+ return s0;
50747
+ }
50748
+
50749
+ function peg$parsestarting() {
50750
+ var s0;
50751
+
50752
+ if (input.substr(peg$currPos, 8) === peg$c40) {
50753
+ s0 = peg$c40;
50754
+ peg$currPos += 8;
50755
+ } else {
50756
+ s0 = peg$FAILED;
50757
+ if (peg$silentFails === 0) { peg$fail(peg$c41); }
50758
+ }
50759
+
50760
+ return s0;
50761
+ }
50762
+
50763
+ function peg$parseupTo() {
50764
+ var s0, s1, s2, s3;
50765
+
50766
+ s0 = peg$currPos;
50767
+ if (input.substr(peg$currPos, 2) === peg$c42) {
50768
+ s1 = peg$c42;
50769
+ peg$currPos += 2;
50770
+ } else {
50771
+ s1 = peg$FAILED;
50772
+ if (peg$silentFails === 0) { peg$fail(peg$c43); }
50773
+ }
50774
+ if (s1 !== peg$FAILED) {
50775
+ s2 = peg$parse_();
50776
+ if (s2 !== peg$FAILED) {
50777
+ if (input.substr(peg$currPos, 2) === peg$c44) {
50778
+ s3 = peg$c44;
50779
+ peg$currPos += 2;
50780
+ } else {
50781
+ s3 = peg$FAILED;
50782
+ if (peg$silentFails === 0) { peg$fail(peg$c45); }
50783
+ }
50784
+ if (s3 !== peg$FAILED) {
50785
+ s1 = [s1, s2, s3];
50786
+ s0 = s1;
50787
+ } else {
50788
+ peg$currPos = s0;
50789
+ s0 = peg$FAILED;
50790
+ }
50791
+ } else {
50792
+ peg$currPos = s0;
50793
+ s0 = peg$FAILED;
50794
+ }
50795
+ } else {
50796
+ peg$currPos = s0;
50797
+ s0 = peg$FAILED;
50798
+ }
50799
+
50800
+ return s0;
50801
+ }
50802
+
50803
+ function peg$parse_() {
50804
+ var s0, s1;
50805
+
50806
+ peg$silentFails++;
50807
+ s0 = [];
50808
+ if (input.charCodeAt(peg$currPos) === 32) {
50809
+ s1 = peg$c47;
50810
+ peg$currPos++;
50811
+ } else {
50812
+ s1 = peg$FAILED;
50813
+ if (peg$silentFails === 0) { peg$fail(peg$c48); }
50814
+ }
50815
+ if (s1 !== peg$FAILED) {
50816
+ while (s1 !== peg$FAILED) {
50817
+ s0.push(s1);
50818
+ if (input.charCodeAt(peg$currPos) === 32) {
50819
+ s1 = peg$c47;
50820
+ peg$currPos++;
50821
+ } else {
50822
+ s1 = peg$FAILED;
50823
+ if (peg$silentFails === 0) { peg$fail(peg$c48); }
50824
+ }
50825
+ }
50826
+ } else {
50827
+ s0 = peg$FAILED;
50828
+ }
50829
+ peg$silentFails--;
50830
+ if (s0 === peg$FAILED) {
50831
+ s1 = peg$FAILED;
50832
+ if (peg$silentFails === 0) { peg$fail(peg$c46); }
50833
+ }
50834
+
50835
+ return s0;
50836
+ }
50837
+
50838
+ function peg$parsed() {
50839
+ var s0, s1;
50840
+
50841
+ peg$silentFails++;
50842
+ if (peg$c50.test(input.charAt(peg$currPos))) {
50843
+ s0 = input.charAt(peg$currPos);
50844
+ peg$currPos++;
50845
+ } else {
50846
+ s0 = peg$FAILED;
50847
+ if (peg$silentFails === 0) { peg$fail(peg$c51); }
50848
+ }
50849
+ peg$silentFails--;
50850
+ if (s0 === peg$FAILED) {
50851
+ s1 = peg$FAILED;
50852
+ if (peg$silentFails === 0) { peg$fail(peg$c49); }
50853
+ }
50854
+
50855
+ return s0;
50856
+ }
50857
+
50858
+ function peg$parsenumber() {
50859
+ var s0, s1, s2;
50860
+
50861
+ peg$silentFails++;
50862
+ s0 = peg$currPos;
50863
+ s1 = [];
50864
+ s2 = peg$parsed();
50865
+ if (s2 !== peg$FAILED) {
50866
+ while (s2 !== peg$FAILED) {
50867
+ s1.push(s2);
50868
+ s2 = peg$parsed();
50869
+ }
50870
+ } else {
50871
+ s1 = peg$FAILED;
50872
+ }
50873
+ if (s1 !== peg$FAILED) {
50874
+ s0 = input.substring(s0, peg$currPos);
50875
+ } else {
50876
+ s0 = s1;
50877
+ }
50878
+ peg$silentFails--;
50879
+ if (s0 === peg$FAILED) {
50880
+ s1 = peg$FAILED;
50881
+ if (peg$silentFails === 0) { peg$fail(peg$c52); }
50882
+ }
50883
+
50884
+ return s0;
50885
+ }
50886
+
50887
+ function peg$parseamount() {
50888
+ var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
50889
+
50890
+ peg$silentFails++;
50891
+ s0 = peg$currPos;
50892
+ s1 = peg$parsecurrencySymbol();
50893
+ if (s1 === peg$FAILED) {
50894
+ s1 = null;
50895
+ }
50896
+ if (s1 !== peg$FAILED) {
50897
+ s2 = peg$parse_();
50898
+ if (s2 === peg$FAILED) {
50899
+ s2 = null;
50900
+ }
50901
+ if (s2 !== peg$FAILED) {
50902
+ s3 = peg$currPos;
50903
+ s4 = peg$currPos;
50904
+ s5 = [];
50905
+ s6 = peg$parsed();
50906
+ if (s6 !== peg$FAILED) {
50907
+ while (s6 !== peg$FAILED) {
50908
+ s5.push(s6);
50909
+ s6 = peg$parsed();
50910
+ }
50911
+ } else {
50912
+ s5 = peg$FAILED;
50913
+ }
50914
+ if (s5 !== peg$FAILED) {
50915
+ s6 = peg$currPos;
50916
+ if (input.charCodeAt(peg$currPos) === 46) {
50917
+ s7 = peg$c54;
50918
+ peg$currPos++;
50919
+ } else {
50920
+ s7 = peg$FAILED;
50921
+ if (peg$silentFails === 0) { peg$fail(peg$c55); }
50922
+ }
50923
+ if (s7 !== peg$FAILED) {
50924
+ s8 = peg$parsed();
50925
+ if (s8 !== peg$FAILED) {
50926
+ s9 = peg$parsed();
50927
+ if (s9 !== peg$FAILED) {
50928
+ s7 = [s7, s8, s9];
50929
+ s6 = s7;
50930
+ } else {
50931
+ peg$currPos = s6;
50932
+ s6 = peg$FAILED;
50933
+ }
50934
+ } else {
50935
+ peg$currPos = s6;
50936
+ s6 = peg$FAILED;
50937
+ }
50938
+ } else {
50939
+ peg$currPos = s6;
50940
+ s6 = peg$FAILED;
50941
+ }
50942
+ if (s6 === peg$FAILED) {
50943
+ s6 = null;
50944
+ }
50945
+ if (s6 !== peg$FAILED) {
50946
+ s5 = [s5, s6];
50947
+ s4 = s5;
50948
+ } else {
50949
+ peg$currPos = s4;
50950
+ s4 = peg$FAILED;
50951
+ }
50952
+ } else {
50953
+ peg$currPos = s4;
50954
+ s4 = peg$FAILED;
50955
+ }
50956
+ if (s4 !== peg$FAILED) {
50957
+ s3 = input.substring(s3, peg$currPos);
50958
+ } else {
50959
+ s3 = s4;
50960
+ }
50961
+ if (s3 !== peg$FAILED) {
50962
+ peg$savedPos = s0;
50963
+ s1 = peg$c56(s3);
50964
+ s0 = s1;
50965
+ } else {
50966
+ peg$currPos = s0;
50967
+ s0 = peg$FAILED;
50968
+ }
50969
+ } else {
50970
+ peg$currPos = s0;
50971
+ s0 = peg$FAILED;
50972
+ }
50973
+ } else {
50974
+ peg$currPos = s0;
50975
+ s0 = peg$FAILED;
50976
+ }
50977
+ peg$silentFails--;
50978
+ if (s0 === peg$FAILED) {
50979
+ s1 = peg$FAILED;
50980
+ if (peg$silentFails === 0) { peg$fail(peg$c53); }
50981
+ }
50982
+
50983
+ return s0;
50984
+ }
50985
+
50986
+ function peg$parsepercent() {
50987
+ var s0, s1, s2, s3;
50988
+
50989
+ peg$silentFails++;
50990
+ s0 = peg$currPos;
50991
+ s1 = peg$currPos;
50992
+ s2 = [];
50993
+ s3 = peg$parsed();
50994
+ if (s3 !== peg$FAILED) {
50995
+ while (s3 !== peg$FAILED) {
50996
+ s2.push(s3);
50997
+ s3 = peg$parsed();
50998
+ }
50999
+ } else {
51000
+ s2 = peg$FAILED;
51001
+ }
51002
+ if (s2 !== peg$FAILED) {
51003
+ s1 = input.substring(s1, peg$currPos);
51004
+ } else {
51005
+ s1 = s2;
51006
+ }
51007
+ if (s1 !== peg$FAILED) {
51008
+ s2 = peg$parse_();
51009
+ if (s2 === peg$FAILED) {
51010
+ s2 = null;
51011
+ }
51012
+ if (s2 !== peg$FAILED) {
51013
+ if (input.charCodeAt(peg$currPos) === 37) {
51014
+ s3 = peg$c58;
51015
+ peg$currPos++;
51016
+ } else {
51017
+ s3 = peg$FAILED;
51018
+ if (peg$silentFails === 0) { peg$fail(peg$c59); }
51019
+ }
51020
+ if (s3 !== peg$FAILED) {
51021
+ peg$savedPos = s0;
51022
+ s1 = peg$c60(s1);
51023
+ s0 = s1;
51024
+ } else {
51025
+ peg$currPos = s0;
51026
+ s0 = peg$FAILED;
51027
+ }
51028
+ } else {
51029
+ peg$currPos = s0;
51030
+ s0 = peg$FAILED;
51031
+ }
51032
+ } else {
51033
+ peg$currPos = s0;
51034
+ s0 = peg$FAILED;
51035
+ }
51036
+ peg$silentFails--;
51037
+ if (s0 === peg$FAILED) {
51038
+ s1 = peg$FAILED;
51039
+ if (peg$silentFails === 0) { peg$fail(peg$c57); }
51040
+ }
51041
+
51042
+ return s0;
51043
+ }
51044
+
51045
+ function peg$parseyear() {
51046
+ var s0, s1, s2, s3, s4, s5;
51047
+
51048
+ peg$silentFails++;
51049
+ s0 = peg$currPos;
51050
+ s1 = peg$currPos;
51051
+ s2 = peg$parsed();
51052
+ if (s2 !== peg$FAILED) {
51053
+ s3 = peg$parsed();
51054
+ if (s3 !== peg$FAILED) {
51055
+ s4 = peg$parsed();
51056
+ if (s4 !== peg$FAILED) {
51057
+ s5 = peg$parsed();
51058
+ if (s5 !== peg$FAILED) {
51059
+ s2 = [s2, s3, s4, s5];
51060
+ s1 = s2;
51061
+ } else {
51062
+ peg$currPos = s1;
51063
+ s1 = peg$FAILED;
51064
+ }
51065
+ } else {
51066
+ peg$currPos = s1;
51067
+ s1 = peg$FAILED;
51068
+ }
51069
+ } else {
51070
+ peg$currPos = s1;
51071
+ s1 = peg$FAILED;
51072
+ }
51073
+ } else {
51074
+ peg$currPos = s1;
51075
+ s1 = peg$FAILED;
51076
+ }
51077
+ if (s1 !== peg$FAILED) {
51078
+ s0 = input.substring(s0, peg$currPos);
51079
+ } else {
51080
+ s0 = s1;
51081
+ }
51082
+ peg$silentFails--;
51083
+ if (s0 === peg$FAILED) {
51084
+ s1 = peg$FAILED;
51085
+ if (peg$silentFails === 0) { peg$fail(peg$c61); }
51086
+ }
51087
+
51088
+ return s0;
51089
+ }
51090
+
51091
+ function peg$parsemonth() {
51092
+ var s0, s1, s2, s3, s4, s5;
51093
+
51094
+ peg$silentFails++;
51095
+ s0 = peg$currPos;
51096
+ s1 = peg$currPos;
51097
+ s2 = peg$parseyear();
51098
+ if (s2 !== peg$FAILED) {
51099
+ if (input.charCodeAt(peg$currPos) === 45) {
51100
+ s3 = peg$c63;
51101
+ peg$currPos++;
51102
+ } else {
51103
+ s3 = peg$FAILED;
51104
+ if (peg$silentFails === 0) { peg$fail(peg$c64); }
51105
+ }
51106
+ if (s3 !== peg$FAILED) {
51107
+ s4 = peg$parsed();
51108
+ if (s4 !== peg$FAILED) {
51109
+ s5 = peg$parsed();
51110
+ if (s5 !== peg$FAILED) {
51111
+ s2 = [s2, s3, s4, s5];
51112
+ s1 = s2;
51113
+ } else {
51114
+ peg$currPos = s1;
51115
+ s1 = peg$FAILED;
51116
+ }
51117
+ } else {
51118
+ peg$currPos = s1;
51119
+ s1 = peg$FAILED;
51120
+ }
51121
+ } else {
51122
+ peg$currPos = s1;
51123
+ s1 = peg$FAILED;
51124
+ }
51125
+ } else {
51126
+ peg$currPos = s1;
51127
+ s1 = peg$FAILED;
51128
+ }
51129
+ if (s1 !== peg$FAILED) {
51130
+ s0 = input.substring(s0, peg$currPos);
51131
+ } else {
51132
+ s0 = s1;
51133
+ }
51134
+ peg$silentFails--;
51135
+ if (s0 === peg$FAILED) {
51136
+ s1 = peg$FAILED;
51137
+ if (peg$silentFails === 0) { peg$fail(peg$c62); }
51138
+ }
51139
+
51140
+ return s0;
51141
+ }
51142
+
51143
+ function peg$parseday() {
51144
+ var s0, s1, s2, s3;
51145
+
51146
+ peg$silentFails++;
51147
+ s0 = peg$currPos;
51148
+ s1 = peg$currPos;
51149
+ s2 = peg$parsed();
51150
+ if (s2 !== peg$FAILED) {
51151
+ s3 = peg$parsed();
51152
+ if (s3 !== peg$FAILED) {
51153
+ s2 = [s2, s3];
51154
+ s1 = s2;
51155
+ } else {
51156
+ peg$currPos = s1;
51157
+ s1 = peg$FAILED;
51158
+ }
51159
+ } else {
51160
+ peg$currPos = s1;
51161
+ s1 = peg$FAILED;
51162
+ }
51163
+ if (s1 !== peg$FAILED) {
51164
+ s0 = input.substring(s0, peg$currPos);
51165
+ } else {
51166
+ s0 = s1;
51167
+ }
51168
+ peg$silentFails--;
51169
+ if (s0 === peg$FAILED) {
51170
+ s1 = peg$FAILED;
51171
+ if (peg$silentFails === 0) { peg$fail(peg$c65); }
51172
+ }
51173
+
51174
+ return s0;
51175
+ }
51176
+
51177
+ function peg$parsedate() {
51178
+ var s0, s1, s2, s3, s4;
51179
+
51180
+ s0 = peg$currPos;
51181
+ s1 = peg$currPos;
51182
+ s2 = peg$parsemonth();
51183
+ if (s2 !== peg$FAILED) {
51184
+ if (input.charCodeAt(peg$currPos) === 45) {
51185
+ s3 = peg$c63;
51186
+ peg$currPos++;
51187
+ } else {
51188
+ s3 = peg$FAILED;
51189
+ if (peg$silentFails === 0) { peg$fail(peg$c64); }
51190
+ }
51191
+ if (s3 !== peg$FAILED) {
51192
+ s4 = peg$parseday();
51193
+ if (s4 !== peg$FAILED) {
51194
+ s2 = [s2, s3, s4];
51195
+ s1 = s2;
51196
+ } else {
51197
+ peg$currPos = s1;
51198
+ s1 = peg$FAILED;
51199
+ }
51200
+ } else {
51201
+ peg$currPos = s1;
51202
+ s1 = peg$FAILED;
51203
+ }
51204
+ } else {
51205
+ peg$currPos = s1;
51206
+ s1 = peg$FAILED;
51207
+ }
51208
+ if (s1 !== peg$FAILED) {
51209
+ s0 = input.substring(s0, peg$currPos);
51210
+ } else {
51211
+ s0 = s1;
51212
+ }
51213
+
51214
+ return s0;
51215
+ }
51216
+
51217
+ function peg$parsecurrencySymbol() {
51218
+ var s0, s1, s2;
51219
+
51220
+ peg$silentFails++;
51221
+ s0 = peg$currPos;
51222
+ if (input.length > peg$currPos) {
51223
+ s1 = input.charAt(peg$currPos);
51224
+ peg$currPos++;
51225
+ } else {
51226
+ s1 = peg$FAILED;
51227
+ if (peg$silentFails === 0) { peg$fail(peg$c67); }
51228
+ }
51229
+ if (s1 !== peg$FAILED) {
51230
+ peg$savedPos = peg$currPos;
51231
+ s2 = peg$c68(s1);
51232
+ if (s2) {
51233
+ s2 = void 0;
51234
+ } else {
51235
+ s2 = peg$FAILED;
51236
+ }
51237
+ if (s2 !== peg$FAILED) {
51238
+ s1 = [s1, s2];
51239
+ s0 = s1;
51240
+ } else {
51241
+ peg$currPos = s0;
51242
+ s0 = peg$FAILED;
51243
+ }
51244
+ } else {
51245
+ peg$currPos = s0;
51246
+ s0 = peg$FAILED;
51247
+ }
51248
+ peg$silentFails--;
51249
+ if (s0 === peg$FAILED) {
51250
+ s1 = peg$FAILED;
51251
+ if (peg$silentFails === 0) { peg$fail(peg$c66); }
51252
+ }
51253
+
51254
+ return s0;
51255
+ }
51256
+
51257
+ peg$result = peg$startRuleFunction();
51258
+
51259
+ if (peg$result !== peg$FAILED && peg$currPos === input.length) {
51260
+ return peg$result;
51261
+ } else {
51262
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
51263
+ peg$fail(peg$endExpectation());
51264
+ }
51265
+
51266
+ throw peg$buildStructuredError(
51267
+ peg$maxFailExpected,
51268
+ peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
51269
+ peg$maxFailPos < input.length
51270
+ ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
51271
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
51272
+ );
51273
+ }
51274
+ }
51275
+
51276
+ module.exports = {
51277
+ SyntaxError: peg$SyntaxError,
51278
+ parse: peg$parse
51279
+ };
51280
+
51281
+
51282
+ /***/ }),
51283
+
51284
+ /***/ "./packages/loot-core/src/server/budget/goaltemplates.js":
51285
+ /*!***************************************************************!*\
51286
+ !*** ./packages/loot-core/src/server/budget/goaltemplates.js ***!
51287
+ \***************************************************************/
51288
+ /*! exports provided: applyTemplate, overwriteTemplate */
51289
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
51290
+
51291
+ "use strict";
51292
+ __webpack_require__.r(__webpack_exports__);
51293
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "applyTemplate", function() { return applyTemplate; });
51294
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "overwriteTemplate", function() { return overwriteTemplate; });
51295
+ /* harmony import */ var date_fns__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! date-fns */ "./node_modules/date-fns/esm/index.js");
51296
+ /* harmony import */ var _shared_months__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../shared/months */ "./packages/loot-core/src/shared/months.js");
51297
+ /* harmony import */ var _shared_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../shared/util */ "./packages/loot-core/src/shared/util.js");
51298
+ /* harmony import */ var _db__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../db */ "./packages/loot-core/src/server/db/index.js");
51299
+ /* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./actions */ "./packages/loot-core/src/server/budget/actions.js");
51300
+ /* harmony import */ var _goal_template_pegjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./goal-template.pegjs */ "./packages/loot-core/src/server/budget/goal-template.pegjs");
51301
+ /* harmony import */ var _goal_template_pegjs__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_goal_template_pegjs__WEBPACK_IMPORTED_MODULE_5__);
51302
+
51303
+
51304
+
51305
+
51306
+
51307
+
51308
+ function applyTemplate({
51309
+ month
51310
+ }) {
51311
+ return processTemplate(month, false);
51312
+ }
51313
+ function overwriteTemplate({
51314
+ month
51315
+ }) {
51316
+ return processTemplate(month, true);
51317
+ }
51318
+
51319
+ async function processTemplate(month, force) {
51320
+ let category_templates = await getCategoryTemplates();
51321
+ let errors = [];
51322
+ let categories = await _db__WEBPACK_IMPORTED_MODULE_3__["all"]('SELECT * FROM v_categories WHERE tombstone = 0');
51323
+ let num_applied = 0;
51324
+
51325
+ for (let c = 0; c < categories.length; c++) {
51326
+ let category = categories[c];
51327
+ let budgeted = await Object(_actions__WEBPACK_IMPORTED_MODULE_4__["getSheetValue"])(_shared_months__WEBPACK_IMPORTED_MODULE_1__["sheetForMonth"](month), `budget-${category.id}`);
51328
+
51329
+ if (budgeted === 0 || force) {
51330
+ let template = category_templates[category.id];
51331
+
51332
+ if (template) {
51333
+ errors = errors.concat(template.filter(t => t.type === 'error').map(({
51334
+ line,
51335
+ error
51336
+ }) => [category.name + ': ' + error.message, line, ' '.repeat(TEMPLATE_PREFIX.length + error.location.start.offset) + '^'].join('\n')));
51337
+ let to_budget = await applyCategoryTemplate(category, template, month, force);
51338
+
51339
+ if (to_budget != null) {
51340
+ num_applied++;
51341
+ await Object(_actions__WEBPACK_IMPORTED_MODULE_4__["setBudget"])({
51342
+ category: category.id,
51343
+ month,
51344
+ amount: to_budget
51345
+ });
51346
+ }
51347
+ }
51348
+ }
51349
+ }
51350
+
51351
+ if (num_applied === 0) {
51352
+ if (errors.length) {
51353
+ return {
51354
+ type: 'error',
51355
+ sticky: true,
51356
+ message: `There were errors interpreting some templates:`,
51357
+ pre: errors.join('\n\n')
51358
+ };
51359
+ } else {
51360
+ return {
51361
+ type: 'message',
51362
+ message: 'All categories were up to date.'
51363
+ };
51364
+ }
51365
+ } else {
51366
+ let applied = `Successfully applied templates to ${num_applied} ${num_applied === 1 ? 'category' : 'categories'}.`;
51367
+
51368
+ if (errors.length) {
51369
+ return {
51370
+ sticky: true,
51371
+ message: `${applied} There were errors interpreting some templates:`,
51372
+ pre: errors.join('\n\n')
51373
+ };
51374
+ } else {
51375
+ return {
51376
+ type: 'message',
51377
+ message: applied
51378
+ };
51379
+ }
51380
+ }
51381
+ }
51382
+
51383
+ const TEMPLATE_PREFIX = '#template ';
51384
+
51385
+ async function getCategoryTemplates() {
51386
+ let templates = {};
51387
+ let notes = await _db__WEBPACK_IMPORTED_MODULE_3__["all"](`SELECT * FROM notes WHERE lower(note) like '%${TEMPLATE_PREFIX}%'`);
51388
+
51389
+ for (let n = 0; n < notes.length; n++) {
51390
+ let lines = notes[n].note.split('\n');
51391
+ let template_lines = [];
51392
+
51393
+ for (let l = 0; l < lines.length; l++) {
51394
+ let line = lines[l].trim();
51395
+ if (!line.toLowerCase().startsWith(TEMPLATE_PREFIX)) continue;
51396
+ let expression = line.slice(TEMPLATE_PREFIX.length);
51397
+
51398
+ try {
51399
+ let parsed = Object(_goal_template_pegjs__WEBPACK_IMPORTED_MODULE_5__["parse"])(expression);
51400
+ template_lines.push(parsed);
51401
+ } catch (e) {
51402
+ template_lines.push({
51403
+ type: 'error',
51404
+ line,
51405
+ error: e
51406
+ });
51407
+ }
51408
+ }
51409
+
51410
+ if (template_lines.length) {
51411
+ templates[notes[n].id] = template_lines;
51412
+ }
51413
+ }
51414
+
51415
+ return templates;
51416
+ }
51417
+
51418
+ async function applyCategoryTemplate(category, template_lines, month, force) {
51419
+ let current_month = new Date(`${month}-01`); // remove lines for past dates, calculate repeating dates
51420
+
51421
+ let got_by = false;
51422
+ template_lines = template_lines.filter(template => {
51423
+ //debugger;
51424
+ switch (template.type) {
51425
+ case 'by':
51426
+ case 'spend':
51427
+ let target_month = new Date(`${template.month}-01`);
51428
+ let num_months = Object(date_fns__WEBPACK_IMPORTED_MODULE_0__["differenceInCalendarMonths"])(target_month, current_month);
51429
+ let repeat = template.annual ? (template.repeat || 1) * 12 : template.repeat;
51430
+ let spend_from;
51431
+
51432
+ if (template.type === 'spend') {
51433
+ spend_from = new Date(`${template.from}-01`);
51434
+ }
51435
+
51436
+ while (num_months < 0 && repeat) {
51437
+ target_month = Object(date_fns__WEBPACK_IMPORTED_MODULE_0__["addMonths"])(target_month, repeat);
51438
+
51439
+ if (spend_from) {
51440
+ spend_from = Object(date_fns__WEBPACK_IMPORTED_MODULE_0__["addMonths"])(spend_from, repeat);
51441
+ }
51442
+
51443
+ num_months = Object(date_fns__WEBPACK_IMPORTED_MODULE_0__["differenceInCalendarMonths"])(target_month, current_month);
51444
+ }
51445
+
51446
+ if (num_months < 0) {
51447
+ console.log(`${category.name}: ${`${template.month} is in the past:`} ${template.line}`);
51448
+ return null;
51449
+ }
51450
+
51451
+ template.month = Object(date_fns__WEBPACK_IMPORTED_MODULE_0__["format"])(target_month, 'yyyy-MM');
51452
+
51453
+ if (spend_from) {
51454
+ template.from = Object(date_fns__WEBPACK_IMPORTED_MODULE_0__["format"])(spend_from, 'yyyy-MM');
51455
+ }
51456
+
51457
+ break;
51458
+
51459
+ default:
51460
+ }
51461
+
51462
+ return template;
51463
+ });
51464
+
51465
+ if (template_lines.length > 1) {
51466
+ template_lines = template_lines.sort((a, b) => {
51467
+ if (a.type === 'by' && !a.annual) {
51468
+ return Object(date_fns__WEBPACK_IMPORTED_MODULE_0__["differenceInCalendarMonths"])(new Date(`${a.month}-01`), new Date(`${b.month}-01`));
51469
+ } else {
51470
+ return a.type.localeCompare(b.type);
51471
+ }
51472
+ }).filter(el => {
51473
+ if (el.type === 'by') {
51474
+ if (!got_by) {
51475
+ got_by = true;
51476
+ return el;
51477
+ } else {
51478
+ return null;
51479
+ }
51480
+ } else {
51481
+ return el;
51482
+ }
51483
+ });
51484
+ }
51485
+
51486
+ let to_budget = 0;
51487
+ let limit;
51488
+ let sheetName = _shared_months__WEBPACK_IMPORTED_MODULE_1__["sheetForMonth"](month);
51489
+ let budgeted = await Object(_actions__WEBPACK_IMPORTED_MODULE_4__["getSheetValue"])(sheetName, `budget-${category.id}`);
51490
+ let spent = await Object(_actions__WEBPACK_IMPORTED_MODULE_4__["getSheetValue"])(sheetName, `sum-amount-${category.id}`);
51491
+ let balance = await Object(_actions__WEBPACK_IMPORTED_MODULE_4__["getSheetValue"])(sheetName, `leftover-${category.id}`);
51492
+ let last_month_balance = balance - spent - budgeted;
51493
+
51494
+ for (let l = 0; l < template_lines.length; l++) {
51495
+ let template = template_lines[l];
51496
+
51497
+ switch (template.type) {
51498
+ case 'simple':
51499
+ {
51500
+ // simple has 'monthly' and/or 'limit' params
51501
+ if (template.limit != null) {
51502
+ if (limit != null) {
51503
+ console.log(`${category.name}: ${`More than one 'up to' limit found.`} ${template.line}`);
51504
+ return null;
51505
+ } else {
51506
+ limit = Object(_shared_util__WEBPACK_IMPORTED_MODULE_2__["amountToInteger"])(template.limit);
51507
+ }
51508
+ }
51509
+
51510
+ if (template.monthly) {
51511
+ let monthly = Object(_shared_util__WEBPACK_IMPORTED_MODULE_2__["amountToInteger"])(template.monthly);
51512
+ to_budget += monthly;
51513
+ } else {
51514
+ to_budget += limit;
51515
+ }
51516
+
51517
+ break;
51518
+ }
51519
+
51520
+ case 'by':
51521
+ {
51522
+ // by has 'amount' and 'month' params
51523
+ let target_month = new Date(`${template.month}-01`);
51524
+ let target = Object(_shared_util__WEBPACK_IMPORTED_MODULE_2__["amountToInteger"])(template.amount);
51525
+ let num_months = Object(date_fns__WEBPACK_IMPORTED_MODULE_0__["differenceInCalendarMonths"])(target_month, current_month);
51526
+ let repeat = template.type === 'by' ? template.repeat : (template.repeat || 1) * 12;
51527
+
51528
+ while (num_months < 0 && repeat) {
51529
+ target_month = Object(date_fns__WEBPACK_IMPORTED_MODULE_0__["addMonths"])(target_month, repeat);
51530
+ num_months = Object(date_fns__WEBPACK_IMPORTED_MODULE_0__["differenceInCalendarMonths"])(target_month, current_month);
51531
+ }
51532
+
51533
+ let diff = target - last_month_balance;
51534
+
51535
+ if (diff >= 0 && num_months > -1) {
51536
+ to_budget += Math.round(diff / (num_months + 1));
51537
+ }
51538
+
51539
+ break;
51540
+ }
51541
+
51542
+ case 'week':
51543
+ {
51544
+ // week has 'amount', 'starting', 'weeks' and optional 'limit' params
51545
+ let amount = Object(_shared_util__WEBPACK_IMPORTED_MODULE_2__["amountToInteger"])(template.amount);
51546
+ let weeks = template.weeks != null ? Math.round(template.weeks) : 1;
51547
+
51548
+ if (template.limit != null) {
51549
+ if (limit != null) {
51550
+ console.log(`${category.name}: ${`More than one 'up to' limit found.`} ${template.line}`);
51551
+ return null;
51552
+ } else {
51553
+ limit = Object(_shared_util__WEBPACK_IMPORTED_MODULE_2__["amountToInteger"])(template.limit);
51554
+ }
51555
+ }
51556
+
51557
+ let w = new Date(template.starting);
51558
+ let next_month = Object(date_fns__WEBPACK_IMPORTED_MODULE_0__["addMonths"])(current_month, 1);
51559
+
51560
+ while (w.getTime() < next_month.getTime()) {
51561
+ if (w.getTime() >= current_month.getTime()) {
51562
+ to_budget += amount;
51563
+ }
51564
+
51565
+ w = Object(date_fns__WEBPACK_IMPORTED_MODULE_0__["addWeeks"])(w, weeks);
51566
+ }
51567
+
51568
+ break;
51569
+ }
51570
+
51571
+ case 'spend':
51572
+ {
51573
+ // spend has 'amount' and 'from' and 'month' params
51574
+ let from_month = new Date(`${template.from}-01`);
51575
+ let to_month = new Date(`${template.month}-01`);
51576
+ let already_budgeted = last_month_balance;
51577
+ let first_month = true;
51578
+
51579
+ for (let m = from_month; Object(date_fns__WEBPACK_IMPORTED_MODULE_0__["differenceInCalendarMonths"])(current_month, m) > 0; m = Object(date_fns__WEBPACK_IMPORTED_MODULE_0__["addMonths"])(m, 1)) {
51580
+ let sheetName = _shared_months__WEBPACK_IMPORTED_MODULE_1__["sheetForMonth"](Object(date_fns__WEBPACK_IMPORTED_MODULE_0__["format"])(m, 'yyyy-MM'));
51581
+
51582
+ if (first_month) {
51583
+ let spent = await Object(_actions__WEBPACK_IMPORTED_MODULE_4__["getSheetValue"])(sheetName, `sum-amount-${category.id}`);
51584
+ let balance = await Object(_actions__WEBPACK_IMPORTED_MODULE_4__["getSheetValue"])(sheetName, `leftover-${category.id}`);
51585
+ already_budgeted = balance - spent;
51586
+ first_month = false;
51587
+ } else {
51588
+ let budgeted = await Object(_actions__WEBPACK_IMPORTED_MODULE_4__["getSheetValue"])(sheetName, `budget-${category.id}`);
51589
+ already_budgeted += budgeted;
51590
+ }
51591
+ }
51592
+
51593
+ let num_months = Object(date_fns__WEBPACK_IMPORTED_MODULE_0__["differenceInCalendarMonths"])(to_month, current_month);
51594
+ let target = Object(_shared_util__WEBPACK_IMPORTED_MODULE_2__["amountToInteger"])(template.amount);
51595
+
51596
+ if (num_months < 0) {
51597
+ console.log(`${category.name}: ${`${template.to} is in the past:`} ${template.line}`);
51598
+ return null;
51599
+ } else if (num_months === 0) {
51600
+ to_budget = target - already_budgeted;
51601
+ } else {
51602
+ to_budget = Math.round((target - already_budgeted) / (num_months + 1));
51603
+ }
51604
+
51605
+ break;
51606
+ }
51607
+
51608
+ case 'percentage':
51609
+ {
51610
+ /*
51611
+ let income_category = (await actual.getCategories()).filter(c => c.is_income == true && c.name == template.category);
51612
+ let func = (getBudgetMonthTestFunc || getBudgetMonth);
51613
+ let budget = await func(month);
51614
+ for (var g = 0; g < budget.categoryGroups.length; g++) {
51615
+ if (income_category.group_id == budget.categoryGroups[g].id) {
51616
+ for (var c = 0; c < budget.categoryGroups[g].categories.length; c++)
51617
+ if (income_category.id == budget.categoryGroups[g].categories[c].id) {
51618
+ let month_category = budget.categoryGroups[g].categories[c];
51619
+ }
51620
+ }
51621
+ }
51622
+ */
51623
+ break;
51624
+ }
51625
+
51626
+ case 'error':
51627
+ return null;
51628
+
51629
+ default:
51630
+ }
51631
+ }
51632
+
51633
+ if (limit != null) {
51634
+ if (to_budget + last_month_balance > limit) {
51635
+ to_budget = limit - last_month_balance;
51636
+ }
51637
+ }
51638
+
51639
+ if ((category.budgeted != null && category.budgeted !== 0 || to_budget === 0) && !force) {
51640
+ return null;
51641
+ } else if (category.budgeted === to_budget && force) {
51642
+ return null;
51643
+ } else {
51644
+ let str = category.name + ': ' + Object(_shared_util__WEBPACK_IMPORTED_MODULE_2__["integerToAmount"])(last_month_balance);
51645
+ str += ' + ' + Object(_shared_util__WEBPACK_IMPORTED_MODULE_2__["integerToAmount"])(to_budget) + ' = ' + Object(_shared_util__WEBPACK_IMPORTED_MODULE_2__["integerToAmount"])(last_month_balance + to_budget);
51646
+ str += ' ' + template_lines.map(x => x.line).join('\n');
51647
+ console.log(str);
51648
+ return to_budget;
51649
+ }
51650
+ }
51651
+
51652
+ /***/ }),
51653
+
49880
51654
  /***/ "./packages/loot-core/src/server/budget/report.js":
49881
51655
  /*!********************************************************!*\
49882
51656
  !*** ./packages/loot-core/src/server/budget/report.js ***!
@@ -50508,7 +52282,6 @@ async function upload() {
50508
52282
  });
50509
52283
  } catch (err) {
50510
52284
  console.log('Upload failure', err);
50511
- let reason = err instanceof _errors__WEBPACK_IMPORTED_MODULE_6__["PostError"] ? err.reason : 'network';
50512
52285
 
50513
52286
  if (err instanceof _errors__WEBPACK_IMPORTED_MODULE_6__["PostError"]) {
50514
52287
  throw new _errors__WEBPACK_IMPORTED_MODULE_6__["FileUploadError"](err.reason === 'unauthorized' ? 'unauthorized' : err.reason || 'network');
@@ -50534,8 +52307,7 @@ async function possiblyUpload() {
50534
52307
  let _prefs$getPrefs5 = _prefs__WEBPACK_IMPORTED_MODULE_9__["getPrefs"](),
50535
52308
  cloudFileId = _prefs$getPrefs5.cloudFileId,
50536
52309
  groupId = _prefs$getPrefs5.groupId,
50537
- lastUploaded = _prefs$getPrefs5.lastUploaded,
50538
- id = _prefs$getPrefs5.id;
52310
+ lastUploaded = _prefs$getPrefs5.lastUploaded;
50539
52311
 
50540
52312
  let threshold = lastUploaded && _shared_months__WEBPACK_IMPORTED_MODULE_4__["addDays"](lastUploaded, UPLOAD_FREQUENCY_IN_DAYS);
50541
52313
  let currentDay = _shared_months__WEBPACK_IMPORTED_MODULE_4__["currentDay"](); // We only want to try to upload every UPLOAD_FREQUENCY_IN_DAYS days
@@ -51765,44 +53537,6 @@ async function getTransaction(id) {
51765
53537
  let rows = await selectWithSchema('transactions', 'SELECT * FROM v_transactions WHERE id = ?', [id]);
51766
53538
  return rows[0];
51767
53539
  }
51768
-
51769
- function _addFragmentForAccount(accountId, addWhere, options = {}) {
51770
- let _options$showClosed = options.showClosed,
51771
- showClosed = _options$showClosed === void 0 ? false : _options$showClosed,
51772
- _options$showOffbudge = options.showOffbudget,
51773
- showOffbudget = _options$showOffbudge === void 0 ? true : _options$showOffbudge;
51774
- let fragment = addWhere ? ' WHERE (' : ' AND ';
51775
- let params = [];
51776
-
51777
- if (accountId) {
51778
- if (accountId === 'offbudget') {
51779
- fragment += 'a.closed = 0 AND a.offbudget = 1 ';
51780
- } else if (accountId === 'budgeted') {
51781
- fragment += 'a.closed = 0 AND a.offbudget = 0 ';
51782
- } else if (accountId === 'uncategorized') {
51783
- fragment += `
51784
- t.category IS NULL AND a.offbudget = 0 AND isParent = 0 AND (
51785
- ta.offbudget IS NULL OR ta.offbudget = 1
51786
- )
51787
- `;
51788
- } else {
51789
- fragment += 'a.id = ? ';
51790
- params.push(accountId);
51791
- }
51792
- } else {
51793
- fragment += showClosed ? '1' : 'a.closed = 0';
51794
-
51795
- if (!showOffbudget) {
51796
- fragment += ' AND a.offbudget = 0';
51797
- }
51798
- }
51799
-
51800
- return {
51801
- fragment,
51802
- params
51803
- };
51804
- }
51805
-
51806
53540
  async function getTransactionsByDate(accountId, startDate, endDate, options = {}) {
51807
53541
  throw new Error('`getTransactionsByDate` is deprecated');
51808
53542
  }
@@ -52401,10 +54135,9 @@ __webpack_require__.r(__webpack_exports__);
52401
54135
  /* harmony import */ var _sync__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ./sync */ "./packages/loot-core/src/server/sync/index.js");
52402
54136
  /* harmony import */ var _sync_migrate__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ./sync/migrate */ "./packages/loot-core/src/server/sync/migrate.js");
52403
54137
  /* harmony import */ var _tools_app__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(/*! ./tools/app */ "./packages/loot-core/src/server/tools/app.js");
52404
- /* harmony import */ var _tracking_events__WEBPACK_IMPORTED_MODULE_44__ = __webpack_require__(/*! ./tracking/events */ "./packages/loot-core/src/server/tracking/events.js");
52405
- /* harmony import */ var _undo__WEBPACK_IMPORTED_MODULE_45__ = __webpack_require__(/*! ./undo */ "./packages/loot-core/src/server/undo.js");
52406
- /* harmony import */ var _update__WEBPACK_IMPORTED_MODULE_46__ = __webpack_require__(/*! ./update */ "./packages/loot-core/src/server/update.js");
52407
- /* harmony import */ var _util_budget_name__WEBPACK_IMPORTED_MODULE_47__ = __webpack_require__(/*! ./util/budget-name */ "./packages/loot-core/src/server/util/budget-name.js");
54138
+ /* harmony import */ var _undo__WEBPACK_IMPORTED_MODULE_44__ = __webpack_require__(/*! ./undo */ "./packages/loot-core/src/server/undo.js");
54139
+ /* harmony import */ var _update__WEBPACK_IMPORTED_MODULE_45__ = __webpack_require__(/*! ./update */ "./packages/loot-core/src/server/update.js");
54140
+ /* harmony import */ var _util_budget_name__WEBPACK_IMPORTED_MODULE_46__ = __webpack_require__(/*! ./util/budget-name */ "./packages/loot-core/src/server/util/budget-name.js");
52408
54141
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
52409
54142
 
52410
54143
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -52469,7 +54202,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
52469
54202
 
52470
54203
 
52471
54204
 
52472
-
52473
54205
 
52474
54206
 
52475
54207
  const YNAB4 = __webpack_require__(/*! @actual-app/import-ynab4/importer */ "./packages/import-ynab4/importer.js");
@@ -52509,10 +54241,10 @@ function onSheetChange({
52509
54241
 
52510
54242
  let handlers = {};
52511
54243
  handlers['undo'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["mutator"])(async function () {
52512
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["undo"])();
54244
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["undo"])();
52513
54245
  });
52514
54246
  handlers['redo'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["mutator"])(function () {
52515
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["redo"])();
54247
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["redo"])();
52516
54248
  });
52517
54249
  handlers['transactions-batch-update'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["mutator"])(async function ({
52518
54250
  added,
@@ -52520,7 +54252,7 @@ handlers['transactions-batch-update'] = Object(_mutators__WEBPACK_IMPORTED_MODUL
52520
54252
  updated,
52521
54253
  learnCategories
52522
54254
  }) {
52523
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
54255
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
52524
54256
  let result = await Object(_accounts_transactions__WEBPACK_IMPORTED_MODULE_20__["batchUpdateTransactions"])({
52525
54257
  added,
52526
54258
  updated,
@@ -52694,7 +54426,7 @@ handlers['category-create'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["mu
52694
54426
  groupId,
52695
54427
  isIncome
52696
54428
  }) {
52697
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
54429
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
52698
54430
  if (!groupId) {
52699
54431
  throw Object(_errors__WEBPACK_IMPORTED_MODULE_31__["APIError"])('Creating a category: groupId is required');
52700
54432
  }
@@ -52707,7 +54439,7 @@ handlers['category-create'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["mu
52707
54439
  });
52708
54440
  });
52709
54441
  handlers['category-update'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["mutator"])(async function (category) {
52710
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
54442
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
52711
54443
  try {
52712
54444
  await _db__WEBPACK_IMPORTED_MODULE_28__["updateCategory"](category);
52713
54445
  } catch (e) {
@@ -52730,7 +54462,7 @@ handlers['category-move'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["muta
52730
54462
  groupId,
52731
54463
  targetId
52732
54464
  }) {
52733
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
54465
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
52734
54466
  await Object(_sync__WEBPACK_IMPORTED_MODULE_41__["batchMessages"])(async () => {
52735
54467
  await _db__WEBPACK_IMPORTED_MODULE_28__["moveCategory"](id, groupId, targetId);
52736
54468
  });
@@ -52741,7 +54473,7 @@ handlers['category-delete'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["mu
52741
54473
  id,
52742
54474
  transferId
52743
54475
  }) {
52744
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
54476
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
52745
54477
  let result = {};
52746
54478
  await Object(_sync__WEBPACK_IMPORTED_MODULE_41__["batchMessages"])(async () => {
52747
54479
  let row = await _db__WEBPACK_IMPORTED_MODULE_28__["first"]('SELECT is_income FROM categories WHERE id = ?', [id]);
@@ -52786,7 +54518,7 @@ handlers['category-group-create'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33
52786
54518
  name,
52787
54519
  isIncome
52788
54520
  }) {
52789
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
54521
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
52790
54522
  return _db__WEBPACK_IMPORTED_MODULE_28__["insertCategoryGroup"]({
52791
54523
  name,
52792
54524
  is_income: isIncome ? 1 : 0
@@ -52794,7 +54526,7 @@ handlers['category-group-create'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33
52794
54526
  });
52795
54527
  });
52796
54528
  handlers['category-group-update'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["mutator"])(async function (group) {
52797
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
54529
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
52798
54530
  return _db__WEBPACK_IMPORTED_MODULE_28__["updateCategoryGroup"](group);
52799
54531
  });
52800
54532
  });
@@ -52802,7 +54534,7 @@ handlers['category-group-move'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__
52802
54534
  id,
52803
54535
  targetId
52804
54536
  }) {
52805
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
54537
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
52806
54538
  await Object(_sync__WEBPACK_IMPORTED_MODULE_41__["batchMessages"])(async () => {
52807
54539
  await _db__WEBPACK_IMPORTED_MODULE_28__["moveCategoryGroup"](id, targetId);
52808
54540
  });
@@ -52813,7 +54545,7 @@ handlers['category-group-delete'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33
52813
54545
  id,
52814
54546
  transferId
52815
54547
  }) {
52816
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
54548
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
52817
54549
  const groupCategories = await _db__WEBPACK_IMPORTED_MODULE_28__["all"]('SELECT id FROM categories WHERE cat_group = ? AND tombstone = 0', [id]);
52818
54550
  return Object(_sync__WEBPACK_IMPORTED_MODULE_41__["batchMessages"])(async () => {
52819
54551
  if (transferId) {
@@ -52851,7 +54583,7 @@ handlers['must-category-transfer'] = async function ({
52851
54583
  handlers['payee-create'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["mutator"])(async function ({
52852
54584
  name
52853
54585
  }) {
52854
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
54586
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
52855
54587
  return _db__WEBPACK_IMPORTED_MODULE_28__["insertPayee"]({
52856
54588
  name
52857
54589
  });
@@ -52864,7 +54596,6 @@ handlers['payees-get'] = async function () {
52864
54596
 
52865
54597
  handlers['payees-get-rule-counts'] = async function () {
52866
54598
  let payeeCounts = {};
52867
- let allRules = _accounts_transaction_rules__WEBPACK_IMPORTED_MODULE_19__["getRules"]();
52868
54599
  _accounts_transaction_rules__WEBPACK_IMPORTED_MODULE_19__["iterateIds"](_accounts_transaction_rules__WEBPACK_IMPORTED_MODULE_19__["getRules"](), 'payee', (rule, id) => {
52869
54600
  if (payeeCounts[id] == null) {
52870
54601
  payeeCounts[id] = 0;
@@ -52879,7 +54610,7 @@ handlers['payees-merge'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["mutat
52879
54610
  targetId,
52880
54611
  mergeIds
52881
54612
  }) {
52882
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
54613
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
52883
54614
  return _db__WEBPACK_IMPORTED_MODULE_28__["mergePayees"](targetId, mergeIds);
52884
54615
  }, {
52885
54616
  targetId,
@@ -52891,7 +54622,7 @@ handlers['payees-batch-change'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__
52891
54622
  deleted,
52892
54623
  updated
52893
54624
  }) {
52894
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
54625
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
52895
54626
  return Object(_sync__WEBPACK_IMPORTED_MODULE_41__["batchMessages"])(async () => {
52896
54627
  if (deleted) {
52897
54628
  await Promise.all(deleted.map(p => _db__WEBPACK_IMPORTED_MODULE_28__["deletePayee"](p)));
@@ -52925,7 +54656,7 @@ handlers['payees-delete-rule'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__[
52925
54656
  id,
52926
54657
  payee_id
52927
54658
  }) {
52928
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
54659
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
52929
54660
  return await _db__WEBPACK_IMPORTED_MODULE_28__["deletePayeeRule"]({
52930
54661
  id
52931
54662
  });
@@ -52934,14 +54665,14 @@ handlers['payees-delete-rule'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__[
52934
54665
  });
52935
54666
  });
52936
54667
  handlers['payees-update-rule'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["mutator"])(async function (rule) {
52937
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
54668
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
52938
54669
  return await _db__WEBPACK_IMPORTED_MODULE_28__["updatePayeeRule"](rule);
52939
54670
  }, {
52940
54671
  payeeId: rule.payee_id
52941
54672
  });
52942
54673
  });
52943
54674
  handlers['payees-add-rule'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["mutator"])(async function (rule) {
52944
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
54675
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
52945
54676
  let id = await _db__WEBPACK_IMPORTED_MODULE_28__["insertPayeeRule"](rule);
52946
54677
  return _objectSpread(_objectSpread({}, rule), {}, {
52947
54678
  id
@@ -53175,7 +54906,7 @@ handlers['account-update'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["mut
53175
54906
  id,
53176
54907
  name
53177
54908
  }) {
53178
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
54909
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
53179
54910
  await _db__WEBPACK_IMPORTED_MODULE_28__["update"]('accounts', {
53180
54911
  id,
53181
54912
  name
@@ -53258,7 +54989,7 @@ handlers['account-create'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["mut
53258
54989
  offBudget,
53259
54990
  closed
53260
54991
  }) {
53261
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
54992
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
53262
54993
  const id = await _db__WEBPACK_IMPORTED_MODULE_28__["insertAccount"]({
53263
54994
  name,
53264
54995
  type,
@@ -53270,7 +55001,7 @@ handlers['account-create'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["mut
53270
55001
  transfer_acct: id
53271
55002
  });
53272
55003
 
53273
- if (balance != null) {
55004
+ if (balance != null && balance !== 0) {
53274
55005
  let payee = await Object(_accounts_payees__WEBPACK_IMPORTED_MODULE_16__["getStartingBalancePayee"])();
53275
55006
  await _db__WEBPACK_IMPORTED_MODULE_28__["insertTransaction"]({
53276
55007
  account: id,
@@ -53298,7 +55029,7 @@ handlers['account-close'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["muta
53298
55029
  await handlers['account-unlink']({
53299
55030
  id
53300
55031
  });
53301
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
55032
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
53302
55033
  let account = await _db__WEBPACK_IMPORTED_MODULE_28__["first"]('SELECT * FROM accounts WHERE id = ? AND tombstone = 0', [id]); // Do nothing if the account doesn't exist or it's already been
53303
55034
  // closed
53304
55035
 
@@ -53380,7 +55111,7 @@ handlers['account-close'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["muta
53380
55111
  handlers['account-reopen'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["mutator"])(async function ({
53381
55112
  id
53382
55113
  }) {
53383
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
55114
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
53384
55115
  await _db__WEBPACK_IMPORTED_MODULE_28__["update"]('accounts', {
53385
55116
  id,
53386
55117
  closed: 0
@@ -53391,7 +55122,7 @@ handlers['account-move'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["mutat
53391
55122
  id,
53392
55123
  targetId
53393
55124
  }) {
53394
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
55125
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
53395
55126
  await _db__WEBPACK_IMPORTED_MODULE_28__["moveAccount"](id, targetId);
53396
55127
  });
53397
55128
  });
@@ -53480,9 +55211,6 @@ handlers['accounts-sync'] = async function ({
53480
55211
  let matchedTransactions = [];
53481
55212
  let updatedAccounts = [];
53482
55213
 
53483
- let _prefs$getPrefs = _prefs__WEBPACK_IMPORTED_MODULE_37__["getPrefs"](),
53484
- groupId = _prefs$getPrefs.groupId;
53485
-
53486
55214
  for (var i = 0; i < accounts.length; i++) {
53487
55215
  const acct = accounts[i];
53488
55216
 
@@ -53514,7 +55242,7 @@ handlers['accounts-sync'] = async function ({
53514
55242
  } else {
53515
55243
  errors.push({
53516
55244
  accountId: acct.id,
53517
- message: 'There was an internal error. Please email help@actualbudget.com for support.',
55245
+ message: 'There was an internal error. Please get in touch https://actualbudget.github.io/docs/Contact for support.',
53518
55246
  internal: err.stack
53519
55247
  });
53520
55248
  err.message = 'Failed syncing account: ' + err.message;
@@ -53543,7 +55271,7 @@ handlers['transactions-import'] = Object(_mutators__WEBPACK_IMPORTED_MODULE_33__
53543
55271
  accountId,
53544
55272
  transactions
53545
55273
  }) {
53546
- return Object(_undo__WEBPACK_IMPORTED_MODULE_45__["withUndo"])(async () => {
55274
+ return Object(_undo__WEBPACK_IMPORTED_MODULE_44__["withUndo"])(async () => {
53547
55275
  if (typeof accountId !== 'string') {
53548
55276
  throw Object(_errors__WEBPACK_IMPORTED_MODULE_31__["APIError"])('transactions-import: accountId must be an id');
53549
55277
  }
@@ -53641,11 +55369,6 @@ handlers['save-global-prefs'] = async function (prefs) {
53641
55369
  await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_4___default.a.setItem('max-months', '' + prefs.maxMonths);
53642
55370
  }
53643
55371
 
53644
- if ('trackUsage' in prefs) {
53645
- _tracking_events__WEBPACK_IMPORTED_MODULE_44__["toggle"](prefs.trackUsage);
53646
- await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_4___default.a.setItem('track-usage', '' + prefs.trackUsage);
53647
- }
53648
-
53649
55372
  if ('autoUpdate' in prefs) {
53650
55373
  await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_4___default.a.setItem('auto-update', '' + prefs.autoUpdate);
53651
55374
  process.send({
@@ -53668,8 +55391,8 @@ handlers['save-global-prefs'] = async function (prefs) {
53668
55391
  };
53669
55392
 
53670
55393
  handlers['load-global-prefs'] = async function () {
53671
- let _await$asyncStorage$m21 = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_4___default.a.multiGet(['floating-sidebar', 'seen-tutorial', 'max-months', 'track-usage', 'auto-update', 'document-dir', 'encrypt-key']),
53672
- _await$asyncStorage$m22 = _slicedToArray(_await$asyncStorage$m21, 7),
55394
+ let _await$asyncStorage$m21 = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_4___default.a.multiGet(['floating-sidebar', 'seen-tutorial', 'max-months', 'auto-update', 'document-dir', 'encrypt-key']),
55395
+ _await$asyncStorage$m22 = _slicedToArray(_await$asyncStorage$m21, 6),
53673
55396
  _await$asyncStorage$m23 = _slicedToArray(_await$asyncStorage$m22[0], 2),
53674
55397
  floatingSidebar = _await$asyncStorage$m23[1],
53675
55398
  _await$asyncStorage$m24 = _slicedToArray(_await$asyncStorage$m22[1], 2),
@@ -53677,20 +55400,16 @@ handlers['load-global-prefs'] = async function () {
53677
55400
  _await$asyncStorage$m25 = _slicedToArray(_await$asyncStorage$m22[2], 2),
53678
55401
  maxMonths = _await$asyncStorage$m25[1],
53679
55402
  _await$asyncStorage$m26 = _slicedToArray(_await$asyncStorage$m22[3], 2),
53680
- trackUsage = _await$asyncStorage$m26[1],
55403
+ autoUpdate = _await$asyncStorage$m26[1],
53681
55404
  _await$asyncStorage$m27 = _slicedToArray(_await$asyncStorage$m22[4], 2),
53682
- autoUpdate = _await$asyncStorage$m27[1],
55405
+ documentDir = _await$asyncStorage$m27[1],
53683
55406
  _await$asyncStorage$m28 = _slicedToArray(_await$asyncStorage$m22[5], 2),
53684
- documentDir = _await$asyncStorage$m28[1],
53685
- _await$asyncStorage$m29 = _slicedToArray(_await$asyncStorage$m22[6], 2),
53686
- encryptKey = _await$asyncStorage$m29[1];
55407
+ encryptKey = _await$asyncStorage$m28[1];
53687
55408
 
53688
55409
  return {
53689
55410
  floatingSidebar: floatingSidebar === 'true' ? true : false,
53690
55411
  seenTutorial: seenTutorial === 'true' ? true : false,
53691
55412
  maxMonths: Object(_shared_util__WEBPACK_IMPORTED_MODULE_12__["stringToInteger"])(maxMonths || ''),
53692
- // Default to true
53693
- trackUsage: trackUsage == null || trackUsage === 'true' ? true : false,
53694
55413
  autoUpdate: autoUpdate == null || autoUpdate === 'true' ? true : false,
53695
55414
  documentDir: documentDir || getDefaultDocumentDir(),
53696
55415
  keyId: encryptKey && JSON.parse(encryptKey).id
@@ -53698,8 +55417,8 @@ handlers['load-global-prefs'] = async function () {
53698
55417
  };
53699
55418
 
53700
55419
  handlers['save-prefs'] = async function (prefsToSet) {
53701
- let _prefs$getPrefs2 = _prefs__WEBPACK_IMPORTED_MODULE_37__["getPrefs"](),
53702
- cloudFileId = _prefs$getPrefs2.cloudFileId; // Need to sync the budget name on the server as well
55420
+ let _prefs$getPrefs = _prefs__WEBPACK_IMPORTED_MODULE_37__["getPrefs"](),
55421
+ cloudFileId = _prefs$getPrefs.cloudFileId; // Need to sync the budget name on the server as well
53703
55422
 
53704
55423
 
53705
55424
  if (prefsToSet.budgetName && cloudFileId) {
@@ -53738,7 +55457,6 @@ handlers['key-make'] = async function ({
53738
55457
  throw new Error('user-set-key must be called with file loaded');
53739
55458
  }
53740
55459
 
53741
- let cloudFileId = _prefs__WEBPACK_IMPORTED_MODULE_37__["getPrefs"]().cloudFileId;
53742
55460
  let salt = _encryption__WEBPACK_IMPORTED_MODULE_30__["default"].randomBytes(32).toString('base64');
53743
55461
  let id = uuid.v4Sync();
53744
55462
  let key = await _encryption__WEBPACK_IMPORTED_MODULE_30__["default"].createKey({
@@ -53840,22 +55558,13 @@ handlers['key-test'] = async function ({
53840
55558
  return {};
53841
55559
  };
53842
55560
 
53843
- handlers['should-pitch-subscribe'] = async function () {
53844
- let seenSubscribe = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_4___default.a.getItem('seenSubscribe');
53845
- return seenSubscribe !== 'true';
53846
- };
53847
-
53848
- handlers['has-pitched-subscribe'] = async function () {
53849
- await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_4___default.a.setItem('seenSubscribe', 'true');
53850
- return 'ok';
53851
- };
53852
-
53853
55561
  handlers['subscribe-needs-bootstrap'] = async function ({
53854
55562
  url
53855
55563
  } = {}) {
53856
55564
  if (Object(_server_config__WEBPACK_IMPORTED_MODULE_39__["getServer"])(url).BASE_SERVER === UNCONFIGURED_SERVER) {
53857
55565
  return {
53858
- bootstrapped: true
55566
+ bootstrapped: true,
55567
+ hasServer: false
53859
55568
  };
53860
55569
  }
53861
55570
 
@@ -53884,7 +55593,8 @@ handlers['subscribe-needs-bootstrap'] = async function ({
53884
55593
  }
53885
55594
 
53886
55595
  return {
53887
- bootstrapped: res.data.bootstrapped
55596
+ bootstrapped: res.data.bootstrapped,
55597
+ hasServer: true
53888
55598
  };
53889
55599
  };
53890
55600
 
@@ -53965,10 +55675,9 @@ handlers['subscribe-change-password'] = async function ({
53965
55675
  password
53966
55676
  }) {
53967
55677
  let userToken = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_4___default.a.getItem('user-token');
53968
- let res;
53969
55678
 
53970
55679
  try {
53971
- res = await Object(_post__WEBPACK_IMPORTED_MODULE_36__["post"])(Object(_server_config__WEBPACK_IMPORTED_MODULE_39__["getServer"])().SIGNUP_SERVER + '/change-password', {
55680
+ await Object(_post__WEBPACK_IMPORTED_MODULE_36__["post"])(Object(_server_config__WEBPACK_IMPORTED_MODULE_39__["getServer"])().SIGNUP_SERVER + '/change-password', {
53972
55681
  token: userToken,
53973
55682
  password
53974
55683
  });
@@ -54033,19 +55742,22 @@ handlers['get-server-url'] = async function () {
54033
55742
  };
54034
55743
 
54035
55744
  handlers['set-server-url'] = async function ({
54036
- url
55745
+ url,
55746
+ validate = true
54037
55747
  }) {
54038
55748
  if (url != null) {
54039
- // Validate the server is running
54040
- let _await$runHandler = await Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["runHandler"])(handlers['subscribe-needs-bootstrap'], {
54041
- url
54042
- }),
54043
- error = _await$runHandler.error;
55749
+ if (validate) {
55750
+ // Validate the server is running
55751
+ let _await$runHandler = await Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["runHandler"])(handlers['subscribe-needs-bootstrap'], {
55752
+ url
55753
+ }),
55754
+ error = _await$runHandler.error;
54044
55755
 
54045
- if (error) {
54046
- return {
54047
- error
54048
- };
55756
+ if (error) {
55757
+ return {
55758
+ error
55759
+ };
55760
+ }
54049
55761
  }
54050
55762
  } else {
54051
55763
  // When the server isn't configured, we just use a placeholder
@@ -54185,26 +55897,31 @@ handlers['download-budget'] = async function ({
54185
55897
  }
54186
55898
  }
54187
55899
 
54188
- let id = result.id; // Load the budget and do a full sync
54189
-
54190
- result = await loadBudget(result.id, VERSION, {
54191
- showUpdate: true
55900
+ let id = result.id;
55901
+ await handlers['load-budget']({
55902
+ id
55903
+ });
55904
+ result = await handlers['sync-budget']({
55905
+ id
54192
55906
  });
55907
+ await handlers['close-budget']();
54193
55908
 
54194
55909
  if (result.error) {
54195
- return {
54196
- error: {
54197
- reason: result.error
54198
- }
54199
- };
55910
+ return result;
54200
55911
  }
54201
55912
 
54202
- Object(_sync__WEBPACK_IMPORTED_MODULE_41__["setSyncingMode"])('enabled');
54203
- await Object(_sync__WEBPACK_IMPORTED_MODULE_41__["initialFullSync"])();
54204
- await handlers['close-budget']();
54205
55913
  return {
54206
55914
  id
54207
55915
  };
55916
+ }; // open and sync, but don’t close
55917
+
55918
+
55919
+ handlers['sync-budget'] = async function ({
55920
+ id
55921
+ }) {
55922
+ Object(_sync__WEBPACK_IMPORTED_MODULE_41__["setSyncingMode"])('enabled');
55923
+ await Object(_sync__WEBPACK_IMPORTED_MODULE_41__["initialFullSync"])();
55924
+ return {};
54208
55925
  };
54209
55926
 
54210
55927
  handlers['load-budget'] = async function ({
@@ -54225,31 +55942,6 @@ handlers['load-budget'] = async function ({
54225
55942
  let res = await loadBudget(id, VERSION, {
54226
55943
  showUpdate: true
54227
55944
  });
54228
-
54229
- async function trackSizes() {
54230
- let getFileSize = async name => {
54231
- let dbFile = _platform_server_fs__WEBPACK_IMPORTED_MODULE_5___default.a.join(_platform_server_fs__WEBPACK_IMPORTED_MODULE_5___default.a.getBudgetDir(id), name);
54232
-
54233
- try {
54234
- return await _platform_server_fs__WEBPACK_IMPORTED_MODULE_5___default.a.size(dbFile);
54235
- } catch (err) {
54236
- return null;
54237
- }
54238
- };
54239
-
54240
- try {
54241
- let dbSize = await getFileSize('db.sqlite');
54242
- let cacheSize = await getFileSize('cache.sqlite');
54243
- _tracking_events__WEBPACK_IMPORTED_MODULE_44__["track"]('app:load-budget', {
54244
- size: dbSize,
54245
- cacheSize
54246
- });
54247
- } catch (err) {
54248
- console.warn(err);
54249
- }
54250
- }
54251
-
54252
- trackSizes();
54253
55945
  return res;
54254
55946
  };
54255
55947
 
@@ -54328,10 +56020,10 @@ handlers['create-budget'] = async function ({
54328
56020
  // Unfortunately we need to load all of the existing files first
54329
56021
  // so we can detect conflicting names.
54330
56022
  let files = await handlers['get-budgets']();
54331
- budgetName = await Object(_util_budget_name__WEBPACK_IMPORTED_MODULE_47__["uniqueFileName"])(files);
56023
+ budgetName = await Object(_util_budget_name__WEBPACK_IMPORTED_MODULE_46__["uniqueFileName"])(files);
54332
56024
  }
54333
56025
 
54334
- id = await Object(_util_budget_name__WEBPACK_IMPORTED_MODULE_47__["idFromFileName"])(budgetName);
56026
+ id = await Object(_util_budget_name__WEBPACK_IMPORTED_MODULE_46__["idFromFileName"])(budgetName);
54335
56027
  }
54336
56028
 
54337
56029
  let budgetDir = _platform_server_fs__WEBPACK_IMPORTED_MODULE_5___default.a.getBudgetDir(id);
@@ -54510,22 +56202,21 @@ async function loadBudget(id, appVersion, {
54510
56202
 
54511
56203
 
54512
56204
  if (!_prefs__WEBPACK_IMPORTED_MODULE_37__["getPrefs"]().userId) {
54513
- let _await$asyncStorage$m30 = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_4___default.a.multiGet(['user-token']),
54514
- _await$asyncStorage$m31 = _slicedToArray(_await$asyncStorage$m30, 1),
54515
- _await$asyncStorage$m32 = _slicedToArray(_await$asyncStorage$m31[0], 2),
54516
- userId = _await$asyncStorage$m32[1];
56205
+ let _await$asyncStorage$m29 = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_4___default.a.multiGet(['user-token']),
56206
+ _await$asyncStorage$m30 = _slicedToArray(_await$asyncStorage$m29, 1),
56207
+ _await$asyncStorage$m31 = _slicedToArray(_await$asyncStorage$m30[0], 2),
56208
+ userId = _await$asyncStorage$m31[1];
54517
56209
 
54518
56210
  _prefs__WEBPACK_IMPORTED_MODULE_37__["savePrefs"]({
54519
56211
  userId
54520
56212
  });
54521
56213
  }
54522
56214
 
54523
- let _prefs$getPrefs3 = _prefs__WEBPACK_IMPORTED_MODULE_37__["getPrefs"](),
54524
- budgetVersion = _prefs$getPrefs3.budgetVersion,
54525
- budgetId = _prefs$getPrefs3.budgetId;
56215
+ let _prefs$getPrefs2 = _prefs__WEBPACK_IMPORTED_MODULE_37__["getPrefs"](),
56216
+ budgetVersion = _prefs$getPrefs2.budgetVersion;
54526
56217
 
54527
56218
  try {
54528
- await Object(_update__WEBPACK_IMPORTED_MODULE_46__["updateVersion"])(budgetVersion, showUpdate);
56219
+ await Object(_update__WEBPACK_IMPORTED_MODULE_45__["updateVersion"])(budgetVersion, showUpdate);
54529
56220
  } catch (e) {
54530
56221
  console.warn('Error updating', e);
54531
56222
  let result;
@@ -54589,7 +56280,7 @@ async function loadBudget(id, appVersion, {
54589
56280
  await _accounts_transaction_rules__WEBPACK_IMPORTED_MODULE_19__["loadRules"]();
54590
56281
  await _sync_migrate__WEBPACK_IMPORTED_MODULE_42__["listen"]();
54591
56282
  await _main_app__WEBPACK_IMPORTED_MODULE_32__["default"].startServices();
54592
- Object(_undo__WEBPACK_IMPORTED_MODULE_45__["clearUndo"])(); // Ensure that syncing is enabled
56283
+ Object(_undo__WEBPACK_IMPORTED_MODULE_44__["clearUndo"])(); // Ensure that syncing is enabled
54593
56284
 
54594
56285
  if (!global.__TESTING__) {
54595
56286
  if (process.env.IS_BETA || id === DEMO_BUDGET_ID) {
@@ -54613,8 +56304,8 @@ async function loadBudget(id, appVersion, {
54613
56304
  }
54614
56305
 
54615
56306
  handlers['get-upgrade-notifications'] = async function () {
54616
- let _prefs$getPrefs4 = _prefs__WEBPACK_IMPORTED_MODULE_37__["getPrefs"](),
54617
- id = _prefs$getPrefs4.id;
56307
+ let _prefs$getPrefs3 = _prefs__WEBPACK_IMPORTED_MODULE_37__["getPrefs"](),
56308
+ id = _prefs$getPrefs3.id;
54618
56309
 
54619
56310
  if (id === TEST_BUDGET_ID || id === DEMO_BUDGET_ID) {
54620
56311
  return [];
@@ -54696,13 +56387,6 @@ handlers['app-focused'] = async function () {
54696
56387
  }
54697
56388
  };
54698
56389
 
54699
- handlers['track'] = async function ({
54700
- name,
54701
- props
54702
- }) {
54703
- _tracking_events__WEBPACK_IMPORTED_MODULE_44__["track"](name, props);
54704
- };
54705
-
54706
56390
  handlers = Object(_api__WEBPACK_IMPORTED_MODULE_21__["default"])(handlers);
54707
56391
 
54708
56392
  _actual_app_api_injected__WEBPACK_IMPORTED_MODULE_1___default.a.send = (name, args) => Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["runHandler"])(_main_app__WEBPACK_IMPORTED_MODULE_32__["default"].handlers[name], args); // A hack for now until we clean up everything
@@ -54755,7 +56439,6 @@ async function initApp(version, isDev, socketName) {
54755
56439
  VERSION = version;
54756
56440
  await _platform_server_sqlite__WEBPACK_IMPORTED_MODULE_7__["init"]();
54757
56441
  await Promise.all([_platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_4___default.a.init(), _platform_server_fs__WEBPACK_IMPORTED_MODULE_5___default.a.init()]);
54758
- await _tracking_events__WEBPACK_IMPORTED_MODULE_44__["init"]();
54759
56442
  await setupDocumentsDir();
54760
56443
  let keysStr = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_4___default.a.getItem('encrypt-keys');
54761
56444
 
@@ -54770,13 +56453,13 @@ async function initApp(version, isDev, socketName) {
54770
56453
  console.log('Error loading key', e);
54771
56454
  throw new Error('load-key-error');
54772
56455
  }
54773
- }
56456
+ } // if (isDev) {
56457
+ // const lastBudget = await asyncStorage.getItem('lastBudget');
56458
+ // if (lastBudget) {
56459
+ // loadBudget(lastBudget, VERSION);
56460
+ // }
56461
+ // }
54774
56462
 
54775
- if (isDev) {
54776
- const lastBudget = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_4___default.a.getItem('lastBudget'); // if (lastBudget) {
54777
- // loadBudget(lastBudget, VERSION);
54778
- // }
54779
- }
54780
56463
 
54781
56464
  const url = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_4___default.a.getItem('server-url');
54782
56465
 
@@ -54785,9 +56468,6 @@ async function initApp(version, isDev, socketName) {
54785
56468
  }
54786
56469
 
54787
56470
  connection.init(socketName, _main_app__WEBPACK_IMPORTED_MODULE_32__["default"].handlers);
54788
- _tracking_events__WEBPACK_IMPORTED_MODULE_44__["track"]('app:init', {
54789
- platform: _platform__WEBPACK_IMPORTED_MODULE_35__["default"].isMobile ? 'mobile' : _platform__WEBPACK_IMPORTED_MODULE_35__["default"].isWeb ? 'web' : 'desktop'
54790
- });
54791
56471
 
54792
56472
  if (!isDev && !_platform__WEBPACK_IMPORTED_MODULE_35__["default"].isMobile && !_platform__WEBPACK_IMPORTED_MODULE_35__["default"].isWeb) {
54793
56473
  let autoUpdate = await _platform_server_asyncStorage__WEBPACK_IMPORTED_MODULE_4___default.a.getItem('auto-update');
@@ -54806,10 +56486,7 @@ async function initApp(version, isDev, socketName) {
54806
56486
  global.$setSyncingMode = _sync__WEBPACK_IMPORTED_MODULE_41__["setSyncingMode"];
54807
56487
  }
54808
56488
  }
54809
- async function init({
54810
- budgetId,
54811
- config
54812
- }) {
56489
+ async function init(config) {
54813
56490
  // Get from build
54814
56491
  // eslint-disable-next-line
54815
56492
  VERSION = "0.0.147";
@@ -54832,6 +56509,12 @@ async function init({
54832
56509
 
54833
56510
  if (serverURL) {
54834
56511
  Object(_server_config__WEBPACK_IMPORTED_MODULE_39__["setServer"])(serverURL);
56512
+
56513
+ if (config.password) {
56514
+ await Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["runHandler"])(handlers['subscribe-sign-in'], {
56515
+ password: config.password
56516
+ });
56517
+ }
54835
56518
  } else {
54836
56519
  // This turns off all server URLs. In this mode we don't want any
54837
56520
  // access to the server, we are doing things locally
@@ -54841,12 +56524,6 @@ async function init({
54841
56524
  });
54842
56525
  }
54843
56526
 
54844
- if (budgetId) {
54845
- await Object(_mutators__WEBPACK_IMPORTED_MODULE_33__["runHandler"])(handlers['load-budget'], {
54846
- id: budgetId
54847
- });
54848
- }
54849
-
54850
56527
  return lib;
54851
56528
  } // Export a few things required for the platform
54852
56529
 
@@ -55493,7 +57170,6 @@ function throwIfNot200(res, text) {
55493
57170
  async function post(url, data) {
55494
57171
  let text;
55495
57172
  let res;
55496
- let s = new Error().stack;
55497
57173
 
55498
57174
  try {
55499
57175
  res = await fetch(url, {
@@ -55912,14 +57588,14 @@ async function createSchedule({
55912
57588
  }]
55913
57589
  });
55914
57590
  let now = Date.now();
55915
- let nextDateId = await _db__WEBPACK_IMPORTED_MODULE_11__["insertWithUUID"]('schedules_next_date', {
57591
+ await _db__WEBPACK_IMPORTED_MODULE_11__["insertWithUUID"]('schedules_next_date', {
55916
57592
  schedule_id: scheduleId,
55917
57593
  local_next_date: nextDateRepr,
55918
57594
  local_next_date_ts: now,
55919
57595
  base_next_date: nextDateRepr,
55920
57596
  base_next_date_ts: now
55921
57597
  });
55922
- let id = await _db__WEBPACK_IMPORTED_MODULE_11__["insertWithSchema"]('schedules', _objectSpread(_objectSpread({}, schedule), {}, {
57598
+ await _db__WEBPACK_IMPORTED_MODULE_11__["insertWithSchema"]('schedules', _objectSpread(_objectSpread({}, schedule), {}, {
55923
57599
  id: scheduleId,
55924
57600
  rule: ruleId
55925
57601
  }));
@@ -55980,7 +57656,7 @@ async function updateSchedule({
55980
57656
  // might switch accounts from a closed one
55981
57657
 
55982
57658
 
55983
- if (resetNextDate || !deep_equal__WEBPACK_IMPORTED_MODULE_1___default()(oldConditions.find(c => c.field === 'account'), oldConditions.find(c => c.field === 'account')) || !deep_equal__WEBPACK_IMPORTED_MODULE_1___default()(stripType(oldConditions.find(c => c.field === 'date')), stripType(newConditions.find(c => c.field === 'date')))) {
57659
+ if (resetNextDate || !deep_equal__WEBPACK_IMPORTED_MODULE_1___default()(oldConditions.find(c => c.field === 'account'), oldConditions.find(c => c.field === 'account')) || !deep_equal__WEBPACK_IMPORTED_MODULE_1___default()(stripType(oldConditions.find(c => c.field === 'date') || {}), stripType(newConditions.find(c => c.field === 'date') || {}))) {
55984
57660
  await setNextDate({
55985
57661
  id: schedule.id,
55986
57662
  conditions: newConditions,
@@ -56078,10 +57754,8 @@ function trackJSONPaths() {
56078
57754
  }
56079
57755
 
56080
57756
  function onApplySync(oldValues, newValues) {
56081
- let found = false;
56082
57757
  newValues.forEach((items, table) => {
56083
57758
  if (table === 'rules') {
56084
- found = true;
56085
57759
  items.forEach(newValue => {
56086
57760
  onRuleUpdate(newValue);
56087
57761
  });
@@ -56315,7 +57989,6 @@ function matchSchedules(allOccurs, config, partialMatchRank = 0.5) {
56315
57989
  for (let trans of baseOccur.transactions) {
56316
57990
  let threshold = Object(_shared_rules__WEBPACK_IMPORTED_MODULE_3__["getApproxNumberThreshold"])(trans.amount);
56317
57991
  let payee = trans.payee;
56318
- let account = trans.account;
56319
57992
  let found = occurs.map(occur => {
56320
57993
  let matched = occur.transactions.find(t => t.amount >= trans.amount - threshold && t.amount <= trans.amount + threshold);
56321
57994
  matched = matched && matched.payee === payee ? matched : null;
@@ -56354,7 +58027,6 @@ function matchSchedules(allOccurs, config, partialMatchRank = 0.5) {
56354
58027
 
56355
58028
  async function schedulesForPattern(baseStart, numDays, baseConfig, accountId, partialMatchRank) {
56356
58029
  let schedules = [];
56357
- let i = 0;
56358
58030
 
56359
58031
  for (let i = 0; i < numDays; i++) {
56360
58032
  let start = date_fns__WEBPACK_IMPORTED_MODULE_0__["addDays"](baseStart, i);
@@ -57238,7 +58910,7 @@ class Spreadsheet {
57238
58910
  result = node._run(...args);
57239
58911
 
57240
58912
  if (result instanceof Promise) {
57241
- console.warn('dynamic cell returned a promise! this is discouraged because errors are not handled properly');
58913
+ console.warn(`dynamic cell ${name} returned a promise! this is discouraged because errors are not handled properly`);
57242
58914
  }
57243
58915
  } else if (node.sql) {
57244
58916
  result = Object(_aql__WEBPACK_IMPORTED_MODULE_1__["runCompiledQuery"])(node.query, node.sql.sqlPieces, node.sql.state);
@@ -57280,7 +58952,7 @@ class Spreadsheet {
57280
58952
  names: this.computeQueue
57281
58953
  }); // Cache the updated cells
57282
58954
 
57283
- if (this.saveCache) {
58955
+ if (typeof this.saveCache === 'function') {
57284
58956
  this.saveCache(this.computeQueue);
57285
58957
  }
57286
58958
 
@@ -57619,7 +59291,6 @@ function resolveNamesAsArrays(sheets) {
57619
59291
  Object.keys(sheets).forEach(sheetName => {
57620
59292
  const sheet = sheets[sheetName];
57621
59293
  sheet.forEach(name => {
57622
- const expr = sheet[name];
57623
59294
  cells.push(resolveName(sheetName, name));
57624
59295
  });
57625
59296
  });
@@ -57908,9 +59579,9 @@ function apply(msg, prev) {
57908
59579
 
57909
59580
  if (dataset === 'prefs') {// Do nothing, it doesn't exist in the db
57910
59581
  } else {
57911
- try {
57912
- let query;
59582
+ let query;
57913
59583
 
59584
+ try {
57914
59585
  if (prev) {
57915
59586
  query = {
57916
59587
  sql: _db__WEBPACK_IMPORTED_MODULE_7__["cache"](`UPDATE ${dataset} SET ${column} = ? WHERE id = ?`),
@@ -57924,9 +59595,14 @@ function apply(msg, prev) {
57924
59595
  }
57925
59596
 
57926
59597
  _db__WEBPACK_IMPORTED_MODULE_7__["runQuery"](query.sql, query.params);
57927
- } catch (e) {
57928
- //console.log(e);
57929
- throw new SyncError('invalid-schema');
59598
+ } catch (error) {
59599
+ throw new SyncError('invalid-schema', {
59600
+ error: {
59601
+ message: error.message,
59602
+ stack: error.stack
59603
+ },
59604
+ query
59605
+ });
57930
59606
  }
57931
59607
  }
57932
59608
  }
@@ -57959,8 +59635,12 @@ async function fetchAll(table, ids) {
57959
59635
  try {
57960
59636
  let rows = await _db__WEBPACK_IMPORTED_MODULE_7__["runQuery"](sql, partIds, true);
57961
59637
  results = results.concat(rows);
57962
- } catch (e) {
57963
- throw new SyncError('invalid-schema');
59638
+ } catch (error) {
59639
+ throw new SyncError('invalid-schema', {
59640
+ error,
59641
+ sql,
59642
+ params: partIds
59643
+ });
57964
59644
  }
57965
59645
  }
57966
59646
 
@@ -58040,11 +59720,7 @@ function applyMessagesForImport(messages) {
58040
59720
  _db__WEBPACK_IMPORTED_MODULE_7__["transaction"](() => {
58041
59721
  for (let i = 0; i < messages.length; i++) {
58042
59722
  let msg = messages[i];
58043
- let dataset = msg.dataset,
58044
- row = msg.row,
58045
- column = msg.column,
58046
- timestamp = msg.timestamp,
58047
- value = msg.value;
59723
+ let dataset = msg.dataset;
58048
59724
 
58049
59725
  if (!msg.old) {
58050
59726
  try {
@@ -58241,11 +59917,13 @@ async function _sendMessages(messages) {
58241
59917
  // message.
58242
59918
  _main_app__WEBPACK_IMPORTED_MODULE_8__["default"].events.emit('sync', {
58243
59919
  type: 'error',
58244
- subtype: 'apply-failure'
59920
+ subtype: 'apply-failure',
59921
+ meta: e.meta
58245
59922
  });
58246
59923
  } else {
58247
59924
  _main_app__WEBPACK_IMPORTED_MODULE_8__["default"].events.emit('sync', {
58248
- type: 'error'
59925
+ type: 'error',
59926
+ meta: e.meta
58249
59927
  });
58250
59928
  }
58251
59929
  }
@@ -58480,7 +60158,6 @@ async function _fullSync(sinceTimestamp, count, prevDiffTime) {
58480
60158
  }
58481
60159
 
58482
60160
  let diffTime = _crdt__WEBPACK_IMPORTED_MODULE_6__["merkle"].diff(res.merkle, Object(_crdt__WEBPACK_IMPORTED_MODULE_6__["getClock"])().merkle);
58483
- let result = res.messages;
58484
60161
 
58485
60162
  if (diffTime !== null) {
58486
60163
  // This is a bit wonky, but we loop until we are in sync with the
@@ -58585,10 +60262,9 @@ __webpack_require__.r(__webpack_exports__);
58585
60262
 
58586
60263
 
58587
60264
 
58588
- function migrateParentIds(oldValues, newValues) {
60265
+ function migrateParentIds(_oldValues, newValues) {
58589
60266
  newValues.forEach((items, table) => {
58590
60267
  if (table === 'transactions') {
58591
- let old = oldValues.get(table);
58592
60268
  let toApply = [];
58593
60269
  items.forEach(newValue => {
58594
60270
  if (newValue.isChild === 1 && newValue.parent_id == null && newValue.id.includes('/')) {
@@ -60287,73 +61963,6 @@ app.method('tools/fix-split-transactions', async () => {
60287
61963
 
60288
61964
  /***/ }),
60289
61965
 
60290
- /***/ "./packages/loot-core/src/server/tracking/events.js":
60291
- /*!**********************************************************!*\
60292
- !*** ./packages/loot-core/src/server/tracking/events.js ***!
60293
- \**********************************************************/
60294
- /*! exports provided: toggle, init, login, track, setProfile */
60295
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
60296
-
60297
- "use strict";
60298
- __webpack_require__.r(__webpack_exports__);
60299
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "toggle", function() { return toggle; });
60300
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "init", function() { return init; });
60301
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "login", function() { return login; });
60302
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "track", function() { return track; });
60303
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setProfile", function() { return setProfile; });
60304
- /* harmony import */ var _encryption_internals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../encryption-internals */ "./packages/loot-core/src/server/encryption-internals.js");
60305
-
60306
- let currentUniqueId;
60307
- let mixpanel;
60308
- let isEnabled = true;
60309
- function toggle(trackUsage) {
60310
- isEnabled = trackUsage == null || trackUsage === 'true' ? true : false;
60311
- } // TODO: Figure out location, send to EU data centers if in EU
60312
- // {
60313
- // host: "api-eu.mixpanel.com",
60314
- // },
60315
- // This must stay up-to-date with all apps that hit mixpanel! That includes the
60316
- // website and server. If changing this, make sure to change it everywhere
60317
-
60318
- async function hash(userId) {
60319
- let hashed = await Object(_encryption_internals__WEBPACK_IMPORTED_MODULE_0__["sha256String"])(userId);
60320
- return `user-${hashed.replace(/[=/]/g, '')}`;
60321
- }
60322
-
60323
- function isAnonymous(id) {
60324
- return !id.startsWith('user-');
60325
- }
60326
-
60327
- async function init() {}
60328
- async function login(userId) {}
60329
- let BUFFERING = false;
60330
- let BUFFER = [];
60331
-
60332
- function startBuffering() {
60333
- BUFFERING = true;
60334
- BUFFER = [];
60335
- }
60336
-
60337
- function stopBuffering() {
60338
- for (let call of BUFFER) {
60339
- call[0](...call[1]);
60340
- }
60341
-
60342
- BUFFERING = false;
60343
- BUFFER = [];
60344
- }
60345
-
60346
- function buffered(func) {
60347
- return (...args) => {
60348
- if (false) {}
60349
- };
60350
- }
60351
-
60352
- const track = buffered((distinct_id, name, props) => {});
60353
- const setProfile = buffered((distinct_id, props) => {});
60354
-
60355
- /***/ }),
60356
-
60357
61966
  /***/ "./packages/loot-core/src/server/undo.js":
60358
61967
  /*!***********************************************!*\
60359
61968
  !*** ./packages/loot-core/src/server/undo.js ***!
@@ -61005,6 +62614,129 @@ function once(fn) {
61005
62614
 
61006
62615
  /***/ }),
61007
62616
 
62617
+ /***/ "./packages/loot-core/src/shared/errors.js":
62618
+ /*!*************************************************!*\
62619
+ !*** ./packages/loot-core/src/shared/errors.js ***!
62620
+ \*************************************************/
62621
+ /*! exports provided: getUploadError, getDownloadError, getCreateKeyError, getTestKeyError, getSubscribeError, getSyncError */
62622
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
62623
+
62624
+ "use strict";
62625
+ __webpack_require__.r(__webpack_exports__);
62626
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getUploadError", function() { return getUploadError; });
62627
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getDownloadError", function() { return getDownloadError; });
62628
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getCreateKeyError", function() { return getCreateKeyError; });
62629
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTestKeyError", function() { return getTestKeyError; });
62630
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getSubscribeError", function() { return getSubscribeError; });
62631
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getSyncError", function() { return getSyncError; });
62632
+ function getUploadError({
62633
+ reason,
62634
+ meta
62635
+ }) {
62636
+ switch (reason) {
62637
+ case 'unauthorized':
62638
+ return 'You are not logged in.';
62639
+
62640
+ case 'encrypt-failure':
62641
+ if (meta.isMissingKey) {
62642
+ return 'Encrypting your file failed because you are missing your encryption key. Create your key in the next step.';
62643
+ }
62644
+
62645
+ return 'Encrypting the file failed. You have the correct key so this is an internal bug. To fix this, generate a new key in the next step.';
62646
+
62647
+ case 'file-has-reset':
62648
+ // Something really weird happened - during reset a sanity
62649
+ // check on the server failed. The user just needs to
62650
+ // restart the whole process.
62651
+ return 'Something went wrong while resetting your file. Please try again.';
62652
+
62653
+ case 'file-has-new-key':
62654
+ return 'Unable to encrypt your data because you are missing the key. Create the latest key in the next step.';
62655
+
62656
+ case 'network':
62657
+ return 'Uploading the file failed. Check your network connection.';
62658
+
62659
+ case 'beta-version':
62660
+ return 'You cannot perform this action in the beta version (resetting sync, deleting a file, etc).';
62661
+
62662
+ default:
62663
+ return `An internal error occurred, sorry! Contact help@actualbudget.com for support. (ref: ${reason})`;
62664
+ }
62665
+ }
62666
+ function getDownloadError({
62667
+ reason,
62668
+ meta,
62669
+ fileName
62670
+ }) {
62671
+ switch (reason) {
62672
+ case 'network':
62673
+ case 'download-failure':
62674
+ return 'Downloading the file failed. Check your network connection.';
62675
+
62676
+ case 'invalid-zip-file':
62677
+ case 'invalid-meta-file':
62678
+ return 'Downloaded file is invalid, sorry! Contact help@actualbudget.com for support.';
62679
+
62680
+ case 'decrypt-failure':
62681
+ return 'Unable to decrypt file ' + (fileName || '(unknown)') + '. To change your key, first ' + 'download this file with the proper password.';
62682
+
62683
+ case 'out-of-sync-migrations':
62684
+ return 'This budget cannot be loaded with this version of the app. ' + 'Make sure the app is up-to-date.';
62685
+
62686
+ default:
62687
+ let info = meta && meta.fileId ? `(fileId: ${meta.fileId})` : '';
62688
+ return 'Something went wrong trying to download that file, sorry! Contact help@actualbudget.com for support. ' + info;
62689
+ }
62690
+ }
62691
+ function getCreateKeyError(error) {
62692
+ return getUploadError(error);
62693
+ }
62694
+ function getTestKeyError({
62695
+ reason
62696
+ }) {
62697
+ switch (reason) {
62698
+ case 'network':
62699
+ return 'Unable to connect to the server. We need to access our server to get some information about your keys.';
62700
+
62701
+ case 'old-key-style':
62702
+ return 'This file is encrypted with an old unsupported key style. Recreate the key ' + 'on a device where the file is available, or use an older version of Actual to download ' + 'it.';
62703
+
62704
+ case 'decrypt-failure':
62705
+ return 'Unable to decrypt file with this password. Please try again.';
62706
+
62707
+ default:
62708
+ return 'Something went wrong trying to create a key, sorry! Contact help@actualbudget.com for support.';
62709
+ }
62710
+ }
62711
+ function getSubscribeError({
62712
+ reason
62713
+ }) {
62714
+ switch (reason) {
62715
+ case 'network':
62716
+ return 'Unable to reach the server. Check your internet connection';
62717
+
62718
+ case 'exists':
62719
+ return 'An account with that email already exists. Did you mean to login?';
62720
+
62721
+ case 'invalid-email':
62722
+ return 'Invalid email';
62723
+
62724
+ default:
62725
+ return 'An error occurred. Please try again later.';
62726
+ }
62727
+ }
62728
+ function getSyncError(error, id) {
62729
+ if (error === 'out-of-sync-migrations' || error === 'out-of-sync-data') {
62730
+ return 'This budget cannot be loaded with this version of the app.';
62731
+ } else if (error === 'budget-not-found') {
62732
+ return 'Budget "' + id + '" not found. Check the id of your budget in the "Advanced" section of the settings page.';
62733
+ } else {
62734
+ return 'We had an unknown problem opening "' + id + '".';
62735
+ }
62736
+ }
62737
+
62738
+ /***/ }),
62739
+
61008
62740
  /***/ "./packages/loot-core/src/shared/months.js":
61009
62741
  /*!*************************************************!*\
61010
62742
  !*** ./packages/loot-core/src/shared/months.js ***!
@@ -61561,6 +63293,9 @@ function mapField(field, opts) {
61561
63293
  case 'amount-outflow':
61562
63294
  return 'amount (outflow)';
61563
63295
 
63296
+ case 'cleared':
63297
+ return 'cleared';
63298
+
61564
63299
  default:
61565
63300
  return field;
61566
63301
  }
@@ -61664,7 +63399,7 @@ function getFieldError(type) {
61664
63399
  return 'Please choose a valid field for this type of rule';
61665
63400
 
61666
63401
  default:
61667
- return 'Internal error, sorry! Contact help@actualbudget.com';
63402
+ return 'Internal error, sorry! Please get in touch https://actualbudget.github.io/docs/Contact/ for support';
61668
63403
  }
61669
63404
  }
61670
63405
  function sortNumbers(num1, num2) {
@@ -61680,7 +63415,7 @@ function parse(item) {
61680
63415
  {
61681
63416
  let parsed = item.value;
61682
63417
 
61683
- if (item.field === 'amount' && item.op !== 'isbetween') {
63418
+ if (item.field === 'amount' && item.op !== 'isbetween' && parsed != null) {
61684
63419
  parsed = Object(_util__WEBPACK_IMPORTED_MODULE_0__["integerToAmount"])(parsed);
61685
63420
  }
61686
63421
 
@@ -61697,6 +63432,14 @@ function parse(item) {
61697
63432
  });
61698
63433
  }
61699
63434
 
63435
+ case 'boolean':
63436
+ {
63437
+ let parsed = item.value;
63438
+ return _objectSpread(_objectSpread({}, item), {}, {
63439
+ value: parsed
63440
+ });
63441
+ }
63442
+
61700
63443
  default:
61701
63444
  }
61702
63445
 
@@ -61731,6 +63474,14 @@ function unparse(_ref) {
61731
63474
  });
61732
63475
  }
61733
63476
 
63477
+ case 'boolean':
63478
+ {
63479
+ let unparsed = item.value == null ? false : item.value;
63480
+ return _objectSpread(_objectSpread({}, item), {}, {
63481
+ value: unparsed
63482
+ });
63483
+ }
63484
+
61734
63485
  default:
61735
63486
  }
61736
63487
 
@@ -61743,7 +63494,7 @@ function makeValue(value, cond) {
61743
63494
  if (cond.op !== 'isbetween') {
61744
63495
  return _objectSpread(_objectSpread({}, cond), {}, {
61745
63496
  error: null,
61746
- value: value ? Object(_util__WEBPACK_IMPORTED_MODULE_0__["currencyToAmount"])(value) || 0 : 0
63497
+ value: value ? Object(_util__WEBPACK_IMPORTED_MODULE_0__["currencyToAmount"])(String(value)) || 0 : 0
61747
63498
  });
61748
63499
  }
61749
63500
 
@@ -61995,11 +63746,12 @@ function getScheduledAmount(amount) {
61995
63746
  /*!*******************************************************!*\
61996
63747
  !*** ./packages/loot-core/src/shared/transactions.js ***!
61997
63748
  \*******************************************************/
61998
- /*! exports provided: makeChild, recalculateSplit, findParentIndex, getSplit, ungroupTransactions, groupTransaction, ungroupTransaction, applyTransactionDiff, replaceTransactions, addSplitTransaction, updateTransaction, deleteTransaction, splitTransaction, realizeTempTransactions */
63749
+ /*! exports provided: isPreviewId, makeChild, recalculateSplit, findParentIndex, getSplit, ungroupTransactions, groupTransaction, ungroupTransaction, applyTransactionDiff, replaceTransactions, addSplitTransaction, updateTransaction, deleteTransaction, splitTransaction, realizeTempTransactions */
61999
63750
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
62000
63751
 
62001
63752
  "use strict";
62002
63753
  __webpack_require__.r(__webpack_exports__);
63754
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isPreviewId", function() { return isPreviewId; });
62003
63755
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "makeChild", function() { return makeChild; });
62004
63756
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "recalculateSplit", function() { return recalculateSplit; });
62005
63757
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findParentIndex", function() { return findParentIndex; });
@@ -62029,8 +63781,11 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
62029
63781
 
62030
63782
 
62031
63783
 
62032
- const uuid = __webpack_require__(/*! ../platform/uuid */ "./packages/loot-core/src/platform/uuid/index.electron.js"); // The amount might be null when adding a new transaction
63784
+ const uuid = __webpack_require__(/*! ../platform/uuid */ "./packages/loot-core/src/platform/uuid/index.electron.js");
62033
63785
 
63786
+ function isPreviewId(id) {
63787
+ return id.indexOf('preview/') !== -1;
63788
+ } // The amount might be null when adding a new transaction
62034
63789
 
62035
63790
  function num(n) {
62036
63791
  return typeof n === 'number' ? n : 0;
@@ -62671,7 +64426,7 @@ const MAX_SAFE_NUMBER = 2 ** 51 - 1;
62671
64426
  const MIN_SAFE_NUMBER = -MAX_SAFE_NUMBER;
62672
64427
  function safeNumber(value) {
62673
64428
  if (!Number.isInteger(value)) {
62674
- throw new Error('safeNumber: number is not an integer: ' + value);
64429
+ throw new Error('safeNumber: number is not an integer: ' + JSON.stringify(value));
62675
64430
  }
62676
64431
 
62677
64432
  if (value > MAX_SAFE_NUMBER || value < MIN_SAFE_NUMBER) {