taxtank-core 0.32.39 → 0.32.41
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.
- package/esm2022/lib/collections/bank-transaction.collection.mjs +19 -4
- package/esm2022/lib/collections/sole/sole-invoice-item.collection.mjs +3 -3
- package/esm2022/lib/collections/sole/sole-invoice.collection.mjs +22 -1
- package/esm2022/lib/collections/transaction/transaction-allocation.collection.mjs +8 -1
- package/esm2022/lib/collections/transaction/transaction.collection.mjs +8 -1
- package/esm2022/lib/db/Json/chart-accounts/chart-accounts-value.json +287 -287
- package/esm2022/lib/db/Models/transaction/transaction-base.mjs +3 -2
- package/esm2022/lib/models/bank/bank-transaction.mjs +2 -2
- package/esm2022/lib/models/endpoint/endpoints.const.mjs +5 -4
- package/esm2022/lib/models/sole/sole-invoice.mjs +3 -4
- package/esm2022/lib/models/transaction/transaction.mjs +2 -2
- package/esm2022/lib/services/bank/bank-account-calculation.service.mjs +7 -11
- package/esm2022/lib/services/bank/index.mjs +1 -2
- package/esm2022/lib/services/transaction/transaction-calculation.service.mjs +2 -55
- package/fesm2022/taxtank-core.mjs +438 -419
- package/fesm2022/taxtank-core.mjs.map +1 -1
- package/lib/collections/bank-transaction.collection.d.ts +9 -2
- package/lib/collections/sole/sole-invoice-item.collection.d.ts +1 -1
- package/lib/collections/sole/sole-invoice.collection.d.ts +5 -1
- package/lib/collections/transaction/transaction-allocation.collection.d.ts +3 -1
- package/lib/collections/transaction/transaction.collection.d.ts +2 -0
- package/lib/services/bank/bank-account-calculation.service.d.ts +2 -7
- package/lib/services/bank/index.d.ts +0 -1
- package/lib/services/transaction/transaction-calculation.service.d.ts +1 -25
- package/package.json +1 -1
- package/esm2022/lib/services/bank/bank-transaction-calculation.service.mjs +0 -61
- package/lib/services/bank/bank-transaction-calculation.service.d.ts +0 -41
|
@@ -1,60 +1,10 @@
|
|
|
1
1
|
import { Injectable } from '@angular/core';
|
|
2
|
-
import { TransactionAllocationCollection
|
|
3
|
-
import { Dictionary } from '../../models/dictionary/dictionary';
|
|
2
|
+
import { TransactionAllocationCollection } from '../../collections';
|
|
4
3
|
import * as i0 from "@angular/core";
|
|
5
4
|
/**
|
|
6
5
|
* @TODO Alex: refactor, move methods to collections and models, remove this service
|
|
7
6
|
*/
|
|
8
7
|
export class TransactionCalculationService {
|
|
9
|
-
/**
|
|
10
|
-
* Sum of allocations for passed transactions
|
|
11
|
-
*/
|
|
12
|
-
getAllocatedAmount(transactions, allocations) {
|
|
13
|
-
return allocations.getByTransactionsIds(transactions.getIds()).amount;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Check if transaction is allocated
|
|
17
|
-
*/
|
|
18
|
-
isAllocated(transaction, allocations) {
|
|
19
|
-
return transaction.isAllocated(allocations);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Get collection of allocated transactions
|
|
23
|
-
* @TODO Alex: consider to move to collection
|
|
24
|
-
*/
|
|
25
|
-
getAllocatedTransactions(transactions, allocations) {
|
|
26
|
-
return new TransactionCollection(transactions.items.filter((transaction) => transaction.isAllocated(allocations)));
|
|
27
|
-
}
|
|
28
|
-
getUnallocatedInvoices(invoices, allocations) {
|
|
29
|
-
return invoices.filter((invoice) => {
|
|
30
|
-
const invoiceAllocatedAmount = allocations.filterBy('transaction.id', invoice.getTransactionsIds()).sumBy('amount');
|
|
31
|
-
return invoice.grossPrice > invoiceAllocatedAmount;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Get invoices paid amounts grouped by invoice id
|
|
36
|
-
*/
|
|
37
|
-
getInvoicePaidAmountById(allocations, invoices) {
|
|
38
|
-
const allocationsByTransactionId = allocations.groupBy('transaction.id');
|
|
39
|
-
const dictionary = new Dictionary([]);
|
|
40
|
-
invoices.toArray().forEach((invoice) => {
|
|
41
|
-
// fully paid if user marked invoice as paid with cash
|
|
42
|
-
const amount = invoice.isPaidCash() ? invoice.grossPrice
|
|
43
|
-
: allocationsByTransactionId.merge(invoice.itemsCollection.mapBy('transaction.id')).amount || 0;
|
|
44
|
-
dictionary.add(invoice.id, amount);
|
|
45
|
-
});
|
|
46
|
-
return dictionary;
|
|
47
|
-
}
|
|
48
|
-
getInvoicesUnallocatedAmount(invoices, allocations) {
|
|
49
|
-
return invoices.sumBy('grossPrice') - allocations.filterBy('transaction.id', invoices.getTransactionsIds()).sumBy('amount');
|
|
50
|
-
}
|
|
51
|
-
getTransactionsByInvoices(invoices, transactions) {
|
|
52
|
-
const transactionsByInvoices = new TransactionCollection([]).groupBy();
|
|
53
|
-
invoices.toArray().forEach((invoice) => {
|
|
54
|
-
transactionsByInvoices.add(invoice.id, transactions.filterBy('id', invoice.getTransactionsIds()));
|
|
55
|
-
});
|
|
56
|
-
return transactionsByInvoices;
|
|
57
|
-
}
|
|
58
8
|
getAllocationsByInvoices(invoices, allocations) {
|
|
59
9
|
const allocationsByInvoices = new TransactionAllocationCollection([]).groupBy();
|
|
60
10
|
invoices.toArray().forEach((invoice) => {
|
|
@@ -62,9 +12,6 @@ export class TransactionCalculationService {
|
|
|
62
12
|
});
|
|
63
13
|
return allocationsByInvoices;
|
|
64
14
|
}
|
|
65
|
-
getBankTransactionsUnallocatedAmount(bankTransactions, allocations) {
|
|
66
|
-
return bankTransactions.sumBy('amount') - allocations.getByBankTransactionsIds(bankTransactions.getIds()).sumBy('amount');
|
|
67
|
-
}
|
|
68
15
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TransactionCalculationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
69
16
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TransactionCalculationService, providedIn: 'root' }); }
|
|
70
17
|
}
|
|
@@ -74,4 +21,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
74
21
|
providedI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