@tomei/finance 0.6.6 → 0.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomei/finance",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "description": "NestJS package for finance module",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -17,33 +17,49 @@ export default class PaymentMethod extends ObjectBase {
17
17
  private _DbTransaction: any;
18
18
  private _PaymentMethodTypes = [];
19
19
 
20
- constructor(dbTransaction?: any, methodId?: string) {
20
+ constructor(
21
+ dbTransaction?: any,
22
+ methodId?: string,
23
+ companyId?: string,
24
+ name?: string,
25
+ ) {
21
26
  super();
22
27
  if (dbTransaction) {
23
28
  this._DbTransaction = dbTransaction;
24
29
  }
25
30
  if (methodId) {
26
31
  this.MethodId = methodId;
27
- PaymentMethod._RepositoryBase
28
- .findOne({
29
- where: {
30
- MethodId: methodId,
31
- },
32
- transaction: dbTransaction,
33
- })
34
- .then((methodData) => {
35
- if (methodData) {
36
- this.Name = methodData.Name;
37
- } else {
38
- throw new RecordNotFoundError(
39
- 'PaymentMethodErrMsg',
40
- 'No record found.',
41
- );
42
- }
43
- })
44
- .catch((err) => {
45
- console.log('Payment method constructor err: ', err);
46
- });
32
+ }
33
+ if (companyId) {
34
+ this.CompanyId = companyId;
35
+ }
36
+ if (name) {
37
+ this.Name = name;
38
+ }
39
+ }
40
+
41
+ static async initPaymentMethod(dbTransaction?: any, methodId?: string) {
42
+ if (methodId) {
43
+ const methodData = await PaymentMethod._RepositoryBase.findOne({
44
+ where: {
45
+ MethodId: methodId,
46
+ },
47
+ transaction: dbTransaction,
48
+ });
49
+
50
+ if (methodData) {
51
+ new PaymentMethod(
52
+ dbTransaction,
53
+ methodData.MethodId,
54
+ methodData.CompanyId,
55
+ methodData.Name,
56
+ );
57
+ } else {
58
+ throw new RecordNotFoundError(
59
+ 'PaymentMethodErrMsg',
60
+ 'No record found.',
61
+ );
62
+ }
47
63
  }
48
64
  }
49
65