taxtank-core 0.28.41 → 0.28.43

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.
@@ -3046,7 +3046,7 @@
3046
3046
  var min = propertyItem.price.product.minQty;
3047
3047
  // if user has property subscription and number of properties doesn't exceed the maximum in the service product - return one more
3048
3048
  if (this.hasItem(propertyItem)) {
3049
- propertiesQty = propertiesQty < max ? propertiesQty + 1 : max;
3049
+ propertiesQty = this.propertyQuantity < max ? this.propertyQuantity + 1 : max;
3050
3050
  }
3051
3051
  return Math.max(min, propertiesQty);
3052
3052
  };
@@ -8893,11 +8893,34 @@
8893
8893
  }
8894
8894
  return this.create(result);
8895
8895
  };
8896
+ ReportItemCollection.prototype.getByCategory = function (categoryId) {
8897
+ var e_2, _a;
8898
+ var result = [];
8899
+ try {
8900
+ for (var _b = __values(this.items), _c = _b.next(); !_c.done; _c = _b.next()) {
8901
+ var reportItem = _c.value;
8902
+ if (reportItem.taxReturnCategory.id === categoryId) {
8903
+ result.push(reportItem);
8904
+ }
8905
+ else if (reportItem.items && reportItem.items.getByCategory(categoryId).length) {
8906
+ result.push.apply(result, __spreadArray([], __read(reportItem.items.getByCategory(categoryId))));
8907
+ }
8908
+ }
8909
+ }
8910
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
8911
+ finally {
8912
+ try {
8913
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8914
+ }
8915
+ finally { if (e_2) throw e_2.error; }
8916
+ }
8917
+ return result;
8918
+ };
8896
8919
  /**
8897
8920
  * Recursively find report item by Tax Return Category ID
8898
8921
  */
8899
8922
  ReportItemCollection.prototype.findByCategory = function (categoryId) {
8900
- var e_2, _a;
8923
+ var e_3, _a;
8901
8924
  var result;
8902
8925
  try {
8903
8926
  for (var _b = __values(this.items), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -8913,35 +8936,54 @@
8913
8936
  }
8914
8937
  }
8915
8938
  }
8916
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
8939
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
8917
8940
  finally {
8918
8941
  try {
8919
8942
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8920
8943
  }
8921
- finally { if (e_2) throw e_2.error; }
8944
+ finally { if (e_3) throw e_3.error; }
8922
8945
  }
8923
8946
  return result;
8924
8947
  };
8925
8948
  /**
8926
- * Get Collection of report items by Tax Return Categories IDs
8949
+ * get Collection of report items by Tax Return Categories IDs (one item per category)
8927
8950
  */
8928
- ReportItemCollection.prototype.getByCategories = function (categories) {
8951
+ ReportItemCollection.prototype.findByCategories = function (categories) {
8929
8952
  var _this = this;
8930
8953
  return this.create(compact__default["default"](categories.map(function (category) { return _this.findByCategory(category); })));
8931
8954
  };
8955
+ /**
8956
+ * Get Collection of report items by Tax Return Categories IDs (all items per category)
8957
+ */
8958
+ ReportItemCollection.prototype.getByCategories = function (categories) {
8959
+ var _this = this;
8960
+ var reportItems = [];
8961
+ categories.forEach(function (category) {
8962
+ reportItems.push.apply(reportItems, __spreadArray([], __read(_this.getByCategory(category))));
8963
+ });
8964
+ return this.create(reportItems);
8965
+ };
8932
8966
  /**
8933
8967
  * A short call to a chain of methods that we often use.
8934
8968
  * Get total amount of report items by Tax Return categories and Tax Summary Section.
8935
8969
  */
8936
8970
  ReportItemCollection.prototype.sumByCategoriesAndSection = function (categories, section) {
8937
- return this.getByCategories(categories).getBySection(section).sumBy('amount');
8971
+ return this.findByCategories(categories).getBySection(section).sumBy('amount');
8972
+ };
8973
+ /**
8974
+ * @TODO vik refactor once Nicole approved
8975
+ * unlike sumByCategoriesAndSection, which find just one reportItem per category,
8976
+ * this method will search for recursively for all matches
8977
+ */
8978
+ ReportItemCollection.prototype.sumByCategories = function (categories) {
8979
+ return this.getByCategories(categories).sumBy('amount');
8938
8980
  };
8939
8981
  /**
8940
8982
  * Get collection of all report item details related to passed income source
8941
8983
  * @TODO Alex: consider to create and move to ReportItemDetailsCollection
8942
8984
  */
8943
8985
  ReportItemCollection.prototype.getDetailsByIncomeSource = function (incomeSource) {
8944
- var e_3, _a;
8986
+ var e_4, _a;
8945
8987
  var result = [];
8946
8988
  try {
8947
8989
  for (var _b = __values(this.items), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -8954,12 +8996,12 @@
8954
8996
  }
8955
8997
  }
8956
8998
  }
8957
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
8999
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
8958
9000
  finally {
8959
9001
  try {
8960
9002
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8961
9003
  }
8962
- finally { if (e_3) throw e_3.error; }
9004
+ finally { if (e_4) throw e_4.error; }
8963
9005
  }
8964
9006
  return new Collection(result);
8965
9007
  };
@@ -9027,6 +9069,9 @@
9027
9069
  TaxReturnCategoryListEnum[TaxReturnCategoryListEnum["TAX_OFFSETS_MIDDLE"] = 62] = "TAX_OFFSETS_MIDDLE";
9028
9070
  TaxReturnCategoryListEnum[TaxReturnCategoryListEnum["TAX_OFFSETS_SOLE"] = 63] = "TAX_OFFSETS_SOLE";
9029
9071
  TaxReturnCategoryListEnum[TaxReturnCategoryListEnum["TAX_PAYABLE"] = 28] = "TAX_PAYABLE";
9072
+ TaxReturnCategoryListEnum[TaxReturnCategoryListEnum["BUSINESS_INCOME_OR_LOSS"] = 59] = "BUSINESS_INCOME_OR_LOSS";
9073
+ TaxReturnCategoryListEnum[TaxReturnCategoryListEnum["DEFERRED_BUSINESS_LOSSES_FROM_PRIOR_YEAR"] = 64] = "DEFERRED_BUSINESS_LOSSES_FROM_PRIOR_YEAR";
9074
+ TaxReturnCategoryListEnum[TaxReturnCategoryListEnum["DEFERRED_BUSINESS_LOSSES"] = 60] = "DEFERRED_BUSINESS_LOSSES";
9030
9075
  })(exports.TaxReturnCategoryListEnum || (exports.TaxReturnCategoryListEnum = {}));
9031
9076
 
9032
9077
  var TAX_RETURN_CATEGORIES = {
@@ -9112,10 +9157,15 @@
9112
9157
  exports.TaxReturnCategoryListEnum.RENT_EXPENSES,
9113
9158
  exports.TaxReturnCategoryListEnum.INTEREST_EXPENSES_WITHIN_AUSTRALIA,
9114
9159
  exports.TaxReturnCategoryListEnum.INTEREST_EXPENSES_OVERSEAS,
9115
- exports.TaxReturnCategoryListEnum.DEPRECIATION_EXPENSES,
9116
9160
  exports.TaxReturnCategoryListEnum.MOTOR_VEHICLE_EXPENSES,
9117
9161
  exports.TaxReturnCategoryListEnum.ALL_OTHER_EXPENSES
9118
9162
  ],
9163
+ depreciation: [
9164
+ exports.TaxReturnCategoryListEnum.DEPRECIATION_EXPENSES,
9165
+ ],
9166
+ loss: [
9167
+ exports.TaxReturnCategoryListEnum.DEFERRED_BUSINESS_LOSSES_FROM_PRIOR_YEAR,
9168
+ ],
9119
9169
  taxOffsets: [
9120
9170
  exports.TaxReturnCategoryListEnum.TAX_OFFSETS_SOLE
9121
9171
  ],
@@ -11855,7 +11905,7 @@
11855
11905
  get: function () {
11856
11906
  var income = this.sole.items.sumByCategoriesAndSection(TAX_RETURN_CATEGORIES.sole.income, exports.TaxSummarySectionEnum.SOLE_TANK);
11857
11907
  var expenses = this.sole.items.sumByCategoriesAndSection(TAX_RETURN_CATEGORIES.sole.expenses, exports.TaxSummarySectionEnum.SOLE_TANK);
11858
- return income - Math.abs(expenses);
11908
+ return income + expenses;
11859
11909
  },
11860
11910
  enumerable: false,
11861
11911
  configurable: true
@@ -11866,9 +11916,11 @@
11866
11916
  * https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/217677990/Dashboard+Main
11867
11917
  */
11868
11918
  get: function () {
11869
- var income = this.sole.items.sumByCategoriesAndSection(TAX_RETURN_CATEGORIES.sole.income, exports.TaxSummarySectionEnum.SOLE_TANK);
11870
- var expenses = this.sole.items.sumByCategoriesAndSection(TAX_RETURN_CATEGORIES.sole.expenses, exports.TaxSummarySectionEnum.SOLE_TANK);
11871
- return income - Math.abs(expenses);
11919
+ var income = this.sole.items.sumByCategories(TAX_RETURN_CATEGORIES.sole.income);
11920
+ var expenses = this.sole.items.sumByCategories(TAX_RETURN_CATEGORIES.sole.expenses);
11921
+ var depreciation = this.sole.items.sumByCategories(TAX_RETURN_CATEGORIES.sole.expenses);
11922
+ var loss = this.sole.items.sumByCategories(TAX_RETURN_CATEGORIES.sole.loss);
11923
+ return income + expenses + depreciation - loss;
11872
11924
  },
11873
11925
  enumerable: false,
11874
11926
  configurable: true
@@ -12297,8 +12349,9 @@
12297
12349
  return _this;
12298
12350
  }
12299
12351
  SoleInvoiceService.prototype.updateStatus = function (invoice, status) {
12352
+ var updatedInvoice = Object.assign({}, invoice, { status: status });
12300
12353
  // use id only to avoid unexpected changes
12301
- return this.update(classTransformer.plainToClass(SoleInvoice, merge__default["default"]({}, { id: invoice.id }, { status: status })));
12354
+ return this.update(updatedInvoice);
12302
12355
  };
12303
12356
  SoleInvoiceService.prototype.publish = function (invoice, document) {
12304
12357
  // use id only to avoid unexpected changes