taxtank-core 0.33.51 → 0.33.52

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 (30) hide show
  1. package/esm2022/src/lib/collections/depreciation.collection.mjs +2 -2
  2. package/esm2022/src/lib/collections/income-source/income-source.collection.mjs +2 -2
  3. package/esm2022/src/lib/collections/transaction/transaction.collection.mjs +3 -3
  4. package/esm2022/src/lib/collections/vehicle/vehicle-logbook.collection.mjs +2 -2
  5. package/esm2022/src/lib/db/Enums/chart-accounts/chart-accounts-adjustment-included-list.enum.mjs +4 -1
  6. package/esm2022/src/lib/db/Enums/tank-type.enum.mjs +6 -6
  7. package/esm2022/src/lib/db/Models/bank/bank-account.mjs +1 -1
  8. package/esm2022/src/lib/db/Models/transaction/transaction-base.mjs +6 -6
  9. package/esm2022/src/lib/forms/bank/bank-account/bank-account-allocation.form.mjs +3 -3
  10. package/esm2022/src/lib/forms/bank/bank-account/bank-account-properties.form.mjs +2 -2
  11. package/esm2022/src/lib/forms/sole/sole-business-allocations.form.mjs +2 -2
  12. package/esm2022/src/lib/forms/transaction/allocation-rule.form.mjs +11 -11
  13. package/esm2022/src/lib/forms/transaction/transaction-base-filter.form.mjs +3 -3
  14. package/esm2022/src/lib/forms/transaction/work/work-income.form.mjs +6 -4
  15. package/esm2022/src/lib/models/bank/allocation-group.mjs +2 -2
  16. package/esm2022/src/lib/models/bank/bank-account.mjs +1 -12
  17. package/esm2022/src/lib/models/bank/bank-transaction.mjs +3 -2
  18. package/esm2022/src/lib/models/report/my-tax/my-tax-deductions/my-tax-deductions.mjs +2 -2
  19. package/esm2022/src/lib/models/transaction/allocation-rule.mjs +4 -4
  20. package/esm2022/src/lib/models/transaction/transaction.mjs +3 -4
  21. package/esm2022/src/lib/models/user/user.mjs +5 -5
  22. package/esm2022/src/lib/models/vehicle/vehicle-claim.mjs +2 -2
  23. package/esm2022/src/lib/models/vehicle/vehicle-logbook.mjs +3 -3
  24. package/fesm2022/taxtank-core.mjs +53 -59
  25. package/fesm2022/taxtank-core.mjs.map +1 -1
  26. package/package.json +1 -1
  27. package/src/lib/db/Enums/chart-accounts/chart-accounts-adjustment-included-list.enum.d.ts +3 -0
  28. package/src/lib/db/Enums/tank-type.enum.d.ts +5 -5
  29. package/src/lib/db/Models/bank/bank-account.d.ts +2 -0
  30. package/src/lib/models/bank/bank-account.d.ts +0 -2
@@ -258,11 +258,11 @@ let DepreciationForecast$1 = class DepreciationForecast extends AbstractModel {
258
258
 
259
259
  var TankTypeEnum;
260
260
  (function (TankTypeEnum) {
261
- TankTypeEnum[TankTypeEnum["PROPERTY"] = 1] = "PROPERTY";
262
- TankTypeEnum[TankTypeEnum["WORK"] = 2] = "WORK";
263
- TankTypeEnum[TankTypeEnum["OTHER"] = 3] = "OTHER";
264
- TankTypeEnum[TankTypeEnum["SOLE"] = 4] = "SOLE";
265
- TankTypeEnum[TankTypeEnum["HOLDING"] = 5] = "HOLDING";
261
+ TankTypeEnum[TankTypeEnum["PROPERTY_TANK"] = 1] = "PROPERTY_TANK";
262
+ TankTypeEnum[TankTypeEnum["WORK_TANK"] = 2] = "WORK_TANK";
263
+ TankTypeEnum[TankTypeEnum["OTHER_TANK"] = 3] = "OTHER_TANK";
264
+ TankTypeEnum[TankTypeEnum["SOLE_TANK"] = 4] = "SOLE_TANK";
265
+ TankTypeEnum[TankTypeEnum["HOLDING_TANK"] = 5] = "HOLDING_TANK";
266
266
  TankTypeEnum[TankTypeEnum["PERSONAL"] = 6] = "PERSONAL";
267
267
  })(TankTypeEnum || (TankTypeEnum = {}));
268
268
 
@@ -276,15 +276,15 @@ class TransactionBase extends ObservableModel {
276
276
  get tankType() {
277
277
  switch (true) {
278
278
  case this.isPropertyTank():
279
- return TankTypeEnum.PROPERTY;
279
+ return TankTypeEnum.PROPERTY_TANK;
280
280
  case this.isWorkTank():
281
- return TankTypeEnum.WORK;
281
+ return TankTypeEnum.WORK_TANK;
282
282
  case this.isSoleTank():
283
- return TankTypeEnum.SOLE;
283
+ return TankTypeEnum.SOLE_TANK;
284
284
  case this.isHoldingTank():
285
- return TankTypeEnum.HOLDING;
285
+ return TankTypeEnum.HOLDING_TANK;
286
286
  case this.isOtherTank():
287
- return TankTypeEnum.OTHER;
287
+ return TankTypeEnum.OTHER_TANK;
288
288
  default:
289
289
  return TankTypeEnum.PERSONAL;
290
290
  }
@@ -689,7 +689,7 @@ class AllocationGroup extends AbstractModel {
689
689
  operation: TransactionOperationEnum.ALLOCATE_INVOICE,
690
690
  description: invoice.reference,
691
691
  invoiceNumber: invoice.getNumber(),
692
- tankType: TankTypeEnum.SOLE,
692
+ tankType: TankTypeEnum.SOLE_TANK,
693
693
  amount: invoice.grossPrice,
694
694
  allocations,
695
695
  bankTransactions
@@ -1129,6 +1129,9 @@ var ChartAccountsSalaryAdjustmentsListEnum;
1129
1129
  ChartAccountsSalaryAdjustmentsListEnum[ChartAccountsSalaryAdjustmentsListEnum["WORK_PLACE_GIVING"] = 653] = "WORK_PLACE_GIVING";
1130
1130
  })(ChartAccountsSalaryAdjustmentsListEnum || (ChartAccountsSalaryAdjustmentsListEnum = {}));
1131
1131
 
1132
+ /**
1133
+ * list of child transactions included in parent amount
1134
+ */
1132
1135
  var ChartAccountsAdjustmentIncludedListEnum;
1133
1136
  (function (ChartAccountsAdjustmentIncludedListEnum) {
1134
1137
  ChartAccountsAdjustmentIncludedListEnum[ChartAccountsAdjustmentIncludedListEnum["ALLOWANCE"] = 4] = "ALLOWANCE";
@@ -5023,11 +5026,11 @@ class VehicleLogbook extends VehicleLogbook$1 {
5023
5026
  get tankType() {
5024
5027
  switch (true) {
5025
5028
  case !!this.business:
5026
- return TankTypeEnum.SOLE;
5029
+ return TankTypeEnum.SOLE_TANK;
5027
5030
  case this.isPersonal:
5028
5031
  return TankTypeEnum.PERSONAL;
5029
5032
  default:
5030
- return TankTypeEnum.WORK;
5033
+ return TankTypeEnum.WORK_TANK;
5031
5034
  }
5032
5035
  }
5033
5036
  }
@@ -5091,7 +5094,7 @@ class VehicleClaim extends VehicleClaim$1 {
5091
5094
  return !!this.business;
5092
5095
  }
5093
5096
  get tankType() {
5094
- return this.isSoleTank() ? TankTypeEnum.SOLE : TankTypeEnum.WORK;
5097
+ return this.isSoleTank() ? TankTypeEnum.SOLE_TANK : TankTypeEnum.WORK_TANK;
5095
5098
  }
5096
5099
  /**
5097
5100
  * Claim amount for KMs method. Exists only for KMs method.
@@ -5413,16 +5416,16 @@ class User extends User$1 {
5413
5416
  getTankTypes() {
5414
5417
  const tankTypes = [];
5415
5418
  if (this.roles.includes(UserRolesEnum.WORK_TANK)) {
5416
- tankTypes.push(TankTypeEnum.WORK);
5419
+ tankTypes.push(TankTypeEnum.WORK_TANK);
5417
5420
  }
5418
5421
  if (this.roles.includes(UserRolesEnum.PROPERTY_TANK)) {
5419
- tankTypes.push(TankTypeEnum.PROPERTY);
5422
+ tankTypes.push(TankTypeEnum.PROPERTY_TANK);
5420
5423
  }
5421
5424
  if (this.roles.includes(UserRolesEnum.SOLE_TANK)) {
5422
- tankTypes.push(TankTypeEnum.SOLE);
5425
+ tankTypes.push(TankTypeEnum.SOLE_TANK);
5423
5426
  }
5424
5427
  if (this.roles.includes(UserRolesEnum.HOLDING_TANK)) {
5425
- tankTypes.push(TankTypeEnum.HOLDING);
5428
+ tankTypes.push(TankTypeEnum.HOLDING_TANK);
5426
5429
  }
5427
5430
  tankTypes.push(TankTypeEnum.PERSONAL);
5428
5431
  return tankTypes;
@@ -6412,8 +6415,7 @@ class Transaction extends Transaction$1 {
6412
6415
  return grossAmount;
6413
6416
  }
6414
6417
  // included transactions affect parent transaction amount and as a result grossAmount, skip to avoid double sum
6415
- const adjustments = new Collection(this.transactions)
6416
- .filter(transaction => !transaction.chartAccounts?.isAdjustmentIncluded());
6418
+ const adjustments = new Collection(this.transactions).filter(transaction => ![ChartAccountsAdjustmentIncludedListEnum.FUNDS_OVER_ADJUSTMENT, ChartAccountsAdjustmentIncludedListEnum.LANDLORD_REIMBURSEMENT].includes(transaction.chartAccounts?.id));
6417
6419
  const income = adjustments.filter(transaction => transaction.isIncome()).sumBy('amount');
6418
6420
  const expense = adjustments.filter(transaction => transaction.isExpense()).sumBy('amount', true);
6419
6421
  // all adjustments except property income increase grossIncome
@@ -6536,13 +6538,13 @@ class AllocationRule extends AllocationRule$1 {
6536
6538
  return this.type === AllocationRuleTypeEnum.TRANSFER;
6537
6539
  }
6538
6540
  isPropertyTank() {
6539
- return this.transaction.tankType === TankTypeEnum.PROPERTY;
6541
+ return this.transaction.tankType === TankTypeEnum.PROPERTY_TANK;
6540
6542
  }
6541
6543
  isWorkTank() {
6542
- return this.transaction.tankType === TankTypeEnum.WORK;
6544
+ return this.transaction.tankType === TankTypeEnum.WORK_TANK;
6543
6545
  }
6544
6546
  isSoleTank() {
6545
- return this.transaction.tankType === TankTypeEnum.SOLE;
6547
+ return this.transaction.tankType === TankTypeEnum.SOLE_TANK;
6546
6548
  }
6547
6549
  isPropertyIncome() {
6548
6550
  return this.isIncome() && this.isPropertyTank();
@@ -6935,7 +6937,7 @@ class TransactionCollection extends TransactionBaseCollection {
6935
6937
  * Get new collection of property transactions
6936
6938
  */
6937
6939
  getPropertyTransactions() {
6938
- return this.filterBy('tankType', TankTypeEnum.PROPERTY);
6940
+ return this.filterBy('tankType', TankTypeEnum.PROPERTY_TANK);
6939
6941
  }
6940
6942
  getDebitTransactions() {
6941
6943
  return new TransactionCollection(this.items.filter((transaction) => transaction.isDebit()));
@@ -7004,7 +7006,7 @@ class TransactionCollection extends TransactionBaseCollection {
7004
7006
  // sole tank may have multiple vehicle claims, so we need to filter by business.id
7005
7007
  ? this.getVehicleTransactions().filterBy('business.id', vehicleClaim.business.id)
7006
7008
  // work tank may have only one vehicle claim, so we need to filter by tank type
7007
- : this.getVehicleTransactions().filterBy('tankType', TankTypeEnum.WORK);
7009
+ : this.getVehicleTransactions().filterBy('tankType', TankTypeEnum.WORK_TANK);
7008
7010
  }
7009
7011
  /**
7010
7012
  * Get list of vehicle transactions except KMS transactions
@@ -7185,7 +7187,7 @@ class DepreciationCollection extends TransactionBaseCollection {
7185
7187
  // sole tank may have multiple vehicle claims, so we need to filter by business.id
7186
7188
  ? this.getVehicleDepreciations().filterBy('business.id', vehicleClaim.business.id)
7187
7189
  // work tank may have only one vehicle claim, so we need to filter by tank type
7188
- : this.getVehicleDepreciations().filterBy('tankType', TankTypeEnum.WORK);
7190
+ : this.getVehicleDepreciations().filterBy('tankType', TankTypeEnum.WORK_TANK);
7189
7191
  }
7190
7192
  getExportBody(params) {
7191
7193
  return [];
@@ -7602,7 +7604,7 @@ class MyTaxDeductions {
7602
7604
  this.workRelatedSelfEducationType = this.workRelatedSelfEducationExpenses.length ?
7603
7605
  DeductionSelfEducationTypeEnum.IMPROVE_SKILLS_FOR_CURRENT_EARNINGS_K : null;
7604
7606
  this.workRelatedSelfEducationTotalAmount = this.calculateWorkRelatedSelfEducationTotalAmount();
7605
- this.lowValuePoolDeductionTotalAmount = this.depreciations.getByTankType(TankTypeEnum.WORK)
7607
+ this.lowValuePoolDeductionTotalAmount = this.depreciations.getByTankType(TankTypeEnum.WORK_TANK)
7606
7608
  .getLVPDepreciations().sumBy('claimAmount');
7607
7609
  this.interestExpensesTotalAmount = this.transactions
7608
7610
  .filterBy('chartAccounts.heading.id', DEDUCTION_CATEGORIES.interestExpenses)
@@ -8694,7 +8696,7 @@ class VehicleLogbookCollection extends Collection {
8694
8696
  // sole tank may have multiple vehicle claims, so we need to filter by business.id
8695
8697
  ? this.filterBy('business.id', vehicleClaim.business.id)
8696
8698
  // work tank may have only one vehicle claim, so we need to filter by tank type
8697
- : this.filterBy('tankType', TankTypeEnum.WORK);
8699
+ : this.filterBy('tankType', TankTypeEnum.WORK_TANK);
8698
8700
  }
8699
8701
  /**
8700
8702
  * get collection of logbooks with the biggest work usage for {@link BestVehicleLogbookCollection.periodDuration}
@@ -9273,7 +9275,7 @@ class IncomeSourceCollection extends Collection {
9273
9275
  filterByTank(tank) {
9274
9276
  return this.items.filter((incomeSource) => {
9275
9277
  switch (tank) {
9276
- case TankTypeEnum.OTHER:
9278
+ case TankTypeEnum.OTHER_TANK:
9277
9279
  return incomeSource.isOtherIncome();
9278
9280
  default:
9279
9281
  return incomeSource.isWorkIncome();
@@ -9811,16 +9813,6 @@ class BankAccount extends BankAccount$1 {
9811
9813
  isSoleTank() {
9812
9814
  return !!this.businessAllocations.length;
9813
9815
  }
9814
- get tankType() {
9815
- switch (true) {
9816
- case this.isPropertyTank():
9817
- return TankTypeEnum.PROPERTY;
9818
- case this.isSoleTank():
9819
- return TankTypeEnum.SOLE;
9820
- default:
9821
- return TankTypeEnum.WORK;
9822
- }
9823
- }
9824
9816
  /**
9825
9817
  * Get Bank account property by id
9826
9818
  * @param id Id of property
@@ -10006,7 +9998,7 @@ class BankTransaction extends BankTransaction$1 {
10006
9998
  * Get bank transaction allocated amount
10007
9999
  */
10008
10000
  getAllocatedAmount(allocations) {
10009
- return allocations.getByBankTransactionsIds([this.id]).amount;
10001
+ return round(allocations.getByBankTransactionsIds([this.id]).amount, 2);
10010
10002
  }
10011
10003
  /**
10012
10004
  * Get bank transaction unallocated amount
@@ -21584,7 +21576,7 @@ class BankAccountPropertiesForm extends UntypedFormArray {
21584
21576
  property: new UntypedFormControl(bankAccountProperty?.property, Validators.required),
21585
21577
  percent: new UntypedFormControl(bankAccountProperty.percent, Validators.required)
21586
21578
  })), [
21587
- conditionalValidator((control) => control.get('tankType').value === TankTypeEnum.PROPERTY, Validators.required),
21579
+ conditionalValidator((control) => control.get('tankType').value === TankTypeEnum.PROPERTY_TANK, Validators.required),
21588
21580
  fieldsSumValidator('percent', 100)
21589
21581
  ]);
21590
21582
  }
@@ -21708,7 +21700,7 @@ class SoleBusinessAllocationsForm extends UntypedFormArray {
21708
21700
  business: new UntypedFormControl(businessAllocation?.business, Validators.required),
21709
21701
  percent: new UntypedFormControl(businessAllocation.percent, Validators.required)
21710
21702
  })), [
21711
- conditionalValidator((control) => control.get('tankType').value === TankTypeEnum.SOLE, Validators.required),
21703
+ conditionalValidator((control) => control.get('tankType').value === TankTypeEnum.SOLE_TANK, Validators.required),
21712
21704
  fieldsSumValidator('percent', 100)
21713
21705
  ]);
21714
21706
  }
@@ -22111,10 +22103,10 @@ class BankAccountAllocationForm extends AbstractForm {
22111
22103
  this.removeControl('bankAccountProperties');
22112
22104
  this.removeControl('businessAllocations');
22113
22105
  switch (tankType) {
22114
- case TankTypeEnum.PROPERTY:
22106
+ case TankTypeEnum.PROPERTY_TANK:
22115
22107
  this.addControl('bankAccountProperties', new BankAccountPropertiesForm(this.bankAccount?.bankAccountProperties));
22116
22108
  break;
22117
- case TankTypeEnum.SOLE:
22109
+ case TankTypeEnum.SOLE_TANK:
22118
22110
  this.addControl('businessAllocations', new SoleBusinessAllocationsForm(this.bankAccount?.businessAllocations));
22119
22111
  break;
22120
22112
  }
@@ -23772,13 +23764,13 @@ class AllocationRuleForm extends AbstractForm {
23772
23764
  }
23773
23765
  get tankTypeLabel() {
23774
23766
  switch (this.transactionFormGroup.get('tankType').value) {
23775
- case TankTypeEnum.WORK:
23767
+ case TankTypeEnum.WORK_TANK:
23776
23768
  return 'work';
23777
- case TankTypeEnum.PROPERTY:
23769
+ case TankTypeEnum.PROPERTY_TANK:
23778
23770
  return 'property';
23779
- case TankTypeEnum.SOLE:
23771
+ case TankTypeEnum.SOLE_TANK:
23780
23772
  return 'sole';
23781
- case TankTypeEnum.HOLDING:
23773
+ case TankTypeEnum.HOLDING_TANK:
23782
23774
  return 'holding';
23783
23775
  default:
23784
23776
  return 'personal';
@@ -23808,13 +23800,13 @@ class AllocationRuleForm extends AbstractForm {
23808
23800
  this.transactionFormGroup.get('business').disable({ emitEvent: false });
23809
23801
  this.transactionFormGroup.get('incomeSource').disable({ emitEvent: false });
23810
23802
  switch (tankType) {
23811
- case TankTypeEnum.WORK:
23803
+ case TankTypeEnum.WORK_TANK:
23812
23804
  this.transactionFormGroup.get('incomeSource').enable({ emitEvent: false });
23813
23805
  break;
23814
- case TankTypeEnum.PROPERTY:
23806
+ case TankTypeEnum.PROPERTY_TANK:
23815
23807
  this.transactionFormGroup.get('property').enable({ emitEvent: false });
23816
23808
  break;
23817
- case TankTypeEnum.SOLE:
23809
+ case TankTypeEnum.SOLE_TANK:
23818
23810
  this.transactionFormGroup.get('business').enable({ emitEvent: false });
23819
23811
  break;
23820
23812
  }
@@ -23829,13 +23821,13 @@ class AllocationRuleForm extends AbstractForm {
23829
23821
  return this.get('type').value === AllocationRuleTypeEnum.TRANSFER;
23830
23822
  }
23831
23823
  isPropertyTank() {
23832
- return this.get('transaction').get('tankType').value === TankTypeEnum.PROPERTY;
23824
+ return this.get('transaction').get('tankType').value === TankTypeEnum.PROPERTY_TANK;
23833
23825
  }
23834
23826
  isWorkTank() {
23835
- return this.get('transaction').get('tankType').value === TankTypeEnum.WORK;
23827
+ return this.get('transaction').get('tankType').value === TankTypeEnum.WORK_TANK;
23836
23828
  }
23837
23829
  isSoleTank() {
23838
- return this.get('transaction').get('tankType').value === TankTypeEnum.SOLE;
23830
+ return this.get('transaction').get('tankType').value === TankTypeEnum.SOLE_TANK;
23839
23831
  }
23840
23832
  isPropertyIncome() {
23841
23833
  return this.isIncome() && this.isPropertyTank();
@@ -24059,15 +24051,17 @@ class WorkTransactionForm extends TransactionForm {
24059
24051
 
24060
24052
  class WorkIncomeForm extends WorkTransactionForm {
24061
24053
  constructor(transaction, registeredForGst, allocations) {
24062
- // for work income we need to show netAmount instead of amount (because some adjustments are included in amount)
24063
- transaction.amount = transaction.netAmount;
24064
24054
  super(transaction, registeredForGst, allocations, {
24055
+ netAmount: new UntypedFormControl(transaction.netAmount, Validators.required),
24065
24056
  tax: new UntypedFormControl({
24066
24057
  value: transaction.tax,
24067
24058
  disabled: !transaction.chartAccounts || transaction.chartAccounts.isNRAS(),
24068
24059
  }, Validators.required),
24069
24060
  incomeSource: new UntypedFormControl(transaction.incomeSource, [Validators.required, autocompleteValidator()]),
24070
24061
  });
24062
+ if (allocations.length) {
24063
+ this.get('netAmount').disable();
24064
+ }
24071
24065
  // forbid to edit some fields for allocated transaction
24072
24066
  if (allocations.length) {
24073
24067
  this.get('chartAccounts').disable();
@@ -24130,7 +24124,7 @@ class WorkIncomeForm extends WorkTransactionForm {
24130
24124
  * ie bankTransaction=1000$ with 900$ salary and 100$ tips will create 2 transactions with 900$ and 100$
24131
24125
  */
24132
24126
  getAmount() {
24133
- return this.get('amount').value - new Collection(this.currentValue.transactions)
24127
+ return this.get('netAmount').value - new Collection(this.currentValue.transactions)
24134
24128
  .filter((t) => t.chartAccounts?.isAdjustmentIncluded())
24135
24129
  .sumBy('amount');
24136
24130
  }
@@ -24250,8 +24244,8 @@ class TransactionBaseFilterForm extends FormGroup {
24250
24244
  }
24251
24245
  listenEvents() {
24252
24246
  this.get('tankType').valueChanges.subscribe(tankType => {
24253
- tankType === TankTypeEnum.SOLE ? this.get('business').enable() : this.get('business').disable();
24254
- tankType === TankTypeEnum.PROPERTY ? this.get('properties').enable() : this.get('properties').disable();
24247
+ tankType === TankTypeEnum.SOLE_TANK ? this.get('business').enable() : this.get('business').disable();
24248
+ tankType === TankTypeEnum.PROPERTY_TANK ? this.get('properties').enable() : this.get('properties').disable();
24255
24249
  });
24256
24250
  }
24257
24251
  filter(collection) {