@tomei/finance 0.6.79 → 0.6.80

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.
Files changed (106) hide show
  1. package/.commitlintrc.json +22 -22
  2. package/.eslintrc.js +72 -72
  3. package/.gitlab-ci.yml +16 -16
  4. package/.husky/commit-msg +4 -4
  5. package/.husky/pre-commit +4 -4
  6. package/.prettierrc +4 -4
  7. package/CONTRIBUTING.md +30 -30
  8. package/LICENSE +21 -21
  9. package/README.md +13 -13
  10. package/configs/config.js +348 -348
  11. package/dist/document/document.d.ts +1 -1
  12. package/dist/document/document.js +6 -2
  13. package/dist/document/document.js.map +1 -1
  14. package/dist/payment-item/payment-item.js +4 -4
  15. package/dist/tsconfig.tsbuildinfo +1 -1
  16. package/invoice-template/assets/css/style.css.map +12 -12
  17. package/invoice-template/assets/css/style.min.css +1 -1
  18. package/invoice-template/assets/img/arrow_bg.svg +11 -11
  19. package/invoice-template/assets/img/coffy_shop_img.svg +18 -18
  20. package/invoice-template/assets/img/logo_accent.svg +3 -3
  21. package/invoice-template/assets/img/logo_white.svg +4 -4
  22. package/invoice-template/assets/img/sign.svg +12 -12
  23. package/invoice-template/assets/img/tomei-logo.svg +9 -9
  24. package/invoice-template/assets/js/html2canvas.min.js +10379 -10379
  25. package/invoice-template/assets/js/jquery.min.js +1 -1
  26. package/invoice-template/assets/sass/common/_color_variable.scss +12 -12
  27. package/invoice-template/assets/sass/common/_typography.scss +178 -178
  28. package/invoice-template/assets/sass/style.scss +12 -12
  29. package/migrations/finance-account-migration.js +97 -97
  30. package/migrations/finance-company-migration.js +29 -29
  31. package/migrations/finance-customer-migration.js +51 -51
  32. package/migrations/finance-document-item-migration.js +111 -111
  33. package/migrations/finance-document-migration.js +122 -122
  34. package/migrations/finance-journal-entry-migration.js +59 -59
  35. package/migrations/finance-ledger-transaction-migration.js +89 -89
  36. package/migrations/finance-payment-item-migration.js +52 -52
  37. package/migrations/finance-payment-method-migration.js +31 -31
  38. package/migrations/finance-payment-method-type-migration.js +55 -55
  39. package/migrations/finance-payment-migration.js +96 -96
  40. package/migrations/finance-post-history-migration.js +45 -45
  41. package/migrations/finance-tax-migration.js +52 -52
  42. package/migrations/refactor-finance-document-migration.js +71 -71
  43. package/nest-cli.json +19 -19
  44. package/package.json +82 -82
  45. package/sonar-project.properties +12 -12
  46. package/src/account/account.repository.ts +11 -11
  47. package/src/account/account.ts +276 -276
  48. package/src/account/interfaces/account-attr.interface.ts +31 -31
  49. package/src/account-system-entity/account-system-entity.ts +66 -66
  50. package/src/account-system-entity/post-history.repository.ts +11 -11
  51. package/src/config.ts +382 -382
  52. package/src/customer/customer.ts +299 -299
  53. package/src/customer/finance-customer.repository.ts +13 -13
  54. package/src/customer/interfaces/customer.repository.interface.ts +3 -3
  55. package/src/customer/interfaces/finance-customer-attr.interface.ts +10 -10
  56. package/src/customer/interfaces/finance-customer.repository.interface.ts +4 -4
  57. package/src/database.ts +48 -48
  58. package/src/document/document-item.repository.ts +11 -11
  59. package/src/document/document.repository.ts +11 -11
  60. package/src/document/document.ts +17 -13
  61. package/src/document/interfaces/document-attr.interface.ts +28 -28
  62. package/src/document/interfaces/document-item-attr.interface.ts +22 -22
  63. package/src/document/interfaces/document-item.repository.interface.ts +4 -4
  64. package/src/enum/collect-payment-type.ts +3 -3
  65. package/src/enum/doc-type.enum.ts +8 -8
  66. package/src/enum/index.ts +19 -19
  67. package/src/enum/payment-method.enum.ts +3 -3
  68. package/src/enum/payment-type.enum.ts +4 -4
  69. package/src/enum/quick-book-client-scopes.enum.ts +14 -14
  70. package/src/finance-company/finance-company.repository.ts +11 -11
  71. package/src/finance-company/finance-company.ts +2229 -2229
  72. package/src/helpers/login-user.ts +38 -38
  73. package/src/helpers/typeof.ts +35 -35
  74. package/src/index.ts +32 -32
  75. package/src/interfaces/account-system.interface.ts +20 -20
  76. package/src/interfaces/index.ts +3 -3
  77. package/src/models/account.entity.ts +206 -206
  78. package/src/models/customer.entity.ts +93 -93
  79. package/src/models/document-item.entity.ts +143 -143
  80. package/src/models/document.entity.ts +211 -211
  81. package/src/models/finance-company.entity.ts +29 -29
  82. package/src/models/journal-entry.entity.ts +110 -110
  83. package/src/models/ledger-transaction.entity.ts +148 -148
  84. package/src/models/payment-item.entity.ts +60 -60
  85. package/src/models/payment-method-type.entity.ts +70 -70
  86. package/src/models/payment-method.entity.ts +51 -51
  87. package/src/models/payment.entity.ts +165 -165
  88. package/src/models/post-history.entity.ts +41 -41
  89. package/src/models/tax.entity.ts +75 -75
  90. package/src/payment/interfaces/payment-attr.interface.ts +23 -23
  91. package/src/payment/interfaces/payment-params.interface.ts +8 -8
  92. package/src/payment/payment.repository.ts +11 -11
  93. package/src/payment/payment.ts +236 -236
  94. package/src/payment-item/interfaces/payment-item-attr.interface.ts +10 -10
  95. package/src/payment-item/payment-item.repository.ts +11 -11
  96. package/src/payment-item/payment-item.ts +134 -134
  97. package/src/payment-method/payment-method.repository.ts +11 -11
  98. package/src/payment-method-type/payment-method-type.repository.ts +11 -11
  99. package/src/tax/interfaces/tax-attr.interface.ts +10 -10
  100. package/src/tax/tax.repository.ts +11 -11
  101. package/src/tax/tax.ts +69 -69
  102. package/src/test-document.ts +25 -25
  103. package/src/test.ts +3 -3
  104. package/tsconfig.build.json +4 -4
  105. package/tsconfig.json +22 -22
  106. package/tslint.json +18 -18
@@ -1,276 +1,276 @@
1
- import { RecordNotFoundError } from '@tomei/general/dist/class/exceptions/record-not-found.error';
2
- import { AccountSystemEntity } from '../account-system-entity/account-system-entity';
3
- import AccountModel from '../models/account.entity';
4
- import { AccountRepository } from './account.repository';
5
-
6
- // eslint-disable-next-line @typescript-eslint/no-var-requires
7
- // const getConfig = require('../config');
8
-
9
- export default class Account extends AccountSystemEntity {
10
- AccountNo = 'New';
11
- ParentAccountNo? = '';
12
- Name = '';
13
- Description = '';
14
- AccountType = '';
15
- AccountSubtype = '';
16
- OwnerId = '';
17
- OwnerType = '';
18
- RelatedObjectId = '';
19
- RelatedObjectType = '';
20
- CreatedById = '';
21
- CreatedAt: Date;
22
- UpdatedById = '';
23
- UpdatedAt: Date;
24
- protected _ObjectType = 'Account';
25
-
26
- private static _RepositoryBase = new AccountRepository();
27
-
28
- private _DbTransaction: any;
29
- private _IsNewRecord = true;
30
-
31
- private get IsNewRecord() {
32
- return this._IsNewRecord;
33
- }
34
-
35
- private set IsNewRecord(record: boolean) {
36
- this._IsNewRecord = record;
37
- }
38
-
39
- get ObjectType() {
40
- return this._ObjectType;
41
- }
42
-
43
- /* AccountSystemEntity Implementation */
44
- get RepositoryBase() {
45
- return Account._RepositoryBase;
46
- }
47
-
48
- /* ObjectBase Implementation */
49
- get ObjectId() {
50
- return this.AccountNo;
51
- }
52
-
53
- get ObjectName() {
54
- return this.Name;
55
- }
56
-
57
- get TableName() {
58
- return 'finance_Account';
59
- }
60
-
61
- constructor(dbTransaction?: any, accountNo?: string) {
62
- super();
63
- if (dbTransaction) {
64
- this._DbTransaction = dbTransaction;
65
- }
66
- if (accountNo) {
67
- this.RepositoryBase.findOne({
68
- where: {
69
- AccountNo: accountNo,
70
- },
71
- transaction: dbTransaction,
72
- })
73
- .then((accountData) => {
74
- if (accountData) {
75
- this.IsNewRecord = false;
76
- this.CompanyId = accountData.CompanyId;
77
- this.ParentAccountNo = accountData.ParentAccountNo;
78
- this.Name = accountData.Name;
79
- this.Description = accountData.Description;
80
- this.AccountType = accountData.AccountType;
81
- this.AccountSubtype = accountData.AccountSubType;
82
- this.OwnerId = accountData.OwnerId;
83
- this.OwnerType = accountData.OwnerType;
84
- this.RelatedObjectId = accountData.RelatedObjectId;
85
- this.RelatedObjectType = accountData.RelatedObjectType;
86
- this.CreatedById = accountData.CreatedById;
87
- this.CreatedAt = accountData.CreatedAt;
88
- this.UpdatedById = accountData.UpdatedById;
89
- this.UpdatedAt = accountData.UpdatedAt;
90
- this.AccSystemRefId = accountData.AccSystemRefId;
91
- this.PostedToAccSystemYN = accountData.PostedToAccSystemYN;
92
- this.PostedById = accountData.PostedById;
93
- this.PostedDateTime = accountData.PostedDateTime;
94
- } else {
95
- const notFoundError = new RecordNotFoundError(
96
- 'AccountErrMsg',
97
- 'No Record Found.',
98
- );
99
- throw notFoundError;
100
- }
101
- })
102
- .catch((err) => {
103
- // tslint:disable-next-line:no-console
104
- console.log('Account Class constructor err: ', err);
105
- });
106
- }
107
- }
108
-
109
- private init(accountData: any) {
110
- this.IsNewRecord = false;
111
- this.CompanyId = accountData.CompanyId;
112
- this.ParentAccountNo = accountData.ParentAccountNo;
113
- this.Name = accountData.Name;
114
- this.Description = accountData.Description;
115
- this.AccountType = accountData.AccountType;
116
- this.AccountSubtype = accountData.AccountSubType;
117
- this.OwnerId = accountData.OwnerId;
118
- this.OwnerType = accountData.OwnerType;
119
- this.RelatedObjectId = accountData.RelatedObjectId;
120
- this.RelatedObjectType = accountData.RelatedObjectType;
121
- this.CreatedById = accountData.CreatedById;
122
- this.CreatedAt = accountData.CreatedAt;
123
- this.UpdatedById = accountData.UpdatedById;
124
- this.UpdatedAt = accountData.UpdatedAt;
125
- this.AccSystemRefId = accountData.AccSystemRefId;
126
- this.PostedToAccSystemYN = accountData.PostedToAccSystemYN;
127
- this.PostedById = accountData.PostedById;
128
- this.PostedDateTime = accountData.PostedDateTime;
129
- }
130
-
131
- static async initAccount(
132
- dbTransaction: any,
133
- accountNo: string,
134
- ): Promise<Account> {
135
- try {
136
- const accountData = await Account._RepositoryBase.findOne({
137
- where: {
138
- AccountNo: accountNo,
139
- },
140
- transaction: dbTransaction,
141
- });
142
- if (accountData) {
143
- const account = new Account(dbTransaction);
144
- account.init(accountData.get({ plain: true }));
145
- return account;
146
- } else {
147
- const notFoundError = new RecordNotFoundError(
148
- 'AccountErrMsg',
149
- 'No Record Found.',
150
- );
151
- throw notFoundError;
152
- }
153
- } catch (error) {
154
- console.log('Account Class constructor err: ', error);
155
- throw error;
156
- }
157
- }
158
-
159
- /**
160
- * Account static constructor
161
- *
162
- * Create the Customer Account Receivable (AR) and Customer Account Payable (AP) default accounts.
163
- * The static constructor is to run once each time the program loads and check if the default accounts have been created.
164
- * If it has not, it will create the accounts.
165
- */
166
- static initialize(): void {
167
- const dbTransaction = null;
168
- let defaultAccountReceivable: Account;
169
- let defaultAccountPayable: Account;
170
-
171
- // const config = getConfig();
172
- // config.systemConfig['EZC']
173
-
174
- try {
175
- defaultAccountReceivable = new Account(dbTransaction, 'EZC-AR');
176
- } catch (err) {
177
- defaultAccountReceivable = new Account(dbTransaction);
178
- defaultAccountReceivable.AccountNo = null;
179
- defaultAccountReceivable.AccountType = 'Account Receivable';
180
- defaultAccountReceivable.OwnerId = 'System';
181
- defaultAccountReceivable.OwnerType = '';
182
- }
183
-
184
- try {
185
- defaultAccountPayable = new Account(dbTransaction, 'EZC-AP');
186
- } catch (err) {
187
- defaultAccountPayable = new Account(dbTransaction);
188
- defaultAccountPayable.AccountNo = null;
189
- defaultAccountPayable.AccountType = 'Account Payable';
190
- defaultAccountPayable.OwnerId = 'System';
191
- }
192
- }
193
-
194
- validateAccountValue() {
195
- if (!this.AccSystemRefId) {
196
- throw new Error('AccSystemAccountId is required.');
197
- }
198
- if (!this.AccountType) {
199
- throw new Error('AccountType is required.');
200
- }
201
- }
202
-
203
- isParentAccountExists() {
204
- if (this.ParentAccountNo) return true;
205
- return false;
206
- }
207
-
208
- async save(
209
- CompanyId: string,
210
- AccSystemRefId: string,
211
- userId: string,
212
- dbTransaction?: any,
213
- ): Promise<AccountModel> {
214
- this.AccSystemRefId = AccSystemRefId;
215
- console.log('Account Save: Before AccountNo FindOne');
216
-
217
- let data = await this.RepositoryBase.findOne({
218
- where: {
219
- AccountNo: this.AccountNo,
220
- },
221
- transaction: dbTransaction,
222
- });
223
- console.log('Account Save: After AccountNo FindOne');
224
- console.log(data, '<><><><><> Account Data Result <><><><><><>');
225
-
226
- if (data) {
227
- console.log('Account Save: THERE IS DATA FOUND');
228
-
229
- this.AccountNo = data.AccountNo;
230
- this.AccSystemRefId = data.AccSystemRefId;
231
- this.Name = data.Name;
232
- this.Description = data.Description;
233
- this.AccountType = data.AccountType;
234
- this.AccountSubtype = data.AccountSubType;
235
- this.CompanyId = data.CompanyId;
236
- this.OwnerId = data.OwnerId;
237
- this.OwnerType = data.OwnerType;
238
- this.RelatedObjectId = data.RelatedObjectId;
239
- this.RelatedObjectType = data.RelatedObjectType;
240
- this.PostedToAccSystemYN = data.PostedToAccSystemYN;
241
- this.CreatedAt = data.CreatedAt;
242
- this.CreatedById = data.CreatedById;
243
- this.UpdatedAt = new Date();
244
- } else {
245
- console.log('Account Save: THERE IS NO DATA FOUND');
246
-
247
- data = await this.RepositoryBase.create(
248
- {
249
- AccountNo: this.AccountNo,
250
- AccSystemRefId: this.AccSystemRefId,
251
- Name: this.Name,
252
- Description: this.Description,
253
- AccountType: this.AccountType,
254
- AccountSubtype: this.AccountSubtype,
255
- CompanyId: CompanyId,
256
- OwnerId: this.OwnerId,
257
- OwnerType: this.OwnerType,
258
- RelatedObjectId: this.RelatedObjectId,
259
- RelatedObjectType: this.RelatedObjectType,
260
- PostedToAccSystemYN: this.PostedToAccSystemYN,
261
- CreatedAt: new Date(),
262
- UpdatedAt: new Date(),
263
- CreatedById: userId,
264
- },
265
- {
266
- transaction: dbTransaction,
267
- },
268
- );
269
- console.log(data, '<><><><><><><> DATA THAT GETS CREATED <><><><><><><>');
270
- }
271
-
272
- console.log(data, 'Account Save: Account details returned');
273
-
274
- return data;
275
- }
276
- }
1
+ import { RecordNotFoundError } from '@tomei/general/dist/class/exceptions/record-not-found.error';
2
+ import { AccountSystemEntity } from '../account-system-entity/account-system-entity';
3
+ import AccountModel from '../models/account.entity';
4
+ import { AccountRepository } from './account.repository';
5
+
6
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
7
+ // const getConfig = require('../config');
8
+
9
+ export default class Account extends AccountSystemEntity {
10
+ AccountNo = 'New';
11
+ ParentAccountNo? = '';
12
+ Name = '';
13
+ Description = '';
14
+ AccountType = '';
15
+ AccountSubtype = '';
16
+ OwnerId = '';
17
+ OwnerType = '';
18
+ RelatedObjectId = '';
19
+ RelatedObjectType = '';
20
+ CreatedById = '';
21
+ CreatedAt: Date;
22
+ UpdatedById = '';
23
+ UpdatedAt: Date;
24
+ protected _ObjectType = 'Account';
25
+
26
+ private static _RepositoryBase = new AccountRepository();
27
+
28
+ private _DbTransaction: any;
29
+ private _IsNewRecord = true;
30
+
31
+ private get IsNewRecord() {
32
+ return this._IsNewRecord;
33
+ }
34
+
35
+ private set IsNewRecord(record: boolean) {
36
+ this._IsNewRecord = record;
37
+ }
38
+
39
+ get ObjectType() {
40
+ return this._ObjectType;
41
+ }
42
+
43
+ /* AccountSystemEntity Implementation */
44
+ get RepositoryBase() {
45
+ return Account._RepositoryBase;
46
+ }
47
+
48
+ /* ObjectBase Implementation */
49
+ get ObjectId() {
50
+ return this.AccountNo;
51
+ }
52
+
53
+ get ObjectName() {
54
+ return this.Name;
55
+ }
56
+
57
+ get TableName() {
58
+ return 'finance_Account';
59
+ }
60
+
61
+ constructor(dbTransaction?: any, accountNo?: string) {
62
+ super();
63
+ if (dbTransaction) {
64
+ this._DbTransaction = dbTransaction;
65
+ }
66
+ if (accountNo) {
67
+ this.RepositoryBase.findOne({
68
+ where: {
69
+ AccountNo: accountNo,
70
+ },
71
+ transaction: dbTransaction,
72
+ })
73
+ .then((accountData) => {
74
+ if (accountData) {
75
+ this.IsNewRecord = false;
76
+ this.CompanyId = accountData.CompanyId;
77
+ this.ParentAccountNo = accountData.ParentAccountNo;
78
+ this.Name = accountData.Name;
79
+ this.Description = accountData.Description;
80
+ this.AccountType = accountData.AccountType;
81
+ this.AccountSubtype = accountData.AccountSubType;
82
+ this.OwnerId = accountData.OwnerId;
83
+ this.OwnerType = accountData.OwnerType;
84
+ this.RelatedObjectId = accountData.RelatedObjectId;
85
+ this.RelatedObjectType = accountData.RelatedObjectType;
86
+ this.CreatedById = accountData.CreatedById;
87
+ this.CreatedAt = accountData.CreatedAt;
88
+ this.UpdatedById = accountData.UpdatedById;
89
+ this.UpdatedAt = accountData.UpdatedAt;
90
+ this.AccSystemRefId = accountData.AccSystemRefId;
91
+ this.PostedToAccSystemYN = accountData.PostedToAccSystemYN;
92
+ this.PostedById = accountData.PostedById;
93
+ this.PostedDateTime = accountData.PostedDateTime;
94
+ } else {
95
+ const notFoundError = new RecordNotFoundError(
96
+ 'AccountErrMsg',
97
+ 'No Record Found.',
98
+ );
99
+ throw notFoundError;
100
+ }
101
+ })
102
+ .catch((err) => {
103
+ // tslint:disable-next-line:no-console
104
+ console.log('Account Class constructor err: ', err);
105
+ });
106
+ }
107
+ }
108
+
109
+ private init(accountData: any) {
110
+ this.IsNewRecord = false;
111
+ this.CompanyId = accountData.CompanyId;
112
+ this.ParentAccountNo = accountData.ParentAccountNo;
113
+ this.Name = accountData.Name;
114
+ this.Description = accountData.Description;
115
+ this.AccountType = accountData.AccountType;
116
+ this.AccountSubtype = accountData.AccountSubType;
117
+ this.OwnerId = accountData.OwnerId;
118
+ this.OwnerType = accountData.OwnerType;
119
+ this.RelatedObjectId = accountData.RelatedObjectId;
120
+ this.RelatedObjectType = accountData.RelatedObjectType;
121
+ this.CreatedById = accountData.CreatedById;
122
+ this.CreatedAt = accountData.CreatedAt;
123
+ this.UpdatedById = accountData.UpdatedById;
124
+ this.UpdatedAt = accountData.UpdatedAt;
125
+ this.AccSystemRefId = accountData.AccSystemRefId;
126
+ this.PostedToAccSystemYN = accountData.PostedToAccSystemYN;
127
+ this.PostedById = accountData.PostedById;
128
+ this.PostedDateTime = accountData.PostedDateTime;
129
+ }
130
+
131
+ static async initAccount(
132
+ dbTransaction: any,
133
+ accountNo: string,
134
+ ): Promise<Account> {
135
+ try {
136
+ const accountData = await Account._RepositoryBase.findOne({
137
+ where: {
138
+ AccountNo: accountNo,
139
+ },
140
+ transaction: dbTransaction,
141
+ });
142
+ if (accountData) {
143
+ const account = new Account(dbTransaction);
144
+ account.init(accountData.get({ plain: true }));
145
+ return account;
146
+ } else {
147
+ const notFoundError = new RecordNotFoundError(
148
+ 'AccountErrMsg',
149
+ 'No Record Found.',
150
+ );
151
+ throw notFoundError;
152
+ }
153
+ } catch (error) {
154
+ console.log('Account Class constructor err: ', error);
155
+ throw error;
156
+ }
157
+ }
158
+
159
+ /**
160
+ * Account static constructor
161
+ *
162
+ * Create the Customer Account Receivable (AR) and Customer Account Payable (AP) default accounts.
163
+ * The static constructor is to run once each time the program loads and check if the default accounts have been created.
164
+ * If it has not, it will create the accounts.
165
+ */
166
+ static initialize(): void {
167
+ const dbTransaction = null;
168
+ let defaultAccountReceivable: Account;
169
+ let defaultAccountPayable: Account;
170
+
171
+ // const config = getConfig();
172
+ // config.systemConfig['EZC']
173
+
174
+ try {
175
+ defaultAccountReceivable = new Account(dbTransaction, 'EZC-AR');
176
+ } catch (err) {
177
+ defaultAccountReceivable = new Account(dbTransaction);
178
+ defaultAccountReceivable.AccountNo = null;
179
+ defaultAccountReceivable.AccountType = 'Account Receivable';
180
+ defaultAccountReceivable.OwnerId = 'System';
181
+ defaultAccountReceivable.OwnerType = '';
182
+ }
183
+
184
+ try {
185
+ defaultAccountPayable = new Account(dbTransaction, 'EZC-AP');
186
+ } catch (err) {
187
+ defaultAccountPayable = new Account(dbTransaction);
188
+ defaultAccountPayable.AccountNo = null;
189
+ defaultAccountPayable.AccountType = 'Account Payable';
190
+ defaultAccountPayable.OwnerId = 'System';
191
+ }
192
+ }
193
+
194
+ validateAccountValue() {
195
+ if (!this.AccSystemRefId) {
196
+ throw new Error('AccSystemAccountId is required.');
197
+ }
198
+ if (!this.AccountType) {
199
+ throw new Error('AccountType is required.');
200
+ }
201
+ }
202
+
203
+ isParentAccountExists() {
204
+ if (this.ParentAccountNo) return true;
205
+ return false;
206
+ }
207
+
208
+ async save(
209
+ CompanyId: string,
210
+ AccSystemRefId: string,
211
+ userId: string,
212
+ dbTransaction?: any,
213
+ ): Promise<AccountModel> {
214
+ this.AccSystemRefId = AccSystemRefId;
215
+ console.log('Account Save: Before AccountNo FindOne');
216
+
217
+ let data = await this.RepositoryBase.findOne({
218
+ where: {
219
+ AccountNo: this.AccountNo,
220
+ },
221
+ transaction: dbTransaction,
222
+ });
223
+ console.log('Account Save: After AccountNo FindOne');
224
+ console.log(data, '<><><><><> Account Data Result <><><><><><>');
225
+
226
+ if (data) {
227
+ console.log('Account Save: THERE IS DATA FOUND');
228
+
229
+ this.AccountNo = data.AccountNo;
230
+ this.AccSystemRefId = data.AccSystemRefId;
231
+ this.Name = data.Name;
232
+ this.Description = data.Description;
233
+ this.AccountType = data.AccountType;
234
+ this.AccountSubtype = data.AccountSubType;
235
+ this.CompanyId = data.CompanyId;
236
+ this.OwnerId = data.OwnerId;
237
+ this.OwnerType = data.OwnerType;
238
+ this.RelatedObjectId = data.RelatedObjectId;
239
+ this.RelatedObjectType = data.RelatedObjectType;
240
+ this.PostedToAccSystemYN = data.PostedToAccSystemYN;
241
+ this.CreatedAt = data.CreatedAt;
242
+ this.CreatedById = data.CreatedById;
243
+ this.UpdatedAt = new Date();
244
+ } else {
245
+ console.log('Account Save: THERE IS NO DATA FOUND');
246
+
247
+ data = await this.RepositoryBase.create(
248
+ {
249
+ AccountNo: this.AccountNo,
250
+ AccSystemRefId: this.AccSystemRefId,
251
+ Name: this.Name,
252
+ Description: this.Description,
253
+ AccountType: this.AccountType,
254
+ AccountSubtype: this.AccountSubtype,
255
+ CompanyId: CompanyId,
256
+ OwnerId: this.OwnerId,
257
+ OwnerType: this.OwnerType,
258
+ RelatedObjectId: this.RelatedObjectId,
259
+ RelatedObjectType: this.RelatedObjectType,
260
+ PostedToAccSystemYN: this.PostedToAccSystemYN,
261
+ CreatedAt: new Date(),
262
+ UpdatedAt: new Date(),
263
+ CreatedById: userId,
264
+ },
265
+ {
266
+ transaction: dbTransaction,
267
+ },
268
+ );
269
+ console.log(data, '<><><><><><><> DATA THAT GETS CREATED <><><><><><><>');
270
+ }
271
+
272
+ console.log(data, 'Account Save: Account details returned');
273
+
274
+ return data;
275
+ }
276
+ }
@@ -1,31 +1,31 @@
1
- import { ObjectBase, LoginUserBase } from '@tomei/general';
2
-
3
- export interface IAccountAttr {
4
- AccountNo: string;
5
- CompanyId: string;
6
- ParentAccountNo?: string;
7
- Name: string;
8
- Description?: string;
9
- AccountType: string;
10
- AccountSubType?: string;
11
- OwnerId?: string;
12
- OwnerType?: string;
13
- RelatedObjectId?: string;
14
- RelatedObjectType?: string;
15
- CreatedAt: Date;
16
- CreatedById: string;
17
- UpdatedAt?: Date;
18
- UpdatedById?: string;
19
- AccSystemRefId: string;
20
- PostedToAccSystemYN: string;
21
- PostedById?: string;
22
- PostedDateTime?: Date;
23
- }
24
-
25
- export interface ICreateAccountAttr {
26
- Owner: LoginUserBase;
27
- RelatedObject?: ObjectBase;
28
- AccountType?: string;
29
- AccountSubType?: string;
30
- ParentAccountNo?: string;
31
- }
1
+ import { ObjectBase, LoginUserBase } from '@tomei/general';
2
+
3
+ export interface IAccountAttr {
4
+ AccountNo: string;
5
+ CompanyId: string;
6
+ ParentAccountNo?: string;
7
+ Name: string;
8
+ Description?: string;
9
+ AccountType: string;
10
+ AccountSubType?: string;
11
+ OwnerId?: string;
12
+ OwnerType?: string;
13
+ RelatedObjectId?: string;
14
+ RelatedObjectType?: string;
15
+ CreatedAt: Date;
16
+ CreatedById: string;
17
+ UpdatedAt?: Date;
18
+ UpdatedById?: string;
19
+ AccSystemRefId: string;
20
+ PostedToAccSystemYN: string;
21
+ PostedById?: string;
22
+ PostedDateTime?: Date;
23
+ }
24
+
25
+ export interface ICreateAccountAttr {
26
+ Owner: LoginUserBase;
27
+ RelatedObject?: ObjectBase;
28
+ AccountType?: string;
29
+ AccountSubType?: string;
30
+ ParentAccountNo?: string;
31
+ }