taxtank-core 0.32.41 → 0.32.42

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.
@@ -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';
@@ -4817,7 +4818,8 @@ class SoleInvoice extends SoleInvoice$1 {
4817
4818
  */
4818
4819
  get netPrice() {
4819
4820
  if (this.isTaxInclusive()) {
4820
- return this.price - this.GSTAmount;
4821
+ // round up to make sure invoice is fully paid
4822
+ return ceil(this.price - this.GSTAmount, 2);
4821
4823
  }
4822
4824
  return this.price;
4823
4825
  }
@@ -4826,7 +4828,8 @@ class SoleInvoice extends SoleInvoice$1 {
4826
4828
  */
4827
4829
  get grossPrice() {
4828
4830
  if (this.isTaxExclusive()) {
4829
- return this.price + this.GSTAmount;
4831
+ // round up to make sure invoice is fully paid
4832
+ return ceil(this.price + this.GSTAmount, 2);
4830
4833
  }
4831
4834
  return this.price;
4832
4835
  }
@@ -4847,13 +4850,13 @@ class SoleInvoice extends SoleInvoice$1 {
4847
4850
  * When tax inclusive, GST amount is included to total price
4848
4851
  */
4849
4852
  get inclusiveGSTAmount() {
4850
- return this.itemsCollection.gstItems.reduce((sum, item) => sum + round(item.totalPrice - (item.totalPrice / (1 + ChartAccounts.GSTRatio)), 2));
4853
+ return this.itemsCollection.gstItems.reduce((sum, item) => sum + item.totalPrice - (item.totalPrice / (1 + ChartAccounts.GSTRatio)));
4851
4854
  }
4852
4855
  /**
4853
4856
  * When tax exclusive, GST amount should be added additionally to total price
4854
4857
  */
4855
4858
  get exclusiveGSTAmount() {
4856
- return this.itemsCollection.gstItems.reduce((sum, item) => sum + round(item.totalPrice * ChartAccounts.GSTRatio, 2));
4859
+ return this.itemsCollection.gstItems.reduce((sum, item) => sum + item.totalPrice * ChartAccounts.GSTRatio);
4857
4860
  }
4858
4861
  isDraft() {
4859
4862
  return this.status === SoleInvoiceStatusesEnum.DRAFT;
@@ -6213,75 +6216,6 @@ __decorate([
6213
6216
  Type(() => ChartAccountsMetaField)
6214
6217
  ], TransactionMetaField.prototype, "chartAccountsMetaField", void 0);
6215
6218
 
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
6219
  class TransactionAllocation extends TransactionAllocation$1 {
6286
6220
  /**
6287
6221
  * Create a new instance of transaction allocation
@@ -6440,7 +6374,7 @@ class Transaction extends Transaction$1 {
6440
6374
  * Check if transaction is completely allocated
6441
6375
  */
6442
6376
  isAllocated(allocations) {
6443
- return (Math.abs(this.netAmount) - Math.abs(this.getAllocatedAmount(allocations))) <= 0.02;
6377
+ return Math.abs(this.getAllocatedAmount(allocations)) - Math.abs(this.netAmount) >= 0;
6444
6378
  }
6445
6379
  getAllocatedAmount(allocations) {
6446
6380
  return allocations.filterBy('transaction.id', this.id).sumBy('amount');
@@ -8878,7 +8812,7 @@ class BankTransactionCollection extends Collection {
8878
8812
  * Difference between total bank transactions amount and sum of allocations for passed bank transactions
8879
8813
  */
8880
8814
  getUnallocatedAmount(allocations) {
8881
- return round(this.getAmount() - allocations.getByBankTransactionsIds(this.getIds()).amount, 2);
8815
+ return this.getAmount() - allocations.getByBankTransactionsIds(this.getIds()).amount;
8882
8816
  }
8883
8817
  getAllocatedAmount(allocations) {
8884
8818
  return allocations.getByBankTransactionsIds(this.getIds()).amount;
@@ -9755,6 +9689,75 @@ const BANK_ACCOUNT_TYPES = [
9755
9689
  { key: BankAccountTypeEnum.TRANSACTION, value: 'Transaction Accounts' },
9756
9690
  ];
9757
9691
 
9692
+ class BankTransaction extends BankTransaction$1 {
9693
+ constructor() {
9694
+ super(...arguments);
9695
+ // allocated money amount for bank transaction
9696
+ this.allocatedAmount = 0;
9697
+ }
9698
+ /**
9699
+ * get allocated amount value but with +/- sign
9700
+ */
9701
+ get balanceAmount() {
9702
+ return this.isCredit() ? this.allocatedAmount : -this.allocatedAmount;
9703
+ }
9704
+ /**
9705
+ * check if bank transaction is debit
9706
+ */
9707
+ isDebit() {
9708
+ return this.type === BankTransactionTypeEnum.DEBIT;
9709
+ }
9710
+ /**
9711
+ * check if bank transaction is credit
9712
+ */
9713
+ isCredit() {
9714
+ return this.type === BankTransactionTypeEnum.CREDIT;
9715
+ }
9716
+ /**
9717
+ * Create Transaction instance based on Bank Transaction
9718
+ */
9719
+ toTransaction(isGST = false, allocations = new TransactionAllocationCollection([])) {
9720
+ const transaction = plainToClass(Transaction, {
9721
+ amount: this.getUnallocatedAmount(allocations),
9722
+ description: this.description,
9723
+ type: this.type,
9724
+ date: this.date,
9725
+ source: TransactionSourceEnum.BANK_TRANSACTION,
9726
+ operation: this.operation,
9727
+ isGST: isGST,
9728
+ });
9729
+ // gst should be included
9730
+ if (isGST) {
9731
+ transaction.amount = transaction.amount / ChartAccounts.GSTCoefficient;
9732
+ }
9733
+ return transaction;
9734
+ }
9735
+ /**
9736
+ * Check if bank transaction is completely allocated
9737
+ */
9738
+ isAllocated(allocations) {
9739
+ return Math.abs(this.getAllocatedAmount(allocations)) - Math.abs(this.amount) >= 0;
9740
+ }
9741
+ /**
9742
+ * Get bank transaction allocated amount
9743
+ */
9744
+ getAllocatedAmount(allocations) {
9745
+ return allocations.getByBankTransactionsIds([this.id]).amount;
9746
+ }
9747
+ /**
9748
+ * Get bank transaction unallocated amount
9749
+ */
9750
+ getUnallocatedAmount(allocations) {
9751
+ return this.amount - this.getAllocatedAmount(allocations);
9752
+ }
9753
+ }
9754
+ __decorate([
9755
+ Type(() => Date)
9756
+ ], BankTransaction.prototype, "date", void 0);
9757
+ __decorate([
9758
+ Type(() => Number)
9759
+ ], BankTransaction.prototype, "amount", void 0);
9760
+
9758
9761
  /**
9759
9762
  * bank transactions collection UI class with frontend specific data
9760
9763
  */