@tomei/finance 0.6.99 → 0.6.102

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 (223) hide show
  1. package/.husky/commit-msg +12 -3
  2. package/.husky/pre-commit +4 -4
  3. package/configs/config.js +1 -1
  4. package/dist/account/account.d.ts +37 -37
  5. package/dist/account/account.js +251 -263
  6. package/dist/account/account.js.map +1 -1
  7. package/dist/account/account.repository.d.ts +5 -5
  8. package/dist/account/account.repository.js +11 -11
  9. package/dist/account/interfaces/account-attr.interface.d.ts +29 -29
  10. package/dist/account/interfaces/account-attr.interface.js +2 -2
  11. package/dist/account-system-entity/account-system-entity.d.ts +12 -12
  12. package/dist/account-system-entity/account-system-entity.js +55 -66
  13. package/dist/account-system-entity/account-system-entity.js.map +1 -1
  14. package/dist/account-system-entity/post-history.repository.d.ts +5 -5
  15. package/dist/account-system-entity/post-history.repository.js +11 -11
  16. package/dist/config.d.ts +1888 -1888
  17. package/dist/config.js +331 -331
  18. package/dist/config.js.map +1 -1
  19. package/dist/customer/customer.d.ts +44 -44
  20. package/dist/customer/customer.js +212 -234
  21. package/dist/customer/customer.js.map +1 -1
  22. package/dist/customer/finance-customer.repository.d.ts +5 -5
  23. package/dist/customer/finance-customer.repository.js +25 -25
  24. package/dist/customer/finance-customer.repository.js.map +1 -1
  25. package/dist/customer/interfaces/customer.repository.interface.d.ts +3 -3
  26. package/dist/customer/interfaces/customer.repository.interface.js +2 -2
  27. package/dist/customer/interfaces/finance-customer-attr.interface.d.ts +10 -10
  28. package/dist/customer/interfaces/finance-customer-attr.interface.js +2 -2
  29. package/dist/customer/interfaces/finance-customer.repository.interface.d.ts +3 -3
  30. package/dist/customer/interfaces/finance-customer.repository.interface.js +2 -2
  31. package/dist/database.d.ts +4 -4
  32. package/dist/database.js +46 -47
  33. package/dist/database.js.map +1 -1
  34. package/dist/document/document-item.d.ts +46 -46
  35. package/dist/document/document-item.js +122 -132
  36. package/dist/document/document-item.js.map +1 -1
  37. package/dist/document/document-item.repository.d.ts +5 -5
  38. package/dist/document/document-item.repository.js +11 -11
  39. package/dist/document/document.d.ts +87 -88
  40. package/dist/document/document.js +735 -766
  41. package/dist/document/document.js.map +1 -1
  42. package/dist/document/document.repository.d.ts +5 -5
  43. package/dist/document/document.repository.js +11 -11
  44. package/dist/document/interfaces/document-attr.interface.d.ts +27 -27
  45. package/dist/document/interfaces/document-attr.interface.js +6 -6
  46. package/dist/document/interfaces/document-find-all.interface.d.ts +13 -13
  47. package/dist/document/interfaces/document-find-all.interface.js +2 -2
  48. package/dist/document/interfaces/document-item-attr.interface.d.ts +26 -26
  49. package/dist/document/interfaces/document-item-attr.interface.js +6 -6
  50. package/dist/document/interfaces/document-item.repository.interface.d.ts +3 -3
  51. package/dist/document/interfaces/document-item.repository.interface.js +2 -2
  52. package/dist/enum/collect-payment-type.d.ts +4 -4
  53. package/dist/enum/collect-payment-type.js +8 -8
  54. package/dist/enum/collect-payment-type.js.map +1 -1
  55. package/dist/enum/doc-type.enum.d.ts +8 -8
  56. package/dist/enum/doc-type.enum.js +12 -12
  57. package/dist/enum/doc-type.enum.js.map +1 -1
  58. package/dist/enum/document-status.enum.d.ts +6 -6
  59. package/dist/enum/document-status.enum.js +10 -10
  60. package/dist/enum/document-status.enum.js.map +1 -1
  61. package/dist/enum/index.d.ts +9 -9
  62. package/dist/enum/index.js +19 -19
  63. package/dist/enum/payment-method.enum.d.ts +3 -3
  64. package/dist/enum/payment-method.enum.js +7 -7
  65. package/dist/enum/payment-method.enum.js.map +1 -1
  66. package/dist/enum/payment-status.enum.d.ts +10 -10
  67. package/dist/enum/payment-status.enum.js +15 -16
  68. package/dist/enum/payment-status.enum.js.map +1 -1
  69. package/dist/enum/payment-type.enum.d.ts +4 -4
  70. package/dist/enum/payment-type.enum.js +8 -8
  71. package/dist/enum/payment-type.enum.js.map +1 -1
  72. package/dist/enum/quick-book-client-scopes.enum.d.ts +13 -13
  73. package/dist/enum/quick-book-client-scopes.enum.js +18 -18
  74. package/dist/enum/quick-book-client-scopes.enum.js.map +1 -1
  75. package/dist/enum/transaction-type.enum.d.ts +4 -4
  76. package/dist/enum/transaction-type.enum.js +8 -8
  77. package/dist/enum/transaction-type.enum.js.map +1 -1
  78. package/dist/finance-company/finance-company.d.ts +88 -88
  79. package/dist/finance-company/finance-company.js +1533 -1576
  80. package/dist/finance-company/finance-company.js.map +1 -1
  81. package/dist/finance-company/finance-company.repository.d.ts +5 -5
  82. package/dist/finance-company/finance-company.repository.js +11 -11
  83. package/dist/helpers/login-user.d.ts +13 -13
  84. package/dist/helpers/login-user.js +28 -28
  85. package/dist/helpers/login-user.js.map +1 -1
  86. package/dist/helpers/typeof.d.ts +1 -1
  87. package/dist/helpers/typeof.js +28 -29
  88. package/dist/helpers/typeof.js.map +1 -1
  89. package/dist/index.d.ts +17 -17
  90. package/dist/index.js +32 -32
  91. package/dist/interfaces/account-system.interface.d.ts +30 -30
  92. package/dist/interfaces/account-system.interface.js +2 -2
  93. package/dist/interfaces/index.d.ts +2 -2
  94. package/dist/interfaces/index.js +2 -2
  95. package/dist/journal-entry/interfaces/journal-entry-attr.interface.d.ts +12 -12
  96. package/dist/journal-entry/interfaces/journal-entry-attr.interface.js +2 -2
  97. package/dist/journal-entry/journal-entry.d.ts +42 -42
  98. package/dist/journal-entry/journal-entry.js +216 -233
  99. package/dist/journal-entry/journal-entry.js.map +1 -1
  100. package/dist/journal-entry/journal-entry.repository.d.ts +6 -6
  101. package/dist/journal-entry/journal-entry.repository.js +16 -27
  102. package/dist/journal-entry/journal-entry.repository.js.map +1 -1
  103. package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.d.ts +17 -17
  104. package/dist/ledger-transaction/interfaces/ledger-transaction-attr.interface.js +2 -2
  105. package/dist/ledger-transaction/interfaces/ledger-transaction.repository.interface.d.ts +5 -5
  106. package/dist/ledger-transaction/interfaces/ledger-transaction.repository.interface.js +2 -2
  107. package/dist/ledger-transaction/ledger-transaction.d.ts +54 -54
  108. package/dist/ledger-transaction/ledger-transaction.js +143 -164
  109. package/dist/ledger-transaction/ledger-transaction.js.map +1 -1
  110. package/dist/ledger-transaction/ledger-transaction.repository.d.ts +6 -6
  111. package/dist/ledger-transaction/ledger-transaction.repository.js +16 -27
  112. package/dist/ledger-transaction/ledger-transaction.repository.js.map +1 -1
  113. package/dist/models/account.entity.d.ts +30 -30
  114. package/dist/models/account.entity.js +232 -232
  115. package/dist/models/account.entity.js.map +1 -1
  116. package/dist/models/customer.entity.d.ts +13 -13
  117. package/dist/models/customer.entity.js +109 -109
  118. package/dist/models/customer.entity.js.map +1 -1
  119. package/dist/models/document-item.entity.d.ts +31 -31
  120. package/dist/models/document-item.entity.js +200 -200
  121. package/dist/models/document-item.entity.js.map +1 -1
  122. package/dist/models/document.entity.d.ts +36 -36
  123. package/dist/models/document.entity.js +242 -242
  124. package/dist/models/document.entity.js.map +1 -1
  125. package/dist/models/finance-company.entity.d.ts +15 -15
  126. package/dist/models/finance-company.entity.js +93 -93
  127. package/dist/models/finance-company.entity.js.map +1 -1
  128. package/dist/models/journal-entry.entity.d.ts +16 -16
  129. package/dist/models/journal-entry.entity.js +127 -127
  130. package/dist/models/journal-entry.entity.js.map +1 -1
  131. package/dist/models/ledger-transaction.entity.d.ts +24 -24
  132. package/dist/models/ledger-transaction.entity.js +172 -172
  133. package/dist/models/ledger-transaction.entity.js.map +1 -1
  134. package/dist/models/payment-item.entity.d.ts +12 -12
  135. package/dist/models/payment-item.entity.js +75 -75
  136. package/dist/models/payment-item.entity.js.map +1 -1
  137. package/dist/models/payment-method-type.entity.d.ts +13 -13
  138. package/dist/models/payment-method-type.entity.js +85 -85
  139. package/dist/models/payment-method-type.entity.js.map +1 -1
  140. package/dist/models/payment-method.entity.d.ts +10 -10
  141. package/dist/models/payment-method.entity.js +62 -62
  142. package/dist/models/payment-method.entity.js.map +1 -1
  143. package/dist/models/payment-paid-with.entity.d.ts +24 -24
  144. package/dist/models/payment-paid-with.entity.js +158 -158
  145. package/dist/models/payment-paid-with.entity.js.map +1 -1
  146. package/dist/models/payment.entity.d.ts +29 -29
  147. package/dist/models/payment.entity.js +193 -193
  148. package/dist/models/payment.entity.js.map +1 -1
  149. package/dist/models/post-history.entity.d.ts +11 -11
  150. package/dist/models/post-history.entity.js +63 -63
  151. package/dist/models/post-history.entity.js.map +1 -1
  152. package/dist/models/tax.entity.d.ts +13 -13
  153. package/dist/models/tax.entity.js +89 -89
  154. package/dist/models/tax.entity.js.map +1 -1
  155. package/dist/payment/interfaces/payment-attr.interface.d.ts +22 -22
  156. package/dist/payment/interfaces/payment-attr.interface.js +6 -6
  157. package/dist/payment/interfaces/payment-params.interface.d.ts +7 -7
  158. package/dist/payment/interfaces/payment-params.interface.js +2 -2
  159. package/dist/payment/payment.d.ts +53 -53
  160. package/dist/payment/payment.js +186 -201
  161. package/dist/payment/payment.js.map +1 -1
  162. package/dist/payment/payment.repository.d.ts +5 -5
  163. package/dist/payment/payment.repository.js +11 -11
  164. package/dist/payment-item/interfaces/payment-item-attr.interface.d.ts +10 -10
  165. package/dist/payment-item/interfaces/payment-item-attr.interface.js +6 -6
  166. package/dist/payment-item/payment-item.d.ts +25 -25
  167. package/dist/payment-item/payment-item.js +111 -122
  168. package/dist/payment-item/payment-item.js.map +1 -1
  169. package/dist/payment-item/payment-item.repository.d.ts +5 -5
  170. package/dist/payment-item/payment-item.repository.js +11 -11
  171. package/dist/payment-method/interfaces/payment-method-attr.interface.d.ts +5 -5
  172. package/dist/payment-method/interfaces/payment-method-attr.interface.js +2 -2
  173. package/dist/payment-method/payment-method.d.ts +21 -21
  174. package/dist/payment-method/payment-method.js +104 -117
  175. package/dist/payment-method/payment-method.js.map +1 -1
  176. package/dist/payment-method/payment-method.repository.d.ts +5 -5
  177. package/dist/payment-method/payment-method.repository.js +11 -11
  178. package/dist/payment-method-type/interfaces/payment-method-type-attr.interface.d.ts +8 -8
  179. package/dist/payment-method-type/interfaces/payment-method-type-attr.interface.js +2 -2
  180. package/dist/payment-method-type/payment-method-type.d.ts +18 -18
  181. package/dist/payment-method-type/payment-method-type.js +65 -76
  182. package/dist/payment-method-type/payment-method-type.js.map +1 -1
  183. package/dist/payment-method-type/payment-method-type.repository.d.ts +5 -5
  184. package/dist/payment-method-type/payment-method-type.repository.js +11 -11
  185. package/dist/payment-paid-with/interfaces/payment-paid-with.interface.d.ts +19 -19
  186. package/dist/payment-paid-with/interfaces/payment-paid-with.interface.js +6 -6
  187. package/dist/payment-paid-with/payment-paid-with.d.ts +33 -33
  188. package/dist/payment-paid-with/payment-paid-with.js +56 -56
  189. package/dist/payment-paid-with/payment-paid-with.js.map +1 -1
  190. package/dist/payment-paid-with/payment-paid-with.repository.d.ts +5 -5
  191. package/dist/payment-paid-with/payment-paid-with.repository.js +11 -11
  192. package/dist/tax/interfaces/tax-attr.interface.d.ts +10 -10
  193. package/dist/tax/interfaces/tax-attr.interface.js +2 -2
  194. package/dist/tax/tax.d.ts +26 -26
  195. package/dist/tax/tax.js +51 -51
  196. package/dist/tax/tax.js.map +1 -1
  197. package/dist/tax/tax.repository.d.ts +5 -5
  198. package/dist/tax/tax.repository.js +11 -11
  199. package/dist/test-document.d.ts +3 -3
  200. package/dist/test-document.js +18 -18
  201. package/dist/test.d.ts +1 -1
  202. package/dist/test.js +6 -7
  203. package/dist/test.js.map +1 -1
  204. package/dist/tsconfig.tsbuildinfo +1 -1
  205. package/eslint.config.mjs +58 -0
  206. package/invoice-template/assets/js/html2canvas.min.js +16 -16
  207. package/package.json +35 -41
  208. package/src/account/account.ts +2 -1
  209. package/src/customer/customer.ts +8 -7
  210. package/src/document/document-item.ts +3 -2
  211. package/src/document/document.ts +20 -13
  212. package/src/enum/collect-payment-type.ts +3 -3
  213. package/src/enum/payment-status.enum.ts +1 -1
  214. package/src/finance-company/finance-company.ts +5 -7
  215. package/src/journal-entry/journal-entry.ts +0 -1
  216. package/src/ledger-transaction/ledger-transaction.ts +4 -4
  217. package/src/payment-method-type/payment-method-type.ts +1 -1
  218. package/src/tax/tax.ts +0 -1
  219. package/tsconfig.json +4 -3
  220. package/.eslintrc.js +0 -72
  221. package/img.png +0 -0
  222. package/img_1.png +0 -0
  223. package/tslint.json +0 -18
package/.husky/commit-msg CHANGED
@@ -1,4 +1,13 @@
1
- #!/bin/sh
2
- . "$(dirname "$0")/_/husky.sh"
3
-
4
1
  npx commitlint --edit $1
2
+ message="$(cat $1)"
3
+ echo "$message"
4
+ a=($(echo "$message" | tr ':' '\n'))
5
+ echo "${a[0]}"
6
+ if [ "${a[0]}" = "feat" ];
7
+ then
8
+ npm version --commit-hooks false --no-git-tag-version minor
9
+ else
10
+ npm version --commit-hooks false --no-git-tag-version patch
11
+ fi
12
+ git add .
13
+ git commit -m "$message" --no-verify
package/.husky/pre-commit CHANGED
@@ -1,4 +1,4 @@
1
- #!/bin/sh
2
- . "$(dirname "$0")/_/husky.sh"
3
-
4
- npx lint-staged
1
+ npm run lint
2
+ npm run format
3
+ npm run build
4
+ git add .
package/configs/config.js CHANGED
@@ -1,4 +1,4 @@
1
- // eslint-disable-next-line @typescript-eslint/no-var-requires
1
+
2
2
  const dotenv = require('dotenv');
3
3
 
4
4
  dotenv.config();
@@ -1,37 +1,37 @@
1
- import { AccountSystemEntity } from '../account-system-entity/account-system-entity';
2
- import AccountModel from '../models/account.entity';
3
- import { AccountRepository } from './account.repository';
4
- export default class Account extends AccountSystemEntity {
5
- AccountNo: 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
- CreatedById: string;
16
- CreatedAt: Date;
17
- UpdatedById: string;
18
- UpdatedAt: Date;
19
- protected _ObjectType: string;
20
- private static _RepositoryBase;
21
- private _DbTransaction;
22
- private _IsNewRecord;
23
- private get IsNewRecord();
24
- private set IsNewRecord(value);
25
- get ObjectType(): string;
26
- get RepositoryBase(): AccountRepository;
27
- get ObjectId(): string;
28
- get ObjectName(): string;
29
- get TableName(): string;
30
- constructor(dbTransaction?: any, accountNo?: string);
31
- init(accountData: any): void;
32
- static initAccount(dbTransaction: any, accountNo: string): Promise<Account>;
33
- static initialize(): void;
34
- validateAccountValue(): void;
35
- isParentAccountExists(): boolean;
36
- save(CompanyId: string, AccSystemRefId: string, userId: string, dbTransaction?: any): Promise<AccountModel>;
37
- }
1
+ import { AccountSystemEntity } from '../account-system-entity/account-system-entity';
2
+ import AccountModel from '../models/account.entity';
3
+ import { AccountRepository } from './account.repository';
4
+ export default class Account extends AccountSystemEntity {
5
+ AccountNo: 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
+ CreatedById: string;
16
+ CreatedAt: Date;
17
+ UpdatedById: string;
18
+ UpdatedAt: Date;
19
+ protected _ObjectType: string;
20
+ private static _RepositoryBase;
21
+ private _DbTransaction;
22
+ private _IsNewRecord;
23
+ private get IsNewRecord();
24
+ private set IsNewRecord(value);
25
+ get ObjectType(): string;
26
+ get RepositoryBase(): AccountRepository;
27
+ get ObjectId(): string;
28
+ get ObjectName(): string;
29
+ get TableName(): string;
30
+ constructor(dbTransaction?: any, accountNo?: string);
31
+ init(accountData: any): void;
32
+ static initAccount(dbTransaction: any, accountNo: string): Promise<Account>;
33
+ static initialize(): void;
34
+ validateAccountValue(): void;
35
+ isParentAccountExists(): boolean;
36
+ save(CompanyId: string, AccSystemRefId: string, userId: string, dbTransaction?: any): Promise<AccountModel>;
37
+ }
@@ -1,264 +1,252 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const record_not_found_error_1 = require("@tomei/general/dist/class/exceptions/record-not-found.error");
13
- const account_system_entity_1 = require("../account-system-entity/account-system-entity");
14
- const account_repository_1 = require("./account.repository");
15
- class Account extends account_system_entity_1.AccountSystemEntity {
16
- get IsNewRecord() {
17
- return this._IsNewRecord;
18
- }
19
- set IsNewRecord(record) {
20
- this._IsNewRecord = record;
21
- }
22
- get ObjectType() {
23
- return this._ObjectType;
24
- }
25
- get RepositoryBase() {
26
- return Account._RepositoryBase;
27
- }
28
- get ObjectId() {
29
- return this.AccountNo;
30
- }
31
- get ObjectName() {
32
- return this.Name;
33
- }
34
- get TableName() {
35
- return 'finance_Account';
36
- }
37
- constructor(dbTransaction, accountNo) {
38
- super();
39
- this.AccountNo = 'New';
40
- this.ParentAccountNo = '';
41
- this.Name = '';
42
- this.Description = '';
43
- this.AccountType = '';
44
- this.AccountSubtype = '';
45
- this.OwnerId = '';
46
- this.OwnerType = '';
47
- this.RelatedObjectId = '';
48
- this.RelatedObjectType = '';
49
- this.CreatedById = '';
50
- this.UpdatedById = '';
51
- this._ObjectType = 'Account';
52
- this._IsNewRecord = true;
53
- if (dbTransaction) {
54
- this._DbTransaction = dbTransaction;
55
- }
56
- if (accountNo) {
57
- this.RepositoryBase.findOne({
58
- where: {
59
- AccountNo: accountNo,
60
- },
61
- transaction: dbTransaction,
62
- })
63
- .then((accountData) => {
64
- if (accountData) {
65
- this.IsNewRecord = false;
66
- this.CompanyId = accountData.CompanyId;
67
- this.ParentAccountNo = accountData.ParentAccountNo;
68
- this.Name = accountData.Name;
69
- this.Description = accountData.Description;
70
- this.AccountType = accountData.AccountType;
71
- this.AccountSubtype = accountData.AccountSubType;
72
- this.OwnerId = accountData.OwnerId;
73
- this.OwnerType = accountData.OwnerType;
74
- this.RelatedObjectId = accountData.RelatedObjectId;
75
- this.RelatedObjectType = accountData.RelatedObjectType;
76
- this.CreatedById = accountData.CreatedById;
77
- this.CreatedAt = accountData.CreatedAt;
78
- this.UpdatedById = accountData.UpdatedById;
79
- this.UpdatedAt = accountData.UpdatedAt;
80
- this.AccSystemRefId = accountData.AccSystemRefId;
81
- this.PostedToAccSystemYN = accountData.PostedToAccSystemYN;
82
- this.PostedById = accountData.PostedById;
83
- this.PostedDateTime = accountData.PostedDateTime;
84
- }
85
- else {
86
- const notFoundError = new record_not_found_error_1.RecordNotFoundError('AccountErrMsg', 'No Record Found.');
87
- throw notFoundError;
88
- }
89
- })
90
- .catch((err) => {
91
- console.log('Account Class constructor err: ', err);
92
- });
93
- }
94
- }
95
- init(accountData) {
96
- this.IsNewRecord = false;
97
- this.CompanyId = accountData.CompanyId;
98
- this.ParentAccountNo = accountData.ParentAccountNo;
99
- this.Name = accountData.Name;
100
- this.Description = accountData.Description;
101
- this.AccountType = accountData.AccountType;
102
- this.AccountSubtype = accountData.AccountSubType;
103
- this.OwnerId = accountData.OwnerId;
104
- this.OwnerType = accountData.OwnerType;
105
- this.RelatedObjectId = accountData.RelatedObjectId;
106
- this.RelatedObjectType = accountData.RelatedObjectType;
107
- this.CreatedById = accountData.CreatedById;
108
- this.CreatedAt = accountData.CreatedAt;
109
- this.UpdatedById = accountData.UpdatedById;
110
- this.UpdatedAt = accountData.UpdatedAt;
111
- this.AccSystemRefId = accountData.AccSystemRefId;
112
- this.PostedToAccSystemYN = accountData.PostedToAccSystemYN;
113
- this.PostedById = accountData.PostedById;
114
- this.PostedDateTime = accountData.PostedDateTime;
115
- }
116
- static initAccount(dbTransaction, accountNo) {
117
- return __awaiter(this, void 0, void 0, function* () {
118
- try {
119
- const accountData = yield Account._RepositoryBase.findOne({
120
- where: {
121
- AccountNo: accountNo,
122
- },
123
- transaction: dbTransaction,
124
- });
125
- if (accountData) {
126
- const account = new Account(dbTransaction);
127
- account.init(accountData.get({ plain: true }));
128
- return account;
129
- }
130
- else {
131
- const notFoundError = new record_not_found_error_1.RecordNotFoundError('AccountErrMsg', 'No Record Found.');
132
- throw notFoundError;
133
- }
134
- }
135
- catch (error) {
136
- console.log('Account Class constructor err: ', error);
137
- throw error;
138
- }
139
- });
140
- }
141
- static initialize() {
142
- const dbTransaction = null;
143
- let defaultAccountReceivable;
144
- let defaultAccountPayable;
145
- try {
146
- defaultAccountReceivable = new Account(dbTransaction, 'EZC-AR');
147
- }
148
- catch (err) {
149
- defaultAccountReceivable = new Account(dbTransaction);
150
- defaultAccountReceivable.AccountNo = null;
151
- defaultAccountReceivable.AccountType = 'Account Receivable';
152
- defaultAccountReceivable.OwnerId = 'System';
153
- defaultAccountReceivable.OwnerType = '';
154
- }
155
- try {
156
- defaultAccountPayable = new Account(dbTransaction, 'EZC-AP');
157
- }
158
- catch (err) {
159
- defaultAccountPayable = new Account(dbTransaction);
160
- defaultAccountPayable.AccountNo = null;
161
- defaultAccountPayable.AccountType = 'Account Payable';
162
- defaultAccountPayable.OwnerId = 'System';
163
- }
164
- }
165
- validateAccountValue() {
166
- if (!this.AccSystemRefId) {
167
- throw new Error('AccSystemAccountId is required.');
168
- }
169
- if (!this.AccountType) {
170
- throw new Error('AccountType is required.');
171
- }
172
- }
173
- isParentAccountExists() {
174
- if (this.ParentAccountNo)
175
- return true;
176
- return false;
177
- }
178
- save(CompanyId, AccSystemRefId, userId, dbTransaction) {
179
- return __awaiter(this, void 0, void 0, function* () {
180
- this.AccSystemRefId = AccSystemRefId;
181
- console.log('Account Save: Before AccountNo FindOne');
182
- let data = yield this.RepositoryBase.findOne({
183
- where: {
184
- AccountNo: this.AccountNo,
185
- },
186
- transaction: dbTransaction,
187
- });
188
- console.log('Account Save: After AccountNo FindOne');
189
- console.log(data, '<><><><><> Account Data Result <><><><><><>');
190
- if (data) {
191
- console.log('Account Save: THERE IS DATA FOUND');
192
- const oldAccountNo = data.AccountNo;
193
- this.AccountNo = this.AccountNo || data.AccountNo;
194
- this.AccSystemRefId = this.AccSystemRefId || data.AccSystemRefId;
195
- this.Name = this.Name || data.Name;
196
- this.Description = this.Description || data.Description;
197
- this.AccountType = this.AccountType || data.AccountType;
198
- this.AccountSubtype = this.AccountSubtype || data.AccountSubType;
199
- this.CompanyId = this.CompanyId || data.CompanyId;
200
- this.OwnerId = this.OwnerId || data.OwnerId;
201
- this.OwnerType = this.OwnerType || data.OwnerType;
202
- this.RelatedObjectId = this.RelatedObjectId || data.RelatedObjectId;
203
- this.RelatedObjectType = this.RelatedObjectType || data.RelatedObjectType;
204
- this.PostedToAccSystemYN = this.PostedToAccSystemYN || data.PostedToAccSystemYN;
205
- this.ParentAccountNo = this.ParentAccountNo || data.ParentAccountNo;
206
- this.CreatedAt = data.CreatedAt;
207
- this.CreatedById = data.CreatedById;
208
- this.UpdatedAt = new Date();
209
- this.UpdatedById = userId;
210
- yield this.RepositoryBase.update({
211
- AccountNo: this.AccountNo,
212
- AccSystemRefId: this.AccSystemRefId,
213
- Name: this.Name,
214
- Description: this.Description,
215
- AccountType: this.AccountType,
216
- AccountSubtype: this.AccountSubtype,
217
- CompanyId: this.CompanyId,
218
- OwnerId: this.OwnerId,
219
- OwnerType: this.OwnerType,
220
- RelatedObjectId: this.RelatedObjectId,
221
- RelatedObjectType: this.RelatedObjectType,
222
- PostedToAccSystemYN: this.PostedToAccSystemYN,
223
- ParentAccountNo: this.ParentAccountNo,
224
- UpdatedAt: this.UpdatedAt,
225
- UpdatedById: this.UpdatedById,
226
- }, {
227
- where: {
228
- AccountNo: oldAccountNo,
229
- },
230
- transaction: dbTransaction,
231
- });
232
- }
233
- else {
234
- console.log('Account Save: THERE IS NO DATA FOUND');
235
- data = yield this.RepositoryBase.create({
236
- AccountNo: this.AccountNo,
237
- AccSystemRefId: this.AccSystemRefId,
238
- Name: this.Name,
239
- Description: this.Description,
240
- AccountType: this.AccountType,
241
- AccountSubtype: this.AccountSubtype,
242
- CompanyId: CompanyId,
243
- OwnerId: this.OwnerId,
244
- OwnerType: this.OwnerType,
245
- RelatedObjectId: this.RelatedObjectId,
246
- RelatedObjectType: this.RelatedObjectType,
247
- PostedToAccSystemYN: this.PostedToAccSystemYN,
248
- ParentAccountNo: this.ParentAccountNo,
249
- CreatedAt: new Date(),
250
- UpdatedAt: new Date(),
251
- CreatedById: userId,
252
- }, {
253
- transaction: dbTransaction,
254
- });
255
- console.log(data, '<><><><><><><> DATA THAT GETS CREATED <><><><><><><>');
256
- }
257
- console.log(data, 'Account Save: Account details returned');
258
- return data;
259
- });
260
- }
261
- }
262
- exports.default = Account;
263
- Account._RepositoryBase = new account_repository_1.AccountRepository();
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const record_not_found_error_1 = require("@tomei/general/dist/class/exceptions/record-not-found.error");
4
+ const account_system_entity_1 = require("../account-system-entity/account-system-entity");
5
+ const account_repository_1 = require("./account.repository");
6
+ class Account extends account_system_entity_1.AccountSystemEntity {
7
+ get IsNewRecord() {
8
+ return this._IsNewRecord;
9
+ }
10
+ set IsNewRecord(record) {
11
+ this._IsNewRecord = record;
12
+ }
13
+ get ObjectType() {
14
+ return this._ObjectType;
15
+ }
16
+ get RepositoryBase() {
17
+ return Account._RepositoryBase;
18
+ }
19
+ get ObjectId() {
20
+ return this.AccountNo;
21
+ }
22
+ get ObjectName() {
23
+ return this.Name;
24
+ }
25
+ get TableName() {
26
+ return 'finance_Account';
27
+ }
28
+ constructor(dbTransaction, accountNo) {
29
+ super();
30
+ this.AccountNo = 'New';
31
+ this.ParentAccountNo = '';
32
+ this.Name = '';
33
+ this.Description = '';
34
+ this.AccountType = '';
35
+ this.AccountSubtype = '';
36
+ this.OwnerId = '';
37
+ this.OwnerType = '';
38
+ this.RelatedObjectId = '';
39
+ this.RelatedObjectType = '';
40
+ this.CreatedById = '';
41
+ this.UpdatedById = '';
42
+ this._ObjectType = 'Account';
43
+ this._IsNewRecord = true;
44
+ if (dbTransaction) {
45
+ this._DbTransaction = dbTransaction;
46
+ }
47
+ if (accountNo) {
48
+ this.RepositoryBase.findOne({
49
+ where: {
50
+ AccountNo: accountNo,
51
+ },
52
+ transaction: dbTransaction,
53
+ })
54
+ .then((accountData) => {
55
+ if (accountData) {
56
+ this.IsNewRecord = false;
57
+ this.CompanyId = accountData.CompanyId;
58
+ this.ParentAccountNo = accountData.ParentAccountNo;
59
+ this.Name = accountData.Name;
60
+ this.Description = accountData.Description;
61
+ this.AccountType = accountData.AccountType;
62
+ this.AccountSubtype = accountData.AccountSubType;
63
+ this.OwnerId = accountData.OwnerId;
64
+ this.OwnerType = accountData.OwnerType;
65
+ this.RelatedObjectId = accountData.RelatedObjectId;
66
+ this.RelatedObjectType = accountData.RelatedObjectType;
67
+ this.CreatedById = accountData.CreatedById;
68
+ this.CreatedAt = accountData.CreatedAt;
69
+ this.UpdatedById = accountData.UpdatedById;
70
+ this.UpdatedAt = accountData.UpdatedAt;
71
+ this.AccSystemRefId = accountData.AccSystemRefId;
72
+ this.PostedToAccSystemYN = accountData.PostedToAccSystemYN;
73
+ this.PostedById = accountData.PostedById;
74
+ this.PostedDateTime = accountData.PostedDateTime;
75
+ }
76
+ else {
77
+ const notFoundError = new record_not_found_error_1.RecordNotFoundError('AccountErrMsg', 'No Record Found.');
78
+ throw notFoundError;
79
+ }
80
+ })
81
+ .catch((err) => {
82
+ console.log('Account Class constructor err: ', err);
83
+ });
84
+ }
85
+ }
86
+ init(accountData) {
87
+ this.IsNewRecord = false;
88
+ this.CompanyId = accountData.CompanyId;
89
+ this.ParentAccountNo = accountData.ParentAccountNo;
90
+ this.Name = accountData.Name;
91
+ this.Description = accountData.Description;
92
+ this.AccountType = accountData.AccountType;
93
+ this.AccountSubtype = accountData.AccountSubType;
94
+ this.OwnerId = accountData.OwnerId;
95
+ this.OwnerType = accountData.OwnerType;
96
+ this.RelatedObjectId = accountData.RelatedObjectId;
97
+ this.RelatedObjectType = accountData.RelatedObjectType;
98
+ this.CreatedById = accountData.CreatedById;
99
+ this.CreatedAt = accountData.CreatedAt;
100
+ this.UpdatedById = accountData.UpdatedById;
101
+ this.UpdatedAt = accountData.UpdatedAt;
102
+ this.AccSystemRefId = accountData.AccSystemRefId;
103
+ this.PostedToAccSystemYN = accountData.PostedToAccSystemYN;
104
+ this.PostedById = accountData.PostedById;
105
+ this.PostedDateTime = accountData.PostedDateTime;
106
+ }
107
+ static async initAccount(dbTransaction, accountNo) {
108
+ try {
109
+ const accountData = await Account._RepositoryBase.findOne({
110
+ where: {
111
+ AccountNo: accountNo,
112
+ },
113
+ transaction: dbTransaction,
114
+ });
115
+ if (accountData) {
116
+ const account = new Account(dbTransaction);
117
+ account.init(accountData.get({ plain: true }));
118
+ return account;
119
+ }
120
+ else {
121
+ const notFoundError = new record_not_found_error_1.RecordNotFoundError('AccountErrMsg', 'No Record Found.');
122
+ throw notFoundError;
123
+ }
124
+ }
125
+ catch (error) {
126
+ console.log('Account Class constructor err: ', error);
127
+ throw error;
128
+ }
129
+ }
130
+ static initialize() {
131
+ const dbTransaction = null;
132
+ let defaultAccountReceivable;
133
+ let defaultAccountPayable;
134
+ try {
135
+ defaultAccountReceivable = new Account(dbTransaction, 'EZC-AR');
136
+ }
137
+ catch (err) {
138
+ defaultAccountReceivable = new Account(dbTransaction);
139
+ defaultAccountReceivable.AccountNo = null;
140
+ defaultAccountReceivable.AccountType = 'Account Receivable';
141
+ defaultAccountReceivable.OwnerId = 'System';
142
+ defaultAccountReceivable.OwnerType = '';
143
+ }
144
+ try {
145
+ defaultAccountPayable = new Account(dbTransaction, 'EZC-AP');
146
+ }
147
+ catch (err) {
148
+ defaultAccountPayable = new Account(dbTransaction);
149
+ defaultAccountPayable.AccountNo = null;
150
+ defaultAccountPayable.AccountType = 'Account Payable';
151
+ defaultAccountPayable.OwnerId = 'System';
152
+ }
153
+ }
154
+ validateAccountValue() {
155
+ if (!this.AccSystemRefId) {
156
+ throw new Error('AccSystemAccountId is required.');
157
+ }
158
+ if (!this.AccountType) {
159
+ throw new Error('AccountType is required.');
160
+ }
161
+ }
162
+ isParentAccountExists() {
163
+ if (this.ParentAccountNo)
164
+ return true;
165
+ return false;
166
+ }
167
+ async save(CompanyId, AccSystemRefId, userId, dbTransaction) {
168
+ this.AccSystemRefId = AccSystemRefId;
169
+ console.log('Account Save: Before AccountNo FindOne');
170
+ let data = await this.RepositoryBase.findOne({
171
+ where: {
172
+ AccountNo: this.AccountNo,
173
+ },
174
+ transaction: dbTransaction,
175
+ });
176
+ console.log('Account Save: After AccountNo FindOne');
177
+ console.log(data, '<><><><><> Account Data Result <><><><><><>');
178
+ if (data) {
179
+ console.log('Account Save: THERE IS DATA FOUND');
180
+ const oldAccountNo = data.AccountNo;
181
+ this.AccountNo = this.AccountNo || data.AccountNo;
182
+ this.AccSystemRefId = this.AccSystemRefId || data.AccSystemRefId;
183
+ this.Name = this.Name || data.Name;
184
+ this.Description = this.Description || data.Description;
185
+ this.AccountType = this.AccountType || data.AccountType;
186
+ this.AccountSubtype = this.AccountSubtype || data.AccountSubType;
187
+ this.CompanyId = this.CompanyId || data.CompanyId;
188
+ this.OwnerId = this.OwnerId || data.OwnerId;
189
+ this.OwnerType = this.OwnerType || data.OwnerType;
190
+ this.RelatedObjectId = this.RelatedObjectId || data.RelatedObjectId;
191
+ this.RelatedObjectType = this.RelatedObjectType || data.RelatedObjectType;
192
+ this.PostedToAccSystemYN =
193
+ this.PostedToAccSystemYN || data.PostedToAccSystemYN;
194
+ this.ParentAccountNo = this.ParentAccountNo || data.ParentAccountNo;
195
+ this.CreatedAt = data.CreatedAt;
196
+ this.CreatedById = data.CreatedById;
197
+ this.UpdatedAt = new Date();
198
+ this.UpdatedById = userId;
199
+ await this.RepositoryBase.update({
200
+ AccountNo: this.AccountNo,
201
+ AccSystemRefId: this.AccSystemRefId,
202
+ Name: this.Name,
203
+ Description: this.Description,
204
+ AccountType: this.AccountType,
205
+ AccountSubtype: this.AccountSubtype,
206
+ CompanyId: this.CompanyId,
207
+ OwnerId: this.OwnerId,
208
+ OwnerType: this.OwnerType,
209
+ RelatedObjectId: this.RelatedObjectId,
210
+ RelatedObjectType: this.RelatedObjectType,
211
+ PostedToAccSystemYN: this.PostedToAccSystemYN,
212
+ ParentAccountNo: this.ParentAccountNo,
213
+ UpdatedAt: this.UpdatedAt,
214
+ UpdatedById: this.UpdatedById,
215
+ }, {
216
+ where: {
217
+ AccountNo: oldAccountNo,
218
+ },
219
+ transaction: dbTransaction,
220
+ });
221
+ }
222
+ else {
223
+ console.log('Account Save: THERE IS NO DATA FOUND');
224
+ data = await this.RepositoryBase.create({
225
+ AccountNo: this.AccountNo,
226
+ AccSystemRefId: this.AccSystemRefId,
227
+ Name: this.Name,
228
+ Description: this.Description,
229
+ AccountType: this.AccountType,
230
+ AccountSubtype: this.AccountSubtype,
231
+ CompanyId: CompanyId,
232
+ OwnerId: this.OwnerId,
233
+ OwnerType: this.OwnerType,
234
+ RelatedObjectId: this.RelatedObjectId,
235
+ RelatedObjectType: this.RelatedObjectType,
236
+ PostedToAccSystemYN: this.PostedToAccSystemYN,
237
+ ParentAccountNo: this.ParentAccountNo,
238
+ CreatedAt: new Date(),
239
+ UpdatedAt: new Date(),
240
+ CreatedById: userId,
241
+ }, {
242
+ transaction: dbTransaction,
243
+ });
244
+ console.log(data, '<><><><><><><> DATA THAT GETS CREATED <><><><><><><>');
245
+ }
246
+ console.log(data, 'Account Save: Account details returned');
247
+ return data;
248
+ }
249
+ }
250
+ Account._RepositoryBase = new account_repository_1.AccountRepository();
251
+ exports.default = Account;
264
252
  //# sourceMappingURL=account.js.map