@things-factory/accounting 8.0.0 → 9.0.0-beta.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist-client/pages/accounting-category/accounting-category-tree-page.js +1 -1
- package/dist-client/pages/accounting-category/accounting-category-tree-page.js.map +1 -1
- package/dist-client/pages/bank/bank-importer.d.ts +23 -0
- package/dist-client/pages/bank/bank-importer.js +93 -0
- package/dist-client/pages/bank/bank-importer.js.map +1 -0
- package/dist-client/pages/bank/bank-list-page.d.ts +66 -0
- package/dist-client/pages/bank/bank-list-page.js +370 -0
- package/dist-client/pages/bank/bank-list-page.js.map +1 -0
- package/dist-client/pages/bank-account/bank-account-importer.d.ts +23 -0
- package/dist-client/pages/bank-account/bank-account-importer.js +93 -0
- package/dist-client/pages/bank-account/bank-account-importer.js.map +1 -0
- package/dist-client/pages/bank-account/bank-account-list-page.d.ts +66 -0
- package/dist-client/pages/bank-account/bank-account-list-page.js +370 -0
- package/dist-client/pages/bank-account/bank-account-list-page.js.map +1 -0
- package/dist-client/pages/financial-institution/financial-institution-importer.d.ts +23 -0
- package/dist-client/pages/financial-institution/financial-institution-importer.js +93 -0
- package/dist-client/pages/financial-institution/financial-institution-importer.js.map +1 -0
- package/dist-client/pages/financial-institution/financial-institution-list-page.d.ts +66 -0
- package/dist-client/pages/financial-institution/financial-institution-list-page.js +370 -0
- package/dist-client/pages/financial-institution/financial-institution-list-page.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/migrations/1725201567284-seed-country-codes.d.ts +5 -0
- package/dist-server/migrations/1725201567284-seed-country-codes.js +248 -0
- package/dist-server/migrations/1725201567284-seed-country-codes.js.map +1 -0
- package/dist-server/migrations/1725201667385-seed-financial-institutions.d.ts +5 -0
- package/dist-server/migrations/1725201667385-seed-financial-institutions.js +348 -0
- package/dist-server/migrations/1725201667385-seed-financial-institutions.js.map +1 -0
- package/dist-server/service/bank-account/bank-account-history.d.ts +34 -0
- package/dist-server/service/bank-account/bank-account-history.js +172 -0
- package/dist-server/service/bank-account/bank-account-history.js.map +1 -0
- package/dist-server/service/bank-account/bank-account-mutation.d.ts +10 -0
- package/dist-server/service/bank-account/bank-account-mutation.js +128 -0
- package/dist-server/service/bank-account/bank-account-mutation.js.map +1 -0
- package/dist-server/service/bank-account/bank-account-query.d.ts +11 -0
- package/dist-server/service/bank-account/bank-account-query.js +79 -0
- package/dist-server/service/bank-account/bank-account-query.js.map +1 -0
- package/dist-server/service/bank-account/bank-account-type.d.ts +39 -0
- package/dist-server/service/bank-account/bank-account-type.js +153 -0
- package/dist-server/service/bank-account/bank-account-type.js.map +1 -0
- package/dist-server/service/bank-account/bank-account.d.ts +38 -0
- package/dist-server/service/bank-account/bank-account.js +164 -0
- package/dist-server/service/bank-account/bank-account.js.map +1 -0
- package/dist-server/service/bank-account/event-subscriber.d.ts +7 -0
- package/dist-server/service/bank-account/event-subscriber.js +21 -0
- package/dist-server/service/bank-account/event-subscriber.js.map +1 -0
- package/dist-server/service/bank-account/index.d.ts +7 -0
- package/dist-server/service/bank-account/index.js +12 -0
- package/dist-server/service/bank-account/index.js.map +1 -0
- package/dist-server/service/financial-institution/financial-institution-mutation.d.ts +10 -0
- package/dist-server/service/financial-institution/financial-institution-mutation.js +169 -0
- package/dist-server/service/financial-institution/financial-institution-mutation.js.map +1 -0
- package/dist-server/service/financial-institution/financial-institution-query.d.ts +12 -0
- package/dist-server/service/financial-institution/financial-institution-query.js +97 -0
- package/dist-server/service/financial-institution/financial-institution-query.js.map +1 -0
- package/dist-server/service/financial-institution/financial-institution-type.d.ts +32 -0
- package/dist-server/service/financial-institution/financial-institution-type.js +126 -0
- package/dist-server/service/financial-institution/financial-institution-type.js.map +1 -0
- package/dist-server/service/financial-institution/financial-institution.d.ts +34 -0
- package/dist-server/service/financial-institution/financial-institution.js +137 -0
- package/dist-server/service/financial-institution/financial-institution.js.map +1 -0
- package/dist-server/service/financial-institution/index.d.ts +6 -0
- package/dist-server/service/financial-institution/index.js +10 -0
- package/dist-server/service/financial-institution/index.js.map +1 -0
- package/dist-server/service/index.d.ts +3 -2
- package/dist-server/service/index.js +5 -0
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/payment/index.d.ts +1 -2
- package/dist-server/service/payment/payment-history.d.ts +8 -1
- package/dist-server/service/payment/payment-history.js +41 -10
- package/dist-server/service/payment/payment-history.js.map +1 -1
- package/dist-server/service/payment/payment-type.d.ts +7 -1
- package/dist-server/service/payment/payment-type.js +24 -0
- package/dist-server/service/payment/payment-type.js.map +1 -1
- package/dist-server/service/payment/payment.d.ts +12 -0
- package/dist-server/service/payment/payment.js +36 -1
- package/dist-server/service/payment/payment.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/helps/accounting/bank-account.md +160 -0
- package/helps/accounting/bank.md +160 -0
- package/helps/accounting/financial-institution.md +160 -0
- package/package.json +7 -7
- package/client/activities/activity-book-edit.ts +0 -88
- package/client/activities/activity-book-view.ts +0 -88
- package/client/activities/activity-expense-edit.ts +0 -88
- package/client/activities/activity-expense-view.ts +0 -88
- package/client/bootstrap.ts +0 -10
- package/client/components/accounting-category-selector.ts +0 -136
- package/client/components/accounting-category-view.ts +0 -75
- package/client/grist-editors/grist-editor-accounting-category-object.ts +0 -83
- package/client/grist-editors/grist-renderer-accounting-category-object.ts +0 -13
- package/client/index.ts +0 -0
- package/client/pages/account/account-importer.ts +0 -97
- package/client/pages/account/account-list-page.ts +0 -364
- package/client/pages/accounting-category/accounting-category-importer.ts +0 -97
- package/client/pages/accounting-category/accounting-category-list-page.ts +0 -368
- package/client/pages/accounting-category/accounting-category-tree-page.ts +0 -338
- package/client/pages/accounting-document/accounting-document-importer.ts +0 -90
- package/client/pages/accounting-document/accounting-document-list-page.ts +0 -398
- package/client/pages/financial-statement/financial-statement-importer.ts +0 -97
- package/client/pages/financial-statement/financial-statement-list-page.ts +0 -338
- package/client/pages/fiscal-month/fiscal-month-importer.ts +0 -90
- package/client/pages/fiscal-month/fiscal-month-list-page.ts +0 -398
- package/client/pages/fiscal-quarter/fiscal-quarter-importer.ts +0 -90
- package/client/pages/fiscal-quarter/fiscal-quarter-list-page.ts +0 -398
- package/client/pages/fiscal-year/fiscal-year-importer.ts +0 -90
- package/client/pages/fiscal-year/fiscal-year-list-page.ts +0 -398
- package/client/pages/income-statement/income-statement-importer.ts +0 -97
- package/client/pages/income-statement/income-statement-list-page.ts +0 -338
- package/client/pages/payment/payment-importer.ts +0 -90
- package/client/pages/payment/payment-list-page.ts +0 -398
- package/client/pages/transaction/transaction-importer.ts +0 -97
- package/client/pages/transaction/transaction-list-page.ts +0 -338
- package/client/route.ts +0 -35
- package/client/tsconfig.json +0 -13
- package/client/types/accounting-category.ts +0 -23
- package/client/types/index.ts +0 -1
- package/server/activities/activity-book.ts +0 -172
- package/server/activities/activity-expense.ts +0 -149
- package/server/activities/index.ts +0 -18
- package/server/controllers/index.ts +0 -1
- package/server/controllers/summary-statements.ts +0 -166
- package/server/index.ts +0 -6
- package/server/middlewares/index.ts +0 -3
- package/server/migrations/1725200507196-seed-fiscal-entities.ts +0 -106
- package/server/migrations/1725201467183-seed-accounts.ts +0 -339
- package/server/migrations/index.ts +0 -9
- package/server/routes.ts +0 -26
- package/server/service/account/account-history.ts +0 -117
- package/server/service/account/account-mutation.ts +0 -140
- package/server/service/account/account-query.ts +0 -51
- package/server/service/account/account-type.ts +0 -44
- package/server/service/account/account.ts +0 -97
- package/server/service/account/event-subscriber.ts +0 -17
- package/server/service/account/index.ts +0 -9
- package/server/service/accounting-category/accounting-category-history.ts +0 -129
- package/server/service/accounting-category/accounting-category-mutation.ts +0 -148
- package/server/service/accounting-category/accounting-category-query.ts +0 -74
- package/server/service/accounting-category/accounting-category-type.ts +0 -48
- package/server/service/accounting-category/accounting-category.ts +0 -100
- package/server/service/accounting-category/event-subscriber.ts +0 -20
- package/server/service/accounting-category/index.ts +0 -9
- package/server/service/accounting-document/accounting-document-history.ts +0 -123
- package/server/service/accounting-document/accounting-document-mutation.ts +0 -137
- package/server/service/accounting-document/accounting-document-query.ts +0 -48
- package/server/service/accounting-document/accounting-document-type.ts +0 -52
- package/server/service/accounting-document/accounting-document.ts +0 -93
- package/server/service/accounting-document/event-subscriber.ts +0 -17
- package/server/service/accounting-document/index.ts +0 -9
- package/server/service/common-type.ts +0 -12
- package/server/service/financial-statement/event-subscriber.ts +0 -17
- package/server/service/financial-statement/financial-statement-history.ts +0 -129
- package/server/service/financial-statement/financial-statement-line-item.ts +0 -82
- package/server/service/financial-statement/financial-statement-mutation.ts +0 -148
- package/server/service/financial-statement/financial-statement-query.ts +0 -53
- package/server/service/financial-statement/financial-statement-type.ts +0 -51
- package/server/service/financial-statement/financial-statement.ts +0 -116
- package/server/service/financial-statement/index.ts +0 -10
- package/server/service/fiscal-month/fiscal-month-mutation.ts +0 -145
- package/server/service/fiscal-month/fiscal-month-query.ts +0 -58
- package/server/service/fiscal-month/fiscal-month-type.ts +0 -66
- package/server/service/fiscal-month/fiscal-month.ts +0 -84
- package/server/service/fiscal-month/index.ts +0 -7
- package/server/service/fiscal-quarter/fiscal-quarter-mutation.ts +0 -148
- package/server/service/fiscal-quarter/fiscal-quarter-query.ts +0 -60
- package/server/service/fiscal-quarter/fiscal-quarter-type.ts +0 -60
- package/server/service/fiscal-quarter/fiscal-quarter.ts +0 -80
- package/server/service/fiscal-quarter/index.ts +0 -7
- package/server/service/fiscal-year/fiscal-year-mutation.ts +0 -145
- package/server/service/fiscal-year/fiscal-year-query.ts +0 -53
- package/server/service/fiscal-year/fiscal-year-type.ts +0 -54
- package/server/service/fiscal-year/fiscal-year.ts +0 -76
- package/server/service/fiscal-year/index.ts +0 -7
- package/server/service/income-statement/event-subscriber.ts +0 -17
- package/server/service/income-statement/income-statement-history.ts +0 -133
- package/server/service/income-statement/income-statement-line-item.ts +0 -84
- package/server/service/income-statement/income-statement-mutation.ts +0 -147
- package/server/service/income-statement/income-statement-query.ts +0 -50
- package/server/service/income-statement/income-statement-type.ts +0 -51
- package/server/service/income-statement/income-statement.ts +0 -120
- package/server/service/income-statement/index.ts +0 -10
- package/server/service/index.ts +0 -108
- package/server/service/payment/event-subscriber.ts +0 -17
- package/server/service/payment/index.ts +0 -9
- package/server/service/payment/payment-history.ts +0 -132
- package/server/service/payment/payment-mutation.ts +0 -139
- package/server/service/payment/payment-query.ts +0 -50
- package/server/service/payment/payment-type.ts +0 -64
- package/server/service/payment/payment.ts +0 -123
- package/server/service/transaction/event-subscriber.ts +0 -17
- package/server/service/transaction/index.ts +0 -9
- package/server/service/transaction/transaction-history.ts +0 -161
- package/server/service/transaction/transaction-mutation.ts +0 -146
- package/server/service/transaction/transaction-query.ts +0 -50
- package/server/service/transaction/transaction-type.ts +0 -48
- package/server/service/transaction/transaction.ts +0 -230
- package/server/tsconfig.json +0 -10
@@ -0,0 +1,164 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.BankAccount = exports.OwnerType = exports.AccountType = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const typeorm_1 = require("typeorm");
|
6
|
+
const type_graphql_1 = require("type-graphql");
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
8
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
9
|
+
var AccountType;
|
10
|
+
(function (AccountType) {
|
11
|
+
AccountType["Bank"] = "Bank";
|
12
|
+
AccountType["Card"] = "Card";
|
13
|
+
})(AccountType || (exports.AccountType = AccountType = {}));
|
14
|
+
(0, type_graphql_1.registerEnumType)(AccountType, {
|
15
|
+
name: 'AccountType',
|
16
|
+
description: 'Type of the account (Bank or Card)'
|
17
|
+
});
|
18
|
+
var OwnerType;
|
19
|
+
(function (OwnerType) {
|
20
|
+
OwnerType["Company"] = "Company";
|
21
|
+
OwnerType["Vendor"] = "Vendor";
|
22
|
+
OwnerType["Employee"] = "Employee";
|
23
|
+
})(OwnerType || (exports.OwnerType = OwnerType = {}));
|
24
|
+
(0, type_graphql_1.registerEnumType)(OwnerType, {
|
25
|
+
name: 'OwnerType',
|
26
|
+
description: 'Type of the owner of the bank account'
|
27
|
+
});
|
28
|
+
let BankAccount = class BankAccount {
|
29
|
+
constructor() {
|
30
|
+
this.version = 1;
|
31
|
+
}
|
32
|
+
};
|
33
|
+
exports.BankAccount = BankAccount;
|
34
|
+
tslib_1.__decorate([
|
35
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
36
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
37
|
+
tslib_1.__metadata("design:type", String)
|
38
|
+
], BankAccount.prototype, "id", void 0);
|
39
|
+
tslib_1.__decorate([
|
40
|
+
(0, typeorm_1.VersionColumn)(),
|
41
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
42
|
+
tslib_1.__metadata("design:type", Number)
|
43
|
+
], BankAccount.prototype, "version", void 0);
|
44
|
+
tslib_1.__decorate([
|
45
|
+
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
46
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
47
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
48
|
+
], BankAccount.prototype, "domain", void 0);
|
49
|
+
tslib_1.__decorate([
|
50
|
+
(0, typeorm_1.RelationId)((bankAccount) => bankAccount.domain),
|
51
|
+
tslib_1.__metadata("design:type", String)
|
52
|
+
], BankAccount.prototype, "domainId", void 0);
|
53
|
+
tslib_1.__decorate([
|
54
|
+
(0, typeorm_1.Column)({ nullable: false }),
|
55
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
56
|
+
tslib_1.__metadata("design:type", String)
|
57
|
+
], BankAccount.prototype, "name", void 0);
|
58
|
+
tslib_1.__decorate([
|
59
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
60
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
61
|
+
tslib_1.__metadata("design:type", String)
|
62
|
+
], BankAccount.prototype, "description", void 0);
|
63
|
+
tslib_1.__decorate([
|
64
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
65
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Name of the account holder' }),
|
66
|
+
tslib_1.__metadata("design:type", String)
|
67
|
+
], BankAccount.prototype, "accountHolderName", void 0);
|
68
|
+
tslib_1.__decorate([
|
69
|
+
(0, typeorm_1.Column)({ nullable: false }),
|
70
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Bank account number' }),
|
71
|
+
tslib_1.__metadata("design:type", String)
|
72
|
+
], BankAccount.prototype, "accountNumber", void 0);
|
73
|
+
tslib_1.__decorate([
|
74
|
+
(0, typeorm_1.Column)({ nullable: false }),
|
75
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Bank name' }),
|
76
|
+
tslib_1.__metadata("design:type", String)
|
77
|
+
], BankAccount.prototype, "bankName", void 0);
|
78
|
+
tslib_1.__decorate([
|
79
|
+
(0, typeorm_1.Column)({ nullable: false }),
|
80
|
+
(0, type_graphql_1.Field)(type => AccountType, { description: 'Type of the account (Bank or Card)' }),
|
81
|
+
tslib_1.__metadata("design:type", String)
|
82
|
+
], BankAccount.prototype, "accountType", void 0);
|
83
|
+
tslib_1.__decorate([
|
84
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
85
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Currency of the account' }),
|
86
|
+
tslib_1.__metadata("design:type", String)
|
87
|
+
], BankAccount.prototype, "currency", void 0);
|
88
|
+
tslib_1.__decorate([
|
89
|
+
(0, typeorm_1.Column)({ nullable: false, default: false }),
|
90
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
91
|
+
tslib_1.__metadata("design:type", Boolean)
|
92
|
+
], BankAccount.prototype, "active", void 0);
|
93
|
+
tslib_1.__decorate([
|
94
|
+
(0, typeorm_1.Column)({ nullable: false }),
|
95
|
+
(0, type_graphql_1.Field)(type => OwnerType, { description: 'Type of the owner of the bank account' }),
|
96
|
+
tslib_1.__metadata("design:type", String)
|
97
|
+
], BankAccount.prototype, "ownerType", void 0);
|
98
|
+
tslib_1.__decorate([
|
99
|
+
(0, typeorm_1.Column)({ nullable: false }),
|
100
|
+
(0, type_graphql_1.Field)({ description: 'ID of the owner of the bank account' }),
|
101
|
+
tslib_1.__metadata("design:type", String)
|
102
|
+
], BankAccount.prototype, "ownerId", void 0);
|
103
|
+
tslib_1.__decorate([
|
104
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
105
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'IBAN of the bank account' }),
|
106
|
+
tslib_1.__metadata("design:type", String)
|
107
|
+
], BankAccount.prototype, "iban", void 0);
|
108
|
+
tslib_1.__decorate([
|
109
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
110
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'BIC of the bank account' }),
|
111
|
+
tslib_1.__metadata("design:type", String)
|
112
|
+
], BankAccount.prototype, "bic", void 0);
|
113
|
+
tslib_1.__decorate([
|
114
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
115
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Country of the bank account' }),
|
116
|
+
tslib_1.__metadata("design:type", String)
|
117
|
+
], BankAccount.prototype, "country", void 0);
|
118
|
+
tslib_1.__decorate([
|
119
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
120
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Cover image of the bank account' }),
|
121
|
+
tslib_1.__metadata("design:type", String)
|
122
|
+
], BankAccount.prototype, "image", void 0);
|
123
|
+
tslib_1.__decorate([
|
124
|
+
(0, typeorm_1.CreateDateColumn)(),
|
125
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
126
|
+
tslib_1.__metadata("design:type", Date)
|
127
|
+
], BankAccount.prototype, "createdAt", void 0);
|
128
|
+
tslib_1.__decorate([
|
129
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
130
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
131
|
+
tslib_1.__metadata("design:type", Date)
|
132
|
+
], BankAccount.prototype, "updatedAt", void 0);
|
133
|
+
tslib_1.__decorate([
|
134
|
+
(0, typeorm_1.DeleteDateColumn)(),
|
135
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
136
|
+
tslib_1.__metadata("design:type", Date)
|
137
|
+
], BankAccount.prototype, "deletedAt", void 0);
|
138
|
+
tslib_1.__decorate([
|
139
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
140
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
141
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
142
|
+
], BankAccount.prototype, "creator", void 0);
|
143
|
+
tslib_1.__decorate([
|
144
|
+
(0, typeorm_1.RelationId)((bankAccount) => bankAccount.creator),
|
145
|
+
tslib_1.__metadata("design:type", String)
|
146
|
+
], BankAccount.prototype, "creatorId", void 0);
|
147
|
+
tslib_1.__decorate([
|
148
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
149
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
150
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
151
|
+
], BankAccount.prototype, "updater", void 0);
|
152
|
+
tslib_1.__decorate([
|
153
|
+
(0, typeorm_1.RelationId)((bankAccount) => bankAccount.updater),
|
154
|
+
tslib_1.__metadata("design:type", String)
|
155
|
+
], BankAccount.prototype, "updaterId", void 0);
|
156
|
+
exports.BankAccount = BankAccount = tslib_1.__decorate([
|
157
|
+
(0, typeorm_1.Entity)(),
|
158
|
+
(0, typeorm_1.Index)('ix_bank_account_0', (bankAccount) => [bankAccount.domain, bankAccount.name], {
|
159
|
+
where: '"deleted_at" IS NULL',
|
160
|
+
unique: true
|
161
|
+
}),
|
162
|
+
(0, type_graphql_1.ObjectType)({ description: 'Entity for BankAccount' })
|
163
|
+
], BankAccount);
|
164
|
+
//# sourceMappingURL=bank-account.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"bank-account.js","sourceRoot":"","sources":["../../../server/service/bank-account/bank-account.ts"],"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oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACd,IAAI;8CAAA;AAIhB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC9B,gBAAI;4CAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC;;8CAC5C;AAIlB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC9B,gBAAI;4CAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC;;8CAC5C;sBAhGP,WAAW;IANvB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,mBAAmB,EAAE,CAAC,WAAwB,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,EAAE;QAChG,KAAK,EAAE,sBAAsB;QAC7B,MAAM,EAAE,IAAI;KACb,CAAC;IACD,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,wBAAwB,EAAE,CAAC;GACzC,WAAW,CAiGvB","sourcesContent":["import {\n CreateDateColumn,\n UpdateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n Column,\n RelationId,\n ManyToOne,\n VersionColumn,\n PrimaryGeneratedColumn\n} from 'typeorm'\nimport { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'\n\nimport { Domain } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\n\nexport enum AccountType {\n Bank = 'Bank',\n Card = 'Card'\n}\n\nregisterEnumType(AccountType, {\n name: 'AccountType',\n description: 'Type of the account (Bank or Card)'\n})\n\nexport enum OwnerType {\n Company = 'Company',\n Vendor = 'Vendor',\n Employee = 'Employee'\n}\n\nregisterEnumType(OwnerType, {\n name: 'OwnerType',\n description: 'Type of the owner of the bank account'\n})\n\n@Entity()\n@Index('ix_bank_account_0', (bankAccount: BankAccount) => [bankAccount.domain, bankAccount.name], {\n where: '\"deleted_at\" IS NULL',\n unique: true\n})\n@ObjectType({ description: 'Entity for BankAccount' })\nexport class BankAccount {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @VersionColumn()\n @Field({ nullable: true })\n version?: number = 1\n\n @ManyToOne(type => Domain)\n @Field({ nullable: true })\n domain?: Domain\n\n @RelationId((bankAccount: BankAccount) => bankAccount.domain)\n domainId?: string\n\n @Column({ nullable: false })\n @Field({ nullable: true })\n name?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n description?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Name of the account holder' })\n accountHolderName?: string // 계좌 소유자의 이름\n\n @Column({ nullable: false })\n @Field({ nullable: true, description: 'Bank account number' })\n accountNumber?: string\n\n @Column({ nullable: false })\n @Field({ nullable: true, description: 'Bank name' })\n bankName?: string\n\n @Column({ nullable: false })\n @Field(type => AccountType, { description: 'Type of the account (Bank or Card)' })\n accountType: AccountType\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Currency of the account' })\n currency?: string\n\n @Column({ nullable: false, default: false })\n @Field({ nullable: true })\n active?: boolean\n\n @Column({ nullable: false })\n @Field(type => OwnerType, { description: 'Type of the owner of the bank account' })\n ownerType: OwnerType\n\n @Column({ nullable: false })\n @Field({ description: 'ID of the owner of the bank account' })\n ownerId: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'IBAN of the bank account' })\n iban?: string // 은행 계좌의 IBAN\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'BIC of the bank account' })\n bic?: string // 은행 계좌의 BIC\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Country of the bank account' })\n country?: string // 은행 계좌의 국적\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Cover image of the bank account' })\n image?: string // 은행 계좌의 커버이미지\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt?: Date\n\n @DeleteDateColumn()\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((bankAccount: BankAccount) => bankAccount.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((bankAccount: BankAccount) => bankAccount.updater)\n updaterId?: string\n}\n"]}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { HistoryEntitySubscriber } from '@operato/typeorm-history';
|
2
|
+
import { BankAccount } from './bank-account';
|
3
|
+
import { BankAccountHistory } from './bank-account-history';
|
4
|
+
export declare class BankAccountHistoryEntitySubscriber extends HistoryEntitySubscriber<BankAccount, BankAccountHistory> {
|
5
|
+
get entity(): typeof BankAccount;
|
6
|
+
get historyEntity(): typeof BankAccountHistory;
|
7
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.BankAccountHistoryEntitySubscriber = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const typeorm_1 = require("typeorm");
|
6
|
+
const typeorm_history_1 = require("@operato/typeorm-history");
|
7
|
+
const bank_account_1 = require("./bank-account");
|
8
|
+
const bank_account_history_1 = require("./bank-account-history");
|
9
|
+
let BankAccountHistoryEntitySubscriber = class BankAccountHistoryEntitySubscriber extends typeorm_history_1.HistoryEntitySubscriber {
|
10
|
+
get entity() {
|
11
|
+
return bank_account_1.BankAccount;
|
12
|
+
}
|
13
|
+
get historyEntity() {
|
14
|
+
return bank_account_history_1.BankAccountHistory;
|
15
|
+
}
|
16
|
+
};
|
17
|
+
exports.BankAccountHistoryEntitySubscriber = BankAccountHistoryEntitySubscriber;
|
18
|
+
exports.BankAccountHistoryEntitySubscriber = BankAccountHistoryEntitySubscriber = tslib_1.__decorate([
|
19
|
+
(0, typeorm_1.EventSubscriber)()
|
20
|
+
], BankAccountHistoryEntitySubscriber);
|
21
|
+
//# sourceMappingURL=event-subscriber.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"event-subscriber.js","sourceRoot":"","sources":["../../../server/service/bank-account/event-subscriber.ts"],"names":[],"mappings":";;;;AAAA,qCAAyC;AAEzC,8DAAkE;AAElE,iDAA4C;AAC5C,iEAA2D;AAGpD,IAAM,kCAAkC,GAAxC,MAAM,kCAAmC,SAAQ,yCAAwD;IAC9G,IAAW,MAAM;QACf,OAAO,0BAAW,CAAA;IACpB,CAAC;IAED,IAAW,aAAa;QACtB,OAAO,yCAAkB,CAAA;IAC3B,CAAC;CACF,CAAA;AARY,gFAAkC;6CAAlC,kCAAkC;IAD9C,IAAA,yBAAe,GAAE;GACL,kCAAkC,CAQ9C","sourcesContent":["import { EventSubscriber } from 'typeorm'\n\nimport { HistoryEntitySubscriber } from '@operato/typeorm-history'\n\nimport { BankAccount } from './bank-account'\nimport { BankAccountHistory } from './bank-account-history'\n\n@EventSubscriber()\nexport class BankAccountHistoryEntitySubscriber extends HistoryEntitySubscriber<BankAccount, BankAccountHistory> {\n public get entity() {\n return BankAccount\n }\n\n public get historyEntity() {\n return BankAccountHistory\n }\n}\n"]}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { BankAccount } from './bank-account';
|
2
|
+
import { BankAccountHistoryEntitySubscriber } from './event-subscriber';
|
3
|
+
import { BankAccountQuery } from './bank-account-query';
|
4
|
+
import { BankAccountMutation } from './bank-account-mutation';
|
5
|
+
export declare const entities: (typeof BankAccount)[];
|
6
|
+
export declare const resolvers: (typeof BankAccountQuery | typeof BankAccountMutation)[];
|
7
|
+
export declare const subscribers: (typeof BankAccountHistoryEntitySubscriber)[];
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.subscribers = exports.resolvers = exports.entities = void 0;
|
4
|
+
const bank_account_1 = require("./bank-account");
|
5
|
+
const bank_account_history_1 = require("./bank-account-history");
|
6
|
+
const event_subscriber_1 = require("./event-subscriber");
|
7
|
+
const bank_account_query_1 = require("./bank-account-query");
|
8
|
+
const bank_account_mutation_1 = require("./bank-account-mutation");
|
9
|
+
exports.entities = [bank_account_1.BankAccount, bank_account_history_1.BankAccountHistory];
|
10
|
+
exports.resolvers = [bank_account_query_1.BankAccountQuery, bank_account_mutation_1.BankAccountMutation];
|
11
|
+
exports.subscribers = [event_subscriber_1.BankAccountHistoryEntitySubscriber];
|
12
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/bank-account/index.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAC5C,iEAA2D;AAC3D,yDAAuE;AACvE,6DAAuD;AACvD,mEAA6D;AAEhD,QAAA,QAAQ,GAAG,CAAC,0BAAW,EAAE,yCAAkB,CAAC,CAAA;AAC5C,QAAA,SAAS,GAAG,CAAC,qCAAgB,EAAE,2CAAmB,CAAC,CAAA;AACnD,QAAA,WAAW,GAAG,CAAC,qDAAkC,CAAC,CAAA","sourcesContent":["import { BankAccount } from './bank-account'\nimport { BankAccountHistory } from './bank-account-history'\nimport { BankAccountHistoryEntitySubscriber } from './event-subscriber'\nimport { BankAccountQuery } from './bank-account-query'\nimport { BankAccountMutation } from './bank-account-mutation'\n\nexport const entities = [BankAccount, BankAccountHistory]\nexport const resolvers = [BankAccountQuery, BankAccountMutation]\nexport const subscribers = [BankAccountHistoryEntitySubscriber]\n"]}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { FinancialInstitution } from './financial-institution';
|
2
|
+
import { NewFinancialInstitution, FinancialInstitutionPatch } from './financial-institution-type';
|
3
|
+
export declare class FinancialInstitutionMutation {
|
4
|
+
createFinancialInstitution(financialInstitution: NewFinancialInstitution, context: ResolverContext): Promise<FinancialInstitution>;
|
5
|
+
updateFinancialInstitution(id: string, patch: FinancialInstitutionPatch, context: ResolverContext): Promise<FinancialInstitution>;
|
6
|
+
updateMultipleFinancialInstitution(patches: FinancialInstitutionPatch[], context: ResolverContext): Promise<FinancialInstitution[]>;
|
7
|
+
deleteFinancialInstitution(id: string, context: ResolverContext): Promise<boolean>;
|
8
|
+
deleteFinancialInstitutions(ids: string[], context: ResolverContext): Promise<boolean>;
|
9
|
+
importFinancialInstitutions(financialInstitutions: FinancialInstitutionPatch[], context: ResolverContext): Promise<boolean>;
|
10
|
+
}
|
@@ -0,0 +1,169 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FinancialInstitutionMutation = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
6
|
+
const typeorm_1 = require("typeorm");
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
8
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
9
|
+
const financial_institution_1 = require("./financial-institution");
|
10
|
+
const financial_institution_type_1 = require("./financial-institution-type");
|
11
|
+
let FinancialInstitutionMutation = class FinancialInstitutionMutation {
|
12
|
+
async createFinancialInstitution(financialInstitution, context) {
|
13
|
+
const { domain, user, tx } = context.state;
|
14
|
+
const result = await (0, shell_1.getRepository)(financial_institution_1.FinancialInstitution, tx).save(Object.assign(Object.assign({}, financialInstitution), { domain, creator: user, updater: user }));
|
15
|
+
if (financialInstitution.thumbnail) {
|
16
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
17
|
+
attachment: {
|
18
|
+
file: financialInstitution.thumbnail,
|
19
|
+
refType: financial_institution_1.FinancialInstitution.name,
|
20
|
+
refBy: result.id
|
21
|
+
}
|
22
|
+
}, context);
|
23
|
+
}
|
24
|
+
return result;
|
25
|
+
}
|
26
|
+
async updateFinancialInstitution(id, patch, context) {
|
27
|
+
const { domain, user, tx } = context.state;
|
28
|
+
const repository = (0, shell_1.getRepository)(financial_institution_1.FinancialInstitution, tx);
|
29
|
+
const financialInstitution = await repository.findOne({
|
30
|
+
where: { domain: { id: domain.id }, id }
|
31
|
+
});
|
32
|
+
const result = await repository.save(Object.assign(Object.assign(Object.assign({}, financialInstitution), patch), { updater: user }));
|
33
|
+
if (patch.thumbnail) {
|
34
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [result.id] }, context);
|
35
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
36
|
+
attachment: {
|
37
|
+
file: patch.thumbnail,
|
38
|
+
refType: financial_institution_1.FinancialInstitution.name,
|
39
|
+
refBy: result.id
|
40
|
+
}
|
41
|
+
}, context);
|
42
|
+
}
|
43
|
+
return result;
|
44
|
+
}
|
45
|
+
async updateMultipleFinancialInstitution(patches, context) {
|
46
|
+
const { domain, user, tx } = context.state;
|
47
|
+
let results = [];
|
48
|
+
const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
|
49
|
+
const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
|
50
|
+
const financialInstitutionRepo = (0, shell_1.getRepository)(financial_institution_1.FinancialInstitution, tx);
|
51
|
+
if (_createRecords.length > 0) {
|
52
|
+
for (let i = 0; i < _createRecords.length; i++) {
|
53
|
+
const newRecord = _createRecords[i];
|
54
|
+
const result = await financialInstitutionRepo.save(Object.assign(Object.assign({}, newRecord), { domain, creator: user, updater: user }));
|
55
|
+
if (newRecord.thumbnail) {
|
56
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
57
|
+
attachment: {
|
58
|
+
file: newRecord.thumbnail,
|
59
|
+
refType: financial_institution_1.FinancialInstitution.name,
|
60
|
+
refBy: result.id
|
61
|
+
}
|
62
|
+
}, context);
|
63
|
+
}
|
64
|
+
results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
|
65
|
+
}
|
66
|
+
}
|
67
|
+
if (_updateRecords.length > 0) {
|
68
|
+
for (let i = 0; i < _updateRecords.length; i++) {
|
69
|
+
const updateRecord = _updateRecords[i];
|
70
|
+
const financialInstitution = await financialInstitutionRepo.findOneBy({ id: updateRecord.id });
|
71
|
+
const result = await financialInstitutionRepo.save(Object.assign(Object.assign(Object.assign({}, financialInstitution), updateRecord), { updater: user }));
|
72
|
+
if (updateRecord.thumbnail) {
|
73
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [result.id] }, context);
|
74
|
+
await (0, attachment_base_1.createAttachment)(null, {
|
75
|
+
attachment: {
|
76
|
+
file: updateRecord.thumbnail,
|
77
|
+
refType: financial_institution_1.FinancialInstitution.name,
|
78
|
+
refBy: result.id
|
79
|
+
}
|
80
|
+
}, context);
|
81
|
+
}
|
82
|
+
results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
|
83
|
+
}
|
84
|
+
}
|
85
|
+
return results;
|
86
|
+
}
|
87
|
+
async deleteFinancialInstitution(id, context) {
|
88
|
+
const { domain, tx } = context.state;
|
89
|
+
await (0, shell_1.getRepository)(financial_institution_1.FinancialInstitution, tx).delete({ domain: { id: domain.id }, id });
|
90
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [id] }, context);
|
91
|
+
return true;
|
92
|
+
}
|
93
|
+
async deleteFinancialInstitutions(ids, context) {
|
94
|
+
const { domain, tx } = context.state;
|
95
|
+
await (0, shell_1.getRepository)(financial_institution_1.FinancialInstitution, tx).delete({
|
96
|
+
domain: { id: domain.id },
|
97
|
+
id: (0, typeorm_1.In)(ids)
|
98
|
+
});
|
99
|
+
await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: ids }, context);
|
100
|
+
return true;
|
101
|
+
}
|
102
|
+
async importFinancialInstitutions(financialInstitutions, context) {
|
103
|
+
const { domain, tx } = context.state;
|
104
|
+
await Promise.all(financialInstitutions.map(async (financialInstitution) => {
|
105
|
+
const createdFinancialInstitution = await (0, shell_1.getRepository)(financial_institution_1.FinancialInstitution, tx).save(Object.assign({ domain }, financialInstitution));
|
106
|
+
}));
|
107
|
+
return true;
|
108
|
+
}
|
109
|
+
};
|
110
|
+
exports.FinancialInstitutionMutation = FinancialInstitutionMutation;
|
111
|
+
tslib_1.__decorate([
|
112
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
113
|
+
(0, type_graphql_1.Mutation)(returns => financial_institution_1.FinancialInstitution, { description: 'To create new FinancialInstitution' }),
|
114
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('financialInstitution')),
|
115
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
116
|
+
tslib_1.__metadata("design:type", Function),
|
117
|
+
tslib_1.__metadata("design:paramtypes", [financial_institution_type_1.NewFinancialInstitution, Object]),
|
118
|
+
tslib_1.__metadata("design:returntype", Promise)
|
119
|
+
], FinancialInstitutionMutation.prototype, "createFinancialInstitution", null);
|
120
|
+
tslib_1.__decorate([
|
121
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
122
|
+
(0, type_graphql_1.Mutation)(returns => financial_institution_1.FinancialInstitution, { description: 'To modify FinancialInstitution information' }),
|
123
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
124
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
|
125
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
126
|
+
tslib_1.__metadata("design:type", Function),
|
127
|
+
tslib_1.__metadata("design:paramtypes", [String, financial_institution_type_1.FinancialInstitutionPatch, Object]),
|
128
|
+
tslib_1.__metadata("design:returntype", Promise)
|
129
|
+
], FinancialInstitutionMutation.prototype, "updateFinancialInstitution", null);
|
130
|
+
tslib_1.__decorate([
|
131
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
132
|
+
(0, type_graphql_1.Mutation)(returns => [financial_institution_1.FinancialInstitution], { description: "To modify multiple FinancialInstitutions' information" }),
|
133
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [financial_institution_type_1.FinancialInstitutionPatch])),
|
134
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
135
|
+
tslib_1.__metadata("design:type", Function),
|
136
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
137
|
+
tslib_1.__metadata("design:returntype", Promise)
|
138
|
+
], FinancialInstitutionMutation.prototype, "updateMultipleFinancialInstitution", null);
|
139
|
+
tslib_1.__decorate([
|
140
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
141
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete FinancialInstitution' }),
|
142
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
143
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
144
|
+
tslib_1.__metadata("design:type", Function),
|
145
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
146
|
+
tslib_1.__metadata("design:returntype", Promise)
|
147
|
+
], FinancialInstitutionMutation.prototype, "deleteFinancialInstitution", null);
|
148
|
+
tslib_1.__decorate([
|
149
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
150
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple FinancialInstitutions' }),
|
151
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
152
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
153
|
+
tslib_1.__metadata("design:type", Function),
|
154
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
155
|
+
tslib_1.__metadata("design:returntype", Promise)
|
156
|
+
], FinancialInstitutionMutation.prototype, "deleteFinancialInstitutions", null);
|
157
|
+
tslib_1.__decorate([
|
158
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
159
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple FinancialInstitutions' }),
|
160
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('financialInstitutions', type => [financial_institution_type_1.FinancialInstitutionPatch])),
|
161
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
162
|
+
tslib_1.__metadata("design:type", Function),
|
163
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
164
|
+
tslib_1.__metadata("design:returntype", Promise)
|
165
|
+
], FinancialInstitutionMutation.prototype, "importFinancialInstitutions", null);
|
166
|
+
exports.FinancialInstitutionMutation = FinancialInstitutionMutation = tslib_1.__decorate([
|
167
|
+
(0, type_graphql_1.Resolver)(financial_institution_1.FinancialInstitution)
|
168
|
+
], FinancialInstitutionMutation);
|
169
|
+
//# sourceMappingURL=financial-institution-mutation.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"financial-institution-mutation.js","sourceRoot":"","sources":["../../../server/service/financial-institution/financial-institution-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAC5B,iDAAqD;AAErD,qEAA0F;AAC1F,mEAA8D;AAC9D,6EAAiG;AAG1F,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAGjC,AAAN,KAAK,CAAC,0BAA0B,CAA8B,oBAA6C,EAAS,OAAwB;QAC1I,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAa,EAAC,4CAAoB,EAAE,EAAE,CAAC,CAAC,IAAI,iCAC5D,oBAAoB,KACvB,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;QAEF,IAAI,oBAAoB,CAAC,SAAS,EAAE,CAAC;YACn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,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;+EAYP;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;IAEvF,mBAAA,IAAA,kBAAG,EAAC,uBAAuB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,sDAAyB,CAAC,CAAC,CAAA;IACjE,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;+EAWP;uCA3LU,4BAA4B;IADxC,IAAA,uBAAQ,EAAC,4CAAoB,CAAC;GAClB,4BAA4B,CA4LxC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { getRepository } from '@things-factory/shell'\n\nimport { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'\nimport { FinancialInstitution } from './financial-institution'\nimport { NewFinancialInstitution, FinancialInstitutionPatch } from './financial-institution-type'\n\n@Resolver(FinancialInstitution)\nexport class FinancialInstitutionMutation {\n @Directive('@transaction')\n @Mutation(returns => FinancialInstitution, { description: 'To create new FinancialInstitution' })\n async createFinancialInstitution(@Arg('financialInstitution') financialInstitution: NewFinancialInstitution, @Ctx() context: ResolverContext): Promise<FinancialInstitution> {\n const { domain, user, tx } = context.state\n\n const result = await getRepository(FinancialInstitution, tx).save({\n ...financialInstitution,\n domain,\n creator: user,\n updater: user\n })\n\n if (financialInstitution.thumbnail) {\n await createAttachment(\n null,\n {\n attachment: {\n file: financialInstitution.thumbnail,\n refType: FinancialInstitution.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => FinancialInstitution, { description: 'To modify FinancialInstitution information' })\n async updateFinancialInstitution(\n @Arg('id') id: string,\n @Arg('patch') patch: FinancialInstitutionPatch,\n @Ctx() context: ResolverContext\n ): Promise<FinancialInstitution> {\n const { domain, user, tx } = context.state\n\n const repository = getRepository(FinancialInstitution, tx)\n const financialInstitution = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...financialInstitution,\n ...patch,\n updater: user\n })\n\n if (patch.thumbnail) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: patch.thumbnail,\n refType: FinancialInstitution.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => [FinancialInstitution], { description: \"To modify multiple FinancialInstitutions' information\" })\n async updateMultipleFinancialInstitution(\n @Arg('patches', type => [FinancialInstitutionPatch]) patches: FinancialInstitutionPatch[],\n @Ctx() context: ResolverContext\n ): Promise<FinancialInstitution[]> {\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 financialInstitutionRepo = getRepository(FinancialInstitution, 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 financialInstitutionRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n if (newRecord.thumbnail) {\n await createAttachment(\n null,\n {\n attachment: {\n file: newRecord.thumbnail,\n refType: FinancialInstitution.name,\n refBy: result.id\n }\n },\n context\n )\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 financialInstitution = await financialInstitutionRepo.findOneBy({ id: updateRecord.id })\n\n const result = await financialInstitutionRepo.save({\n ...financialInstitution,\n ...updateRecord,\n updater: user\n })\n\n if (updateRecord.thumbnail) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: updateRecord.thumbnail,\n refType: FinancialInstitution.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete FinancialInstitution' })\n async deleteFinancialInstitution(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(FinancialInstitution, tx).delete({ domain: { id: domain.id }, id })\n await deleteAttachmentsByRef(null, { refBys: [id] }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple FinancialInstitutions' })\n async deleteFinancialInstitutions(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(FinancialInstitution, tx).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n await deleteAttachmentsByRef(null, { refBys: ids }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To import multiple FinancialInstitutions' })\n async importFinancialInstitutions(\n @Arg('financialInstitutions', type => [FinancialInstitutionPatch]) financialInstitutions: FinancialInstitutionPatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n financialInstitutions.map(async (financialInstitution: FinancialInstitutionPatch) => {\n const createdFinancialInstitution: FinancialInstitution = await getRepository(FinancialInstitution, tx).save({ domain, ...financialInstitution })\n })\n )\n\n return true\n }\n}\n"]}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { Domain, ListParam } from '@things-factory/shell';
|
2
|
+
import { User } from '@things-factory/auth-base';
|
3
|
+
import { FinancialInstitution } from './financial-institution';
|
4
|
+
import { FinancialInstitutionList } from './financial-institution-type';
|
5
|
+
export declare class FinancialInstitutionQuery {
|
6
|
+
financialInstitution(id: string, context: ResolverContext): Promise<FinancialInstitution>;
|
7
|
+
financialInstitutions(params: ListParam, context: ResolverContext): Promise<FinancialInstitutionList>;
|
8
|
+
thumbnail(financialInstitution: FinancialInstitution): Promise<string | undefined>;
|
9
|
+
domain(financialInstitution: FinancialInstitution): Promise<Domain>;
|
10
|
+
updater(financialInstitution: FinancialInstitution): Promise<User>;
|
11
|
+
creator(financialInstitution: FinancialInstitution): Promise<User>;
|
12
|
+
}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.FinancialInstitutionQuery = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
6
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
8
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
9
|
+
const financial_institution_1 = require("./financial-institution");
|
10
|
+
const financial_institution_type_1 = require("./financial-institution-type");
|
11
|
+
let FinancialInstitutionQuery = class FinancialInstitutionQuery {
|
12
|
+
async financialInstitution(id, context) {
|
13
|
+
const { domain } = context.state;
|
14
|
+
return await (0, shell_1.getRepository)(financial_institution_1.FinancialInstitution).findOne({
|
15
|
+
where: { domain: { id: domain.id }, id }
|
16
|
+
});
|
17
|
+
}
|
18
|
+
async financialInstitutions(params, context) {
|
19
|
+
const { domain } = context.state;
|
20
|
+
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
21
|
+
domain,
|
22
|
+
params,
|
23
|
+
repository: await (0, shell_1.getRepository)(financial_institution_1.FinancialInstitution),
|
24
|
+
searchables: ['name', 'description']
|
25
|
+
});
|
26
|
+
const [items, total] = await queryBuilder.getManyAndCount();
|
27
|
+
return { items, total };
|
28
|
+
}
|
29
|
+
async thumbnail(financialInstitution) {
|
30
|
+
const attachment = await (0, shell_1.getRepository)(attachment_base_1.Attachment).findOne({
|
31
|
+
where: {
|
32
|
+
domain: { id: financialInstitution.domainId },
|
33
|
+
refType: financial_institution_1.FinancialInstitution.name,
|
34
|
+
refBy: financialInstitution.id
|
35
|
+
}
|
36
|
+
});
|
37
|
+
return attachment === null || attachment === void 0 ? void 0 : attachment.fullpath;
|
38
|
+
}
|
39
|
+
async domain(financialInstitution) {
|
40
|
+
return financialInstitution.domainId && (await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: financialInstitution.domainId }));
|
41
|
+
}
|
42
|
+
async updater(financialInstitution) {
|
43
|
+
return financialInstitution.updaterId && (await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: financialInstitution.updaterId }));
|
44
|
+
}
|
45
|
+
async creator(financialInstitution) {
|
46
|
+
return financialInstitution.creatorId && (await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: financialInstitution.creatorId }));
|
47
|
+
}
|
48
|
+
};
|
49
|
+
exports.FinancialInstitutionQuery = FinancialInstitutionQuery;
|
50
|
+
tslib_1.__decorate([
|
51
|
+
(0, type_graphql_1.Query)(returns => financial_institution_1.FinancialInstitution, { nullable: true, description: 'To fetch a FinancialInstitution' }),
|
52
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
53
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
54
|
+
tslib_1.__metadata("design:type", Function),
|
55
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
56
|
+
tslib_1.__metadata("design:returntype", Promise)
|
57
|
+
], FinancialInstitutionQuery.prototype, "financialInstitution", null);
|
58
|
+
tslib_1.__decorate([
|
59
|
+
(0, type_graphql_1.Query)(returns => financial_institution_type_1.FinancialInstitutionList, { description: 'To fetch multiple FinancialInstitutions' }),
|
60
|
+
tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
|
61
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
62
|
+
tslib_1.__metadata("design:type", Function),
|
63
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
64
|
+
tslib_1.__metadata("design:returntype", Promise)
|
65
|
+
], FinancialInstitutionQuery.prototype, "financialInstitutions", null);
|
66
|
+
tslib_1.__decorate([
|
67
|
+
(0, type_graphql_1.FieldResolver)(type => String),
|
68
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
69
|
+
tslib_1.__metadata("design:type", Function),
|
70
|
+
tslib_1.__metadata("design:paramtypes", [financial_institution_1.FinancialInstitution]),
|
71
|
+
tslib_1.__metadata("design:returntype", Promise)
|
72
|
+
], FinancialInstitutionQuery.prototype, "thumbnail", null);
|
73
|
+
tslib_1.__decorate([
|
74
|
+
(0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
|
75
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
76
|
+
tslib_1.__metadata("design:type", Function),
|
77
|
+
tslib_1.__metadata("design:paramtypes", [financial_institution_1.FinancialInstitution]),
|
78
|
+
tslib_1.__metadata("design:returntype", Promise)
|
79
|
+
], FinancialInstitutionQuery.prototype, "domain", null);
|
80
|
+
tslib_1.__decorate([
|
81
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
82
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
83
|
+
tslib_1.__metadata("design:type", Function),
|
84
|
+
tslib_1.__metadata("design:paramtypes", [financial_institution_1.FinancialInstitution]),
|
85
|
+
tslib_1.__metadata("design:returntype", Promise)
|
86
|
+
], FinancialInstitutionQuery.prototype, "updater", null);
|
87
|
+
tslib_1.__decorate([
|
88
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
89
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
90
|
+
tslib_1.__metadata("design:type", Function),
|
91
|
+
tslib_1.__metadata("design:paramtypes", [financial_institution_1.FinancialInstitution]),
|
92
|
+
tslib_1.__metadata("design:returntype", Promise)
|
93
|
+
], FinancialInstitutionQuery.prototype, "creator", null);
|
94
|
+
exports.FinancialInstitutionQuery = FinancialInstitutionQuery = tslib_1.__decorate([
|
95
|
+
(0, type_graphql_1.Resolver)(financial_institution_1.FinancialInstitution)
|
96
|
+
], FinancialInstitutionQuery);
|
97
|
+
//# sourceMappingURL=financial-institution-query.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"financial-institution-query.js","sourceRoot":"","sources":["../../../server/service/financial-institution/financial-institution-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,qEAA4D;AAC5D,iDAAuG;AACvG,yDAAgD;AAChD,mEAA8D;AAC9D,6EAAuE;AAGhE,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAE9B,AAAN,KAAK,CAAC,oBAAoB,CAAY,EAAU,EAAS,OAAwB;QAC/E,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,qBAAa,EAAC,4CAAoB,CAAC,CAAC,OAAO,CAAC;YACvD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;SACzC,CAAC,CAAA;IACJ,CAAC;IAGK,AAAN,KAAK,CAAC,qBAAqB,CAA0B,MAAiB,EAAS,OAAwB;QACrG,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,4CAAoB,CAAC;YACrD,WAAW,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC;SACrC,CAAC,CAAA;QAEF,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,YAAY,CAAC,eAAe,EAAE,CAAA;QAE3D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;IAGK,AAAN,KAAK,CAAC,SAAS,CAAS,oBAA0C;QAChE,MAAM,UAAU,GAAe,MAAM,IAAA,qBAAa,EAAC,4BAAU,CAAC,CAAC,OAAO,CAAC;YACrE,KAAK,EA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wB,EAAE,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;IAC1E,mBAAA,IAAA,mBAAI,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAS,CAAC,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;sEAarE;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAuB,4CAAoB;;0DAUjE;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAuB,4CAAoB;;uDAE9D;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAuB,4CAAoB;;wDAE/D;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAuB,4CAAoB;;wDAE/D;oCApDU,yBAAyB;IADrC,IAAA,uBAAQ,EAAC,4CAAoB,CAAC;GAClB,yBAAyB,CAqDrC","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'\nimport { Attachment } from '@things-factory/attachment-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { FinancialInstitution } from './financial-institution'\nimport { FinancialInstitutionList } from './financial-institution-type'\n\n@Resolver(FinancialInstitution)\nexport class FinancialInstitutionQuery {\n @Query(returns => FinancialInstitution!, { nullable: true, description: 'To fetch a FinancialInstitution' })\n async financialInstitution(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<FinancialInstitution> {\n const { domain } = context.state\n\n return await getRepository(FinancialInstitution).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => FinancialInstitutionList, { description: 'To fetch multiple FinancialInstitutions' })\n async financialInstitutions(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<FinancialInstitutionList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(FinancialInstitution),\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => String)\n async thumbnail(@Root() financialInstitution: FinancialInstitution): Promise<string | undefined> {\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n domain: { id: financialInstitution.domainId },\n refType: FinancialInstitution.name,\n refBy: financialInstitution.id\n }\n })\n\n return attachment?.fullpath\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() financialInstitution: FinancialInstitution): Promise<Domain> {\n return financialInstitution.domainId && (await getRepository(Domain).findOneBy({ id: financialInstitution.domainId }))\n }\n\n @FieldResolver(type => User)\n async updater(@Root() financialInstitution: FinancialInstitution): Promise<User> {\n return financialInstitution.updaterId && (await getRepository(User).findOneBy({ id: financialInstitution.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() financialInstitution: FinancialInstitution): Promise<User> {\n return financialInstitution.creatorId && (await getRepository(User).findOneBy({ id: financialInstitution.creatorId }))\n }\n}\n"]}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import type { FileUpload } from 'graphql-upload/GraphQLUpload.js';
|
2
|
+
import { FinancialInstitution, FinancialInstitutionType } from './financial-institution';
|
3
|
+
export declare class NewFinancialInstitution {
|
4
|
+
name: string;
|
5
|
+
description?: string;
|
6
|
+
type: FinancialInstitutionType;
|
7
|
+
swiftCode?: string;
|
8
|
+
country?: string;
|
9
|
+
contactNumber?: string;
|
10
|
+
website?: string;
|
11
|
+
address?: string;
|
12
|
+
email?: string;
|
13
|
+
thumbnail?: FileUpload;
|
14
|
+
}
|
15
|
+
export declare class FinancialInstitutionPatch {
|
16
|
+
id?: string;
|
17
|
+
name?: string;
|
18
|
+
description?: string;
|
19
|
+
type: FinancialInstitutionType;
|
20
|
+
swiftCode?: string;
|
21
|
+
country?: string;
|
22
|
+
contactNumber?: string;
|
23
|
+
website?: string;
|
24
|
+
address?: string;
|
25
|
+
email?: string;
|
26
|
+
thumbnail?: FileUpload;
|
27
|
+
cuFlag?: string;
|
28
|
+
}
|
29
|
+
export declare class FinancialInstitutionList {
|
30
|
+
items: FinancialInstitution[];
|
31
|
+
total: number;
|
32
|
+
}
|