@things-factory/accounting 10.1.134 → 10.1.135
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/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +0 -12
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/index.d.ts +0 -1
- package/dist-server/index.js +0 -1
- package/dist-server/index.js.map +1 -1
- package/dist-server/service/account/account-history.d.ts +13 -6
- package/dist-server/service/account/account-history.js +44 -17
- package/dist-server/service/account/account-history.js.map +1 -1
- package/dist-server/service/account/account-mutation.js +2 -2
- package/dist-server/service/account/account-mutation.js.map +1 -1
- package/dist-server/service/account/account-type.d.ts +16 -0
- package/dist-server/service/account/account-type.js +71 -13
- package/dist-server/service/account/account-type.js.map +1 -1
- package/dist-server/service/account/account.d.ts +9 -3
- package/dist-server/service/account/account.js +34 -8
- package/dist-server/service/account/account.js.map +1 -1
- package/dist-server/service/accounting-category/accounting-category-mutation.js +2 -2
- package/dist-server/service/accounting-category/accounting-category-mutation.js.map +1 -1
- package/dist-server/service/accounting-document/accounting-document-mutation.js +12 -3
- package/dist-server/service/accounting-document/accounting-document-mutation.js.map +1 -1
- package/dist-server/service/accounting-document/accounting-document-query.js +2 -0
- package/dist-server/service/accounting-document/accounting-document-query.js.map +1 -1
- package/dist-server/service/bank-account/bank-account-history.d.ts +11 -14
- package/dist-server/service/bank-account/bank-account-history.js +46 -59
- package/dist-server/service/bank-account/bank-account-history.js.map +1 -1
- package/dist-server/service/bank-account/bank-account-mutation.d.ts +1 -2
- package/dist-server/service/bank-account/bank-account-mutation.js +25 -69
- package/dist-server/service/bank-account/bank-account-mutation.js.map +1 -1
- package/dist-server/service/bank-account/bank-account-query.js +2 -0
- package/dist-server/service/bank-account/bank-account-query.js.map +1 -1
- package/dist-server/service/bank-account/bank-account-service.d.ts +5 -0
- package/dist-server/service/bank-account/bank-account-service.js +21 -0
- package/dist-server/service/bank-account/bank-account-service.js.map +1 -0
- package/dist-server/service/bank-account/bank-account-type.d.ts +13 -19
- package/dist-server/service/bank-account/bank-account-type.js +45 -69
- package/dist-server/service/bank-account/bank-account-type.js.map +1 -1
- package/dist-server/service/bank-account/bank-account.d.ts +14 -17
- package/dist-server/service/bank-account/bank-account.js +45 -57
- package/dist-server/service/bank-account/bank-account.js.map +1 -1
- package/dist-server/service/bank-statement/bank-statement-query.d.ts +14 -0
- package/dist-server/service/bank-statement/bank-statement-query.js +92 -0
- package/dist-server/service/bank-statement/bank-statement-query.js.map +1 -0
- package/dist-server/service/bank-statement/bank-statement.d.ts +26 -0
- package/dist-server/service/bank-statement/bank-statement.js +109 -0
- package/dist-server/service/bank-statement/bank-statement.js.map +1 -0
- package/dist-server/service/bank-statement/index.d.ts +5 -0
- package/dist-server/service/bank-statement/index.js +9 -0
- package/dist-server/service/bank-statement/index.js.map +1 -0
- package/dist-server/service/cash-flow-type.d.ts +5 -0
- package/dist-server/service/cash-flow-type.js +15 -0
- package/dist-server/service/cash-flow-type.js.map +1 -0
- package/dist-server/service/financial-institution/financial-institution-mutation.js +10 -1
- package/dist-server/service/financial-institution/financial-institution-mutation.js.map +1 -1
- package/dist-server/service/financial-institution/financial-institution-query.js +14 -6
- package/dist-server/service/financial-institution/financial-institution-query.js.map +1 -1
- package/dist-server/service/financial-institution/index.d.ts +1 -1
- package/dist-server/service/financial-statement/financial-statement-history.d.ts +11 -9
- package/dist-server/service/financial-statement/financial-statement-history.js +47 -36
- package/dist-server/service/financial-statement/financial-statement-history.js.map +1 -1
- package/dist-server/service/financial-statement/financial-statement-line.d.ts +24 -0
- package/dist-server/service/financial-statement/financial-statement-line.js +108 -0
- package/dist-server/service/financial-statement/financial-statement-line.js.map +1 -0
- package/dist-server/service/financial-statement/financial-statement-mutation.d.ts +1 -8
- package/dist-server/service/financial-statement/financial-statement-mutation.js +10 -135
- package/dist-server/service/financial-statement/financial-statement-mutation.js.map +1 -1
- package/dist-server/service/financial-statement/financial-statement-query.d.ts +8 -7
- package/dist-server/service/financial-statement/financial-statement-query.js +40 -30
- package/dist-server/service/financial-statement/financial-statement-query.js.map +1 -1
- package/dist-server/service/financial-statement/financial-statement-service.d.ts +33 -0
- package/dist-server/service/financial-statement/financial-statement-service.js +44 -0
- package/dist-server/service/financial-statement/financial-statement-service.js.map +1 -0
- package/dist-server/service/financial-statement/financial-statement.d.ts +19 -11
- package/dist-server/service/financial-statement/financial-statement.js +73 -65
- package/dist-server/service/financial-statement/financial-statement.js.map +1 -1
- package/dist-server/service/financial-statement/index.d.ts +3 -2
- package/dist-server/service/financial-statement/index.js +2 -2
- package/dist-server/service/financial-statement/index.js.map +1 -1
- package/dist-server/service/index.d.ts +15 -3
- package/dist-server/service/index.js +30 -13
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/payment/index.d.ts +1 -0
- package/dist-server/service/payment/index.js +1 -0
- package/dist-server/service/payment/index.js.map +1 -1
- package/dist-server/service/payment/payment-history.d.ts +9 -16
- package/dist-server/service/payment/payment-history.js +36 -70
- package/dist-server/service/payment/payment-history.js.map +1 -1
- package/dist-server/service/payment/payment-mutation.d.ts +0 -1
- package/dist-server/service/payment/payment-mutation.js +14 -79
- package/dist-server/service/payment/payment-mutation.js.map +1 -1
- package/dist-server/service/payment/payment-query.d.ts +3 -0
- package/dist-server/service/payment/payment-query.js +30 -1
- package/dist-server/service/payment/payment-query.js.map +1 -1
- package/dist-server/service/payment/payment-service.d.ts +16 -0
- package/dist-server/service/payment/payment-service.js +140 -0
- package/dist-server/service/payment/payment-service.js.map +1 -0
- package/dist-server/service/payment/payment-targets.d.ts +31 -0
- package/dist-server/service/payment/payment-targets.js +19 -0
- package/dist-server/service/payment/payment-targets.js.map +1 -0
- package/dist-server/service/payment/payment-type.d.ts +13 -17
- package/dist-server/service/payment/payment-type.js +35 -51
- package/dist-server/service/payment/payment-type.js.map +1 -1
- package/dist-server/service/payment/payment.d.ts +23 -22
- package/dist-server/service/payment/payment.js +66 -94
- package/dist-server/service/payment/payment.js.map +1 -1
- package/dist-server/service/payment/transfer-target.d.ts +1 -0
- package/dist-server/service/payment/transfer-target.js +43 -0
- package/dist-server/service/payment/transfer-target.js.map +1 -0
- package/dist-server/service/recurring-cash-item/index.d.ts +6 -0
- package/dist-server/service/recurring-cash-item/index.js +10 -0
- package/dist-server/service/recurring-cash-item/index.js.map +1 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.d.ts +7 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.js +63 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-mutation.js.map +1 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-query.d.ts +15 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-query.js +101 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-query.js.map +1 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-service.d.ts +23 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-service.js +91 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-service.js.map +1 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-type.d.ts +23 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-type.js +85 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item-type.js.map +1 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item.d.ts +35 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item.js +142 -0
- package/dist-server/service/recurring-cash-item/recurring-cash-item.js.map +1 -0
- package/dist-server/service/recurring-cash-item/recurring-schedule.d.ts +36 -0
- package/dist-server/service/recurring-cash-item/recurring-schedule.js +41 -0
- package/dist-server/service/recurring-cash-item/recurring-schedule.js.map +1 -0
- package/dist-server/service/transaction/transaction-history.d.ts +42 -15
- package/dist-server/service/transaction/transaction-history.js +160 -54
- package/dist-server/service/transaction/transaction-history.js.map +1 -1
- package/dist-server/service/transaction/transaction-mutation.d.ts +0 -1
- package/dist-server/service/transaction/transaction-mutation.js +13 -78
- package/dist-server/service/transaction/transaction-mutation.js.map +1 -1
- package/dist-server/service/transaction/transaction-period.d.ts +16 -0
- package/dist-server/service/transaction/transaction-period.js +49 -0
- package/dist-server/service/transaction/transaction-period.js.map +1 -0
- package/dist-server/service/transaction/transaction-query.d.ts +12 -0
- package/dist-server/service/transaction/transaction-query.js +84 -2
- package/dist-server/service/transaction/transaction-query.js.map +1 -1
- package/dist-server/service/transaction/transaction-service.d.ts +30 -0
- package/dist-server/service/transaction/transaction-service.js +130 -0
- package/dist-server/service/transaction/transaction-service.js.map +1 -0
- package/dist-server/service/transaction/transaction-type.d.ts +39 -7
- package/dist-server/service/transaction/transaction-type.js +145 -23
- package/dist-server/service/transaction/transaction-type.js.map +1 -1
- package/dist-server/service/transaction/transaction.d.ts +58 -31
- package/dist-server/service/transaction/transaction.js +216 -102
- package/dist-server/service/transaction/transaction.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -3
- package/things-factory.config.js +0 -4
- package/translations/en.json +34 -2
- package/translations/ja.json +0 -1
- package/translations/ko.json +34 -2
- package/translations/ms.json +0 -1
- package/translations/zh.json +0 -1
- package/dist-client/pages/account/account-importer.d.ts +0 -22
- package/dist-client/pages/account/account-importer.js +0 -99
- package/dist-client/pages/account/account-importer.js.map +0 -1
- package/dist-client/pages/account/account-list-page.d.ts +0 -57
- package/dist-client/pages/account/account-list-page.js +0 -306
- package/dist-client/pages/account/account-list-page.js.map +0 -1
- package/dist-client/pages/bank-account/bank-account-importer.d.ts +0 -23
- package/dist-client/pages/bank-account/bank-account-importer.js +0 -92
- package/dist-client/pages/bank-account/bank-account-importer.js.map +0 -1
- package/dist-client/pages/bank-account/bank-account-list-page.d.ts +0 -60
- package/dist-client/pages/bank-account/bank-account-list-page.js +0 -317
- package/dist-client/pages/bank-account/bank-account-list-page.js.map +0 -1
- package/dist-client/pages/financial-statement/financial-statement-importer.d.ts +0 -22
- package/dist-client/pages/financial-statement/financial-statement-importer.js +0 -99
- package/dist-client/pages/financial-statement/financial-statement-importer.js.map +0 -1
- package/dist-client/pages/financial-statement/financial-statement-list-page.d.ts +0 -57
- package/dist-client/pages/financial-statement/financial-statement-list-page.js +0 -280
- package/dist-client/pages/financial-statement/financial-statement-list-page.js.map +0 -1
- package/dist-client/pages/income-statement/income-statement-importer.d.ts +0 -22
- package/dist-client/pages/income-statement/income-statement-importer.js +0 -99
- package/dist-client/pages/income-statement/income-statement-importer.js.map +0 -1
- package/dist-client/pages/income-statement/income-statement-list-page.d.ts +0 -57
- package/dist-client/pages/income-statement/income-statement-list-page.js +0 -280
- package/dist-client/pages/income-statement/income-statement-list-page.js.map +0 -1
- package/dist-client/pages/payment/payment-importer.d.ts +0 -23
- package/dist-client/pages/payment/payment-importer.js +0 -92
- package/dist-client/pages/payment/payment-importer.js.map +0 -1
- package/dist-client/pages/payment/payment-list-page.d.ts +0 -60
- package/dist-client/pages/payment/payment-list-page.js +0 -317
- package/dist-client/pages/payment/payment-list-page.js.map +0 -1
- package/dist-client/pages/transaction/transaction-importer.d.ts +0 -22
- package/dist-client/pages/transaction/transaction-importer.js +0 -99
- package/dist-client/pages/transaction/transaction-importer.js.map +0 -1
- package/dist-client/pages/transaction/transaction-list-page.d.ts +0 -57
- package/dist-client/pages/transaction/transaction-list-page.js +0 -280
- package/dist-client/pages/transaction/transaction-list-page.js.map +0 -1
- package/dist-server/controllers/index.d.ts +0 -1
- package/dist-server/controllers/index.js +0 -5
- package/dist-server/controllers/index.js.map +0 -1
- package/dist-server/controllers/summary-statements.d.ts +0 -4
- package/dist-server/controllers/summary-statements.js +0 -149
- package/dist-server/controllers/summary-statements.js.map +0 -1
- package/dist-server/migrations/1725201567284-seed-country-codes.d.ts +0 -5
- package/dist-server/migrations/1725201567284-seed-country-codes.js +0 -255
- package/dist-server/migrations/1725201567284-seed-country-codes.js.map +0 -1
- package/dist-server/service/financial-statement/financial-statement-line-item.d.ts +0 -19
- package/dist-server/service/financial-statement/financial-statement-line-item.js +0 -95
- package/dist-server/service/financial-statement/financial-statement-line-item.js.map +0 -1
- package/dist-server/service/financial-statement/financial-statement-type.d.ts +0 -20
- package/dist-server/service/financial-statement/financial-statement-type.js +0 -77
- package/dist-server/service/financial-statement/financial-statement-type.js.map +0 -1
- package/dist-server/service/income-statement/event-subscriber.d.ts +0 -7
- package/dist-server/service/income-statement/event-subscriber.js +0 -21
- package/dist-server/service/income-statement/event-subscriber.js.map +0 -1
- package/dist-server/service/income-statement/income-statement-history.d.ts +0 -28
- package/dist-server/service/income-statement/income-statement-history.js +0 -146
- package/dist-server/service/income-statement/income-statement-history.js.map +0 -1
- package/dist-server/service/income-statement/income-statement-line-item.d.ts +0 -19
- package/dist-server/service/income-statement/income-statement-line-item.js +0 -97
- package/dist-server/service/income-statement/income-statement-line-item.js.map +0 -1
- package/dist-server/service/income-statement/income-statement-mutation.d.ts +0 -10
- package/dist-server/service/income-statement/income-statement-mutation.js +0 -159
- package/dist-server/service/income-statement/income-statement-mutation.js.map +0 -1
- package/dist-server/service/income-statement/income-statement-query.d.ts +0 -11
- package/dist-server/service/income-statement/income-statement-query.js +0 -81
- package/dist-server/service/income-statement/income-statement-query.js.map +0 -1
- package/dist-server/service/income-statement/income-statement-type.d.ts +0 -20
- package/dist-server/service/income-statement/income-statement-type.js +0 -77
- package/dist-server/service/income-statement/income-statement-type.js.map +0 -1
- package/dist-server/service/income-statement/income-statement.d.ts +0 -28
- package/dist-server/service/income-statement/income-statement.js +0 -137
- package/dist-server/service/income-statement/income-statement.js.map +0 -1
- package/dist-server/service/income-statement/index.d.ts +0 -8
- package/dist-server/service/income-statement/index.js +0 -13
- package/dist-server/service/income-statement/index.js.map +0 -1
|
@@ -10,9 +10,9 @@ const env_1 = require("@things-factory/env");
|
|
|
10
10
|
const shell_1 = require("@things-factory/shell");
|
|
11
11
|
const transaction_1 = require("../transaction/transaction");
|
|
12
12
|
const payment_1 = require("./payment");
|
|
13
|
-
const bank_account_1 = require("../bank-account/bank-account");
|
|
14
13
|
const ORMCONFIG = env_1.config.get('ormconfig', {});
|
|
15
14
|
const DATABASE_TYPE = ORMCONFIG.type;
|
|
15
|
+
/** Each version of a payment, written when it changes. */
|
|
16
16
|
let PaymentHistory = class PaymentHistory {
|
|
17
17
|
constructor() {
|
|
18
18
|
this.version = 1;
|
|
@@ -21,134 +21,100 @@ let PaymentHistory = class PaymentHistory {
|
|
|
21
21
|
exports.PaymentHistory = PaymentHistory;
|
|
22
22
|
tslib_1.__decorate([
|
|
23
23
|
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
24
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
|
24
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier of the version' }),
|
|
25
25
|
tslib_1.__metadata("design:type", String)
|
|
26
26
|
], PaymentHistory.prototype, "id", void 0);
|
|
27
27
|
tslib_1.__decorate([
|
|
28
28
|
(0, typeorm_1.Column)({ nullable: true, default: 1 }),
|
|
29
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
29
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Version number' }),
|
|
30
30
|
tslib_1.__metadata("design:type", Number)
|
|
31
31
|
], PaymentHistory.prototype, "version", void 0);
|
|
32
32
|
tslib_1.__decorate([
|
|
33
33
|
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
34
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
34
|
+
(0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true, description: 'The domain' }),
|
|
35
35
|
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
36
36
|
], PaymentHistory.prototype, "domain", void 0);
|
|
37
37
|
tslib_1.__decorate([
|
|
38
|
-
(0, typeorm_1.RelationId)((
|
|
38
|
+
(0, typeorm_1.RelationId)((paymentHistory) => paymentHistory.domain),
|
|
39
39
|
tslib_1.__metadata("design:type", String)
|
|
40
40
|
], PaymentHistory.prototype, "domainId", void 0);
|
|
41
41
|
tslib_1.__decorate([
|
|
42
|
-
(0, typeorm_1.ManyToOne)(type => transaction_1.Transaction,
|
|
43
|
-
(0, type_graphql_1.Field)(type => transaction_1.Transaction, { description: '
|
|
44
|
-
tslib_1.__metadata("design:type", transaction_1.Transaction
|
|
45
|
-
)
|
|
42
|
+
(0, typeorm_1.ManyToOne)(type => transaction_1.Transaction, { nullable: true, createForeignKeyConstraints: false }),
|
|
43
|
+
(0, type_graphql_1.Field)(type => transaction_1.Transaction, { nullable: true, description: 'transaction at this version' }),
|
|
44
|
+
tslib_1.__metadata("design:type", transaction_1.Transaction)
|
|
46
45
|
], PaymentHistory.prototype, "transaction", void 0);
|
|
47
46
|
tslib_1.__decorate([
|
|
48
|
-
(0, typeorm_1.RelationId)((
|
|
47
|
+
(0, typeorm_1.RelationId)((paymentHistory) => paymentHistory.transaction),
|
|
49
48
|
tslib_1.__metadata("design:type", String)
|
|
50
49
|
], PaymentHistory.prototype, "transactionId", void 0);
|
|
51
50
|
tslib_1.__decorate([
|
|
52
51
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
53
|
-
(0, type_graphql_1.Field)({ nullable: true, description: '
|
|
52
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'targetType at this version' }),
|
|
54
53
|
tslib_1.__metadata("design:type", String)
|
|
55
|
-
], PaymentHistory.prototype, "
|
|
54
|
+
], PaymentHistory.prototype, "targetType", void 0);
|
|
56
55
|
tslib_1.__decorate([
|
|
57
|
-
(0, typeorm_1.Column)(
|
|
58
|
-
(0, type_graphql_1.Field)({ nullable:
|
|
59
|
-
tslib_1.__metadata("design:type", Number)
|
|
60
|
-
], PaymentHistory.prototype, "amount", void 0);
|
|
61
|
-
tslib_1.__decorate([
|
|
62
|
-
(0, typeorm_1.Column)(),
|
|
63
|
-
(0, type_graphql_1.Field)(type => payment_1.PaymentType, { description: 'Type of the payment' }),
|
|
64
|
-
tslib_1.__metadata("design:type", String)
|
|
65
|
-
], PaymentHistory.prototype, "paymentType", void 0);
|
|
66
|
-
tslib_1.__decorate([
|
|
67
|
-
(0, typeorm_1.ManyToOne)(type => bank_account_1.BankAccount, { nullable: true }),
|
|
68
|
-
(0, type_graphql_1.Field)(type => bank_account_1.BankAccount, { nullable: true, description: 'Source bank account for the payment' }),
|
|
69
|
-
tslib_1.__metadata("design:type", bank_account_1.BankAccount)
|
|
70
|
-
], PaymentHistory.prototype, "sourceBankAccount", void 0);
|
|
71
|
-
tslib_1.__decorate([
|
|
72
|
-
(0, typeorm_1.RelationId)((payment) => payment.sourceBankAccount),
|
|
73
|
-
tslib_1.__metadata("design:type", String)
|
|
74
|
-
], PaymentHistory.prototype, "sourceBankAccountId", void 0);
|
|
75
|
-
tslib_1.__decorate([
|
|
76
|
-
(0, typeorm_1.ManyToOne)(type => bank_account_1.BankAccount, { nullable: true }),
|
|
77
|
-
(0, type_graphql_1.Field)(type => bank_account_1.BankAccount, { nullable: true, description: 'Destination bank account for the payment' }),
|
|
78
|
-
tslib_1.__metadata("design:type", bank_account_1.BankAccount)
|
|
79
|
-
], PaymentHistory.prototype, "destinationBankAccount", void 0);
|
|
80
|
-
tslib_1.__decorate([
|
|
81
|
-
(0, typeorm_1.RelationId)((payment) => payment.destinationBankAccount),
|
|
56
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
57
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'targetId at this version' }),
|
|
82
58
|
tslib_1.__metadata("design:type", String)
|
|
83
|
-
], PaymentHistory.prototype, "
|
|
59
|
+
], PaymentHistory.prototype, "targetId", void 0);
|
|
84
60
|
tslib_1.__decorate([
|
|
85
|
-
(0, typeorm_1.Column)({ nullable: true }),
|
|
86
|
-
(0, type_graphql_1.Field)({ nullable: true, description: '
|
|
61
|
+
(0, typeorm_1.Column)((0, shell_1.moneyColumn)({ nullable: true })),
|
|
62
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'amount at this version' }),
|
|
87
63
|
tslib_1.__metadata("design:type", Number)
|
|
88
|
-
], PaymentHistory.prototype, "
|
|
64
|
+
], PaymentHistory.prototype, "amount", void 0);
|
|
89
65
|
tslib_1.__decorate([
|
|
90
66
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
91
|
-
(0, type_graphql_1.Field)({ nullable: true, description: '
|
|
92
|
-
tslib_1.__metadata("design:type",
|
|
93
|
-
], PaymentHistory.prototype, "
|
|
67
|
+
(0, type_graphql_1.Field)(type => payment_1.PaymentPurpose, { nullable: true, description: 'purpose at this version' }),
|
|
68
|
+
tslib_1.__metadata("design:type", String)
|
|
69
|
+
], PaymentHistory.prototype, "purpose", void 0);
|
|
94
70
|
tslib_1.__decorate([
|
|
95
71
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
96
|
-
(0, type_graphql_1.Field)({ nullable: true, description: '
|
|
97
|
-
tslib_1.__metadata("design:type",
|
|
98
|
-
], PaymentHistory.prototype, "
|
|
99
|
-
tslib_1.__decorate([
|
|
100
|
-
(0, typeorm_1.Column)({ nullable: false }),
|
|
101
|
-
(0, type_graphql_1.Field)({ nullable: false, description: 'The date and time when the payment was made' }),
|
|
102
|
-
tslib_1.__metadata("design:type", Date // 결제가 이루어진 날짜 및 시간
|
|
103
|
-
)
|
|
104
|
-
], PaymentHistory.prototype, "paidAt", void 0);
|
|
72
|
+
(0, type_graphql_1.Field)(type => payment_1.PaymentMethod, { nullable: true, description: 'method at this version' }),
|
|
73
|
+
tslib_1.__metadata("design:type", String)
|
|
74
|
+
], PaymentHistory.prototype, "method", void 0);
|
|
105
75
|
tslib_1.__decorate([
|
|
106
|
-
(0, typeorm_1.Column)({ nullable:
|
|
107
|
-
(0, type_graphql_1.Field)(
|
|
76
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
77
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'basis at this version' }),
|
|
108
78
|
tslib_1.__metadata("design:type", String)
|
|
109
|
-
], PaymentHistory.prototype, "
|
|
79
|
+
], PaymentHistory.prototype, "basis", void 0);
|
|
110
80
|
tslib_1.__decorate([
|
|
111
|
-
(0, typeorm_1.Column)({ nullable: true }),
|
|
112
|
-
(0, type_graphql_1.Field)({ nullable: true, description: '
|
|
81
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
82
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'notes at this version' }),
|
|
113
83
|
tslib_1.__metadata("design:type", String)
|
|
114
|
-
], PaymentHistory.prototype, "
|
|
84
|
+
], PaymentHistory.prototype, "notes", void 0);
|
|
115
85
|
tslib_1.__decorate([
|
|
116
86
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
117
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
87
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'When it was created' }),
|
|
118
88
|
tslib_1.__metadata("design:type", Date)
|
|
119
89
|
], PaymentHistory.prototype, "createdAt", void 0);
|
|
120
90
|
tslib_1.__decorate([
|
|
121
91
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
122
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
92
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'When this version was written' }),
|
|
123
93
|
tslib_1.__metadata("design:type", Date)
|
|
124
94
|
], PaymentHistory.prototype, "updatedAt", void 0);
|
|
125
95
|
tslib_1.__decorate([
|
|
126
96
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
127
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
97
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'When it was deleted' }),
|
|
128
98
|
tslib_1.__metadata("design:type", Date)
|
|
129
99
|
], PaymentHistory.prototype, "deletedAt", void 0);
|
|
130
100
|
tslib_1.__decorate([
|
|
131
101
|
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
132
|
-
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
102
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who created it' }),
|
|
133
103
|
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
134
104
|
], PaymentHistory.prototype, "creator", void 0);
|
|
135
105
|
tslib_1.__decorate([
|
|
136
|
-
(0, typeorm_1.RelationId)((
|
|
106
|
+
(0, typeorm_1.RelationId)((paymentHistory) => paymentHistory.creator),
|
|
137
107
|
tslib_1.__metadata("design:type", String)
|
|
138
108
|
], PaymentHistory.prototype, "creatorId", void 0);
|
|
139
109
|
tslib_1.__decorate([
|
|
140
110
|
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
141
|
-
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
111
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'Who wrote this version' }),
|
|
142
112
|
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
143
113
|
], PaymentHistory.prototype, "updater", void 0);
|
|
144
114
|
tslib_1.__decorate([
|
|
145
|
-
(0, typeorm_1.RelationId)((
|
|
115
|
+
(0, typeorm_1.RelationId)((paymentHistory) => paymentHistory.updater),
|
|
146
116
|
tslib_1.__metadata("design:type", String)
|
|
147
117
|
], PaymentHistory.prototype, "updaterId", void 0);
|
|
148
|
-
tslib_1.__decorate([
|
|
149
|
-
(0, type_graphql_1.Field)(type => String, { nullable: true }),
|
|
150
|
-
tslib_1.__metadata("design:type", String)
|
|
151
|
-
], PaymentHistory.prototype, "thumbnail", void 0);
|
|
152
118
|
tslib_1.__decorate([
|
|
153
119
|
(0, typeorm_history_1.HistoryOriginalIdColumn)(),
|
|
154
120
|
tslib_1.__metadata("design:type", String)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment-history.js","sourceRoot":"","sources":["../../../server/service/payment/payment-history.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,qCAA8F;AAE9F,8DAKiC;AACjC,yDAAsD;AACtD,6CAA4C;AAC5C,iDAA2D;AAE3D,4DAAwD;AACxD,uCAAkE;AAClE,+DAA0D;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;oBACZ,CAAC,CAAC,SAAS;QACnB,IAAI,EACF,aAAa,IAAI,UAAU,IAAI,aAAa,IAAI,OAAO,IAAI,aAAa,IAAI,SAAS;YACnF,CAAC,CAAC,mCAAiB;YACnB,CAAC,CAAC,SAAS;QACf,MAAM,EAAE,aAAa,IAAI,UAAU,IAAI,aAAa,IAAI,OAAO,IAAI,aAAa,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;KAC/G,CAAC;;8CAC+B;yBAzHtB,cAAc;IAZ1B,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EACJ,sBAAsB,EACtB,CAAC,cAA8B,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,UAAU,EAAE,cAAc,CAAC,OAAO,CAAC,EACvF,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,eAAK,EACJ,sBAAsB,EACtB,CAAC,cAA8B,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,EAAE,cAAc,CAAC,OAAO,CAAC,EAC9G,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;GAC5C,cAAc,CA0H1B","sourcesContent":["import { Field, ID, ObjectType } from 'type-graphql'\nimport { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId } from 'typeorm'\n\nimport {\n HistoryActionColumn,\n HistoryActionType,\n HistoryEntityInterface,\n HistoryOriginalIdColumn\n} from '@operato/typeorm-history'\nimport { Role, User } from '@things-factory/auth-base'\nimport { config } from '@things-factory/env'\nimport { Domain, moneyColumn } from '@things-factory/shell'\n\nimport { Transaction } from '../transaction/transaction'\nimport { Payment, PaymentDirection, PaymentType } from './payment'\nimport { BankAccount } from '../bank-account/bank-account'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\n@Entity()\n@Index(\n 'ix_payment_history_0',\n (paymentHistory: PaymentHistory) => [paymentHistory.originalId, paymentHistory.version],\n { unique: true }\n)\n@Index(\n 'ix_payment_history_1',\n (paymentHistory: PaymentHistory) => [paymentHistory.domain, paymentHistory.originalId, paymentHistory.version],\n { unique: true }\n)\n@ObjectType({ description: 'History Entity of Payment' })\nexport class PaymentHistory implements HistoryEntityInterface<Payment> {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @Column({ nullable: true, default: 1 })\n @Field({ nullable: true })\n version?: number = 1\n\n @ManyToOne(type => Domain)\n @Field({ nullable: true })\n domain?: Domain\n\n @RelationId((payment: Payment) => payment.domain)\n domainId?: string\n\n @ManyToOne(type => Transaction, transaction => transaction.payments)\n @Field(type => Transaction, { description: 'The transaction associated with this payment' })\n transaction: Transaction // 결제와 연결된 트랜잭션\n\n @RelationId((payment: Payment) => payment.transaction)\n transactionId: string // 연결된 트랜잭션의 ID\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'The currency used in the payment' })\n currency?: string // 결제에 사용된 통화\n\n @Column(moneyColumn({ nullable: false }))\n @Field({ nullable: false, description: 'The amount of money involved in the payment' })\n amount: number // 결제된 금액\n\n @Column()\n @Field(type => PaymentType, { description: 'Type of the payment' })\n paymentType: PaymentType // 결제 유형\n\n @ManyToOne(type => BankAccount, { nullable: true })\n @Field(type => BankAccount, { nullable: true, description: 'Source bank account for the payment' })\n sourceBankAccount?: BankAccount\n\n @RelationId((payment: Payment) => payment.sourceBankAccount)\n sourceBankAccountId?: string\n\n @ManyToOne(type => BankAccount, { nullable: true })\n @Field(type => BankAccount, { nullable: true, description: 'Destination bank account for the payment' })\n destinationBankAccount?: BankAccount\n\n @RelationId((payment: Payment) => payment.destinationBankAccount)\n destinationBankAccountId?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Fiscal year in which the payment was made' })\n year?: number // 결제가 발생한 회계 연도\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Fiscal quarter in which the payment was made' })\n quarter?: number // 결제가 발생한 회계 분기\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Fiscal month in which the payment was made' })\n month?: number // 결제가 발생한 회계 월\n\n @Column({ nullable: false })\n @Field({ nullable: false, description: 'The date and time when the payment was made' })\n paidAt: Date // 결제가 이루어진 날짜 및 시간\n\n @Column({ nullable: false })\n @Field(type => PaymentDirection, { description: 'Direction of the payment (Incoming or Outgoing)' })\n direction: PaymentDirection // 결제 방향 (수금 또는 지출)\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Additional notes or comments about the payment' })\n note?: string // 결제에 대한 추가 설명 또는 메모\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n createdAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n updatedAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((payment: Payment) => payment.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((payment: Payment) => payment.updater)\n updaterId?: string\n\n @Field(type => String, { nullable: true })\n thumbnail?: string\n\n @HistoryOriginalIdColumn()\n public originalId!: string\n\n @HistoryActionColumn({\n nullable: false,\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : DATABASE_TYPE == 'mssql'\n ? 'nvarchar'\n : 'varchar',\n enum:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? HistoryActionType\n : undefined,\n length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 10\n })\n public action!: HistoryActionType\n}\n"]}
|
|
1
|
+
{"version":3,"file":"payment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eAAK,EACJ,sBAAsB,EACtB,CAAC,cAA8B,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,EAAE,cAAc,CAAC,OAAO,CAAC,EAC9G,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;GAC5C,cAAc,CAiG1B","sourcesContent":["import { Field, Float, ID, Int, ObjectType } from 'type-graphql'\nimport { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId } from 'typeorm'\n\nimport {\n HistoryActionColumn,\n HistoryActionType,\n HistoryEntityInterface,\n HistoryOriginalIdColumn\n} from '@operato/typeorm-history'\nimport { User } from '@things-factory/auth-base'\nimport { config } from '@things-factory/env'\nimport { Domain, moneyColumn } from '@things-factory/shell'\n\nimport { Transaction } from '../transaction/transaction'\nimport { Payment, PaymentMethod, PaymentPurpose } from './payment'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\n/** Each version of a payment, written when it changes. */\n@Entity()\n@Index(\n 'ix_payment_history_0',\n (paymentHistory: PaymentHistory) => [paymentHistory.originalId, paymentHistory.version],\n { unique: true }\n)\n@Index(\n 'ix_payment_history_1',\n (paymentHistory: PaymentHistory) => [paymentHistory.domain, paymentHistory.originalId, paymentHistory.version],\n { unique: true }\n)\n@ObjectType({ description: 'History Entity of Payment' })\nexport class PaymentHistory implements HistoryEntityInterface<Payment> {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier of the version' })\n readonly id: string\n\n @Column({ nullable: true, default: 1 })\n @Field({ nullable: true, description: 'Version number' })\n version?: number = 1\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain' })\n domain?: Domain\n\n @RelationId((paymentHistory: PaymentHistory) => paymentHistory.domain)\n domainId?: string\n\n @ManyToOne(type => Transaction, { nullable: true, createForeignKeyConstraints: false })\n @Field(type => Transaction, { nullable: true, description: 'transaction at this version' })\n transaction: Transaction\n\n @RelationId((paymentHistory: PaymentHistory) => paymentHistory.transaction)\n transactionId?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'targetType at this version' })\n targetType: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'targetId at this version' })\n targetId: string\n\n @Column(moneyColumn({ nullable: true }))\n @Field(type => Float, { nullable: true, description: 'amount at this version' })\n amount: number\n\n @Column({ nullable: true })\n @Field(type => PaymentPurpose, { nullable: true, description: 'purpose at this version' })\n purpose: PaymentPurpose\n\n @Column({ nullable: true })\n @Field(type => PaymentMethod, { nullable: true, description: 'method at this version' })\n method: PaymentMethod\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'basis at this version' })\n basis: string\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'notes at this version' })\n notes: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'When it was created' })\n createdAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'When this version was written' })\n updatedAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'When it was deleted' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who created it' })\n creator?: User\n\n @RelationId((paymentHistory: PaymentHistory) => paymentHistory.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'Who wrote this version' })\n updater?: User\n\n @RelationId((paymentHistory: PaymentHistory) => paymentHistory.updater)\n updaterId?: string\n\n @HistoryOriginalIdColumn()\n public originalId!: string\n\n @HistoryActionColumn({\n nullable: false,\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : DATABASE_TYPE == 'mssql'\n ? 'nvarchar'\n : 'varchar',\n enum:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? HistoryActionType\n : undefined,\n length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 10\n })\n public action!: HistoryActionType\n}\n"]}
|
|
@@ -6,5 +6,4 @@ export declare class PaymentMutation {
|
|
|
6
6
|
updateMultiplePayment(patches: PaymentPatch[], context: ResolverContext): Promise<Payment[]>;
|
|
7
7
|
deletePayment(id: string, context: ResolverContext): Promise<boolean>;
|
|
8
8
|
deletePayments(ids: string[], context: ResolverContext): Promise<boolean>;
|
|
9
|
-
importPayments(payments: PaymentPatch[], context: ResolverContext): Promise<boolean>;
|
|
10
9
|
}
|
|
@@ -3,89 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PaymentMutation = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
|
-
const typeorm_1 = require("typeorm");
|
|
7
6
|
const shell_1 = require("@things-factory/shell");
|
|
8
7
|
const payment_1 = require("./payment");
|
|
8
|
+
const payment_service_1 = require("./payment-service");
|
|
9
9
|
const payment_type_1 = require("./payment-type");
|
|
10
10
|
let PaymentMutation = class PaymentMutation {
|
|
11
11
|
async createPayment(payment, context) {
|
|
12
12
|
const { domain, user, tx } = context.state;
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
domain,
|
|
16
|
-
creator: user,
|
|
17
|
-
updater: user
|
|
18
|
-
});
|
|
19
|
-
return result;
|
|
13
|
+
const [saved] = await (0, payment_service_1.savePayments)(tx, domain, user, [{ ...payment, cuFlag: '+' }]);
|
|
14
|
+
return saved;
|
|
20
15
|
}
|
|
21
16
|
async updatePayment(id, patch, context) {
|
|
22
17
|
const { domain, user, tx } = context.state;
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
where: { domain: { id: domain.id }, id }
|
|
26
|
-
});
|
|
27
|
-
const result = await repository.save({
|
|
28
|
-
...payment,
|
|
29
|
-
...patch,
|
|
30
|
-
updater: user
|
|
31
|
-
});
|
|
32
|
-
return result;
|
|
18
|
+
const [saved] = await (0, payment_service_1.savePayments)(tx, domain, user, [{ ...patch, id, cuFlag: 'M' }]);
|
|
19
|
+
return saved;
|
|
33
20
|
}
|
|
34
21
|
async updateMultiplePayment(patches, context) {
|
|
35
22
|
const { domain, user, tx } = context.state;
|
|
36
|
-
|
|
37
|
-
const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
|
|
38
|
-
const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
|
|
39
|
-
const paymentRepo = (0, shell_1.getRepository)(payment_1.Payment, tx);
|
|
40
|
-
if (_createRecords.length > 0) {
|
|
41
|
-
for (let i = 0; i < _createRecords.length; i++) {
|
|
42
|
-
const newRecord = _createRecords[i];
|
|
43
|
-
const result = await paymentRepo.save({
|
|
44
|
-
...newRecord,
|
|
45
|
-
domain,
|
|
46
|
-
creator: user,
|
|
47
|
-
updater: user
|
|
48
|
-
});
|
|
49
|
-
results.push({ ...result, cuFlag: '+' });
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (_updateRecords.length > 0) {
|
|
53
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
|
54
|
-
const updateRecord = _updateRecords[i];
|
|
55
|
-
const payment = await paymentRepo.findOne({
|
|
56
|
-
where: { domain: { id: domain.id }, id: updateRecord.id }
|
|
57
|
-
});
|
|
58
|
-
if (!payment) {
|
|
59
|
-
throw new Error(`failed to find payment to update: ${updateRecord.id}`);
|
|
60
|
-
}
|
|
61
|
-
const result = await paymentRepo.save({
|
|
62
|
-
...payment,
|
|
63
|
-
...updateRecord,
|
|
64
|
-
updater: user
|
|
65
|
-
});
|
|
66
|
-
results.push({ ...result, cuFlag: 'M' });
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return results;
|
|
23
|
+
return await (0, payment_service_1.savePayments)(tx, domain, user, patches);
|
|
70
24
|
}
|
|
71
25
|
async deletePayment(id, context) {
|
|
72
|
-
const { domain, tx } = context.state;
|
|
73
|
-
await (0,
|
|
26
|
+
const { domain, user, tx } = context.state;
|
|
27
|
+
await (0, payment_service_1.savePayments)(tx, domain, user, [{ id, cuFlag: '-' }]);
|
|
74
28
|
return true;
|
|
75
29
|
}
|
|
76
30
|
async deletePayments(ids, context) {
|
|
77
|
-
const { domain, tx } = context.state;
|
|
78
|
-
await (0,
|
|
79
|
-
domain: { id: domain.id },
|
|
80
|
-
id: (0, typeorm_1.In)(ids)
|
|
81
|
-
});
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
async importPayments(payments, context) {
|
|
85
|
-
const { domain, tx } = context.state;
|
|
86
|
-
await Promise.all(payments.map(async (payment) => {
|
|
87
|
-
const createdPayment = await (0, shell_1.getRepository)(payment_1.Payment, tx).save({ domain, ...payment });
|
|
88
|
-
}));
|
|
31
|
+
const { domain, user, tx } = context.state;
|
|
32
|
+
await (0, payment_service_1.savePayments)(tx, domain, user, ids.map(id => ({ id, cuFlag: '-' })));
|
|
89
33
|
return true;
|
|
90
34
|
}
|
|
91
35
|
};
|
|
@@ -93,7 +37,7 @@ exports.PaymentMutation = PaymentMutation;
|
|
|
93
37
|
tslib_1.__decorate([
|
|
94
38
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
95
39
|
(0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
|
|
96
|
-
(0, type_graphql_1.Mutation)(returns => payment_1.Payment, { description: 'To
|
|
40
|
+
(0, type_graphql_1.Mutation)(returns => payment_1.Payment, { description: 'To put a part of a transaction on what it paid' }),
|
|
97
41
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('payment')),
|
|
98
42
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
99
43
|
tslib_1.__metadata("design:type", Function),
|
|
@@ -114,7 +58,7 @@ tslib_1.__decorate([
|
|
|
114
58
|
tslib_1.__decorate([
|
|
115
59
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
116
60
|
(0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
|
|
117
|
-
(0, type_graphql_1.Mutation)(returns => [payment_1.Payment], { description:
|
|
61
|
+
(0, type_graphql_1.Mutation)(returns => [payment_1.Payment], { description: 'To add, modify and delete multiple Payments' }),
|
|
118
62
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [payment_type_1.PaymentPatch])),
|
|
119
63
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
120
64
|
tslib_1.__metadata("design:type", Function),
|
|
@@ -141,17 +85,8 @@ tslib_1.__decorate([
|
|
|
141
85
|
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
142
86
|
tslib_1.__metadata("design:returntype", Promise)
|
|
143
87
|
], PaymentMutation.prototype, "deletePayments", null);
|
|
144
|
-
tslib_1.__decorate([
|
|
145
|
-
(0, type_graphql_1.Directive)('@transaction'),
|
|
146
|
-
(0, type_graphql_1.Directive)('@privilege(category: "accounting", privilege: "mutation", domainOwnerGranted: true)'),
|
|
147
|
-
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple Payments' }),
|
|
148
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('payments', type => [payment_type_1.PaymentPatch])),
|
|
149
|
-
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
150
|
-
tslib_1.__metadata("design:type", Function),
|
|
151
|
-
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
152
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
153
|
-
], PaymentMutation.prototype, "importPayments", null);
|
|
154
88
|
exports.PaymentMutation = PaymentMutation = tslib_1.__decorate([
|
|
155
|
-
(0, type_graphql_1.Resolver)(payment_1.Payment)
|
|
89
|
+
(0, type_graphql_1.Resolver)(payment_1.Payment),
|
|
90
|
+
(0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals)
|
|
156
91
|
], PaymentMutation);
|
|
157
92
|
//# sourceMappingURL=payment-mutation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment-mutation.js","sourceRoot":"","sources":["../../../server/service/payment/payment-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAC5B,iDAAqD;AAErD,uCAAmC;AACnC,iDAAyD;AAGlD,IAAM,eAAe,GAArB,MAAM,eAAe;IAIpB,AAAN,KAAK,CAAC,aAAa,CAAiB,OAAmB,EAAS,OAAwB;QACtF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAa,EAAC,iBAAO,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;YACnD,GAAG,OAAO;YACV,MAAM;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;IAKK,AAAN,KAAK,CAAC,aAAa,CACN,EAAU,EACP,KAAmB,EAC1B,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,iBAAO,EAAE,EAAE,CAAC,CAAA;QAC7C,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YACvC,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;SACzC,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC;YACnC,GAAG,OAAO;YACV,GAAG,KAAK;YACR,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QAE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ACvC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;qDAWP;0BAvIU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,eAAe,CAwI3B","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { getRepository } from '@things-factory/shell'\n\nimport { Payment } from './payment'\nimport { NewPayment, PaymentPatch } from './payment-type'\n\n@Resolver(Payment)\nexport class PaymentMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Payment, { description: 'To create new Payment' })\n async createPayment(@Arg('payment') payment: NewPayment, @Ctx() context: ResolverContext): Promise<Payment> {\n const { domain, user, tx } = context.state\n\n const result = await getRepository(Payment, tx).save({\n ...payment,\n domain,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Payment, { description: 'To modify Payment information' })\n async updatePayment(\n @Arg('id') id: string,\n @Arg('patch') patch: PaymentPatch,\n @Ctx() context: ResolverContext\n ): Promise<Payment> {\n const { domain, user, tx } = context.state\n\n const repository = getRepository(Payment, tx)\n const payment = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...payment,\n ...patch,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [Payment], { description: \"To modify multiple Payments' information\" })\n async updateMultiplePayment(\n @Arg('patches', type => [PaymentPatch]) patches: PaymentPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Payment[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const paymentRepo = getRepository(Payment, tx)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await paymentRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const payment = await paymentRepo.findOne({\n where: { domain: { id: domain.id }, id: updateRecord.id }\n })\n\n if (!payment) {\n throw new Error(`failed to find payment to update: ${updateRecord.id}`)\n }\n\n const result = await paymentRepo.save({\n ...payment,\n ...updateRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete Payment' })\n async deletePayment(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(Payment, tx).delete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete multiple Payments' })\n async deletePayments(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(Payment, tx).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To import multiple Payments' })\n async importPayments(\n @Arg('payments', type => [PaymentPatch]) payments: PaymentPatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n payments.map(async (payment: PaymentPatch) => {\n const createdPayment: Payment = await getRepository(Payment, tx).save({ domain, ...payment })\n })\n )\n\n return true\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"payment-mutation.js","sourceRoot":"","sources":["../../../server/service/payment/payment-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAqF;AAErF,iDAAqD;AAErD,uCAAmC;AACnC,uDAAgD;AAChD,iDAAyD;AAIlD,IAAM,eAAe,GAArB,MAAM,eAAe;IAIpB,AAAN,KAAK,CAAC,aAAa,CAAiB,OAAmB,EAAS,OAAwB;QACtF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,IAAA,8BAAY,EAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;QAEnF,OAAO,KAAK,CAAA;IACd,CAAC;IAKK,AAAN,KAAK,CAAC,aAAa,CACN,EAAU,EACP,KAAmB,EAC1B,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,IAAA,8BAAY,EAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;QAErF,OAAO,KAAK,CAAA;IACd,CAAC;IAKK,AAAN,KAAK,CAAC,qBAAqB,CACe,OAAuB,EACxD,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,IAAA,8BAAY,EAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IACtD,CAAC;IAKK,AAAN,KAAK,CAAC,a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graphql'\n\nimport { SpeakRefusals } from '@things-factory/shell'\n\nimport { Payment } from './payment'\nimport { savePayments } from './payment-service'\nimport { NewPayment, PaymentPatch } from './payment-type'\n\n@Resolver(Payment)\n@UseMiddleware(SpeakRefusals)\nexport class PaymentMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Payment, { description: 'To put a part of a transaction on what it paid' })\n async createPayment(@Arg('payment') payment: NewPayment, @Ctx() context: ResolverContext): Promise<Payment> {\n const { domain, user, tx } = context.state\n const [saved] = await savePayments(tx, domain, user, [{ ...payment, cuFlag: '+' }])\n\n return saved\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Payment, { description: 'To modify Payment information' })\n async updatePayment(\n @Arg('id') id: string,\n @Arg('patch') patch: PaymentPatch,\n @Ctx() context: ResolverContext\n ): Promise<Payment> {\n const { domain, user, tx } = context.state\n const [saved] = await savePayments(tx, domain, user, [{ ...patch, id, cuFlag: 'M' }])\n\n return saved\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [Payment], { description: 'To add, modify and delete multiple Payments' })\n async updateMultiplePayment(\n @Arg('patches', type => [PaymentPatch]) patches: PaymentPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Payment[]> {\n const { domain, user, tx } = context.state\n\n return await savePayments(tx, domain, user, patches)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete Payment' })\n async deletePayment(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, user, tx } = context.state\n await savePayments(tx, domain, user, [{ id, cuFlag: '-' }])\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"accounting\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete multiple Payments' })\n async deletePayments(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, user, tx } = context.state\n await savePayments(\n tx,\n domain,\n user,\n ids.map(id => ({ id, cuFlag: '-' }))\n )\n\n return true\n }\n}\n"]}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Domain, ListParam } from '@things-factory/shell';
|
|
2
2
|
import { User } from '@things-factory/auth-base';
|
|
3
|
+
import { Transaction } from '../transaction/transaction';
|
|
3
4
|
import { Payment } from './payment';
|
|
4
5
|
import { PaymentList } from './payment-type';
|
|
5
6
|
export declare class PaymentQuery {
|
|
6
7
|
payment(id: string, context: ResolverContext): Promise<Payment>;
|
|
7
8
|
payments(params: ListParam, context: ResolverContext): Promise<PaymentList>;
|
|
9
|
+
transaction(payment: Payment): Promise<Transaction>;
|
|
10
|
+
targetLabel(payment: Payment): Promise<string | null>;
|
|
8
11
|
domain(payment: Payment): Promise<Domain>;
|
|
9
12
|
updater(payment: Payment): Promise<User>;
|
|
10
13
|
creator(payment: Payment): Promise<User>;
|
|
@@ -5,7 +5,9 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
6
|
const shell_1 = require("@things-factory/shell");
|
|
7
7
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
8
|
+
const transaction_1 = require("../transaction/transaction");
|
|
8
9
|
const payment_1 = require("./payment");
|
|
10
|
+
const payment_targets_1 = require("./payment-targets");
|
|
9
11
|
const payment_type_1 = require("./payment-type");
|
|
10
12
|
let PaymentQuery = class PaymentQuery {
|
|
11
13
|
async payment(id, context) {
|
|
@@ -20,11 +22,21 @@ let PaymentQuery = class PaymentQuery {
|
|
|
20
22
|
domain,
|
|
21
23
|
params,
|
|
22
24
|
repository: await (0, shell_1.getRepository)(payment_1.Payment),
|
|
23
|
-
searchables: []
|
|
25
|
+
searchables: ['targetType', 'basis', 'notes']
|
|
24
26
|
});
|
|
25
27
|
const [items, total] = await queryBuilder.getManyAndCount();
|
|
26
28
|
return { items, total };
|
|
27
29
|
}
|
|
30
|
+
async transaction(payment) {
|
|
31
|
+
return payment.transaction ?? (await (0, shell_1.getRepository)(transaction_1.Transaction).findOneBy({ id: payment.transactionId }));
|
|
32
|
+
}
|
|
33
|
+
async targetLabel(payment) {
|
|
34
|
+
const label = (0, payment_targets_1.paymentTargetOf)(payment.targetType)?.label;
|
|
35
|
+
if (!label)
|
|
36
|
+
return null;
|
|
37
|
+
const labels = await label((0, shell_1.getRepository)(payment_1.Payment).manager, { id: payment.domainId }, [payment.targetId]);
|
|
38
|
+
return labels.get(payment.targetId) ?? null;
|
|
39
|
+
}
|
|
28
40
|
async domain(payment) {
|
|
29
41
|
return payment.domainId && (await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: payment.domainId }));
|
|
30
42
|
}
|
|
@@ -54,6 +66,23 @@ tslib_1.__decorate([
|
|
|
54
66
|
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
55
67
|
tslib_1.__metadata("design:returntype", Promise)
|
|
56
68
|
], PaymentQuery.prototype, "payments", null);
|
|
69
|
+
tslib_1.__decorate([
|
|
70
|
+
(0, type_graphql_1.FieldResolver)(type => transaction_1.Transaction),
|
|
71
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
72
|
+
tslib_1.__metadata("design:type", Function),
|
|
73
|
+
tslib_1.__metadata("design:paramtypes", [payment_1.Payment]),
|
|
74
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
75
|
+
], PaymentQuery.prototype, "transaction", null);
|
|
76
|
+
tslib_1.__decorate([
|
|
77
|
+
(0, type_graphql_1.FieldResolver)(type => String, {
|
|
78
|
+
nullable: true,
|
|
79
|
+
description: 'What people call what was paid, as its module names it'
|
|
80
|
+
}),
|
|
81
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
82
|
+
tslib_1.__metadata("design:type", Function),
|
|
83
|
+
tslib_1.__metadata("design:paramtypes", [payment_1.Payment]),
|
|
84
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
85
|
+
], PaymentQuery.prototype, "targetLabel", null);
|
|
57
86
|
tslib_1.__decorate([
|
|
58
87
|
(0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
|
|
59
88
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment-query.js","sourceRoot":"","sources":["../../../server/service/payment/payment-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;
|
|
1
|
+
{"version":3,"file":"payment-query.js","sourceRoot":"","sources":["../../../server/service/payment/payment-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,iDAAuG;AACvG,yDAAgD;AAEhD,4DAAwD;AACxD,uCAAmC;AACnC,uDAAmD;AACnD,iDAA4C;AAGrC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAGjB,AAAN,KAAK,CAAC,OAAO,CAAY,EAAU,EAAS,OAAwB;QAClE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,qBAAa,EAAC,iBAAO,CAAC,CAAC,OAAO,CAAC;YAC1C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;SACzC,CAAC,CAAA;IACJ,CAAC;IAIK,AAAN,KAAK,CAAC,QAAQ,CAA0B,MAAiB,EAAS,OAAwB;QACxF,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,MAAM;YACN,MAAM;YACN,UAAU,EAAE,MAAM,IAAA,qBAAa,EAAC,iBAAO,CAAC;YACxC,WAAW,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,OAA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cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;0CAEpC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;2CAErC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;2CAErC;uBA1DU,YAAY;IADxB,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,YAAY,CA2DxB","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'\n\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\n\nimport { Transaction } from '../transaction/transaction'\nimport { Payment } from './payment'\nimport { paymentTargetOf } from './payment-targets'\nimport { PaymentList } from './payment-type'\n\n@Resolver(Payment)\nexport class PaymentQuery {\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => Payment!, { nullable: true, description: 'To fetch a Payment' })\n async payment(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Payment> {\n const { domain } = context.state\n\n return await getRepository(Payment).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Directive('@privilege(category: \"accounting\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => PaymentList, { description: 'To fetch multiple Payments' })\n async payments(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<PaymentList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(Payment),\n searchables: ['targetType', 'basis', 'notes']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => Transaction)\n async transaction(@Root() payment: Payment): Promise<Transaction> {\n return payment.transaction ?? (await getRepository(Transaction).findOneBy({ id: payment.transactionId }))\n }\n\n @FieldResolver(type => String, {\n nullable: true,\n description: 'What people call what was paid, as its module names it'\n })\n async targetLabel(@Root() payment: Payment): Promise<string | null> {\n const label = paymentTargetOf(payment.targetType)?.label\n if (!label) return null\n const labels = await label(getRepository(Payment).manager, { id: payment.domainId }, [payment.targetId])\n\n return labels.get(payment.targetId) ?? null\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() payment: Payment): Promise<Domain> {\n return payment.domainId && (await getRepository(Domain).findOneBy({ id: payment.domainId }))\n }\n\n @FieldResolver(type => User)\n async updater(@Root() payment: Payment): Promise<User> {\n return payment.updaterId && (await getRepository(User).findOneBy({ id: payment.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() payment: Payment): Promise<User> {\n return payment.creatorId && (await getRepository(User).findOneBy({ id: payment.creatorId }))\n }\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm';
|
|
2
|
+
import { Payment } from './payment';
|
|
3
|
+
import { PaymentPatch } from './payment-type';
|
|
4
|
+
/**
|
|
5
|
+
* Within one purpose a transaction pays no more than itself. Run after its payments or its amount change.
|
|
6
|
+
*/
|
|
7
|
+
export declare function checkPaymentsWithin(tx: EntityManager, domain: {
|
|
8
|
+
id: string;
|
|
9
|
+
}, transactionIds: string[]): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Apply rows to a domain's payments: `+` (or no id) adds, `M` changes, `-` deletes (softly). Then the general rule
|
|
12
|
+
* (§`checkPaymentsWithin`) and each touched kind's own rules run, in the same database transaction.
|
|
13
|
+
*/
|
|
14
|
+
export declare function savePayments(tx: EntityManager, domain: {
|
|
15
|
+
id: string;
|
|
16
|
+
}, user: any, patches: PaymentPatch[]): Promise<Payment[]>;
|