taxtank-core 0.32.41 → 0.32.44

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 (24) hide show
  1. package/esm2022/lib/collections/bank-account.collection.mjs +7 -11
  2. package/esm2022/lib/collections/bank-transaction.collection.mjs +2 -3
  3. package/esm2022/lib/collections/transaction/transaction.collection.mjs +2 -3
  4. package/esm2022/lib/db/Json/chart-accounts/chart-accounts-value.json +22 -0
  5. package/esm2022/lib/db/Json/holding/holding-type-exchange.json +11 -11
  6. package/esm2022/lib/db/Models/property/property-valuation.mjs +1 -1
  7. package/esm2022/lib/models/bank/bank-account.mjs +5 -3
  8. package/esm2022/lib/models/bank/bank-transaction.mjs +2 -2
  9. package/esm2022/lib/models/property/property-valuation.mjs +5 -1
  10. package/esm2022/lib/models/sole/sole-invoice.mjs +8 -6
  11. package/esm2022/lib/models/transaction/transaction-allocation.mjs +2 -2
  12. package/esm2022/lib/models/transaction/transaction.mjs +2 -2
  13. package/esm2022/lib/services/http/bank/bank-account/bank-account.service.mjs +5 -1
  14. package/fesm2022/taxtank-core.mjs +148 -115
  15. package/fesm2022/taxtank-core.mjs.map +1 -1
  16. package/lib/collections/bank-account.collection.d.ts +2 -2
  17. package/lib/collections/bank-transaction.collection.d.ts +3 -6
  18. package/lib/collections/transaction/transaction.collection.d.ts +1 -1
  19. package/lib/db/Models/property/property-valuation.d.ts +2 -0
  20. package/lib/models/bank/bank-account.d.ts +1 -1
  21. package/lib/models/property/property-valuation.d.ts +2 -0
  22. package/lib/models/transaction/transaction-allocation.d.ts +1 -1
  23. package/lib/services/http/bank/bank-account/bank-account.service.d.ts +1 -0
  24. package/package.json +1 -1
@@ -22,6 +22,7 @@ import uniq from 'lodash/uniq';
22
22
  import moment from 'moment';
23
23
  import { DateRange } from 'moment-range';
24
24
  import merge from 'lodash/merge';
25
+ import ceil from 'lodash/ceil';
25
26
  import range from 'lodash/range';
26
27
  import { Validators, UntypedFormGroup, UntypedFormControl, UntypedFormArray, FormControl, FormArray, FormGroup } from '@angular/forms';
27
28
  import compact from 'lodash/compact';
@@ -3150,6 +3151,32 @@ var ChartAccountsValues = [
3150
3151
  unitOfMeasure: "hours",
3151
3152
  createdAt: "2024-01-30 15:15:00",
3152
3153
  updatedAt: "2024-01-30 15:15:00"
3154
+ },
3155
+ {
3156
+ id: 54,
3157
+ chartAccounts: {
3158
+ id: 888
3159
+ },
3160
+ financialYear: 2023,
3161
+ startDate: null,
3162
+ endDate: null,
3163
+ value: 0.67,
3164
+ unitOfMeasure: "hours",
3165
+ createdAt: "2024-01-30 15:15:00",
3166
+ updatedAt: "2024-01-30 15:15:00"
3167
+ },
3168
+ {
3169
+ id: 55,
3170
+ chartAccounts: {
3171
+ id: 888
3172
+ },
3173
+ financialYear: 2024,
3174
+ startDate: null,
3175
+ endDate: null,
3176
+ value: 0.67,
3177
+ unitOfMeasure: "hours",
3178
+ createdAt: "2024-01-30 15:15:00",
3179
+ updatedAt: "2024-01-30 15:15:00"
3153
3180
  }
3154
3181
  ];
3155
3182
 
@@ -4817,7 +4844,8 @@ class SoleInvoice extends SoleInvoice$1 {
4817
4844
  */
4818
4845
  get netPrice() {
4819
4846
  if (this.isTaxInclusive()) {
4820
- return this.price - this.GSTAmount;
4847
+ // round up to make sure invoice is fully paid
4848
+ return ceil(this.price - this.GSTAmount, 2);
4821
4849
  }
4822
4850
  return this.price;
4823
4851
  }
@@ -4826,7 +4854,8 @@ class SoleInvoice extends SoleInvoice$1 {
4826
4854
  */
4827
4855
  get grossPrice() {
4828
4856
  if (this.isTaxExclusive()) {
4829
- return this.price + this.GSTAmount;
4857
+ // round up to make sure invoice is fully paid
4858
+ return ceil(this.price + this.GSTAmount, 2);
4830
4859
  }
4831
4860
  return this.price;
4832
4861
  }
@@ -4847,13 +4876,13 @@ class SoleInvoice extends SoleInvoice$1 {
4847
4876
  * When tax inclusive, GST amount is included to total price
4848
4877
  */
4849
4878
  get inclusiveGSTAmount() {
4850
- return this.itemsCollection.gstItems.reduce((sum, item) => sum + round(item.totalPrice - (item.totalPrice / (1 + ChartAccounts.GSTRatio)), 2));
4879
+ return this.itemsCollection.gstItems.reduce((sum, item) => sum + item.totalPrice - (item.totalPrice / (1 + ChartAccounts.GSTRatio)));
4851
4880
  }
4852
4881
  /**
4853
4882
  * When tax exclusive, GST amount should be added additionally to total price
4854
4883
  */
4855
4884
  get exclusiveGSTAmount() {
4856
- return this.itemsCollection.gstItems.reduce((sum, item) => sum + round(item.totalPrice * ChartAccounts.GSTRatio, 2));
4885
+ return this.itemsCollection.gstItems.reduce((sum, item) => sum + item.totalPrice * ChartAccounts.GSTRatio);
4857
4886
  }
4858
4887
  isDraft() {
4859
4888
  return this.status === SoleInvoiceStatusesEnum.DRAFT;
@@ -5513,6 +5542,24 @@ __decorate([
5513
5542
  Type(() => AppFile)
5514
5543
  ], PropertyDocument.prototype, "file", void 0);
5515
5544
 
5545
+ class PropertyCategoryMovement extends PropertyCategoryMovement$1 {
5546
+ }
5547
+ __decorate([
5548
+ Type(() => PropertyValuation)
5549
+ ], PropertyCategoryMovement.prototype, "valuation", void 0);
5550
+ __decorate([
5551
+ Type(() => PropertyCategory)
5552
+ ], PropertyCategoryMovement.prototype, "propertyCategory", void 0);
5553
+ __decorate([
5554
+ Type(() => Property)
5555
+ ], PropertyCategoryMovement.prototype, "property", void 0);
5556
+ __decorate([
5557
+ Type(() => Date)
5558
+ ], PropertyCategoryMovement.prototype, "fromDate", void 0);
5559
+ __decorate([
5560
+ Type(() => Date)
5561
+ ], PropertyCategoryMovement.prototype, "toDate", void 0);
5562
+
5516
5563
  class PropertyValuation extends PropertyValuation$1 {
5517
5564
  get financialYear() {
5518
5565
  return new FinancialYear(this.date).year;
@@ -5527,6 +5574,9 @@ __decorate([
5527
5574
  __decorate([
5528
5575
  Type(() => PropertyDocument)
5529
5576
  ], PropertyValuation.prototype, "document", void 0);
5577
+ __decorate([
5578
+ Type(() => PropertyCategoryMovement)
5579
+ ], PropertyValuation.prototype, "categoryMovement", void 0);
5530
5580
 
5531
5581
  class PropertyForecast extends PropertyForecast$1 {
5532
5582
  constructor() {
@@ -5580,24 +5630,6 @@ __decorate([
5580
5630
  Transform(({ value }) => +value)
5581
5631
  ], PropertyForecast.prototype, "marketValue", void 0);
5582
5632
 
5583
- class PropertyCategoryMovement extends PropertyCategoryMovement$1 {
5584
- }
5585
- __decorate([
5586
- Type(() => PropertyValuation)
5587
- ], PropertyCategoryMovement.prototype, "valuation", void 0);
5588
- __decorate([
5589
- Type(() => PropertyCategory)
5590
- ], PropertyCategoryMovement.prototype, "propertyCategory", void 0);
5591
- __decorate([
5592
- Type(() => Property)
5593
- ], PropertyCategoryMovement.prototype, "property", void 0);
5594
- __decorate([
5595
- Type(() => Date)
5596
- ], PropertyCategoryMovement.prototype, "fromDate", void 0);
5597
- __decorate([
5598
- Type(() => Date)
5599
- ], PropertyCategoryMovement.prototype, "toDate", void 0);
5600
-
5601
5633
  /**
5602
5634
  * propertySale docs - https://taxtank.atlassian.net/wiki/spaces/TAXTANK/pages/4209508353/Property+Sold+button
5603
5635
  */
@@ -6213,75 +6245,6 @@ __decorate([
6213
6245
  Type(() => ChartAccountsMetaField)
6214
6246
  ], TransactionMetaField.prototype, "chartAccountsMetaField", void 0);
6215
6247
 
6216
- class BankTransaction extends BankTransaction$1 {
6217
- constructor() {
6218
- super(...arguments);
6219
- // allocated money amount for bank transaction
6220
- this.allocatedAmount = 0;
6221
- }
6222
- /**
6223
- * get allocated amount value but with +/- sign
6224
- */
6225
- get balanceAmount() {
6226
- return this.isCredit() ? this.allocatedAmount : -this.allocatedAmount;
6227
- }
6228
- /**
6229
- * check if bank transaction is debit
6230
- */
6231
- isDebit() {
6232
- return this.type === BankTransactionTypeEnum.DEBIT;
6233
- }
6234
- /**
6235
- * check if bank transaction is credit
6236
- */
6237
- isCredit() {
6238
- return this.type === BankTransactionTypeEnum.CREDIT;
6239
- }
6240
- /**
6241
- * Create Transaction instance based on Bank Transaction
6242
- */
6243
- toTransaction(isGST = false, allocations = new TransactionAllocationCollection([])) {
6244
- const transaction = plainToClass(Transaction, {
6245
- amount: this.getUnallocatedAmount(allocations),
6246
- description: this.description,
6247
- type: this.type,
6248
- date: this.date,
6249
- source: TransactionSourceEnum.BANK_TRANSACTION,
6250
- operation: this.operation,
6251
- isGST: isGST,
6252
- });
6253
- // gst should be included
6254
- if (isGST) {
6255
- transaction.amount = transaction.amount / ChartAccounts.GSTCoefficient;
6256
- }
6257
- return transaction;
6258
- }
6259
- /**
6260
- * Check if bank transaction is completely allocated
6261
- */
6262
- isAllocated(allocations) {
6263
- return (Math.abs(this.amount) - Math.abs(this.getAllocatedAmount(allocations))) <= 0.02;
6264
- }
6265
- /**
6266
- * Get bank transaction allocated amount
6267
- */
6268
- getAllocatedAmount(allocations) {
6269
- return allocations.getByBankTransactionsIds([this.id]).amount;
6270
- }
6271
- /**
6272
- * Get bank transaction unallocated amount
6273
- */
6274
- getUnallocatedAmount(allocations) {
6275
- return this.amount - this.getAllocatedAmount(allocations);
6276
- }
6277
- }
6278
- __decorate([
6279
- Type(() => Date)
6280
- ], BankTransaction.prototype, "date", void 0);
6281
- __decorate([
6282
- Type(() => Number)
6283
- ], BankTransaction.prototype, "amount", void 0);
6284
-
6285
6248
  class TransactionAllocation extends TransactionAllocation$1 {
6286
6249
  /**
6287
6250
  * Create a new instance of transaction allocation
@@ -6440,7 +6403,7 @@ class Transaction extends Transaction$1 {
6440
6403
  * Check if transaction is completely allocated
6441
6404
  */
6442
6405
  isAllocated(allocations) {
6443
- return (Math.abs(this.netAmount) - Math.abs(this.getAllocatedAmount(allocations))) <= 0.02;
6406
+ return Math.abs(this.getAllocatedAmount(allocations)) - Math.abs(this.netAmount) >= 0;
6444
6407
  }
6445
6408
  getAllocatedAmount(allocations) {
6446
6409
  return allocations.filterBy('transaction.id', this.id).sumBy('amount');
@@ -8747,10 +8710,11 @@ class BankAccountCollection extends Collection {
8747
8710
  return new BankAccountCollection(this.items.filter((bankAccount) => bankAccount.bankAccountProperties.find((bankAccountProperty) => ids.includes(bankAccountProperty.property.id))));
8748
8711
  }
8749
8712
  /**
8713
+ * @TODO feature functionality allow to work with shared accounts
8750
8714
  * get collection of active bank accounts
8751
8715
  */
8752
- getActiveBankAccounts() {
8753
- return new BankAccountCollection(this.items.filter((bankAccount) => bankAccount.isActive()));
8716
+ getActive() {
8717
+ return this.getOwn().filter((bankAccount) => bankAccount.isActive());
8754
8718
  }
8755
8719
  /**
8756
8720
  * get reduction of loan (reduction of principle) percentage
@@ -8846,17 +8810,12 @@ class BankAccountCollection extends Collection {
8846
8810
  }
8847
8811
  /**
8848
8812
  * @TODO Alex/Vik: maybe we should get it from jwtToken or think about some localStorageService?
8849
- * get own bankAccounts active for current financial year
8850
8813
  */
8851
8814
  getOwn() {
8852
- return this.filter((bankAccount) => {
8853
- const commencementDate = bankAccount.loan?.commencementDate;
8854
- const endDate = new FinancialYear().endDate;
8855
- return bankAccount.isOwner(+localStorage.getItem('userId')) && (!commencementDate || commencementDate <= endDate);
8856
- });
8815
+ return this.filter((bankAccount) => bankAccount.isOwner(+localStorage.getItem('userId')));
8857
8816
  }
8858
8817
  getActiveLoanAccountsByProperties(ids) {
8859
- return this.getActiveBankAccounts().getLoanAccounts().getByPropertiesIds(ids);
8818
+ return this.getActive().getLoanAccounts().getByPropertiesIds(ids);
8860
8819
  }
8861
8820
  }
8862
8821
 
@@ -8878,7 +8837,7 @@ class BankTransactionCollection extends Collection {
8878
8837
  * Difference between total bank transactions amount and sum of allocations for passed bank transactions
8879
8838
  */
8880
8839
  getUnallocatedAmount(allocations) {
8881
- return round(this.getAmount() - allocations.getByBankTransactionsIds(this.getIds()).amount, 2);
8840
+ return this.getAmount() - allocations.getByBankTransactionsIds(this.getIds()).amount;
8882
8841
  }
8883
8842
  getAllocatedAmount(allocations) {
8884
8843
  return allocations.getByBankTransactionsIds(this.getIds()).amount;
@@ -9663,10 +9622,12 @@ class BankAccount extends BankAccount$1 {
9663
9622
  return this.loan ? this.loan.monthlyRepaymentAmount * this.getPropertyPercentage(propertyId) : 0;
9664
9623
  }
9665
9624
  /**
9666
- * Check if bank account is active (has 'active' status or hasn't been paid out/refinanced)
9625
+ * Check if bank account is active for current financial year (has 'active' status or hasn't been paid out/refinanced)
9667
9626
  */
9668
9627
  isActive() {
9669
- return this.status === BankAccountStatusEnum.ACTIVE;
9628
+ const commencementDate = this.loan?.commencementDate;
9629
+ const endDate = new FinancialYear().endDate;
9630
+ return this.status === BankAccountStatusEnum.ACTIVE && (!commencementDate || commencementDate <= endDate);
9670
9631
  }
9671
9632
  /**
9672
9633
  * first import (transactions) of basiq accounts
@@ -9755,6 +9716,75 @@ const BANK_ACCOUNT_TYPES = [
9755
9716
  { key: BankAccountTypeEnum.TRANSACTION, value: 'Transaction Accounts' },
9756
9717
  ];
9757
9718
 
9719
+ class BankTransaction extends BankTransaction$1 {
9720
+ constructor() {
9721
+ super(...arguments);
9722
+ // allocated money amount for bank transaction
9723
+ this.allocatedAmount = 0;
9724
+ }
9725
+ /**
9726
+ * get allocated amount value but with +/- sign
9727
+ */
9728
+ get balanceAmount() {
9729
+ return this.isCredit() ? this.allocatedAmount : -this.allocatedAmount;
9730
+ }
9731
+ /**
9732
+ * check if bank transaction is debit
9733
+ */
9734
+ isDebit() {
9735
+ return this.type === BankTransactionTypeEnum.DEBIT;
9736
+ }
9737
+ /**
9738
+ * check if bank transaction is credit
9739
+ */
9740
+ isCredit() {
9741
+ return this.type === BankTransactionTypeEnum.CREDIT;
9742
+ }
9743
+ /**
9744
+ * Create Transaction instance based on Bank Transaction
9745
+ */
9746
+ toTransaction(isGST = false, allocations = new TransactionAllocationCollection([])) {
9747
+ const transaction = plainToClass(Transaction, {
9748
+ amount: this.getUnallocatedAmount(allocations),
9749
+ description: this.description,
9750
+ type: this.type,
9751
+ date: this.date,
9752
+ source: TransactionSourceEnum.BANK_TRANSACTION,
9753
+ operation: this.operation,
9754
+ isGST: isGST,
9755
+ });
9756
+ // gst should be included
9757
+ if (isGST) {
9758
+ transaction.amount = transaction.amount / ChartAccounts.GSTCoefficient;
9759
+ }
9760
+ return transaction;
9761
+ }
9762
+ /**
9763
+ * Check if bank transaction is completely allocated
9764
+ */
9765
+ isAllocated(allocations) {
9766
+ return Math.abs(this.getAllocatedAmount(allocations)) - Math.abs(this.amount) >= 0;
9767
+ }
9768
+ /**
9769
+ * Get bank transaction allocated amount
9770
+ */
9771
+ getAllocatedAmount(allocations) {
9772
+ return allocations.getByBankTransactionsIds([this.id]).amount;
9773
+ }
9774
+ /**
9775
+ * Get bank transaction unallocated amount
9776
+ */
9777
+ getUnallocatedAmount(allocations) {
9778
+ return this.amount - this.getAllocatedAmount(allocations);
9779
+ }
9780
+ }
9781
+ __decorate([
9782
+ Type(() => Date)
9783
+ ], BankTransaction.prototype, "date", void 0);
9784
+ __decorate([
9785
+ Type(() => Number)
9786
+ ], BankTransaction.prototype, "amount", void 0);
9787
+
9758
9788
  /**
9759
9789
  * bank transactions collection UI class with frontend specific data
9760
9790
  */
@@ -11083,6 +11113,9 @@ class BankAccountService extends RestService$1 {
11083
11113
  this.disabledMethods = ['post', 'putBatch', 'delete', 'deleteBatch'];
11084
11114
  this.listenEvents();
11085
11115
  }
11116
+ getActive() {
11117
+ return this.getBy('status', BankAccountStatusEnum.ACTIVE);
11118
+ }
11086
11119
  /**
11087
11120
  * Listen system notifications and update cache when got basiq notification received
11088
11121
  */
@@ -15694,17 +15727,6 @@ var HoldingImportMessagesEnum;
15694
15727
  })(HoldingImportMessagesEnum || (HoldingImportMessagesEnum = {}));
15695
15728
 
15696
15729
  var HoldingTypeExchanges = [
15697
- {
15698
- id: 1,
15699
- code: "US",
15700
- name: "NYSE",
15701
- currency: "USD",
15702
- close_time: "16:00",
15703
- timezone: "America/New_York",
15704
- exchange_updated_at: "2023-04-21 11:54:56",
15705
- min_market_cap: 100000000,
15706
- min_avg_volume50d: 1000000
15707
- },
15708
15730
  {
15709
15731
  id: 2,
15710
15732
  code: "AU",
@@ -15716,6 +15738,17 @@ var HoldingTypeExchanges = [
15716
15738
  min_market_cap: 10000000,
15717
15739
  min_avg_volume50d: 10000
15718
15740
  },
15741
+ {
15742
+ id: 1,
15743
+ code: "US",
15744
+ name: "NYSE",
15745
+ currency: "USD",
15746
+ close_time: "16:00",
15747
+ timezone: "America/New_York",
15748
+ exchange_updated_at: "2023-04-21 11:54:56",
15749
+ min_market_cap: 100000000,
15750
+ min_avg_volume50d: 1000000
15751
+ },
15719
15752
  {
15720
15753
  id: 3,
15721
15754
  code: "LSE",