taxtank-core 0.33.25 → 0.33.26
Sign up to get free protection for your applications and to get access to all the features.
- package/esm2022/src/lib/collections/report/income-expense/transaction-report-item.collection.mjs +21 -2
- package/esm2022/src/lib/models/report/income-expense/transaction-report-item.mjs +2 -2
- package/fesm2022/taxtank-core.mjs +20 -2
- package/fesm2022/taxtank-core.mjs.map +1 -1
- package/package.json +1 -1
package/esm2022/src/lib/collections/report/income-expense/transaction-report-item.collection.mjs
CHANGED
@@ -1,13 +1,32 @@
|
|
1
1
|
import { Collection } from '../../collection';
|
2
2
|
import { TransactionReportItem } from '../../../models/report';
|
3
|
+
import { ChartAccountsCategoryEnum } from '../../../db/Enums';
|
3
4
|
export class TransactionReportItemCollection extends Collection {
|
4
5
|
static fromTransactions(transactions, priorTransactions) {
|
5
6
|
const transactionsByChartAccounts = transactions.groupBy('chartAccounts.id');
|
6
7
|
const priorTransactionsByChartAccounts = priorTransactions.groupBy('chartAccounts.id');
|
7
|
-
|
8
|
+
console.log(transactionsByChartAccounts.keys);
|
9
|
+
console.log(priorTransactionsByChartAccounts.keys);
|
10
|
+
const items = new TransactionReportItemCollection([...new Set([...transactionsByChartAccounts.keys, ...priorTransactionsByChartAccounts.keys])].map(chartAccountsId => new TransactionReportItem(transactionsByChartAccounts.get(chartAccountsId), priorTransactionsByChartAccounts.get(chartAccountsId))));
|
11
|
+
const categoriesOrder = [
|
12
|
+
ChartAccountsCategoryEnum.PROPERTY_INCOME,
|
13
|
+
ChartAccountsCategoryEnum.WORK_INCOME,
|
14
|
+
ChartAccountsCategoryEnum.SOLE_INCOME,
|
15
|
+
ChartAccountsCategoryEnum.HOLDING_INCOME,
|
16
|
+
ChartAccountsCategoryEnum.OTHER_INCOME,
|
17
|
+
ChartAccountsCategoryEnum.PERSONAL_INCOME,
|
18
|
+
ChartAccountsCategoryEnum.PROPERTY_EXPENSE,
|
19
|
+
ChartAccountsCategoryEnum.WORK_EXPENSE,
|
20
|
+
ChartAccountsCategoryEnum.SOLE_EXPENSE,
|
21
|
+
ChartAccountsCategoryEnum.HOLDING_EXPENSE,
|
22
|
+
ChartAccountsCategoryEnum.OTHER_EXPENSE,
|
23
|
+
ChartAccountsCategoryEnum.PERSONAL_EXPENSE,
|
24
|
+
];
|
25
|
+
items.sort((a, b) => categoriesOrder.indexOf(a.category) - categoriesOrder.indexOf(b.category));
|
26
|
+
return items;
|
8
27
|
}
|
9
28
|
sumBy(path, abs = false) {
|
10
29
|
return super.sumBy(path, abs);
|
11
30
|
}
|
12
31
|
}
|
13
|
-
//# sourceMappingURL=data:application/json;base64,
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHJhbnNhY3Rpb24tcmVwb3J0LWl0ZW0uY29sbGVjdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL3R0LWNvcmUvc3JjL2xpYi9jb2xsZWN0aW9ucy9yZXBvcnQvaW5jb21lLWV4cGVuc2UvdHJhbnNhY3Rpb24tcmVwb3J0LWl0ZW0uY29sbGVjdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDOUMsT0FBTyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFL0QsT0FBTyxFQUFFLHlCQUF5QixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFFOUQsTUFBTSxPQUFPLCtCQUFnQyxTQUFRLFVBQWlDO0lBQ3BGLE1BQU0sQ0FBQyxnQkFBZ0IsQ0FBQyxZQUFtQyxFQUFFLGlCQUF3QztRQUNuRyxNQUFNLDJCQUEyQixHQUFHLFlBQVksQ0FBQyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FBQztRQUM3RSxNQUFNLGdDQUFnQyxHQUFHLGlCQUFpQixDQUFDL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eUVudW0uUEVSU09OQUxfSU5DT01FLFxuICAgICAgQ2hhcnRBY2NvdW50c0NhdGVnb3J5RW51bS5QUk9QRVJUWV9FWFBFTlNFLFxuICAgICAgQ2hhcnRBY2NvdW50c0NhdGVnb3J5RW51bS5XT1JLX0VYUEVOU0UsXG4gICAgICBDaGFydEFjY291bnRzQ2F0ZWdvcnlFbnVtLlNPTEVfRVhQRU5TRSxcbiAgICAgIENoYXJ0QWNjb3VudHNDYXRlZ29yeUVudW0uSE9MRElOR19FWFBFTlNFLFxuICAgICAgQ2hhcnRBY2NvdW50c0NhdGVnb3J5RW51bS5PVEhFUl9FWFBFTlNFLFxuICAgICAgQ2hhcnRBY2NvdW50c0NhdGVnb3J5RW51bS5QRVJTT05BTF9FWFBFTlNFLFxuICAgIF07XG5cbiAgICBpdGVtcy5zb3J0KChhLCBiKSA9PiBjYXRlZ29yaWVzT3JkZXIuaW5kZXhPZihhLmNhdGVnb3J5KSAtIGNhdGVnb3JpZXNPcmRlci5pbmRleE9mKGIuY2F0ZWdvcnkpKTtcblxuICAgIHJldHVybiBpdGVtcztcbiAgfVxuXG4gIHN1bUJ5KHBhdGg6IHN0cmluZywgYWJzID0gZmFsc2UpOiBudW1iZXIge1xuICAgIHJldHVybiBzdXBlci5zdW1CeShwYXRoLCBhYnMpO1xuICB9XG59XG4iXX0=
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { FinancialYear } from '../../financial-year';
|
2
2
|
export class TransactionReportItem {
|
3
3
|
constructor(transactions, priorTransactions) {
|
4
|
-
const firstTransaction = transactions.first;
|
4
|
+
const firstTransaction = transactions.first ?? priorTransactions.first;
|
5
5
|
this.category = firstTransaction.chartAccounts.category;
|
6
6
|
this.name = firstTransaction.chartAccounts.name;
|
7
7
|
new FinancialYear().getPastMonths().forEach(month => {
|
@@ -13,4 +13,4 @@ export class TransactionReportItem {
|
|
13
13
|
this.priorClaimAmount = priorTransactions.sumBy('grossClaimAmountWithoutGst');
|
14
14
|
}
|
15
15
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VHJhbnNhY3Rpb24uY2hhcnRBY2NvdW50cy5jYXRlZ29yeTtcbiAgICB0aGlzLm5hbWUgPSBmaXJzdFRyYW5zYWN0aW9uLmNoYXJ0QWNjb3VudHMubmFtZTtcbiAgICBuZXcgRmluYW5jaWFsWWVhcigpLmdldFBhc3RNb250aHMoKS5mb3JFYWNoKG1vbnRoID0+IHtcbiAgICAgIHRoaXNbbW9udGhdID0gdHJhbnNhY3Rpb25zLmdldEJ5TW9udGgobW9udGgpLnN1bUJ5KCdncm9zc0Ftb3VudFdpdGhvdXRHc3QnKTtcbiAgICB9KTtcbiAgICB0aGlzLmFtb3VudCA9IHRyYW5zYWN0aW9ucy5zdW1CeSgnZ3Jvc3NBbW91bnRXaXRob3V0R3N0Jyk7XG4gICAgdGhpcy5jbGFpbUFtb3VudCA9IHRyYW5zYWN0aW9ucy5zdW1CeSgnZ3Jvc3NDbGFpbUFtb3VudFdpdGhvdXRHc3QnKTtcbiAgICB0aGlzLnByaW9yQW1vdW50ID0gcHJpb3JUcmFuc2FjdGlvbnMuc3VtQnkoJ2dyb3NzQW1vdW50V2l0aG91dEdzdCcpO1xuICAgIHRoaXMucHJpb3JDbGFpbUFtb3VudCA9IHByaW9yVHJhbnNhY3Rpb25zLnN1bUJ5KCdncm9zc0NsYWltQW1vdW50V2l0aG91dEdzdCcpO1xuICB9XG59XG4iXX0=
|
@@ -8266,7 +8266,7 @@ const REPORTS = {
|
|
8266
8266
|
|
8267
8267
|
class TransactionReportItem {
|
8268
8268
|
constructor(transactions, priorTransactions) {
|
8269
|
-
const firstTransaction = transactions.first;
|
8269
|
+
const firstTransaction = transactions.first ?? priorTransactions.first;
|
8270
8270
|
this.category = firstTransaction.chartAccounts.category;
|
8271
8271
|
this.name = firstTransaction.chartAccounts.name;
|
8272
8272
|
new FinancialYear().getPastMonths().forEach(month => {
|
@@ -8348,7 +8348,25 @@ class TransactionReportItemCollection extends Collection {
|
|
8348
8348
|
static fromTransactions(transactions, priorTransactions) {
|
8349
8349
|
const transactionsByChartAccounts = transactions.groupBy('chartAccounts.id');
|
8350
8350
|
const priorTransactionsByChartAccounts = priorTransactions.groupBy('chartAccounts.id');
|
8351
|
-
|
8351
|
+
console.log(transactionsByChartAccounts.keys);
|
8352
|
+
console.log(priorTransactionsByChartAccounts.keys);
|
8353
|
+
const items = new TransactionReportItemCollection([...new Set([...transactionsByChartAccounts.keys, ...priorTransactionsByChartAccounts.keys])].map(chartAccountsId => new TransactionReportItem(transactionsByChartAccounts.get(chartAccountsId), priorTransactionsByChartAccounts.get(chartAccountsId))));
|
8354
|
+
const categoriesOrder = [
|
8355
|
+
ChartAccountsCategoryEnum.PROPERTY_INCOME,
|
8356
|
+
ChartAccountsCategoryEnum.WORK_INCOME,
|
8357
|
+
ChartAccountsCategoryEnum.SOLE_INCOME,
|
8358
|
+
ChartAccountsCategoryEnum.HOLDING_INCOME,
|
8359
|
+
ChartAccountsCategoryEnum.OTHER_INCOME,
|
8360
|
+
ChartAccountsCategoryEnum.PERSONAL_INCOME,
|
8361
|
+
ChartAccountsCategoryEnum.PROPERTY_EXPENSE,
|
8362
|
+
ChartAccountsCategoryEnum.WORK_EXPENSE,
|
8363
|
+
ChartAccountsCategoryEnum.SOLE_EXPENSE,
|
8364
|
+
ChartAccountsCategoryEnum.HOLDING_EXPENSE,
|
8365
|
+
ChartAccountsCategoryEnum.OTHER_EXPENSE,
|
8366
|
+
ChartAccountsCategoryEnum.PERSONAL_EXPENSE,
|
8367
|
+
];
|
8368
|
+
items.sort((a, b) => categoriesOrder.indexOf(a.category) - categoriesOrder.indexOf(b.category));
|
8369
|
+
return items;
|
8352
8370
|
}
|
8353
8371
|
sumBy(path, abs = false) {
|
8354
8372
|
return super.sumBy(path, abs);
|