taxtank-core 0.29.35 → 0.29.37

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.
Files changed (26) hide show
  1. package/bundles/taxtank-core.umd.js +154 -76
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/collection.js +18 -5
  4. package/esm2015/lib/collections/property/property.collection.js +2 -2
  5. package/esm2015/lib/collections/subscription/service-product.collection.js +4 -1
  6. package/esm2015/lib/collections/subscription/service-subscription.collection.js +4 -1
  7. package/esm2015/lib/db/Enums/chart-accounts/chart-accounts-list.enum.js +2 -1
  8. package/esm2015/lib/forms/transaction/index.js +3 -2
  9. package/esm2015/lib/forms/transaction/transaction.form.js +5 -2
  10. package/esm2015/lib/forms/transaction/work/work-expense.form.js +21 -0
  11. package/esm2015/lib/forms/transaction/work/work-income.form.js +87 -0
  12. package/esm2015/lib/forms/transaction/work/work-transaction.form.js +40 -0
  13. package/esm2015/lib/models/chart-accounts/chart-accounts.js +2 -2
  14. package/esm2015/lib/services/http/user/user.service.js +2 -2
  15. package/fesm2015/taxtank-core.js +133 -76
  16. package/fesm2015/taxtank-core.js.map +1 -1
  17. package/lib/collections/collection.d.ts +6 -2
  18. package/lib/collections/subscription/service-product.collection.d.ts +1 -0
  19. package/lib/collections/subscription/service-subscription.collection.d.ts +1 -0
  20. package/lib/db/Enums/chart-accounts/chart-accounts-list.enum.d.ts +1 -0
  21. package/lib/forms/transaction/index.d.ts +2 -1
  22. package/lib/forms/transaction/work/work-expense.form.d.ts +6 -0
  23. package/lib/forms/transaction/{work-income.form.d.ts → work/work-income.form.d.ts} +4 -8
  24. package/lib/forms/transaction/work/work-transaction.form.d.ts +15 -0
  25. package/package.json +1 -1
  26. package/esm2015/lib/forms/transaction/work-income.form.js +0 -109
@@ -2166,6 +2166,27 @@
2166
2166
  (_b = this.items).push.apply(_b, __spreadArray([], __read(items)));
2167
2167
  return this.create(this.items);
2168
2168
  };
2169
+ Collection.prototype.remove = function () {
2170
+ var _this = this;
2171
+ var items = [];
2172
+ for (var _i = 0; _i < arguments.length; _i++) {
2173
+ items[_i] = arguments[_i];
2174
+ }
2175
+ items.forEach(function (item) {
2176
+ var index = _this.findIndexBy('id', item.id);
2177
+ if (index < 0) {
2178
+ return;
2179
+ }
2180
+ _this.items.splice(index, 1);
2181
+ });
2182
+ return this;
2183
+ };
2184
+ /**
2185
+ * @TODO it's filter, not remove
2186
+ */
2187
+ Collection.prototype.removeBy = function (path, values) {
2188
+ return this.filter(function (item) { return !(Array.isArray(values) ? values : [values]).includes(get__default["default"](item, path)); });
2189
+ };
2169
2190
  Collection.prototype.replaceBy = function (path, value, item) {
2170
2191
  var index = this.findIndexBy(path, value);
2171
2192
  if (index >= 0) {
@@ -2173,12 +2194,9 @@
2173
2194
  }
2174
2195
  return this;
2175
2196
  };
2176
- Collection.prototype.remove = function (items) {
2197
+ Collection.prototype.diff = function (items) {
2177
2198
  return this.filter(function (model) { return !items.map(function (item) { return item.id; }).includes(model.id); });
2178
2199
  };
2179
- Collection.prototype.removeBy = function (path, values) {
2180
- return this.filter(function (item) { return !(Array.isArray(values) ? values : [values]).includes(get__default["default"](item, path)); });
2181
- };
2182
2200
  Collection.prototype.minBy = function (path) {
2183
2201
  return this.items.reduce(function (prev, current) { return (get__default["default"](prev, path) < get__default["default"](current, path) ? prev : current); });
2184
2202
  };
@@ -2858,7 +2876,7 @@
2858
2876
  activeProperties.getBestPerformanceGrowthProperty(),
2859
2877
  activeProperties.getBestPerformanceTaxProperty(transactions, depreciations)
2860
2878
  ]).toArray(), 'id');
2861
- var newItems = this.remove(bestProperties).toArray();
2879
+ var newItems = this.diff(bestProperties).toArray();
2862
2880
  newItems.unshift.apply(newItems, __spreadArray([], __read(bestProperties)));
2863
2881
  return this.create(newItems);
2864
2882
  };
@@ -3057,6 +3075,7 @@
3057
3075
 
3058
3076
  exports.ChartAccountsListEnum = void 0;
3059
3077
  (function (ChartAccountsListEnum) {
3078
+ ChartAccountsListEnum[ChartAccountsListEnum["HOME_OFFICE_WORK_HOURS"] = 103] = "HOME_OFFICE_WORK_HOURS";
3060
3079
  ChartAccountsListEnum[ChartAccountsListEnum["PARTNERSHIP_EXPENSES"] = 156] = "PARTNERSHIP_EXPENSES";
3061
3080
  ChartAccountsListEnum[ChartAccountsListEnum["TRUST_EXPENSES"] = 157] = "TRUST_EXPENSES";
3062
3081
  ChartAccountsListEnum[ChartAccountsListEnum["INTEREST_CHARGED_BY_ATO"] = 278] = "INTEREST_CHARGED_BY_ATO";
@@ -3470,6 +3489,50 @@
3470
3489
  return ChartAccountsMetadata;
3471
3490
  }(ChartAccountsMetadata$1));
3472
3491
 
3492
+ /**
3493
+ * @TODO move to pipe/translation
3494
+ * enum with months short names.
3495
+ * Order of items match with financial year months order
3496
+ */
3497
+ exports.MonthNameShortEnum = void 0;
3498
+ (function (MonthNameShortEnum) {
3499
+ MonthNameShortEnum["JULY"] = "Jul";
3500
+ MonthNameShortEnum["AUGUST"] = "Aug";
3501
+ MonthNameShortEnum["SEPTEMBER"] = "Sep";
3502
+ MonthNameShortEnum["OCTOBER"] = "Oct";
3503
+ MonthNameShortEnum["NOVEMBER"] = "Nov";
3504
+ MonthNameShortEnum["DECEMBER"] = "Dec";
3505
+ MonthNameShortEnum["JANUARY"] = "Jan";
3506
+ MonthNameShortEnum["FEBRUARY"] = "Feb";
3507
+ MonthNameShortEnum["MARCH"] = "Mar";
3508
+ MonthNameShortEnum["APRIL"] = "Apr";
3509
+ MonthNameShortEnum["MAY"] = "May";
3510
+ MonthNameShortEnum["JUNE"] = "Jun";
3511
+ })(exports.MonthNameShortEnum || (exports.MonthNameShortEnum = {}));
3512
+
3513
+ /**
3514
+ * enum with months indexes.
3515
+ * item value match with js Date month index from 0 to 11
3516
+ * Order of items match with financial year months order
3517
+ */
3518
+ exports.MonthNumberEnum = void 0;
3519
+ (function (MonthNumberEnum) {
3520
+ MonthNumberEnum[MonthNumberEnum["JULY"] = 6] = "JULY";
3521
+ MonthNumberEnum[MonthNumberEnum["AUGUST"] = 7] = "AUGUST";
3522
+ MonthNumberEnum[MonthNumberEnum["SEPTEMBER"] = 8] = "SEPTEMBER";
3523
+ MonthNumberEnum[MonthNumberEnum["OCTOBER"] = 9] = "OCTOBER";
3524
+ MonthNumberEnum[MonthNumberEnum["NOVEMBER"] = 10] = "NOVEMBER";
3525
+ MonthNumberEnum[MonthNumberEnum["DECEMBER"] = 11] = "DECEMBER";
3526
+ MonthNumberEnum[MonthNumberEnum["JANUARY"] = 0] = "JANUARY";
3527
+ MonthNumberEnum[MonthNumberEnum["FEBRUARY"] = 1] = "FEBRUARY";
3528
+ MonthNumberEnum[MonthNumberEnum["MARCH"] = 2] = "MARCH";
3529
+ MonthNumberEnum[MonthNumberEnum["APRIL"] = 3] = "APRIL";
3530
+ MonthNumberEnum[MonthNumberEnum["MAY"] = 4] = "MAY";
3531
+ MonthNumberEnum[MonthNumberEnum["JUNE"] = 5] = "JUNE";
3532
+ })(exports.MonthNumberEnum || (exports.MonthNumberEnum = {}));
3533
+
3534
+ var MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan'];
3535
+
3473
3536
  exports.ChartAccountsTaxLabelsEnum = void 0;
3474
3537
  (function (ChartAccountsTaxLabelsEnum) {
3475
3538
  ChartAccountsTaxLabelsEnum["TAX_WITHHELD"] = "Tax withheld";
@@ -5381,8 +5444,6 @@
5381
5444
  classTransformer.Type(function () { return ChartSerie; })
5382
5445
  ], ChartData.prototype, "data", void 0);
5383
5446
 
5384
- var MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'Jan'];
5385
-
5386
5447
  /**
5387
5448
  * Collection of transactions
5388
5449
  */
@@ -6206,6 +6267,13 @@
6206
6267
  function ServiceProductCollection() {
6207
6268
  return _super !== null && _super.apply(this, arguments) || this;
6208
6269
  }
6270
+ Object.defineProperty(ServiceProductCollection.prototype, "title", {
6271
+ get: function () {
6272
+ return this.mapBy('title').join(', ');
6273
+ },
6274
+ enumerable: false,
6275
+ configurable: true
6276
+ });
6209
6277
  ServiceProductCollection.prototype.getActive = function () {
6210
6278
  return this.filterBy('status', exports.ServiceProductStatusEnum.ACTIVE);
6211
6279
  };
@@ -6342,6 +6410,9 @@
6342
6410
  // @TODO vik remove paid products
6343
6411
  return this.getInactive().getTrials();
6344
6412
  };
6413
+ ServiceSubscriptionCollection.prototype.getExpiredAfter = function (date) {
6414
+ return this.getInactive().filter(function (item) { return !date || item.endDate >= date; });
6415
+ };
6345
6416
  ServiceSubscriptionCollection.prototype.getPaid = function () {
6346
6417
  return this.filter(function (subscription) { return !!subscription.stripeId; });
6347
6418
  };
@@ -7621,48 +7692,6 @@
7621
7692
  classTransformer.Type(function () { return ServiceSubscriptionItem; })
7622
7693
  ], ServiceSubscription.prototype, "items", void 0);
7623
7694
 
7624
- /**
7625
- * @TODO move to pipe/translation
7626
- * enum with months short names.
7627
- * Order of items match with financial year months order
7628
- */
7629
- exports.MonthNameShortEnum = void 0;
7630
- (function (MonthNameShortEnum) {
7631
- MonthNameShortEnum["JULY"] = "Jul";
7632
- MonthNameShortEnum["AUGUST"] = "Aug";
7633
- MonthNameShortEnum["SEPTEMBER"] = "Sep";
7634
- MonthNameShortEnum["OCTOBER"] = "Oct";
7635
- MonthNameShortEnum["NOVEMBER"] = "Nov";
7636
- MonthNameShortEnum["DECEMBER"] = "Dec";
7637
- MonthNameShortEnum["JANUARY"] = "Jan";
7638
- MonthNameShortEnum["FEBRUARY"] = "Feb";
7639
- MonthNameShortEnum["MARCH"] = "Mar";
7640
- MonthNameShortEnum["APRIL"] = "Apr";
7641
- MonthNameShortEnum["MAY"] = "May";
7642
- MonthNameShortEnum["JUNE"] = "Jun";
7643
- })(exports.MonthNameShortEnum || (exports.MonthNameShortEnum = {}));
7644
-
7645
- /**
7646
- * enum with months indexes.
7647
- * item value match with js Date month index from 0 to 11
7648
- * Order of items match with financial year months order
7649
- */
7650
- exports.MonthNumberEnum = void 0;
7651
- (function (MonthNumberEnum) {
7652
- MonthNumberEnum[MonthNumberEnum["JULY"] = 6] = "JULY";
7653
- MonthNumberEnum[MonthNumberEnum["AUGUST"] = 7] = "AUGUST";
7654
- MonthNumberEnum[MonthNumberEnum["SEPTEMBER"] = 8] = "SEPTEMBER";
7655
- MonthNumberEnum[MonthNumberEnum["OCTOBER"] = 9] = "OCTOBER";
7656
- MonthNumberEnum[MonthNumberEnum["NOVEMBER"] = 10] = "NOVEMBER";
7657
- MonthNumberEnum[MonthNumberEnum["DECEMBER"] = 11] = "DECEMBER";
7658
- MonthNumberEnum[MonthNumberEnum["JANUARY"] = 0] = "JANUARY";
7659
- MonthNumberEnum[MonthNumberEnum["FEBRUARY"] = 1] = "FEBRUARY";
7660
- MonthNumberEnum[MonthNumberEnum["MARCH"] = 2] = "MARCH";
7661
- MonthNumberEnum[MonthNumberEnum["APRIL"] = 3] = "APRIL";
7662
- MonthNumberEnum[MonthNumberEnum["MAY"] = 4] = "MAY";
7663
- MonthNumberEnum[MonthNumberEnum["JUNE"] = 5] = "JUNE";
7664
- })(exports.MonthNumberEnum || (exports.MonthNumberEnum = {}));
7665
-
7666
7695
  var User = /** @class */ (function (_super) {
7667
7696
  __extends(User, _super);
7668
7697
  function User() {
@@ -11105,8 +11134,8 @@
11105
11134
  return this.http.get(this.environment.apiV2 + "/users/current")
11106
11135
  .pipe(operators.map(function (userBase) {
11107
11136
  var user = classTransformer.plainToClass(User, userBase);
11137
+ // @TODO Vik remove
11108
11138
  localStorage.setItem('userId', user.id.toString());
11109
- // @TODO remove
11110
11139
  localStorage.setItem('financialYear', user.financialYear.toString());
11111
11140
  _this.cache = user;
11112
11141
  _this.cacheSubject.next(_this.cache);
@@ -21272,7 +21301,10 @@
21272
21301
  __extends(TransactionForm, _super);
21273
21302
  function TransactionForm(transaction, registeredForGst, allocations, controls) {
21274
21303
  if (controls === void 0) { controls = {}; }
21275
- var _this = _super.call(this, transaction, registeredForGst, Object.assign(controls, { transactions: new forms.FormArray([]) })) || this;
21304
+ var _this = _super.call(this, transaction, registeredForGst, Object.assign(controls, {
21305
+ transactions: new forms.FormArray([]),
21306
+ source: new forms.FormControl(transaction.source || exports.TransactionSourceEnum.BANK_TRANSACTION, forms.Validators.required)
21307
+ })) || this;
21276
21308
  _this.get('date').addValidators([currentFinYearValidator()]);
21277
21309
  // convert child transactions to controls
21278
21310
  transaction.transactions.map(function (transaction) {
@@ -21331,6 +21363,50 @@
21331
21363
  return TransactionForm;
21332
21364
  }(TransactionBaseForm));
21333
21365
 
21366
+ var WorkTransactionForm = /** @class */ (function (_super) {
21367
+ __extends(WorkTransactionForm, _super);
21368
+ function WorkTransactionForm(transaction, registeredForGst, allocations, controls) {
21369
+ if (controls === void 0) { controls = {}; }
21370
+ var _this = _super.call(this, transaction, registeredForGst, allocations, Object.assign(controls, {
21371
+ // additional data related to work (like tax instalments)
21372
+ metadata: new forms.FormArray((transaction.metadata || []).map(function (transactionMetadata) {
21373
+ return new forms.FormGroup({
21374
+ value: new forms.FormControl(transactionMetadata.value),
21375
+ chartAccountsMetadata: new forms.FormControl(transactionMetadata.chartAccountsMetadata)
21376
+ });
21377
+ }))
21378
+ })) || this;
21379
+ _this.listenEvents();
21380
+ return _this;
21381
+ }
21382
+ WorkTransactionForm.prototype.listenEvents = function () {
21383
+ this.watchChartAccounts();
21384
+ };
21385
+ WorkTransactionForm.prototype.watchChartAccounts = function () {
21386
+ var _this = this;
21387
+ _super.prototype.watchChartAccounts.call(this);
21388
+ this.get('chartAccounts').valueChanges.subscribe(function (chartAccounts) {
21389
+ _this.buildMetadataForm();
21390
+ });
21391
+ };
21392
+ /**
21393
+ * depends on chartAccounts the form could include different extra fields
21394
+ */
21395
+ WorkTransactionForm.prototype.buildMetadataForm = function () {
21396
+ var _this = this;
21397
+ // Remove all controls in the FormArray before pushing
21398
+ this.get('metadata').clear();
21399
+ // create form controls for each metadata object from selected chart accounts
21400
+ (this.get('chartAccounts').value.metadata).forEach(function (chartAccountsMetadata) {
21401
+ _this.get('metadata').push(new forms.FormGroup({
21402
+ value: new forms.FormControl(chartAccountsMetadata.isSharePercentage() ? 100 : 0),
21403
+ chartAccountsMetadata: new forms.FormControl(chartAccountsMetadata),
21404
+ }));
21405
+ });
21406
+ };
21407
+ return WorkTransactionForm;
21408
+ }(TransactionForm));
21409
+
21334
21410
  var WorkIncomeForm = /** @class */ (function (_super) {
21335
21411
  __extends(WorkIncomeForm, _super);
21336
21412
  function WorkIncomeForm(transaction, registeredForGst, allocations) {
@@ -21339,13 +21415,6 @@
21339
21415
  // for work income we need to show netAmount instead of amount (because some adjustments are included in amount)
21340
21416
  transaction.amount = transaction.netAmount;
21341
21417
  _this = _super.call(this, transaction, registeredForGst, allocations, {
21342
- // additional data related to work income (like tax instalments)
21343
- metadata: new forms.FormArray((transaction.metadata || []).map(function (transactionMetadata) {
21344
- return new forms.FormGroup({
21345
- value: new forms.FormControl(transactionMetadata.value),
21346
- chartAccountsMetadata: new forms.FormControl(transactionMetadata.chartAccountsMetadata)
21347
- });
21348
- })),
21349
21418
  tax: new forms.FormControl({
21350
21419
  value: transaction.tax,
21351
21420
  disabled: !transaction.chartAccounts || transaction.chartAccounts.isNRAS(),
@@ -21372,8 +21441,8 @@
21372
21441
  return _this;
21373
21442
  }
21374
21443
  WorkIncomeForm.prototype.listenEvents = function () {
21444
+ _super.prototype.listenEvents.call(this);
21375
21445
  this.watchIncomeSource();
21376
- this.watchChartAccounts();
21377
21446
  };
21378
21447
  WorkIncomeForm.prototype.watchIncomeSource = function () {
21379
21448
  var _this = this;
@@ -21391,7 +21460,6 @@
21391
21460
  var _this = this;
21392
21461
  _super.prototype.watchChartAccounts.call(this);
21393
21462
  this.get('chartAccounts').valueChanges.subscribe(function (chartAccounts) {
21394
- _this.buildMetadataForm();
21395
21463
  // tax make no sense for pre-paying tax category
21396
21464
  if (chartAccounts.isNRAS()) {
21397
21465
  _this.get('tax').disable();
@@ -21408,21 +21476,6 @@
21408
21476
  }
21409
21477
  });
21410
21478
  };
21411
- /**
21412
- * depends on chartAccounts the form could include different extra fields
21413
- */
21414
- WorkIncomeForm.prototype.buildMetadataForm = function () {
21415
- var _this = this;
21416
- // Remove all controls in the FormArray before pushing
21417
- this.get('metadata').clear();
21418
- // create form controls for each metadata object from selected chart accounts
21419
- (this.get('chartAccounts').value.metadata).forEach(function (chartAccountsMetadata) {
21420
- _this.get('metadata').push(new forms.FormGroup({
21421
- value: new forms.FormControl(chartAccountsMetadata.isSharePercentage() ? 100 : 0),
21422
- chartAccountsMetadata: new forms.FormControl(chartAccountsMetadata),
21423
- }));
21424
- });
21425
- };
21426
21479
  /**
21427
21480
  * salary comes to bankAccount together with related transactions like tips (kind of salary, but reported in different tax summary section),
21428
21481
  * adjustments used to clarify received payment by separating it into multiple transactions,
@@ -21440,7 +21493,31 @@
21440
21493
  return _super.prototype.submit.call(this, Object.assign(data, { amount: this.getAmount() }));
21441
21494
  };
21442
21495
  return WorkIncomeForm;
21443
- }(TransactionForm));
21496
+ }(WorkTransactionForm));
21497
+
21498
+ var WorkExpenseForm = /** @class */ (function (_super) {
21499
+ __extends(WorkExpenseForm, _super);
21500
+ function WorkExpenseForm() {
21501
+ return _super !== null && _super.apply(this, arguments) || this;
21502
+ }
21503
+ WorkExpenseForm.prototype.listenEvents = function () {
21504
+ this.watchChartAccountsMetadata();
21505
+ };
21506
+ WorkExpenseForm.prototype.watchChartAccountsMetadata = function () {
21507
+ var _this = this;
21508
+ this.get('metadata').valueChanges.subscribe(function (metadata) {
21509
+ var hoursMetadata = new Collection(metadata).findBy('chartAccountsMetadata.id', exports.ChartAccountsMetadataListEnum.HOURS);
21510
+ if (!hoursMetadata) {
21511
+ return;
21512
+ }
21513
+ // for home office hours expense amount is a fixed rate per hour
21514
+ _this.get('amount').reset();
21515
+ _this.get('amount').disable();
21516
+ _this.get('amount').setValue(_this.get('chartAccounts').value.getCurrentYearValue().value * +hoursMetadata.value);
21517
+ });
21518
+ };
21519
+ return WorkExpenseForm;
21520
+ }(WorkTransactionForm));
21444
21521
 
21445
21522
  var DepreciationForm = /** @class */ (function (_super) {
21446
21523
  __extends(DepreciationForm, _super);
@@ -21852,6 +21929,7 @@
21852
21929
  exports.VehicleLogbookForm = VehicleLogbookForm;
21853
21930
  exports.VehicleLogbookService = VehicleLogbookService;
21854
21931
  exports.VehicleService = VehicleService;
21932
+ exports.WorkExpenseForm = WorkExpenseForm;
21855
21933
  exports.WorkIncomeForm = WorkIncomeForm;
21856
21934
  exports.XlsxService = XlsxService;
21857
21935
  exports.atLeastOneCheckedValidator = atLeastOneCheckedValidator;