taxtank-core 0.21.7 → 0.21.10

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 (36) hide show
  1. package/bundles/taxtank-core.umd.js +149 -38
  2. package/bundles/taxtank-core.umd.js.map +1 -1
  3. package/esm2015/lib/collections/collection.js +7 -1
  4. package/esm2015/lib/db/Enums/chart-accounts-heading-list.enum.js +8 -1
  5. package/esm2015/lib/db/Enums/income-source-forecast-trust-type.enum.js +15 -0
  6. package/esm2015/lib/db/Enums/income-source-type-list-other.enum.js +3 -2
  7. package/esm2015/lib/db/Models/incomeSource/income-source-forecast.js +1 -1
  8. package/esm2015/lib/forms/report/my-tax/my-tax-deductions.form.js +9 -3
  9. package/esm2015/lib/forms/report/my-tax/my-tax-partnerships-and-trusts.form.js +5 -2
  10. package/esm2015/lib/interfaces/income-source-forecast.interface.js +1 -1
  11. package/esm2015/lib/models/income-source/income-source-type.js +3 -3
  12. package/esm2015/lib/models/report/my-tax/my-tax-deductions/deduction-fields.const.js +9 -2
  13. package/esm2015/lib/models/report/my-tax/my-tax-deductions/my-tax-deductions.js +16 -16
  14. package/esm2015/lib/models/report/my-tax/my-tax-estimate/my-tax-estimate.js +3 -3
  15. package/esm2015/lib/models/report/my-tax/my-tax-interest/my-tax-interest.js +2 -2
  16. package/esm2015/lib/models/report/my-tax/my-tax-partnerships-and-trusts/my-tax-partnerships-and-trusts.js +20 -2
  17. package/esm2015/lib/models/report/my-tax/my-tax-rent/my-tax-rent.js +35 -9
  18. package/esm2015/lib/validators/conditional.validator.js +26 -0
  19. package/esm2015/lib/validators/index.js +2 -1
  20. package/esm2015/public-api.js +2 -1
  21. package/fesm2015/taxtank-core.js +150 -40
  22. package/fesm2015/taxtank-core.js.map +1 -1
  23. package/lib/collections/collection.d.ts +2 -0
  24. package/lib/db/Enums/chart-accounts-heading-list.enum.d.ts +7 -0
  25. package/lib/db/Enums/income-source-forecast-trust-type.enum.d.ts +13 -0
  26. package/lib/db/Enums/income-source-type-list-other.enum.d.ts +3 -2
  27. package/lib/db/Models/incomeSource/income-source-forecast.d.ts +3 -1
  28. package/lib/forms/report/my-tax/my-tax-deductions.form.d.ts +1 -1
  29. package/lib/forms/report/my-tax/my-tax-partnerships-and-trusts.form.d.ts +1 -1
  30. package/lib/interfaces/income-source-forecast.interface.d.ts +2 -0
  31. package/lib/models/report/my-tax/my-tax-partnerships-and-trusts/my-tax-partnerships-and-trusts.d.ts +9 -1
  32. package/lib/models/report/my-tax/my-tax-rent/my-tax-rent.d.ts +11 -1
  33. package/lib/validators/conditional.validator.d.ts +2 -0
  34. package/lib/validators/index.d.ts +1 -0
  35. package/package.json +1 -1
  36. package/public-api.d.ts +1 -0
@@ -2867,6 +2867,12 @@
2867
2867
  Collection.prototype.removeBy = function (path, values) {
2868
2868
  return this.filter(function (item) { return !(Array.isArray(values) ? values : [values]).includes(get__default["default"](item, path)); });
2869
2869
  };
2870
+ Collection.prototype.minBy = function (path) {
2871
+ return this.items.reduce(function (prev, current) { return (get__default["default"](prev, path) < get__default["default"](current, path) ? prev : current); });
2872
+ };
2873
+ Collection.prototype.maxBy = function (path) {
2874
+ return this.items.reduce(function (prev, current) { return (get__default["default"](prev, path) > get__default["default"](current, path) ? prev : current); });
2875
+ };
2870
2876
  return Collection;
2871
2877
  }());
2872
2878
 
@@ -5688,10 +5694,16 @@
5688
5694
  (function (IncomeSourceTypeListOtherEnum) {
5689
5695
  IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["PSI"] = 6] = "PSI";
5690
5696
  IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
5691
- IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["PARTNERSHIPS_AND_TRUSTS"] = 9] = "PARTNERSHIPS_AND_TRUSTS";
5697
+ IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["TRUSTS"] = 9] = "TRUSTS";
5692
5698
  IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["OTHER_INCOME"] = 10] = "OTHER_INCOME";
5699
+ IncomeSourceTypeListOtherEnum[IncomeSourceTypeListOtherEnum["PARTNERSHIPS"] = 12] = "PARTNERSHIPS";
5693
5700
  })(exports.IncomeSourceTypeListOtherEnum || (exports.IncomeSourceTypeListOtherEnum = {}));
5694
5701
 
5702
+ exports.IncomeSourceTypeListSoleEnum = void 0;
5703
+ (function (IncomeSourceTypeListSoleEnum) {
5704
+ IncomeSourceTypeListSoleEnum[IncomeSourceTypeListSoleEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
5705
+ })(exports.IncomeSourceTypeListSoleEnum || (exports.IncomeSourceTypeListSoleEnum = {}));
5706
+
5695
5707
  var IncomeSourceType = /** @class */ (function (_super) {
5696
5708
  __extends(IncomeSourceType, _super);
5697
5709
  function IncomeSourceType() {
@@ -5707,8 +5719,7 @@
5707
5719
  return !!exports.IncomeSourceTypeListOtherEnum[this.id];
5708
5720
  };
5709
5721
  IncomeSourceType.prototype.isSole = function () {
5710
- // @TODO use IncomeSourceTypeListSoleEnum when sole tank ready
5711
- return !!exports.IncomeSourceTypeListOtherEnum[this.id];
5722
+ return !!exports.IncomeSourceTypeListSoleEnum[this.id];
5712
5723
  };
5713
5724
  Object.defineProperty(IncomeSourceType.prototype, "type", {
5714
5725
  get: function () {
@@ -7134,6 +7145,13 @@
7134
7145
  ChartAccountsHeadingListEnum[ChartAccountsHeadingListEnum["HOME_OFFICE_RUNNING"] = 17] = "HOME_OFFICE_RUNNING";
7135
7146
  ChartAccountsHeadingListEnum[ChartAccountsHeadingListEnum["TOOLS_EQUIPMENT"] = 18] = "TOOLS_EQUIPMENT";
7136
7147
  ChartAccountsHeadingListEnum[ChartAccountsHeadingListEnum["HOME_OFFICE_OCCUPANCY"] = 19] = "HOME_OFFICE_OCCUPANCY";
7148
+ ChartAccountsHeadingListEnum[ChartAccountsHeadingListEnum["AWARD_OVERTIME_MEAL_ALLOWANCE_EXPENSE"] = 20] = "AWARD_OVERTIME_MEAL_ALLOWANCE_EXPENSE";
7149
+ ChartAccountsHeadingListEnum[ChartAccountsHeadingListEnum["NEWSPAPER"] = 21] = "NEWSPAPER";
7150
+ ChartAccountsHeadingListEnum[ChartAccountsHeadingListEnum["PRINTING_POSTAGE_STATIONERY"] = 22] = "PRINTING_POSTAGE_STATIONERY";
7151
+ ChartAccountsHeadingListEnum[ChartAccountsHeadingListEnum["SEMINARS_ETC"] = 23] = "SEMINARS_ETC";
7152
+ ChartAccountsHeadingListEnum[ChartAccountsHeadingListEnum["TELEPHONE"] = 24] = "TELEPHONE";
7153
+ ChartAccountsHeadingListEnum[ChartAccountsHeadingListEnum["UNION_FEES"] = 25] = "UNION_FEES";
7154
+ ChartAccountsHeadingListEnum[ChartAccountsHeadingListEnum["OTHER"] = 26] = "OTHER";
7137
7155
  ChartAccountsHeadingListEnum[ChartAccountsHeadingListEnum["DONATIONS"] = 27] = "DONATIONS";
7138
7156
  ChartAccountsHeadingListEnum[ChartAccountsHeadingListEnum["PSI"] = 30] = "PSI";
7139
7157
  ChartAccountsHeadingListEnum[ChartAccountsHeadingListEnum["BONUSES"] = 34] = "BONUSES";
@@ -7224,10 +7242,20 @@
7224
7242
  DepreciationWriteOffAmountEnum[DepreciationWriteOffAmountEnum["BORROWING_EXPENSES"] = 100] = "BORROWING_EXPENSES";
7225
7243
  })(exports.DepreciationWriteOffAmountEnum || (exports.DepreciationWriteOffAmountEnum = {}));
7226
7244
 
7227
- exports.IncomeSourceTypeListSoleEnum = void 0;
7228
- (function (IncomeSourceTypeListSoleEnum) {
7229
- IncomeSourceTypeListSoleEnum[IncomeSourceTypeListSoleEnum["SOLE_TRADER"] = 7] = "SOLE_TRADER";
7230
- })(exports.IncomeSourceTypeListSoleEnum || (exports.IncomeSourceTypeListSoleEnum = {}));
7245
+ exports.IncomeSourceForecastTrustTypeEnum = void 0;
7246
+ (function (IncomeSourceForecastTrustTypeEnum) {
7247
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["SPECIAL_DISABILITY_TRUST"] = 1] = "SPECIAL_DISABILITY_TRUST";
7248
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["DECEASED_ESTATE"] = 2] = "DECEASED_ESTATE";
7249
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["FIXED_TRUST"] = 3] = "FIXED_TRUST";
7250
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["HYBRID_TRUST"] = 4] = "HYBRID_TRUST";
7251
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["DISCRETIONARY_SERVICE_TRUST"] = 5] = "DISCRETIONARY_SERVICE_TRUST";
7252
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["DISCRETIONARY_TRADING_TRUST"] = 6] = "DISCRETIONARY_TRADING_TRUST";
7253
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["DISCRETIONARY_INVESTMENT_TRUST"] = 7] = "DISCRETIONARY_INVESTMENT_TRUST";
7254
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["CASH_MANAGEMENT_UNIT_TRUST"] = 8] = "CASH_MANAGEMENT_UNIT_TRUST";
7255
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["PUBLIC_UNIT_TRUST_LISTED"] = 9] = "PUBLIC_UNIT_TRUST_LISTED";
7256
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["PUBLIC_UNIT_TRUST_UNLISTED"] = 10] = "PUBLIC_UNIT_TRUST_UNLISTED";
7257
+ IncomeSourceForecastTrustTypeEnum[IncomeSourceForecastTrustTypeEnum["TESTAMENTARY_TRUST"] = 11] = "TESTAMENTARY_TRUST";
7258
+ })(exports.IncomeSourceForecastTrustTypeEnum || (exports.IncomeSourceForecastTrustTypeEnum = {}));
7231
7259
 
7232
7260
  exports.InviteStatusEnum = void 0;
7233
7261
  (function (InviteStatusEnum) {
@@ -9323,7 +9351,14 @@
9323
9351
  exports.ChartAccountsHeadingListEnum.OTHER_WORK_RELATED_EXPENSES,
9324
9352
  exports.ChartAccountsHeadingListEnum.SUBSCRIPTIONS,
9325
9353
  exports.ChartAccountsHeadingListEnum.HOME_OFFICE_RUNNING,
9326
- exports.ChartAccountsHeadingListEnum.HOME_OFFICE_OCCUPANCY
9354
+ exports.ChartAccountsHeadingListEnum.HOME_OFFICE_OCCUPANCY,
9355
+ exports.ChartAccountsHeadingListEnum.AWARD_OVERTIME_MEAL_ALLOWANCE_EXPENSE,
9356
+ exports.ChartAccountsHeadingListEnum.NEWSPAPER,
9357
+ exports.ChartAccountsHeadingListEnum.PRINTING_POSTAGE_STATIONERY,
9358
+ exports.ChartAccountsHeadingListEnum.SEMINARS_ETC,
9359
+ exports.ChartAccountsHeadingListEnum.TELEPHONE,
9360
+ exports.ChartAccountsHeadingListEnum.UNION_FEES,
9361
+ exports.ChartAccountsHeadingListEnum.OTHER
9327
9362
  ],
9328
9363
  workRelatedSelfEducationExpenses: [
9329
9364
  exports.ChartAccountsHeadingListEnum.SELF_EDUCATIONAL_EXPENSES
@@ -9399,45 +9434,45 @@
9399
9434
  this.workRelatedClothingExpenses = this.transactions
9400
9435
  .filterBy('chartAccounts.heading.id', DEDUCTION_CATEGORIES.workRelatedClothingExpenses);
9401
9436
  this.personalSuperContributions = this.transactions
9402
- .filterBy('chartAccounts.heading.id', DEDUCTION_CATEGORIES.personalSuperContributions);
9437
+ .filterBy('chartAccounts.id', DEDUCTION_CATEGORIES.personalSuperContributions);
9403
9438
  this.workRelatedSelfEducationExpenses = this.transactions
9404
9439
  .filterBy('chartAccounts.heading.id', DEDUCTION_CATEGORIES.workRelatedSelfEducationExpenses);
9405
9440
  this.vehicleExpensesTotalAmount = this.getVehicleExpensesTotalAmount();
9406
9441
  this.workRelatedTravelExpensesTotalAmount = this.transactions
9407
9442
  .filterBy('chartAccounts.heading.id', exports.ChartAccountsHeadingListEnum.WORK_RELATED_TRAVEL_EXPENSES)
9408
- .sumBy('amount');
9443
+ .sumBy('claimAmount');
9409
9444
  this.workRelatedClothingType = this.workRelatedClothingExpenses.length ? exports.DeductionClothingTypeEnum.COMPULSORY_C : null;
9410
- this.workRelatedClothingTotalAmount = this.workRelatedClothingExpenses.sumBy('amount');
9445
+ this.workRelatedClothingTotalAmount = this.workRelatedClothingExpenses.sumBy('claimAmount');
9411
9446
  this.workRelatedSelfEducationType = this.workRelatedSelfEducationExpenses.length ?
9412
9447
  exports.DeductionSelfEducationTypeEnum.IMPROVE_SKILLS_FOR_CURRENT_EARNINGS_K : null;
9413
- this.workRelatedSelfEducationTotalAmount = this.workRelatedSelfEducationExpenses.sumBy('amount');
9448
+ this.workRelatedSelfEducationTotalAmount = this.workRelatedSelfEducationExpenses.sumBy('claimAmount');
9414
9449
  this.lowValuePoolDeductionTotalAmount = this.depreciations.getByTankType(exports.TankTypeEnum.WORK)
9415
9450
  .getLowValuePoolDepreciations().sumBy('claimAmount');
9416
9451
  this.interestExpensesTotalAmount = this.transactions
9417
9452
  .filterBy('chartAccounts.heading.id', DEDUCTION_CATEGORIES.interestExpenses)
9418
- .sumBy('amount');
9453
+ .sumBy('claimAmount');
9419
9454
  this.dividendExpensesTotalAmount = this.transactions
9420
9455
  .filterBy('chartAccounts.heading.id', DEDUCTION_CATEGORIES.dividendExpenses)
9421
- .sumBy('amount');
9456
+ .sumBy('claimAmount');
9422
9457
  this.donationsTotalAmount = this.transactions
9423
9458
  .filterBy('chartAccounts.heading.id', DEDUCTION_CATEGORIES.donations)
9424
- .sumBy('amount');
9459
+ .sumBy('claimAmount');
9425
9460
  this.interestsChargedByATOTotalAmount = this.transactions
9426
9461
  .filterBy('chartAccounts.id', DEDUCTION_CATEGORIES.interestsChargedByATO)
9427
- .sumBy('amount');
9462
+ .sumBy('claimAmount');
9428
9463
  this.litigationCostsTotalAmount = this.transactions
9429
9464
  .filterBy('chartAccounts.id', DEDUCTION_CATEGORIES.litigationCosts)
9430
- .sumBy('amount');
9465
+ .sumBy('claimAmount');
9431
9466
  this.otherManagingCostsTotalAmount = this.transactions
9432
9467
  .filterBy('chartAccounts.id', DEDUCTION_CATEGORIES.otherManagingCosts)
9433
- .sumBy('amount');
9434
- this.personalSuperContributionsTotalAmount = this.personalSuperContributions.sumBy('amount');
9468
+ .sumBy('claimAmount');
9469
+ this.personalSuperContributionsTotalAmount = this.personalSuperContributions.sumBy('claimAmount');
9435
9470
  this.forestryManagedInvestmentSchemesDeductionsTotalAmount = this.transactions
9436
9471
  .filterBy('chartAccounts.id', DEDUCTION_CATEGORIES.forestryManagedInvestmentSchemesDeductions)
9437
- .sumBy('amount');
9472
+ .sumBy('claimAmount');
9438
9473
  this.otherDeductionsTotalAmount = this.transactions
9439
9474
  .filterBy('chartAccounts.id', DEDUCTION_CATEGORIES.otherDeductions)
9440
- .sumBy('amount');
9475
+ .sumBy('claimAmount');
9441
9476
  }
9442
9477
  MyTaxDeductions.prototype.getVehicleExpensesTotalAmount = function () {
9443
9478
  var _a;
@@ -9448,7 +9483,7 @@
9448
9483
  };
9449
9484
  MyTaxDeductions.prototype.setVehicleClaimData = function () {
9450
9485
  this.klmsMethodClaimAmount = this.vehicleClaim.getKLMsClaimAmount(this.vehicleClaimRate);
9451
- this.totalExpensesAmount = new VehicleExpenseCollection(this.transactions.getByTankType(this.vehicleClaim.tankType), this.depreciations.getByTankType(this.vehicleClaim.tankType), this.vehicleClaim).sumBy('amount');
9486
+ this.totalExpensesAmount = new VehicleExpenseCollection(this.transactions.getByTankType(this.vehicleClaim.tankType), this.depreciations.getByTankType(this.vehicleClaim.tankType), this.vehicleClaim).sumBy('claimAmount');
9452
9487
  };
9453
9488
  /**
9454
9489
  * Total amount from Other work related expenses and Tools & equipment depreciations
@@ -9456,7 +9491,7 @@
9456
9491
  MyTaxDeductions.prototype.setOtherWorkRelatedExpensesTotalAmount = function () {
9457
9492
  var otherIncomeRelatedExpenses = this.transactions
9458
9493
  .filterBy('chartAccounts.heading.id', DEDUCTION_CATEGORIES.otherIncomeRelatedExpenses);
9459
- this.otherWorkRelatedExpensesTotalAmount = Math.abs(otherIncomeRelatedExpenses.sumBy('amount')) +
9494
+ this.otherWorkRelatedExpensesTotalAmount = Math.abs(otherIncomeRelatedExpenses.sumBy('claimAmount')) +
9460
9495
  this.depreciations.filterBy('chartAccounts.heading.id', exports.ChartAccountsHeadingListEnum.TOOLS_EQUIPMENT).sumBy('claimAmount');
9461
9496
  };
9462
9497
  return MyTaxDeductions;
@@ -9515,8 +9550,8 @@
9515
9550
  var taxOffsetsReportItem = summarySection.items.findBy('taxReturnCategory.id', exports.TaxReturnCategoryListEnum.TAX_OFFSETS);
9516
9551
  var lowMiddleIncomeTaxOffsets = this.getLowMiddleIncomeTaxOffsets(taxOffsetsReportItem);
9517
9552
  var taxPayable = grossTaxPayableReportItem.items.findBy('taxReturnCategory.id', exports.TaxReturnCategoryListEnum.TAX_ON_TAXABLE_INCOME).amount;
9518
- var medicareLevy = medicareReportItem.details.findBy('name', 'Medicare Levy Surcharge').amount;
9519
- var medicareLevySurcharge = medicareReportItem.details.findBy('name', 'Medicare Levy (based on single)').amount;
9553
+ var medicareLevy = medicareReportItem.details.findBy('name', 'Medicare Levy (based on single)').amount;
9554
+ var medicareLevySurcharge = medicareReportItem.details.findBy('name', 'Medicare Levy Surcharge').amount;
9520
9555
  var taxCredits = summarySection.items.findBy('taxReturnCategory.id', exports.TaxReturnCategoryListEnum.TAX_CREDITS).amount;
9521
9556
  var taxOffsets = this.getTaxOffsets(taxOffsetsReportItem.amount, lowMiddleIncomeTaxOffsets);
9522
9557
  return classTransformer.plainToClass(MyTaxEstimate, {
@@ -9624,7 +9659,7 @@
9624
9659
  this.interestPaidTransactions = transactions.filterBy('chartAccounts.id', exports.ChartAccountsListEnum.ATO_INTEREST_PAID);
9625
9660
  this.interestEarnedTotalAmount = this.interestEarnedTransactions.sumBy('amount');
9626
9661
  this.interestEarnedTotalTax = this.interestEarnedTransactions.sumBy('tax');
9627
- this.interestPaidTotalAmount = this.interestEarnedTransactions.sumBy('amount');
9662
+ this.interestPaidTotalAmount = this.interestPaidTransactions.sumBy('amount');
9628
9663
  }
9629
9664
  return MyTaxInterest;
9630
9665
  }());
@@ -9676,12 +9711,14 @@
9676
9711
  }());
9677
9712
 
9678
9713
  var MyTaxPartnershipsAndTrusts = /** @class */ (function () {
9679
- function MyTaxPartnershipsAndTrusts(transactions) {
9714
+ function MyTaxPartnershipsAndTrusts(transactions, incomeSources) {
9680
9715
  this.transactions = transactions;
9716
+ this.incomeSources = incomeSources;
9681
9717
  this.partnershipIncomes = this.transactions.filterBy('chartAccounts.id', exports.ChartAccountsListEnum.PARTNERSHIP_INCOME);
9682
9718
  this.partnershipExpenses = this.transactions.filterBy('chartAccounts.id', exports.ChartAccountsListEnum.PARTNERSHIP_EXPENSES);
9683
9719
  this.trustsIncomes = this.transactions.filterBy('chartAccounts.id', exports.ChartAccountsListEnum.TRUST_INCOME);
9684
9720
  this.trustsExpenses = this.transactions.filterBy('chartAccounts.id', exports.ChartAccountsListEnum.TRUST_EXPENSES);
9721
+ this.trustType = this.getTrustType();
9685
9722
  this.netNonPrimaryProductionAmount = (this.partnershipIncomes.sumBy('amount') - this.partnershipExpenses.sumBy('amount')) +
9686
9723
  (this.trustsIncomes.sumBy('amount') - this.trustsExpenses.sumBy('amount'));
9687
9724
  this.partnershipsNetIncome = this.partnershipIncomes.sumBy('amount') -
@@ -9701,30 +9738,71 @@
9701
9738
  .sumBy('value');
9702
9739
  this.taxOffsetNRASTotalAmount = this.transactions.filterBy('chartAccounts.id', exports.ChartAccountsListEnum.TAX_OFFSETS_N_R_A_S).sumBy('amount');
9703
9740
  }
9741
+ /**
9742
+ * Get Income source forecast trust type, related to trust income with max amount
9743
+ */
9744
+ MyTaxPartnershipsAndTrusts.prototype.getTrustType = function () {
9745
+ var filteredTrustIncomes = this.trustsIncomes
9746
+ .filterBy('incomeSource.id', this.incomeSources
9747
+ .removeBy('actualForecast.trustType', null)
9748
+ .getIds());
9749
+ if (!filteredTrustIncomes.length) {
9750
+ return null;
9751
+ }
9752
+ return this.incomeSources
9753
+ .findBy('id', filteredTrustIncomes.maxBy('amount').incomeSource.id)
9754
+ .actualForecast
9755
+ .trustType;
9756
+ };
9704
9757
  return MyTaxPartnershipsAndTrusts;
9705
9758
  }());
9706
9759
 
9707
9760
  var MyTaxRent = /** @class */ (function () {
9708
- function MyTaxRent(transactions, depreciations) {
9761
+ function MyTaxRent(transactions, depreciations, taxSummary) {
9709
9762
  this.propertyExpenses = transactions.getPropertyTransactions().getExpenseTransactions();
9763
+ this.taxSummaryPropertySection = taxSummary.property;
9710
9764
  this.grossRentAmount = transactions
9765
+ .getPropertyTransactions()
9711
9766
  .getIncomeTransactions()
9712
9767
  .filterBy('chartAccounts.id', exports.ChartAccountsListEnum.RENTAL_INCOME)
9713
- .sumBy('amount') +
9714
- transactions.
9715
- getIncomeTransactions()
9768
+ .sumBy('claimAmount') +
9769
+ transactions
9770
+ .getPropertyTransactions()
9771
+ .getIncomeTransactions()
9716
9772
  .filterBy('chartAccounts.id', exports.ChartAccountsListEnum.OTHER_RENTAL_INCOME)
9717
- .sumBy('amount');
9773
+ .sumBy('claimAmount');
9718
9774
  this.interestDeductionsAmount = Math.abs(transactions.getInterestTransactions().sumBy('amount'));
9719
9775
  this.capitalWorksDeductionsAmount = Math.abs(depreciations.getCapitalDepreciations().sumBy('claimAmount'));
9720
- this.otherRentalDeductionsAmount = Math.abs(depreciations.getAssets().sumBy('claimAmount') +
9721
- depreciations.getBorrowingExpenseDepreciations().sumBy('claimAmount') +
9722
- this.propertyExpenses.sumBy('amount'));
9776
+ this.otherRentalDeductionsAmount = this.calculateOtherRentalDeductionsAmount();
9777
+ /**
9778
+ * @Todo Vik uncomment when task TT-2009 will be implemented
9779
+ */
9780
+ // this.otherRentalDeductionsAmount = depreciations.getByTankType(TankTypeEnum.PROPERTY).getAssets().claimAmount +
9781
+ // depreciations.getByTankType(TankTypeEnum.PROPERTY).getBorrowingExpenseDepreciations().claimAmount +
9782
+ // Math.abs(this.propertyExpenses.sumBy('claimAmount'));
9723
9783
  this.netRent = this.grossRentAmount -
9724
9784
  this.interestDeductionsAmount -
9725
9785
  this.capitalWorksDeductionsAmount -
9726
9786
  this.otherRentalDeductionsAmount;
9727
9787
  }
9788
+ /**
9789
+ * @Todo Vik remove when TT-2009 will be implemented.
9790
+ * We use tax summary data here because claim amount from depreciation is different
9791
+ * from the claim amount that we get from tax summary (depreciation claim amount is not affected by property share,
9792
+ * property contract date, e.t.c.). Details in the TT-2009 task
9793
+ */
9794
+ MyTaxRent.prototype.calculateOtherRentalDeductionsAmount = function () {
9795
+ var plantAndEquipmentAmount = Math.abs(this.taxSummaryPropertySection.items
9796
+ .findBy('taxReturnCategory.id', exports.TaxReturnCategoryListEnum.DEPRECIATION)
9797
+ .amount);
9798
+ var borrowingExpensesAmount = Math.abs(this.taxSummaryPropertySection.items
9799
+ .findBy('taxReturnCategory.id', exports.TaxReturnCategoryListEnum.BORROWING_EXPENSES)
9800
+ .amount);
9801
+ var otherRentalDeductionsAmount = Math.abs(this.taxSummaryPropertySection.items
9802
+ .findBy('taxReturnCategory.id', exports.TaxReturnCategoryListEnum.OTHER_RENTAL_DEDUCTIONS)
9803
+ .amount);
9804
+ return +Math.floor(plantAndEquipmentAmount + borrowingExpensesAmount + otherRentalDeductionsAmount).toFixed(2);
9805
+ };
9728
9806
  return MyTaxRent;
9729
9807
  }());
9730
9808
 
@@ -15265,6 +15343,31 @@
15265
15343
  };
15266
15344
  }
15267
15345
 
15346
+ function conditionalValidator(condition, validator) {
15347
+ return function (control) {
15348
+ revalidateOnChanges(control);
15349
+ if (control && control.parent) {
15350
+ if (condition(control.parent)) {
15351
+ return validator(control);
15352
+ }
15353
+ }
15354
+ return null;
15355
+ };
15356
+ }
15357
+ /**
15358
+ * Conditional validator depends on other fields and should be updated on each form value change
15359
+ */
15360
+ function revalidateOnChanges(control) {
15361
+ if (control && control.parent && !control['_revalidateOnChanges']) {
15362
+ control['_revalidateOnChanges'] = true;
15363
+ control.parent.valueChanges.pipe(operators.distinctUntilChanged(function (a, b) { return JSON.stringify(a) === JSON.stringify(b); }))
15364
+ .subscribe(function () {
15365
+ control.updateValueAndValidity({ emitEvent: false });
15366
+ });
15367
+ }
15368
+ return;
15369
+ }
15370
+
15268
15371
  /**
15269
15372
  * Regular expressions that are used to check password strength and valid values
15270
15373
  */
@@ -15553,12 +15656,12 @@
15553
15656
  value: deductions.workRelatedTravelExpensesTotalAmount,
15554
15657
  disabled: true
15555
15658
  }),
15556
- workRelatedClothingType: new forms.FormControl(deductions.workRelatedClothingType, forms.Validators.required),
15659
+ workRelatedClothingType: new forms.FormControl(deductions.workRelatedClothingType, conditionalValidator(function () { return !!deductions.workRelatedClothingTotalAmount; }, forms.Validators.required)),
15557
15660
  workRelatedClothingTotalAmount: new forms.FormControl({
15558
15661
  value: deductions.workRelatedClothingTotalAmount,
15559
15662
  disabled: true
15560
15663
  }),
15561
- workRelatedSelfEducationType: new forms.FormControl(deductions.workRelatedSelfEducationType, forms.Validators.required),
15664
+ workRelatedSelfEducationType: new forms.FormControl(deductions.workRelatedSelfEducationType, conditionalValidator(function () { return !!deductions.workRelatedSelfEducationTotalAmount; }, forms.Validators.required)),
15562
15665
  workRelatedSelfEducationTotalAmount: new forms.FormControl({
15563
15666
  value: deductions.workRelatedSelfEducationTotalAmount,
15564
15667
  disabled: true
@@ -15595,6 +15698,11 @@
15595
15698
  value: deductions.otherManagingCostsTotalAmount,
15596
15699
  disabled: true
15597
15700
  }),
15701
+ fundName: new forms.FormControl(''),
15702
+ hasFund: new forms.FormControl(false),
15703
+ fundABN: new forms.FormControl(''),
15704
+ fundTFN: new forms.FormControl(''),
15705
+ fundAccountNumber: new forms.FormControl(''),
15598
15706
  personalSuperContributionsTotalAmount: new forms.FormControl({
15599
15707
  value: deductions.personalSuperContributionsTotalAmount,
15600
15708
  disabled: true
@@ -15873,7 +15981,9 @@
15873
15981
  value: partnershipsAndTrusts.trustsNetIncome,
15874
15982
  disabled: true
15875
15983
  }),
15876
- trustType: new forms.FormControl(1),
15984
+ trustType: new forms.FormControl(partnershipsAndTrusts.trustType, conditionalValidator(function (control) {
15985
+ return !!partnershipsAndTrusts.trustsIncomes.length;
15986
+ }, forms.Validators.required)),
15877
15987
  partnershipsSmallBusinessNetIncome: new forms.FormControl(partnershipsAndTrusts.partnershipsSmallBusinessNetIncome, forms.Validators.required),
15878
15988
  trustsSmallBusinessNetIncome: new forms.FormControl(partnershipsAndTrusts.trustsSmallBusinessNetIncome, forms.Validators.required),
15879
15989
  taxPaidTotal: new forms.FormControl({
@@ -16200,6 +16310,7 @@
16200
16310
  exports.cloneDeep = cloneDeep;
16201
16311
  exports.compare = compare;
16202
16312
  exports.compareMatOptions = compareMatOptions;
16313
+ exports.conditionalValidator = conditionalValidator;
16203
16314
  exports.createDate = createDate;
16204
16315
  exports.displayMatOptions = displayMatOptions;
16205
16316
  exports.enumToList = enumToList;