@tomei/finance 0.6.53 → 0.6.55

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.53",
3
+ "version": "0.6.55",
4
4
  "description": "NestJS package for finance module",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -2014,7 +2014,7 @@ export default class FinanceCompany extends ObjectBase {
2014
2014
  receipt.CreatedById = loginUser.ObjectId;
2015
2015
  receipt.UpdatedById = loginUser.ObjectId;
2016
2016
 
2017
- const paymentItems = await payment.getPaymentItems();
2017
+ const paymentItems = await payment.getPaymentItems(dbTransaction);
2018
2018
  for (const paymentItem of paymentItems) {
2019
2019
  const receiptItem = new DocumentItem(dbTransaction, receipt);
2020
2020
  receiptItem.Name = `Payment for ${paymentItem.PayForObjectType} No. ${paymentItem.PayForObjectId}`;
@@ -2110,7 +2110,7 @@ export default class FinanceCompany extends ObjectBase {
2110
2110
 
2111
2111
  /*Registering the Journal Entries for the transaction*/
2112
2112
  const transactionDate = new Date();
2113
- const paymentPaidWithItems = await payment.getPaymentPaidWith();
2113
+ const paymentPaidWithItems = await payment.getPaymentPaidWith(dbTransaction);
2114
2114
 
2115
2115
  for (const paymentPaidWith of paymentPaidWithItems) {
2116
2116
  let paymentMethodType = await PaymentMethodType.initMethodType(
@@ -2157,8 +2157,22 @@ export default class FinanceCompany extends ObjectBase {
2157
2157
  creditLT.RelatedObjectType = type(payment);
2158
2158
  creditLT.RelatedPaymentId = payment.PaymentId;
2159
2159
 
2160
- await
2161
- await this.postJournal(dbTransaction, journalEntry, loginUser);
2160
+ await FinanceCompany._PaymentRepository.update(
2161
+ {
2162
+ ReceiptDocNo: receipt.DocNo,
2163
+ Status: payment.Status,
2164
+ UpdatedAt: new Date(),
2165
+ UpdatedBy: loginUser.ObjectId,
2166
+ },
2167
+ {
2168
+ where: {
2169
+ PaymentId: payment.PaymentId,
2170
+ },
2171
+ transaction: dbTransaction,
2172
+ }
2173
+ );
2174
+
2175
+ await this.postJournal(dbTransaction, journalEntry, loginUser);
2162
2176
  }
2163
2177
  break;
2164
2178
  default:
@@ -1,6 +1,6 @@
1
1
  import { ClassError, LoginUserBase, ObjectBase } from '@tomei/general';
2
2
  import { RecordNotFoundError } from '@tomei/general/dist/class/exceptions/record-not-found.error';
3
- import { PaymentType } from '../enum';
3
+ import { PaymentType, TransactionTypeOptions } from '../enum';
4
4
  import { IPaymentParams } from './interfaces/payment-params.interface';
5
5
  import { AccountSystemEntity } from '../account-system-entity/account-system-entity';
6
6
  import { PaymentStatus } from '../enum/payment-status.enum';
@@ -12,6 +12,8 @@ import PaymentPaidWith from '../payment-paid-with/payment-paid-with';
12
12
  import { PaymentPaidWithRepository } from '../payment-paid-with/payment-paid-with.repository';
13
13
  import FinanceCustomerBase from 'src/customer/customer';
14
14
  import { ApplicationConfig } from '@tomei/config';
15
+ import JournalEntry from 'src/journal-entry/journal-entry';
16
+ import PaymentMethodType from 'src/payment-method-type/payment-method-type';
15
17
 
16
18
  export default class Payment extends AccountSystemEntity {
17
19
  private _PaymentId = 'New';
@@ -130,14 +132,14 @@ export default class Payment extends AccountSystemEntity {
130
132
  }
131
133
  }
132
134
 
133
- async getPaymentItems(): Promise<PaymentItem[]> {
135
+ async getPaymentItems(dbTransaction?: any): Promise<PaymentItem[]> {
134
136
  try {
135
137
  if (this.PaymentId !== 'New') {
136
138
  const paymentItems = await Payment._PaymentItemRepository.findAll({
137
139
  where: {
138
140
  PaymentId: this.PaymentId,
139
141
  },
140
- transaction: this._DbTransaction,
142
+ transaction: dbTransaction || this._DbTransaction,
141
143
  });
142
144
  const paymentItemObjects = paymentItems.map((paymentItem) => {
143
145
  const pi = new PaymentItem(
@@ -169,7 +171,7 @@ export default class Payment extends AccountSystemEntity {
169
171
  }
170
172
  }
171
173
 
172
- async getPaymentPaidWith(): Promise<PaymentPaidWith[]> {
174
+ async getPaymentPaidWith(dbTransaction?: any): Promise<PaymentPaidWith[]> {
173
175
  try {
174
176
  if (this.PaymentId !== 'New') {
175
177
  const paymentPaidWithItems =
@@ -177,7 +179,7 @@ export default class Payment extends AccountSystemEntity {
177
179
  where: {
178
180
  PaymentId: this.PaymentId,
179
181
  },
180
- transaction: this._DbTransaction,
182
+ transaction: dbTransaction || this._DbTransaction,
181
183
  });
182
184
  const paymentPaidWithObjects = paymentPaidWithItems.map(
183
185
  (paymentPaidWithItem) => {
@@ -235,40 +237,4 @@ export default class Payment extends AccountSystemEntity {
235
237
  if (Params.Currency) this.Currency = Params.Currency;
236
238
  if (Params.PaymentType) this.PaymentType = Params.PaymentType;
237
239
  }
238
-
239
- async confirmPayment(
240
- dbTransaction: any,
241
- loginUser: LoginUserBase,
242
- customer: FinanceCustomerBase,
243
- status: PaymentStatus,
244
- remarks?: string,
245
- ctAccountNo?: string,
246
- ): Promise<void> {
247
- try {
248
- const systemCode =
249
- ApplicationConfig.getComponentConfigValue('system-code');
250
-
251
- const isPrivileged = await loginUser.checkPrivileges(
252
- systemCode,
253
- 'Payment - Update',
254
- );
255
- if (!isPrivileged) {
256
- throw new ClassError(
257
- 'Payment',
258
- 'PaymentChangeStatusErrMsg00',
259
- `You do not have 'Payment - Update' privilege.`,
260
- );
261
- }
262
-
263
- if (this.PaymentId === 'New') {
264
- throw new ClassError(
265
- 'Payment',
266
- 'PaymentChangeStatusErrMsg01',
267
- `Payment not found.`,
268
- );
269
- }
270
- } catch (error) {
271
- throw error;
272
- }
273
- }
274
240
  }