@tomei/finance 0.3.76 → 0.3.78

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.
@@ -9,7 +9,7 @@ module.exports = {
9
9
  allowNull: false,
10
10
  },
11
11
  DocType: {
12
- type: Sequelize.ENUM(['Invoice', 'Debit Note', 'Credit Note', 'Quotation', 'Receipt']),
12
+ type: Sequelize.ENUM(['Invoice', 'Debit Note', 'Credit Note', 'Quotation', 'Receipt', 'Purchase Order']),
13
13
  allowNull: false,
14
14
  },
15
15
  DocDate: {
@@ -39,7 +39,7 @@ module.exports = {
39
39
  allowNull: false,
40
40
  },
41
41
  Status: {
42
- type: Sequelize.STRING(20),
42
+ type: Sequelize.ENUM(['Unpaid', 'Paid', 'Partial Paid', 'Cancelled']),
43
43
  allowNull: false,
44
44
  },
45
45
  IssuedById: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomei/finance",
3
- "version": "0.3.76",
3
+ "version": "0.3.78",
4
4
  "description": "NestJS package for finance module",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,5 +1,6 @@
1
1
  export enum DocumentStatus {
2
2
  UNPAID = 'Unpaid',
3
+ PARTIALPAID = 'Partial Paid',
3
4
  PAID = 'Paid',
4
5
  CANCELLED = 'Cancelled',
5
6
  }
@@ -61,6 +61,7 @@ export default class FinanceCompany extends ObjectBase {
61
61
 
62
62
  private _AccountingSystem: IAccountSystem;
63
63
 
64
+ private _DbTransaction: any;
64
65
  private _PaymentMethods = [];
65
66
 
66
67
  get CompSystemCode(): string {
@@ -1326,11 +1327,54 @@ export default class FinanceCompany extends ObjectBase {
1326
1327
  }
1327
1328
  }
1328
1329
 
1329
- get PaymentMethods() {
1330
- if (this._PaymentMethods === null || this._PaymentMethods.length === 0) {
1331
- this.LoadPaymentMethods();
1332
- }
1333
- return this._PaymentMethods;
1330
+ get PaymentMethods(): Promise<PaymentMethod[]> {
1331
+ return new Promise((resolve, reject) => {
1332
+ if (this.CompanyId !== 'New') {
1333
+ FinanceCompany._PaymentMethodRepository
1334
+ .findAll({
1335
+ where: {
1336
+ CompanyId: this.CompanyId,
1337
+ },
1338
+ transaction: this._DbTransaction,
1339
+ })
1340
+ .then((paymentMethod) => {
1341
+ const paymentMethodObjects = paymentMethod.map(
1342
+ (paymentMethodData) => {
1343
+ return new Promise((resolve, reject) => {
1344
+ FinanceCompany._PaymentMethodTypeRepository
1345
+ .findAll({
1346
+ where: {
1347
+ MethodId: paymentMethodData.MethodId,
1348
+ },
1349
+ transaction: this._DbTransaction,
1350
+ raw: true,
1351
+ })
1352
+ .then((paymentMethodTypes) => {
1353
+ const paymentMethodObjects = {
1354
+ ...paymentMethodData.get({ plain: true }),
1355
+ Types: paymentMethodTypes,
1356
+ };
1357
+ resolve(paymentMethodObjects);
1358
+ })
1359
+ .catch((err) => {
1360
+ reject(err);
1361
+ });
1362
+ }).then((paymentMethods) => paymentMethods);
1363
+ },
1364
+ );
1365
+ return Promise.all(paymentMethodObjects);
1366
+ })
1367
+ .then((paymentMethodObjects) => {
1368
+ this._PaymentMethods = paymentMethodObjects;
1369
+ resolve(this._PaymentMethods);
1370
+ })
1371
+ .catch((err) => {
1372
+ reject(err);
1373
+ });
1374
+ } else {
1375
+ resolve(this._PaymentMethods);
1376
+ }
1377
+ });
1334
1378
  }
1335
1379
 
1336
1380
  /**
@@ -195,8 +195,8 @@ export default class Payment extends AccountSystemEntity {
195
195
  return paymentItem;
196
196
  }
197
197
 
198
- newPaymentPaidWIth(paymentMethodId: string) {
199
- const paymentPaidWith = new PaymentPaidWith(this, paymentMethodId);
198
+ newPaymentPaidWith(paymentMethodTypeId: string) {
199
+ const paymentPaidWith = new PaymentPaidWith(this, paymentMethodTypeId);
200
200
  this._PaymentPaidWith.push(paymentPaidWith);
201
201
  return paymentPaidWith;
202
202
  }