fix: rename interfaces to PaymentReceived

This commit is contained in:
Ahmed Bouhuolia
2024-08-13 14:17:37 +02:00
parent 9991eebaaf
commit 961e4b99e8
28 changed files with 216 additions and 216 deletions

View File

@@ -8,7 +8,7 @@ import { ILedgerEntry } from './Ledger';
import { ISaleInvoice } from './SaleInvoice'; import { ISaleInvoice } from './SaleInvoice';
import { AttachmentLinkDTO } from './Attachments'; import { AttachmentLinkDTO } from './Attachments';
export interface IPaymentReceive { export interface IPaymentReceived {
id?: number; id?: number;
customerId: number; customerId: number;
paymentDate: Date; paymentDate: Date;
@@ -19,14 +19,14 @@ export interface IPaymentReceive {
depositAccountId: number; depositAccountId: number;
paymentReceiveNo: string; paymentReceiveNo: string;
statement: string; statement: string;
entries: IPaymentReceiveEntry[]; entries: IPaymentReceivedEntry[];
userId: number; userId: number;
createdAt: Date; createdAt: Date;
updatedAt: Date; updatedAt: Date;
localAmount?: number; localAmount?: number;
branchId?: number; branchId?: number;
} }
export interface IPaymentReceiveCreateDTO { export interface IPaymentReceivedCreateDTO {
customerId: number; customerId: number;
paymentDate: Date; paymentDate: Date;
amount: number; amount: number;
@@ -35,13 +35,13 @@ export interface IPaymentReceiveCreateDTO {
depositAccountId: number; depositAccountId: number;
paymentReceiveNo?: string; paymentReceiveNo?: string;
statement: string; statement: string;
entries: IPaymentReceiveEntryDTO[]; entries: IPaymentReceivedEntryDTO[];
branchId?: number; branchId?: number;
attachments?: AttachmentLinkDTO[]; attachments?: AttachmentLinkDTO[];
} }
export interface IPaymentReceiveEditDTO { export interface IPaymentReceivedEditDTO {
customerId: number; customerId: number;
paymentDate: Date; paymentDate: Date;
amount: number; amount: number;
@@ -50,12 +50,12 @@ export interface IPaymentReceiveEditDTO {
depositAccountId: number; depositAccountId: number;
paymentReceiveNo?: string; paymentReceiveNo?: string;
statement: string; statement: string;
entries: IPaymentReceiveEntryDTO[]; entries: IPaymentReceivedEntryDTO[];
branchId?: number; branchId?: number;
attachments?: AttachmentLinkDTO[]; attachments?: AttachmentLinkDTO[];
} }
export interface IPaymentReceiveEntry { export interface IPaymentReceivedEntry {
id?: number; id?: number;
paymentReceiveId: number; paymentReceiveId: number;
invoiceId: number; invoiceId: number;
@@ -64,7 +64,7 @@ export interface IPaymentReceiveEntry {
invoice?: ISaleInvoice; invoice?: ISaleInvoice;
} }
export interface IPaymentReceiveEntryDTO { export interface IPaymentReceivedEntryDTO {
id?: number; id?: number;
index: number; index: number;
paymentReceiveId: number; paymentReceiveId: number;
@@ -72,7 +72,7 @@ export interface IPaymentReceiveEntryDTO {
paymentAmount: number; paymentAmount: number;
} }
export interface IPaymentReceivesFilter extends IDynamicListFilterDTO { export interface IPaymentsReceivedFilter extends IDynamicListFilterDTO {
stringifiedFilterRoles?: string; stringifiedFilterRoles?: string;
} }
@@ -88,65 +88,65 @@ export interface IPaymentReceivePageEntry {
date: Date | string; date: Date | string;
} }
export interface IPaymentReceiveEditPage { export interface IPaymentReceivedEditPage {
paymentReceive: IPaymentReceive; paymentReceive: IPaymentReceived;
entries: IPaymentReceivePageEntry[]; entries: IPaymentReceivePageEntry[];
} }
export interface IPaymentsReceiveService { export interface IPaymentsReceivedService {
validateCustomerHasNoPayments( validateCustomerHasNoPayments(
tenantId: number, tenantId: number,
customerId: number customerId: number
): Promise<void>; ): Promise<void>;
} }
export interface IPaymentReceiveSmsDetails { export interface IPaymentReceivedSmsDetails {
customerName: string; customerName: string;
customerPhoneNumber: string; customerPhoneNumber: string;
smsMessage: string; smsMessage: string;
} }
export interface IPaymentReceiveCreatingPayload { export interface IPaymentReceivedCreatingPayload {
tenantId: number; tenantId: number;
paymentReceiveDTO: IPaymentReceiveCreateDTO; paymentReceiveDTO: IPaymentReceivedCreateDTO;
trx: Knex.Transaction; trx: Knex.Transaction;
} }
export interface IPaymentReceiveCreatedPayload { export interface IPaymentReceivedCreatedPayload {
tenantId: number; tenantId: number;
paymentReceive: IPaymentReceive; paymentReceive: IPaymentReceived;
paymentReceiveId: number; paymentReceiveId: number;
authorizedUser: ISystemUser; authorizedUser: ISystemUser;
paymentReceiveDTO: IPaymentReceiveCreateDTO; paymentReceiveDTO: IPaymentReceivedCreateDTO;
trx: Knex.Transaction; trx: Knex.Transaction;
} }
export interface IPaymentReceiveEditedPayload { export interface IPaymentReceivedEditedPayload {
tenantId: number; tenantId: number;
paymentReceiveId: number; paymentReceiveId: number;
paymentReceive: IPaymentReceive; paymentReceive: IPaymentReceived;
oldPaymentReceive: IPaymentReceive; oldPaymentReceive: IPaymentReceived;
paymentReceiveDTO: IPaymentReceiveEditDTO; paymentReceiveDTO: IPaymentReceivedEditDTO;
authorizedUser: ISystemUser; authorizedUser: ISystemUser;
trx: Knex.Transaction; trx: Knex.Transaction;
} }
export interface IPaymentReceiveEditingPayload { export interface IPaymentReceivedEditingPayload {
tenantId: number; tenantId: number;
oldPaymentReceive: IPaymentReceive; oldPaymentReceive: IPaymentReceived;
paymentReceiveDTO: IPaymentReceiveEditDTO; paymentReceiveDTO: IPaymentReceivedEditDTO;
trx: Knex.Transaction; trx: Knex.Transaction;
} }
export interface IPaymentReceiveDeletingPayload { export interface IPaymentReceivedDeletingPayload {
tenantId: number; tenantId: number;
oldPaymentReceive: IPaymentReceive; oldPaymentReceive: IPaymentReceived;
trx: Knex.Transaction; trx: Knex.Transaction;
} }
export interface IPaymentReceiveDeletedPayload { export interface IPaymentReceivedDeletedPayload {
tenantId: number; tenantId: number;
paymentReceiveId: number; paymentReceiveId: number;
oldPaymentReceive: IPaymentReceive; oldPaymentReceive: IPaymentReceived;
authorizedUser: ISystemUser; authorizedUser: ISystemUser;
trx: Knex.Transaction; trx: Knex.Transaction;
} }

View File

@@ -1,10 +1,10 @@
import { Inject, Service } from 'typedi'; import { Inject, Service } from 'typedi';
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import { import {
IPaymentReceiveCreatedPayload, IPaymentReceivedCreatedPayload,
IPaymentReceiveCreatingPayload, IPaymentReceivedCreatingPayload,
IPaymentReceiveDeletingPayload, IPaymentReceivedDeletingPayload,
IPaymentReceiveEditedPayload, IPaymentReceivedEditedPayload,
} from '@/interfaces'; } from '@/interfaces';
import events from '@/subscribers/events'; import events from '@/subscribers/events';
import { LinkAttachment } from '../LinkAttachment'; import { LinkAttachment } from '../LinkAttachment';
@@ -50,13 +50,13 @@ export class AttachmentsOnPaymentsReceived {
/** /**
* Validates the attachment keys on creating payment. * Validates the attachment keys on creating payment.
* @param {IPaymentReceiveCreatingPayload} * @param {IPaymentReceivedCreatingPayload}
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
private async validateAttachmentsOnPaymentCreate({ private async validateAttachmentsOnPaymentCreate({
paymentReceiveDTO, paymentReceiveDTO,
tenantId, tenantId,
}: IPaymentReceiveCreatingPayload): Promise<void> { }: IPaymentReceivedCreatingPayload): Promise<void> {
if (isEmpty(paymentReceiveDTO.attachments)) { if (isEmpty(paymentReceiveDTO.attachments)) {
return; return;
} }
@@ -67,7 +67,7 @@ export class AttachmentsOnPaymentsReceived {
/** /**
* Handles linking the attachments of the created payment. * Handles linking the attachments of the created payment.
* @param {IPaymentReceiveCreatedPayload} * @param {IPaymentReceivedCreatedPayload}
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
private async handleAttachmentsOnPaymentCreated({ private async handleAttachmentsOnPaymentCreated({
@@ -75,7 +75,7 @@ export class AttachmentsOnPaymentsReceived {
paymentReceiveDTO, paymentReceiveDTO,
paymentReceive, paymentReceive,
trx, trx,
}: IPaymentReceiveCreatedPayload): Promise<void> { }: IPaymentReceivedCreatedPayload): Promise<void> {
if (isEmpty(paymentReceiveDTO.attachments)) return; if (isEmpty(paymentReceiveDTO.attachments)) return;
const keys = paymentReceiveDTO.attachments?.map( const keys = paymentReceiveDTO.attachments?.map(
@@ -92,14 +92,14 @@ export class AttachmentsOnPaymentsReceived {
/** /**
* Handles unlinking all the unpresented keys of the edited payment. * Handles unlinking all the unpresented keys of the edited payment.
* @param {IPaymentReceiveEditedPayload} * @param {IPaymentReceivedEditedPayload}
*/ */
private async handleUnlinkUnpresentedKeysOnPaymentEdited({ private async handleUnlinkUnpresentedKeysOnPaymentEdited({
tenantId, tenantId,
paymentReceiveDTO, paymentReceiveDTO,
oldPaymentReceive, oldPaymentReceive,
trx, trx,
}: IPaymentReceiveEditedPayload) { }: IPaymentReceivedEditedPayload) {
const keys = paymentReceiveDTO.attachments?.map( const keys = paymentReceiveDTO.attachments?.map(
(attachment) => attachment.key (attachment) => attachment.key
); );
@@ -114,7 +114,7 @@ export class AttachmentsOnPaymentsReceived {
/** /**
* Handles linking all the presented keys of the edited payment. * Handles linking all the presented keys of the edited payment.
* @param {IPaymentReceiveEditedPayload} * @param {IPaymentReceivedEditedPayload}
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
private async handleLinkPresentedKeysOnPaymentEdited({ private async handleLinkPresentedKeysOnPaymentEdited({
@@ -122,7 +122,7 @@ export class AttachmentsOnPaymentsReceived {
paymentReceiveDTO, paymentReceiveDTO,
oldPaymentReceive, oldPaymentReceive,
trx, trx,
}: IPaymentReceiveEditedPayload) { }: IPaymentReceivedEditedPayload) {
if (isEmpty(paymentReceiveDTO.attachments)) return; if (isEmpty(paymentReceiveDTO.attachments)) return;
const keys = paymentReceiveDTO.attachments?.map( const keys = paymentReceiveDTO.attachments?.map(
@@ -146,7 +146,7 @@ export class AttachmentsOnPaymentsReceived {
tenantId, tenantId,
oldPaymentReceive, oldPaymentReceive,
trx, trx,
}: IPaymentReceiveDeletingPayload) { }: IPaymentReceivedDeletingPayload) {
await this.unlinkAttachmentService.unlinkAllModelKeys( await this.unlinkAttachmentService.unlinkAllModelKeys(
tenantId, tenantId,
'PaymentReceive', 'PaymentReceive',

View File

@@ -1,7 +1,7 @@
import { Inject, Service } from 'typedi'; import { Inject, Service } from 'typedi';
import { import {
IBillPaymentEventDeletedPayload, IBillPaymentEventDeletedPayload,
IPaymentReceiveDeletedPayload, IPaymentReceivedDeletedPayload,
} from '@/interfaces'; } from '@/interfaces';
import { ValidateTransactionMatched } from '../ValidateTransactionsMatched'; import { ValidateTransactionMatched } from '../ValidateTransactionsMatched';
import events from '@/subscribers/events'; import events from '@/subscribers/events';
@@ -23,7 +23,7 @@ export class ValidateMatchingOnPaymentMadeDelete {
/** /**
* Validates the payment made transaction whether matched with bank transaction on deleting. * Validates the payment made transaction whether matched with bank transaction on deleting.
* @param {IPaymentReceiveDeletedPayload} * @param {IPaymentReceivedDeletedPayload}
*/ */
public async validateMatchingOnPaymentMadeDeleting({ public async validateMatchingOnPaymentMadeDeleting({
tenantId, tenantId,

View File

@@ -1,5 +1,5 @@
import { Inject, Service } from 'typedi'; import { Inject, Service } from 'typedi';
import { IPaymentReceiveDeletedPayload } from '@/interfaces'; import { IPaymentReceivedDeletedPayload } from '@/interfaces';
import { ValidateTransactionMatched } from '../ValidateTransactionsMatched'; import { ValidateTransactionMatched } from '../ValidateTransactionsMatched';
import events from '@/subscribers/events'; import events from '@/subscribers/events';
@@ -20,13 +20,13 @@ export class ValidateMatchingOnPaymentReceivedDelete {
/** /**
* Validates the payment received transaction whether matched with bank transaction on deleting. * Validates the payment received transaction whether matched with bank transaction on deleting.
* @param {IPaymentReceiveDeletedPayload} * @param {IPaymentReceivedDeletedPayload}
*/ */
public async validateMatchingOnPaymentReceivedDeleting({ public async validateMatchingOnPaymentReceivedDeleting({
tenantId, tenantId,
oldPaymentReceive, oldPaymentReceive,
trx, trx,
}: IPaymentReceiveDeletedPayload) { }: IPaymentReceivedDeletedPayload) {
await this.validateNoMatchingLinkedService.validateTransactionNoMatchLinking( await this.validateNoMatchingLinkedService.validateTransactionNoMatchLinking(
tenantId, tenantId,
'PaymentReceive', 'PaymentReceive',

View File

@@ -1,8 +1,8 @@
import { Inject, Service } from 'typedi'; import { Inject, Service } from 'typedi';
import events from '@/subscribers/events'; import events from '@/subscribers/events';
import { import {
IPaymentReceiveCreatingPayload, IPaymentReceivedCreatingPayload,
IPaymentReceiveEditingPayload, IPaymentReceivedEditingPayload,
} from '@/interfaces'; } from '@/interfaces';
import { ValidateBranchExistance } from '../../Integrations/ValidateBranchExistance'; import { ValidateBranchExistance } from '../../Integrations/ValidateBranchExistance';
@@ -28,12 +28,12 @@ export class PaymentReceiveBranchValidateSubscriber {
/** /**
* Validate branch existance on estimate creating. * Validate branch existance on estimate creating.
* @param {IPaymentReceiveCreatingPayload} payload * @param {IPaymentReceivedCreatingPayload} payload
*/ */
private validateBranchExistanceOnPaymentCreating = async ({ private validateBranchExistanceOnPaymentCreating = async ({
tenantId, tenantId,
paymentReceiveDTO, paymentReceiveDTO,
}: IPaymentReceiveCreatingPayload) => { }: IPaymentReceivedCreatingPayload) => {
await this.validateBranchExistance.validateTransactionBranchWhenActive( await this.validateBranchExistance.validateTransactionBranchWhenActive(
tenantId, tenantId,
paymentReceiveDTO.branchId paymentReceiveDTO.branchId
@@ -42,12 +42,12 @@ export class PaymentReceiveBranchValidateSubscriber {
/** /**
* Validate branch existance once estimate editing. * Validate branch existance once estimate editing.
* @param {IPaymentReceiveEditingPayload} payload * @param {IPaymentReceivedEditingPayload} payload
*/ */
private validateBranchExistanceOnPaymentEditing = async ({ private validateBranchExistanceOnPaymentEditing = async ({
paymentReceiveDTO, paymentReceiveDTO,
tenantId, tenantId,
}: IPaymentReceiveEditingPayload) => { }: IPaymentReceivedEditingPayload) => {
await this.validateBranchExistance.validateTransactionBranchWhenActive( await this.validateBranchExistance.validateTransactionBranchWhenActive(
tenantId, tenantId,
paymentReceiveDTO.branchId paymentReceiveDTO.branchId

View File

@@ -6,7 +6,7 @@ import SaleNotifyBySms from '../SaleNotifyBySms';
import SmsNotificationsSettingsService from '@/services/Settings/SmsNotificationsSettings'; import SmsNotificationsSettingsService from '@/services/Settings/SmsNotificationsSettings';
import { import {
ICustomer, ICustomer,
IPaymentReceiveSmsDetails, IPaymentReceivedSmsDetails,
ISaleEstimate, ISaleEstimate,
SMS_NOTIFICATION_KEY, SMS_NOTIFICATION_KEY,
} from '@/interfaces'; } from '@/interfaces';
@@ -173,12 +173,12 @@ export class SaleEstimateNotifyBySms {
* Retrieve the SMS details of the given payment receive transaction. * Retrieve the SMS details of the given payment receive transaction.
* @param {number} tenantId * @param {number} tenantId
* @param {number} saleEstimateId * @param {number} saleEstimateId
* @returns {Promise<IPaymentReceiveSmsDetails>} * @returns {Promise<IPaymentReceivedSmsDetails>}
*/ */
public smsDetails = async ( public smsDetails = async (
tenantId: number, tenantId: number,
saleEstimateId: number saleEstimateId: number
): Promise<IPaymentReceiveSmsDetails> => { ): Promise<IPaymentReceivedSmsDetails> => {
const { SaleEstimate } = this.tenancy.models(tenantId); const { SaleEstimate } = this.tenancy.models(tenantId);
// Retrieve the sale invoice or throw not found service error. // Retrieve the sale invoice or throw not found service error.

View File

@@ -3,7 +3,7 @@ import { CreateSaleEstimate } from './CreateSaleEstimate';
import { import {
IFilterMeta, IFilterMeta,
IPaginationMeta, IPaginationMeta,
IPaymentReceiveSmsDetails, IPaymentReceivedSmsDetails,
ISaleEstimate, ISaleEstimate,
ISaleEstimateDTO, ISaleEstimateDTO,
ISalesEstimatesFilter, ISalesEstimatesFilter,
@@ -191,12 +191,12 @@ export class SaleEstimatesApplication {
* Retrieve the SMS details of the given payment receive transaction. * Retrieve the SMS details of the given payment receive transaction.
* @param {number} tenantId * @param {number} tenantId
* @param {number} saleEstimateId * @param {number} saleEstimateId
* @returns {Promise<IPaymentReceiveSmsDetails>} * @returns {Promise<IPaymentReceivedSmsDetails>}
*/ */
public getSaleEstimateSmsDetails = ( public getSaleEstimateSmsDetails = (
tenantId: number, tenantId: number,
saleEstimateId: number saleEstimateId: number
): Promise<IPaymentReceiveSmsDetails> => { ): Promise<IPaymentReceivedSmsDetails> => {
return this.saleEstimateNotifyBySmsService.smsDetails( return this.saleEstimateNotifyBySmsService.smsDetails(
tenantId, tenantId,
saleEstimateId saleEstimateId

View File

@@ -2,9 +2,9 @@ import { Inject, Service } from 'typedi';
import { Knex } from 'knex'; import { Knex } from 'knex';
import { import {
ICustomer, ICustomer,
IPaymentReceiveCreateDTO, IPaymentReceivedCreateDTO,
IPaymentReceiveCreatedPayload, IPaymentReceivedCreatedPayload,
IPaymentReceiveCreatingPayload, IPaymentReceivedCreatingPayload,
ISystemUser, ISystemUser,
} from '@/interfaces'; } from '@/interfaces';
import { PaymentReceivedValidators } from './PaymentReceivedValidators'; import { PaymentReceivedValidators } from './PaymentReceivedValidators';
@@ -37,11 +37,11 @@ export class CreatePaymentReceived {
* with associated invoices payment and journal transactions. * with associated invoices payment and journal transactions.
* @async * @async
* @param {number} tenantId - Tenant id. * @param {number} tenantId - Tenant id.
* @param {IPaymentReceive} paymentReceive * @param {IPaymentReceived} paymentReceive
*/ */
public async createPaymentReceived( public async createPaymentReceived(
tenantId: number, tenantId: number,
paymentReceiveDTO: IPaymentReceiveCreateDTO, paymentReceiveDTO: IPaymentReceivedCreateDTO,
authorizedUser: ISystemUser, authorizedUser: ISystemUser,
trx?: Knex.Transaction trx?: Knex.Transaction
) { ) {
@@ -97,7 +97,7 @@ export class CreatePaymentReceived {
trx, trx,
paymentReceiveDTO, paymentReceiveDTO,
tenantId, tenantId,
} as IPaymentReceiveCreatingPayload); } as IPaymentReceivedCreatingPayload);
// Inserts the payment receive transaction. // Inserts the payment receive transaction.
const paymentReceive = await PaymentReceive.query( const paymentReceive = await PaymentReceive.query(
@@ -113,7 +113,7 @@ export class CreatePaymentReceived {
paymentReceiveDTO, paymentReceiveDTO,
authorizedUser, authorizedUser,
trx, trx,
} as IPaymentReceiveCreatedPayload); } as IPaymentReceivedCreatedPayload);
return paymentReceive; return paymentReceive;
}, },
@@ -125,13 +125,13 @@ export class CreatePaymentReceived {
* Transform the create payment receive DTO. * Transform the create payment receive DTO.
* @param {number} tenantId * @param {number} tenantId
* @param {ICustomer} customer * @param {ICustomer} customer
* @param {IPaymentReceiveCreateDTO} paymentReceiveDTO * @param {IPaymentReceivedCreateDTO} paymentReceiveDTO
* @returns * @returns
*/ */
private transformCreateDTOToModel = async ( private transformCreateDTOToModel = async (
tenantId: number, tenantId: number,
customer: ICustomer, customer: ICustomer,
paymentReceiveDTO: IPaymentReceiveCreateDTO paymentReceiveDTO: IPaymentReceivedCreateDTO
) => { ) => {
return this.transformer.transformPaymentReceiveDTOToModel( return this.transformer.transformPaymentReceiveDTOToModel(
tenantId, tenantId,

View File

@@ -1,8 +1,8 @@
import { Inject, Service } from 'typedi'; import { Inject, Service } from 'typedi';
import { Knex } from 'knex'; import { Knex } from 'knex';
import { import {
IPaymentReceiveDeletedPayload, IPaymentReceivedDeletedPayload,
IPaymentReceiveDeletingPayload, IPaymentReceivedDeletingPayload,
ISystemUser, ISystemUser,
} from '@/interfaces'; } from '@/interfaces';
import UnitOfWork from '@/services/UnitOfWork'; import UnitOfWork from '@/services/UnitOfWork';
@@ -33,7 +33,7 @@ export class DeletePaymentReceived {
* @async * @async
* @param {number} tenantId - Tenant id. * @param {number} tenantId - Tenant id.
* @param {Integer} paymentReceiveId - Payment receive id. * @param {Integer} paymentReceiveId - Payment receive id.
* @param {IPaymentReceive} paymentReceive - Payment receive object. * @param {IPaymentReceived} paymentReceive - Payment receive object.
*/ */
public async deletePaymentReceive( public async deletePaymentReceive(
tenantId: number, tenantId: number,
@@ -56,7 +56,7 @@ export class DeletePaymentReceived {
tenantId, tenantId,
oldPaymentReceive, oldPaymentReceive,
trx, trx,
} as IPaymentReceiveDeletingPayload); } as IPaymentReceivedDeletingPayload);
// Deletes the payment receive associated entries. // Deletes the payment receive associated entries.
await PaymentReceiveEntry.query(trx) await PaymentReceiveEntry.query(trx)
@@ -73,7 +73,7 @@ export class DeletePaymentReceived {
oldPaymentReceive, oldPaymentReceive,
authorizedUser, authorizedUser,
trx, trx,
} as IPaymentReceiveDeletedPayload); } as IPaymentReceivedDeletedPayload);
}); });
} }
} }

View File

@@ -2,10 +2,10 @@ import { Inject, Service } from 'typedi';
import { Knex } from 'knex'; import { Knex } from 'knex';
import { import {
ICustomer, ICustomer,
IPaymentReceive, IPaymentReceived,
IPaymentReceiveEditDTO, IPaymentReceivedEditDTO,
IPaymentReceiveEditedPayload, IPaymentReceivedEditedPayload,
IPaymentReceiveEditingPayload, IPaymentReceivedEditingPayload,
ISystemUser, ISystemUser,
} from '@/interfaces'; } from '@/interfaces';
import { PaymentReceiveDTOTransformer } from './PaymentReceivedDTOTransformer'; import { PaymentReceiveDTOTransformer } from './PaymentReceivedDTOTransformer';
@@ -46,12 +46,12 @@ export class EditPaymentReceived {
* @async * @async
* @param {number} tenantId - * @param {number} tenantId -
* @param {Integer} paymentReceiveId - * @param {Integer} paymentReceiveId -
* @param {IPaymentReceive} paymentReceive - * @param {IPaymentReceived} paymentReceive -
*/ */
public async editPaymentReceive( public async editPaymentReceive(
tenantId: number, tenantId: number,
paymentReceiveId: number, paymentReceiveId: number,
paymentReceiveDTO: IPaymentReceiveEditDTO, paymentReceiveDTO: IPaymentReceivedEditDTO,
authorizedUser: ISystemUser authorizedUser: ISystemUser
) { ) {
const { PaymentReceive, Contact } = this.tenancy.models(tenantId); const { PaymentReceive, Contact } = this.tenancy.models(tenantId);
@@ -131,7 +131,7 @@ export class EditPaymentReceived {
tenantId, tenantId,
oldPaymentReceive, oldPaymentReceive,
paymentReceiveDTO, paymentReceiveDTO,
} as IPaymentReceiveEditingPayload); } as IPaymentReceivedEditingPayload);
// Update the payment receive transaction. // Update the payment receive transaction.
const paymentReceive = await PaymentReceive.query( const paymentReceive = await PaymentReceive.query(
@@ -149,7 +149,7 @@ export class EditPaymentReceived {
paymentReceiveDTO, paymentReceiveDTO,
authorizedUser, authorizedUser,
trx, trx,
} as IPaymentReceiveEditedPayload); } as IPaymentReceivedEditedPayload);
return paymentReceive; return paymentReceive;
}); });
@@ -159,15 +159,15 @@ export class EditPaymentReceived {
* Transform the edit payment receive DTO. * Transform the edit payment receive DTO.
* @param {number} tenantId * @param {number} tenantId
* @param {ICustomer} customer * @param {ICustomer} customer
* @param {IPaymentReceiveEditDTO} paymentReceiveDTO * @param {IPaymentReceivedEditDTO} paymentReceiveDTO
* @param {IPaymentReceive} oldPaymentReceive * @param {IPaymentReceived} oldPaymentReceive
* @returns * @returns
*/ */
private transformEditDTOToModel = async ( private transformEditDTOToModel = async (
tenantId: number, tenantId: number,
customer: ICustomer, customer: ICustomer,
paymentReceiveDTO: IPaymentReceiveEditDTO, paymentReceiveDTO: IPaymentReceivedEditDTO,
oldPaymentReceive: IPaymentReceive oldPaymentReceive: IPaymentReceived
) => { ) => {
return this.transformer.transformPaymentReceiveDTOToModel( return this.transformer.transformPaymentReceiveDTOToModel(
tenantId, tenantId,

View File

@@ -1,5 +1,5 @@
import { ServiceError } from '@/exceptions'; import { ServiceError } from '@/exceptions';
import { IPaymentReceive } from '@/interfaces'; import { IPaymentReceived } from '@/interfaces';
import HasTenancyService from '@/services/Tenancy/TenancyService'; import HasTenancyService from '@/services/Tenancy/TenancyService';
import { Inject, Service } from 'typedi'; import { Inject, Service } from 'typedi';
import { ERRORS } from './constants'; import { ERRORS } from './constants';
@@ -18,12 +18,12 @@ export class GetPaymentReceived {
* Retrieve payment receive details. * Retrieve payment receive details.
* @param {number} tenantId - Tenant id. * @param {number} tenantId - Tenant id.
* @param {number} paymentReceiveId - Payment receive id. * @param {number} paymentReceiveId - Payment receive id.
* @return {Promise<IPaymentReceive>} * @return {Promise<IPaymentReceived>}
*/ */
public async getPaymentReceive( public async getPaymentReceive(
tenantId: number, tenantId: number,
paymentReceiveId: number paymentReceiveId: number
): Promise<IPaymentReceive> { ): Promise<IPaymentReceived> {
const { PaymentReceive } = this.tenancy.models(tenantId); const { PaymentReceive } = this.tenancy.models(tenantId);
const paymentReceive = await PaymentReceive.query() const paymentReceive = await PaymentReceive.query()

View File

@@ -4,7 +4,7 @@ import { TemplateInjectable } from '@/services/TemplateInjectable/TemplateInject
import { GetPaymentReceived } from './GetPaymentReceived'; import { GetPaymentReceived } from './GetPaymentReceived';
@Service() @Service()
export default class GetPaymentReceivePdf { export default class GetPaymentReceivedPdf {
@Inject() @Inject()
private chromiumlyTenancy: ChromiumlyTenancy; private chromiumlyTenancy: ChromiumlyTenancy;
@@ -17,7 +17,7 @@ export default class GetPaymentReceivePdf {
/** /**
* Retrieve sale invoice pdf content. * Retrieve sale invoice pdf content.
* @param {number} tenantId - * @param {number} tenantId -
* @param {IPaymentReceive} paymentReceive - * @param {IPaymentReceived} paymentReceive -
* @returns {Promise<Buffer>} * @returns {Promise<Buffer>}
*/ */
async getPaymentReceivePdf( async getPaymentReceivePdf(

View File

@@ -3,8 +3,8 @@ import * as R from 'ramda';
import { import {
IFilterMeta, IFilterMeta,
IPaginationMeta, IPaginationMeta,
IPaymentReceive, IPaymentReceived,
IPaymentReceivesFilter, IPaymentsReceivedFilter,
} from '@/interfaces'; } from '@/interfaces';
import { PaymentReceiveTransfromer } from './PaymentReceivedTransformer'; import { PaymentReceiveTransfromer } from './PaymentReceivedTransformer';
import HasTenancyService from '@/services/Tenancy/TenancyService'; import HasTenancyService from '@/services/Tenancy/TenancyService';
@@ -25,13 +25,13 @@ export class GetPaymentReceives {
/** /**
* Retrieve payment receives paginated and filterable list. * Retrieve payment receives paginated and filterable list.
* @param {number} tenantId * @param {number} tenantId
* @param {IPaymentReceivesFilter} paymentReceivesFilter * @param {IPaymentsReceivedFilter} paymentReceivesFilter
*/ */
public async getPaymentReceives( public async getPaymentReceives(
tenantId: number, tenantId: number,
filterDTO: IPaymentReceivesFilter filterDTO: IPaymentsReceivedFilter
): Promise<{ ): Promise<{
paymentReceives: IPaymentReceive[]; paymentReceives: IPaymentReceived[];
pagination: IPaginationMeta; pagination: IPaginationMeta;
filterMeta: IFilterMeta; filterMeta: IFilterMeta;
}> { }> {

View File

@@ -1,11 +1,11 @@
import { import {
IFilterMeta, IFilterMeta,
IPaginationMeta, IPaginationMeta,
IPaymentReceive, IPaymentReceived,
IPaymentReceiveCreateDTO, IPaymentReceivedCreateDTO,
IPaymentReceiveEditDTO, IPaymentReceivedEditDTO,
IPaymentReceiveSmsDetails, IPaymentReceivedSmsDetails,
IPaymentReceivesFilter, IPaymentsReceivedFilter,
ISystemUser, ISystemUser,
PaymentReceiveMailOptsDTO, PaymentReceiveMailOptsDTO,
} from '@/interfaces'; } from '@/interfaces';
@@ -17,7 +17,7 @@ import { GetPaymentReceives } from './GetPaymentsReceived';
import { GetPaymentReceived } from './GetPaymentReceived'; import { GetPaymentReceived } from './GetPaymentReceived';
import { GetPaymentReceivedInvoices } from './GetPaymentReceivedInvoices'; import { GetPaymentReceivedInvoices } from './GetPaymentReceivedInvoices';
import { PaymentReceiveNotifyBySms } from './PaymentReceivedSmsNotify'; import { PaymentReceiveNotifyBySms } from './PaymentReceivedSmsNotify';
import GetPaymentReceivePdf from './GetPaymentReceivedPdf'; import GetPaymentReceivedPdf from './GetPaymentReceivedPdf';
import { SendPaymentReceiveMailNotification } from './PaymentReceivedMailNotification'; import { SendPaymentReceiveMailNotification } from './PaymentReceivedMailNotification';
@Service() @Service()
@@ -47,18 +47,18 @@ export class PaymentReceivesApplication {
private paymentMailNotify: SendPaymentReceiveMailNotification; private paymentMailNotify: SendPaymentReceiveMailNotification;
@Inject() @Inject()
private getPaymentReceivePdfService: GetPaymentReceivePdf; private getPaymentReceivePdfService: GetPaymentReceivedPdf;
/** /**
* Creates a new payment receive. * Creates a new payment receive.
* @param {number} tenantId * @param {number} tenantId
* @param {IPaymentReceiveCreateDTO} paymentReceiveDTO * @param {IPaymentReceivedCreateDTO} paymentReceiveDTO
* @param {ISystemUser} authorizedUser * @param {ISystemUser} authorizedUser
* @returns * @returns
*/ */
public createPaymentReceived( public createPaymentReceived(
tenantId: number, tenantId: number,
paymentReceiveDTO: IPaymentReceiveCreateDTO, paymentReceiveDTO: IPaymentReceivedCreateDTO,
authorizedUser: ISystemUser authorizedUser: ISystemUser
) { ) {
return this.createPaymentReceivedService.createPaymentReceived( return this.createPaymentReceivedService.createPaymentReceived(
@@ -72,14 +72,14 @@ export class PaymentReceivesApplication {
* Edit details the given payment receive with associated entries. * Edit details the given payment receive with associated entries.
* @param {number} tenantId * @param {number} tenantId
* @param {number} paymentReceiveId * @param {number} paymentReceiveId
* @param {IPaymentReceiveEditDTO} paymentReceiveDTO * @param {IPaymentReceivedEditDTO} paymentReceiveDTO
* @param {ISystemUser} authorizedUser * @param {ISystemUser} authorizedUser
* @returns * @returns
*/ */
public editPaymentReceive( public editPaymentReceive(
tenantId: number, tenantId: number,
paymentReceiveId: number, paymentReceiveId: number,
paymentReceiveDTO: IPaymentReceiveEditDTO, paymentReceiveDTO: IPaymentReceivedEditDTO,
authorizedUser: ISystemUser authorizedUser: ISystemUser
) { ) {
return this.editPaymentReceivedService.editPaymentReceive( return this.editPaymentReceivedService.editPaymentReceive(
@@ -112,14 +112,14 @@ export class PaymentReceivesApplication {
/** /**
* Retrieve payment receives paginated and filterable. * Retrieve payment receives paginated and filterable.
* @param {number} tenantId * @param {number} tenantId
* @param {IPaymentReceivesFilter} filterDTO * @param {IPaymentsReceivedFilter} filterDTO
* @returns * @returns
*/ */
public async getPaymentReceives( public async getPaymentReceives(
tenantId: number, tenantId: number,
filterDTO: IPaymentReceivesFilter filterDTO: IPaymentsReceivedFilter
): Promise<{ ): Promise<{
paymentReceives: IPaymentReceive[]; paymentReceives: IPaymentReceived[];
pagination: IPaginationMeta; pagination: IPaginationMeta;
filterMeta: IFilterMeta; filterMeta: IFilterMeta;
}> { }> {
@@ -133,12 +133,12 @@ export class PaymentReceivesApplication {
* Retrieves the given payment receive. * Retrieves the given payment receive.
* @param {number} tenantId * @param {number} tenantId
* @param {number} paymentReceiveId * @param {number} paymentReceiveId
* @returns {Promise<IPaymentReceive>} * @returns {Promise<IPaymentReceived>}
*/ */
public async getPaymentReceive( public async getPaymentReceive(
tenantId: number, tenantId: number,
paymentReceiveId: number paymentReceiveId: number
): Promise<IPaymentReceive> { ): Promise<IPaymentReceived> {
return this.getPaymentReceivedService.getPaymentReceive( return this.getPaymentReceivedService.getPaymentReceive(
tenantId, tenantId,
paymentReceiveId paymentReceiveId
@@ -175,7 +175,7 @@ export class PaymentReceivesApplication {
public getPaymentSmsDetails = async ( public getPaymentSmsDetails = async (
tenantId: number, tenantId: number,
paymentReceiveId: number paymentReceiveId: number
): Promise<IPaymentReceiveSmsDetails> => { ): Promise<IPaymentReceivedSmsDetails> => {
return this.paymentSmsNotify.smsDetails(tenantId, paymentReceiveId); return this.paymentSmsNotify.smsDetails(tenantId, paymentReceiveId);
}; };

View File

@@ -3,9 +3,9 @@ import { Inject, Service } from 'typedi';
import { omit, sumBy } from 'lodash'; import { omit, sumBy } from 'lodash';
import { import {
ICustomer, ICustomer,
IPaymentReceive, IPaymentReceived,
IPaymentReceiveCreateDTO, IPaymentReceivedCreateDTO,
IPaymentReceiveEditDTO, IPaymentReceivedEditDTO,
} from '@/interfaces'; } from '@/interfaces';
import { PaymentReceivedValidators } from './PaymentReceivedValidators'; import { PaymentReceivedValidators } from './PaymentReceivedValidators';
import { PaymentReceivedIncrement } from './PaymentReceivedIncrement'; import { PaymentReceivedIncrement } from './PaymentReceivedIncrement';
@@ -26,16 +26,16 @@ export class PaymentReceiveDTOTransformer {
/** /**
* Transformes the create payment receive DTO to model object. * Transformes the create payment receive DTO to model object.
* @param {number} tenantId * @param {number} tenantId
* @param {IPaymentReceiveCreateDTO|IPaymentReceiveEditDTO} paymentReceiveDTO - Payment receive DTO. * @param {IPaymentReceivedCreateDTO|IPaymentReceivedEditDTO} paymentReceiveDTO - Payment receive DTO.
* @param {IPaymentReceive} oldPaymentReceive - * @param {IPaymentReceived} oldPaymentReceive -
* @return {IPaymentReceive} * @return {IPaymentReceived}
*/ */
public async transformPaymentReceiveDTOToModel( public async transformPaymentReceiveDTOToModel(
tenantId: number, tenantId: number,
customer: ICustomer, customer: ICustomer,
paymentReceiveDTO: IPaymentReceiveCreateDTO | IPaymentReceiveEditDTO, paymentReceiveDTO: IPaymentReceivedCreateDTO | IPaymentReceivedEditDTO,
oldPaymentReceive?: IPaymentReceive oldPaymentReceive?: IPaymentReceived
): Promise<IPaymentReceive> { ): Promise<IPaymentReceived> {
const amount = const amount =
paymentReceiveDTO.amount ?? paymentReceiveDTO.amount ??
sumBy(paymentReceiveDTO.entries, 'paymentAmount'); sumBy(paymentReceiveDTO.entries, 'paymentAmount');
@@ -65,7 +65,7 @@ export class PaymentReceiveDTOTransformer {
})), })),
}; };
return R.compose( return R.compose(
this.branchDTOTransform.transformDTO<IPaymentReceive>(tenantId) this.branchDTOTransform.transformDTO<IPaymentReceived>(tenantId)
)(initialDTO); )(initialDTO);
} }
} }

View File

@@ -4,7 +4,7 @@ import { Knex } from 'knex';
import Ledger from '@/services/Accounting/Ledger'; import Ledger from '@/services/Accounting/Ledger';
import TenancyService from '@/services/Tenancy/TenancyService'; import TenancyService from '@/services/Tenancy/TenancyService';
import { import {
IPaymentReceive, IPaymentReceived,
ILedgerEntry, ILedgerEntry,
AccountNormal, AccountNormal,
IPaymentReceiveGLCommonEntry, IPaymentReceiveGLCommonEntry,
@@ -93,14 +93,14 @@ export class PaymentReceivedGLEntries {
/** /**
* Retrieves the payment receive general ledger. * Retrieves the payment receive general ledger.
* @param {number} tenantId - * @param {number} tenantId -
* @param {IPaymentReceive} paymentReceive - * @param {IPaymentReceived} paymentReceive -
* @param {string} baseCurrencyCode - * @param {string} baseCurrencyCode -
* @param {Knex.Transaction} trx - * @param {Knex.Transaction} trx -
* @returns {Ledger} * @returns {Ledger}
*/ */
public getPaymentReceiveGLedger = async ( public getPaymentReceiveGLedger = async (
tenantId: number, tenantId: number,
paymentReceive: IPaymentReceive, paymentReceive: IPaymentReceived,
baseCurrencyCode: string, baseCurrencyCode: string,
trx?: Knex.Transaction trx?: Knex.Transaction
): Promise<Ledger> => { ): Promise<Ledger> => {
@@ -132,7 +132,7 @@ export class PaymentReceivedGLEntries {
* @returns {number} * @returns {number}
*/ */
private getPaymentExGainOrLoss = ( private getPaymentExGainOrLoss = (
paymentReceive: IPaymentReceive paymentReceive: IPaymentReceived
): number => { ): number => {
return sumBy(paymentReceive.entries, (entry) => { return sumBy(paymentReceive.entries, (entry) => {
const paymentLocalAmount = const paymentLocalAmount =
@@ -145,11 +145,11 @@ export class PaymentReceivedGLEntries {
/** /**
* Retrieves the common entry of payment receive. * Retrieves the common entry of payment receive.
* @param {IPaymentReceive} paymentReceive * @param {IPaymentReceived} paymentReceive
* @returns {} * @returns {}
*/ */
private getPaymentReceiveCommonEntry = ( private getPaymentReceiveCommonEntry = (
paymentReceive: IPaymentReceive paymentReceive: IPaymentReceived
): IPaymentReceiveGLCommonEntry => { ): IPaymentReceiveGLCommonEntry => {
return { return {
debit: 0, debit: 0,
@@ -174,14 +174,14 @@ export class PaymentReceivedGLEntries {
/** /**
* Retrieves the payment exchange gain/loss entry. * Retrieves the payment exchange gain/loss entry.
* @param {IPaymentReceive} paymentReceive - * @param {IPaymentReceived} paymentReceive -
* @param {number} ARAccountId - * @param {number} ARAccountId -
* @param {number} exchangeGainOrLossAccountId - * @param {number} exchangeGainOrLossAccountId -
* @param {string} baseCurrencyCode - * @param {string} baseCurrencyCode -
* @returns {ILedgerEntry[]} * @returns {ILedgerEntry[]}
*/ */
private getPaymentExchangeGainLossEntry = ( private getPaymentExchangeGainLossEntry = (
paymentReceive: IPaymentReceive, paymentReceive: IPaymentReceived,
ARAccountId: number, ARAccountId: number,
exchangeGainOrLossAccountId: number, exchangeGainOrLossAccountId: number,
baseCurrencyCode: string baseCurrencyCode: string
@@ -219,11 +219,11 @@ export class PaymentReceivedGLEntries {
/** /**
* Retrieves the payment deposit GL entry. * Retrieves the payment deposit GL entry.
* @param {IPaymentReceive} paymentReceive * @param {IPaymentReceived} paymentReceive
* @returns {ILedgerEntry} * @returns {ILedgerEntry}
*/ */
private getPaymentDepositGLEntry = ( private getPaymentDepositGLEntry = (
paymentReceive: IPaymentReceive paymentReceive: IPaymentReceived
): ILedgerEntry => { ): ILedgerEntry => {
const commonJournal = this.getPaymentReceiveCommonEntry(paymentReceive); const commonJournal = this.getPaymentReceiveCommonEntry(paymentReceive);
@@ -238,12 +238,12 @@ export class PaymentReceivedGLEntries {
/** /**
* Retrieves the payment receivable entry. * Retrieves the payment receivable entry.
* @param {IPaymentReceive} paymentReceive * @param {IPaymentReceived} paymentReceive
* @param {number} ARAccountId * @param {number} ARAccountId
* @returns {ILedgerEntry} * @returns {ILedgerEntry}
*/ */
private getPaymentReceivableEntry = ( private getPaymentReceivableEntry = (
paymentReceive: IPaymentReceive, paymentReceive: IPaymentReceived,
ARAccountId: number ARAccountId: number
): ILedgerEntry => { ): ILedgerEntry => {
const commonJournal = this.getPaymentReceiveCommonEntry(paymentReceive); const commonJournal = this.getPaymentReceiveCommonEntry(paymentReceive);
@@ -267,14 +267,14 @@ export class PaymentReceivedGLEntries {
* - Payment account [current asset] -> Credit * - Payment account [current asset] -> Credit
* *
* @param {number} tenantId * @param {number} tenantId
* @param {IPaymentReceive} paymentRecieve - Payment receive model. * @param {IPaymentReceived} paymentRecieve - Payment receive model.
* @param {number} ARAccountId - A/R account id. * @param {number} ARAccountId - A/R account id.
* @param {number} exGainOrLossAccountId - Exchange gain/loss account id. * @param {number} exGainOrLossAccountId - Exchange gain/loss account id.
* @param {string} baseCurrency - Base currency code. * @param {string} baseCurrency - Base currency code.
* @returns {Promise<ILedgerEntry>} * @returns {Promise<ILedgerEntry>}
*/ */
public getPaymentReceiveGLEntries = ( public getPaymentReceiveGLEntries = (
paymentReceive: IPaymentReceive, paymentReceive: IPaymentReceived,
ARAccountId: number, ARAccountId: number,
exGainOrLossAccountId: number, exGainOrLossAccountId: number,
baseCurrency: string baseCurrency: string

View File

@@ -1,6 +1,6 @@
import { Inject, Service } from 'typedi'; import { Inject, Service } from 'typedi';
import { Knex } from 'knex'; import { Knex } from 'knex';
import { IPaymentReceiveEntryDTO } from '@/interfaces'; import { IPaymentReceivedEntryDTO } from '@/interfaces';
import HasTenancyService from '@/services/Tenancy/TenancyService'; import HasTenancyService from '@/services/Tenancy/TenancyService';
import { entriesAmountDiff } from '@/utils'; import { entriesAmountDiff } from '@/utils';
@@ -19,8 +19,8 @@ export class PaymentReceivedInvoiceSync {
*/ */
public async saveChangeInvoicePaymentAmount( public async saveChangeInvoicePaymentAmount(
tenantId: number, tenantId: number,
newPaymentReceiveEntries: IPaymentReceiveEntryDTO[], newPaymentReceiveEntries: IPaymentReceivedEntryDTO[],
oldPaymentReceiveEntries?: IPaymentReceiveEntryDTO[], oldPaymentReceiveEntries?: IPaymentReceivedEntryDTO[],
trx?: Knex.Transaction trx?: Knex.Transaction
): Promise<void> { ): Promise<void> {
const { SaleInvoice } = this.tenancy.models(tenantId); const { SaleInvoice } = this.tenancy.models(tenantId);

View File

@@ -2,10 +2,10 @@ import { Service, Inject } from 'typedi';
import HasTenancyService from '@/services/Tenancy/TenancyService'; import HasTenancyService from '@/services/Tenancy/TenancyService';
import events from '@/subscribers/events'; import events from '@/subscribers/events';
import { import {
IPaymentReceiveSmsDetails, IPaymentReceivedSmsDetails,
SMS_NOTIFICATION_KEY, SMS_NOTIFICATION_KEY,
IPaymentReceive, IPaymentReceived,
IPaymentReceiveEntry, IPaymentReceivedEntry,
} from '@/interfaces'; } from '@/interfaces';
import SmsNotificationsSettingsService from '@/services/Settings/SmsNotificationsSettings'; import SmsNotificationsSettingsService from '@/services/Settings/SmsNotificationsSettings';
import { formatNumber, formatSmsMessage } from 'utils'; import { formatNumber, formatSmsMessage } from 'utils';
@@ -71,12 +71,12 @@ export class PaymentReceiveNotifyBySms {
/** /**
* Sends the payment details sms notification of the given customer. * Sends the payment details sms notification of the given customer.
* @param {number} tenantId * @param {number} tenantId
* @param {IPaymentReceive} paymentReceive * @param {IPaymentReceived} paymentReceive
* @param {ICustomer} customer * @param {ICustomer} customer
*/ */
private sendSmsNotification = async ( private sendSmsNotification = async (
tenantId: number, tenantId: number,
paymentReceive: IPaymentReceive paymentReceive: IPaymentReceived
) => { ) => {
const smsClient = this.tenancy.smsClient(tenantId); const smsClient = this.tenancy.smsClient(tenantId);
const tenantMetadata = await TenantMetadata.query().findOne({ tenantId }); const tenantMetadata = await TenantMetadata.query().findOne({ tenantId });
@@ -116,12 +116,12 @@ export class PaymentReceiveNotifyBySms {
/** /**
* Formates the payment receive details sms message. * Formates the payment receive details sms message.
* @param {number} tenantId - * @param {number} tenantId -
* @param {IPaymentReceive} payment - * @param {IPaymentReceived} payment -
* @param {ICustomer} customer - * @param {ICustomer} customer -
*/ */
private formattedPaymentDetailsMessage = ( private formattedPaymentDetailsMessage = (
tenantId: number, tenantId: number,
payment: IPaymentReceive, payment: IPaymentReceived,
tenantMetadata: TenantMetadata tenantMetadata: TenantMetadata
) => { ) => {
const notification = this.smsNotificationsSettings.getSmsNotificationMeta( const notification = this.smsNotificationsSettings.getSmsNotificationMeta(
@@ -138,14 +138,14 @@ export class PaymentReceiveNotifyBySms {
/** /**
* Formattes the payment details sms notification messafge. * Formattes the payment details sms notification messafge.
* @param {string} smsMessage * @param {string} smsMessage
* @param {IPaymentReceive} payment * @param {IPaymentReceived} payment
* @param {ICustomer} customer * @param {ICustomer} customer
* @param {TenantMetadata} tenantMetadata * @param {TenantMetadata} tenantMetadata
* @returns {string} * @returns {string}
*/ */
private formatPaymentDetailsMessage = ( private formatPaymentDetailsMessage = (
smsMessage: string, smsMessage: string,
payment: IPaymentReceive, payment: IPaymentReceived,
tenantMetadata: any tenantMetadata: any
): string => { ): string => {
const invoiceNumbers = this.stringifyPaymentInvoicesNumber(payment); const invoiceNumbers = this.stringifyPaymentInvoicesNumber(payment);
@@ -167,12 +167,12 @@ export class PaymentReceiveNotifyBySms {
/** /**
* Stringify payment receive invoices to numbers as string. * Stringify payment receive invoices to numbers as string.
* @param {IPaymentReceive} payment * @param {IPaymentReceived} payment
* @returns {string} * @returns {string}
*/ */
private stringifyPaymentInvoicesNumber(payment: IPaymentReceive) { private stringifyPaymentInvoicesNumber(payment: IPaymentReceived) {
const invoicesNumberes = payment.entries.map( const invoicesNumberes = payment.entries.map(
(entry: IPaymentReceiveEntry) => entry.invoice.invoiceNo (entry: IPaymentReceivedEntry) => entry.invoice.invoiceNo
); );
return invoicesNumberes.join(', '); return invoicesNumberes.join(', ');
} }
@@ -185,7 +185,7 @@ export class PaymentReceiveNotifyBySms {
public smsDetails = async ( public smsDetails = async (
tenantId: number, tenantId: number,
paymentReceiveid: number paymentReceiveid: number
): Promise<IPaymentReceiveSmsDetails> => { ): Promise<IPaymentReceivedSmsDetails> => {
const { PaymentReceive } = this.tenancy.models(tenantId); const { PaymentReceive } = this.tenancy.models(tenantId);
// Retrieve the payment receive or throw not found service error. // Retrieve the payment receive or throw not found service error.

View File

@@ -1,4 +1,4 @@
import { IPaymentReceive, IPaymentReceiveEntry } from '@/interfaces'; import { IPaymentReceived, IPaymentReceivedEntry } from '@/interfaces';
import { Transformer } from '@/lib/Transformer/Transformer'; import { Transformer } from '@/lib/Transformer/Transformer';
import { formatNumber } from 'utils'; import { formatNumber } from 'utils';
import { PaymentReceivedEntryTransfromer } from './PaymentReceivedEntryTransformer'; import { PaymentReceivedEntryTransfromer } from './PaymentReceivedEntryTransformer';
@@ -24,25 +24,25 @@ export class PaymentReceiveTransfromer extends Transformer {
* @param {ISaleInvoice} invoice * @param {ISaleInvoice} invoice
* @returns {String} * @returns {String}
*/ */
protected formattedPaymentDate = (payment: IPaymentReceive): string => { protected formattedPaymentDate = (payment: IPaymentReceived): string => {
return this.formatDate(payment.paymentDate); return this.formatDate(payment.paymentDate);
}; };
/** /**
* Retrieves the formatted created at date. * Retrieves the formatted created at date.
* @param {IPaymentReceive} payment * @param {IPaymentReceived} payment
* @returns {string} * @returns {string}
*/ */
protected formattedCreatedAt = (payment: IPaymentReceive): string => { protected formattedCreatedAt = (payment: IPaymentReceived): string => {
return this.formatDate(payment.createdAt); return this.formatDate(payment.createdAt);
}; };
/** /**
* Retrieve the formatted payment subtotal. * Retrieve the formatted payment subtotal.
* @param {IPaymentReceive} payment * @param {IPaymentReceived} payment
* @returns {string} * @returns {string}
*/ */
protected subtotalFormatted = (payment: IPaymentReceive): string => { protected subtotalFormatted = (payment: IPaymentReceived): string => {
return formatNumber(payment.amount, { return formatNumber(payment.amount, {
currencyCode: payment.currencyCode, currencyCode: payment.currencyCode,
money: false, money: false,
@@ -54,25 +54,25 @@ export class PaymentReceiveTransfromer extends Transformer {
* @param {ISaleInvoice} invoice * @param {ISaleInvoice} invoice
* @returns {string} * @returns {string}
*/ */
protected formattedAmount = (payment: IPaymentReceive): string => { protected formattedAmount = (payment: IPaymentReceived): string => {
return formatNumber(payment.amount, { currencyCode: payment.currencyCode }); return formatNumber(payment.amount, { currencyCode: payment.currencyCode });
}; };
/** /**
* Retrieve the formatted exchange rate. * Retrieve the formatted exchange rate.
* @param {IPaymentReceive} payment * @param {IPaymentReceived} payment
* @returns {string} * @returns {string}
*/ */
protected formattedExchangeRate = (payment: IPaymentReceive): string => { protected formattedExchangeRate = (payment: IPaymentReceived): string => {
return formatNumber(payment.exchangeRate, { money: false }); return formatNumber(payment.exchangeRate, { money: false });
}; };
/** /**
* Retrieves the payment entries. * Retrieves the payment entries.
* @param {IPaymentReceive} payment * @param {IPaymentReceived} payment
* @returns {IPaymentReceiveEntry[]} * @returns {IPaymentReceivedEntry[]}
*/ */
protected entries = (payment: IPaymentReceive): IPaymentReceiveEntry[] => { protected entries = (payment: IPaymentReceived): IPaymentReceivedEntry[] => {
return this.item(payment.entries, new PaymentReceivedEntryTransfromer()); return this.item(payment.entries, new PaymentReceivedEntryTransfromer());
}; };
} }

View File

@@ -2,10 +2,10 @@ import { Inject, Service } from 'typedi';
import { difference, sumBy } from 'lodash'; import { difference, sumBy } from 'lodash';
import { import {
IAccount, IAccount,
IPaymentReceive, IPaymentReceived,
IPaymentReceiveEditDTO, IPaymentReceivedEditDTO,
IPaymentReceiveEntry, IPaymentReceivedEntry,
IPaymentReceiveEntryDTO, IPaymentReceivedEntryDTO,
ISaleInvoice, ISaleInvoice,
} from '@/interfaces'; } from '@/interfaces';
import { ServiceError } from '@/exceptions'; import { ServiceError } from '@/exceptions';
@@ -58,7 +58,7 @@ export class PaymentReceivedValidators {
* Validates the invoices IDs existance. * Validates the invoices IDs existance.
* @param {number} tenantId - * @param {number} tenantId -
* @param {number} customerId - * @param {number} customerId -
* @param {IPaymentReceiveEntryDTO[]} paymentReceiveEntries - * @param {IPaymentReceivedEntryDTO[]} paymentReceiveEntries -
*/ */
public async validateInvoicesIDsExistance( public async validateInvoicesIDsExistance(
tenantId: number, tenantId: number,
@@ -100,12 +100,12 @@ export class PaymentReceivedValidators {
*/ */
public async validateInvoicesPaymentsAmount( public async validateInvoicesPaymentsAmount(
tenantId: number, tenantId: number,
paymentReceiveEntries: IPaymentReceiveEntryDTO[], paymentReceiveEntries: IPaymentReceivedEntryDTO[],
oldPaymentEntries: IPaymentReceiveEntry[] = [] oldPaymentEntries: IPaymentReceivedEntry[] = []
) { ) {
const { SaleInvoice } = this.tenancy.models(tenantId); const { SaleInvoice } = this.tenancy.models(tenantId);
const invoicesIds = paymentReceiveEntries.map( const invoicesIds = paymentReceiveEntries.map(
(e: IPaymentReceiveEntryDTO) => e.invoiceId (e: IPaymentReceivedEntryDTO) => e.invoiceId
); );
const storedInvoices = await SaleInvoice.query().whereIn('id', invoicesIds); const storedInvoices = await SaleInvoice.query().whereIn('id', invoicesIds);
@@ -124,7 +124,7 @@ export class PaymentReceivedValidators {
const hasWrongPaymentAmount: any[] = []; const hasWrongPaymentAmount: any[] = [];
paymentReceiveEntries.forEach( paymentReceiveEntries.forEach(
(entry: IPaymentReceiveEntryDTO, index: number) => { (entry: IPaymentReceivedEntryDTO, index: number) => {
const entryInvoice = storedInvoicesMap.get(entry.invoiceId); const entryInvoice = storedInvoicesMap.get(entry.invoiceId);
const { dueAmount } = entryInvoice; const { dueAmount } = entryInvoice;
@@ -140,9 +140,9 @@ export class PaymentReceivedValidators {
/** /**
* Validate the payment receive number require. * Validate the payment receive number require.
* @param {IPaymentReceive} paymentReceiveObj * @param {IPaymentReceived} paymentReceiveObj
*/ */
public validatePaymentReceiveNoRequire(paymentReceiveObj: IPaymentReceive) { public validatePaymentReceiveNoRequire(paymentReceiveObj: IPaymentReceived) {
if (!paymentReceiveObj.paymentReceiveNo) { if (!paymentReceiveObj.paymentReceiveNo) {
throw new ServiceError(ERRORS.PAYMENT_RECEIVE_NO_IS_REQUIRED); throw new ServiceError(ERRORS.PAYMENT_RECEIVE_NO_IS_REQUIRED);
} }
@@ -152,12 +152,12 @@ export class PaymentReceivedValidators {
* Validate the payment receive entries IDs existance. * Validate the payment receive entries IDs existance.
* @param {number} tenantId * @param {number} tenantId
* @param {number} paymentReceiveId * @param {number} paymentReceiveId
* @param {IPaymentReceiveEntryDTO[]} paymentReceiveEntries * @param {IPaymentReceivedEntryDTO[]} paymentReceiveEntries
*/ */
public async validateEntriesIdsExistance( public async validateEntriesIdsExistance(
tenantId: number, tenantId: number,
paymentReceiveId: number, paymentReceiveId: number,
paymentReceiveEntries: IPaymentReceiveEntryDTO[] paymentReceiveEntries: IPaymentReceivedEntryDTO[]
) { ) {
const { PaymentReceiveEntry } = this.tenancy.models(tenantId); const { PaymentReceiveEntry } = this.tenancy.models(tenantId);
@@ -189,12 +189,12 @@ export class PaymentReceivedValidators {
/** /**
* Validate the payment customer whether modified. * Validate the payment customer whether modified.
* @param {IPaymentReceiveEditDTO} paymentReceiveDTO * @param {IPaymentReceivedEditDTO} paymentReceiveDTO
* @param {IPaymentReceive} oldPaymentReceive * @param {IPaymentReceived} oldPaymentReceive
*/ */
public validateCustomerNotModified( public validateCustomerNotModified(
paymentReceiveDTO: IPaymentReceiveEditDTO, paymentReceiveDTO: IPaymentReceivedEditDTO,
oldPaymentReceive: IPaymentReceive oldPaymentReceive: IPaymentReceived
) { ) {
if (paymentReceiveDTO.customerId !== oldPaymentReceive.customerId) { if (paymentReceiveDTO.customerId !== oldPaymentReceive.customerId) {
throw new ServiceError(ERRORS.PAYMENT_CUSTOMER_SHOULD_NOT_UPDATE); throw new ServiceError(ERRORS.PAYMENT_CUSTOMER_SHOULD_NOT_UPDATE);
@@ -230,7 +230,7 @@ export class PaymentReceivedValidators {
async getPaymentReceiveOrThrowError( async getPaymentReceiveOrThrowError(
tenantId: number, tenantId: number,
paymentReceiveId: number paymentReceiveId: number
): Promise<IPaymentReceive> { ): Promise<IPaymentReceived> {
const { PaymentReceive } = this.tenancy.models(tenantId); const { PaymentReceive } = this.tenancy.models(tenantId);
const paymentReceive = await PaymentReceive.query() const paymentReceive = await PaymentReceive.query()
.withGraphFetched('entries') .withGraphFetched('entries')

View File

@@ -1,5 +1,5 @@
import { Inject, Service } from 'typedi'; import { Inject, Service } from 'typedi';
import { IAccountsStructureType, IPaymentReceivesFilter } from '@/interfaces'; import { IAccountsStructureType, IPaymentsReceivedFilter } from '@/interfaces';
import { Exportable } from '@/services/Export/Exportable'; import { Exportable } from '@/services/Export/Exportable';
import { PaymentReceivesApplication } from './PaymentReceivedApplication'; import { PaymentReceivesApplication } from './PaymentReceivedApplication';
@@ -11,17 +11,17 @@ export class PaymentsReceivedExportable extends Exportable {
/** /**
* Retrieves the accounts data to exportable sheet. * Retrieves the accounts data to exportable sheet.
* @param {number} tenantId * @param {number} tenantId
* @param {IPaymentReceivesFilter} query - * @param {IPaymentsReceivedFilter} query -
* @returns * @returns
*/ */
public exportable(tenantId: number, query: IPaymentReceivesFilter) { public exportable(tenantId: number, query: IPaymentsReceivedFilter) {
const parsedQuery = { const parsedQuery = {
sortOrder: 'desc', sortOrder: 'desc',
columnSortBy: 'created_at', columnSortBy: 'created_at',
inactiveMode: false, inactiveMode: false,
...query, ...query,
structure: IAccountsStructureType.Flat, structure: IAccountsStructureType.Flat,
} as IPaymentReceivesFilter; } as IPaymentsReceivedFilter;
return this.paymentReceivedApp return this.paymentReceivedApp
.getPaymentReceives(tenantId, parsedQuery) .getPaymentReceives(tenantId, parsedQuery)

View File

@@ -1,6 +1,6 @@
import { Inject, Service } from 'typedi'; import { Inject, Service } from 'typedi';
import { Knex } from 'knex'; import { Knex } from 'knex';
import { IPaymentReceiveCreateDTO } from '@/interfaces'; import { IPaymentReceivedCreateDTO } from '@/interfaces';
import { Importable } from '@/services/Import/Importable'; import { Importable } from '@/services/Import/Importable';
import { CreatePaymentReceived } from './CreatePaymentReceived'; import { CreatePaymentReceived } from './CreatePaymentReceived';
import { PaymentsReceiveSampleData } from './constants'; import { PaymentsReceiveSampleData } from './constants';
@@ -18,7 +18,7 @@ export class PaymentsReceivedImportable extends Importable {
*/ */
public importable( public importable(
tenantId: number, tenantId: number,
createPaymentDTO: IPaymentReceiveCreateDTO, createPaymentDTO: IPaymentReceivedCreateDTO,
trx?: Knex.Transaction trx?: Knex.Transaction
) { ) {
return this.createPaymentReceiveService.createPaymentReceived( return this.createPaymentReceiveService.createPaymentReceived(

View File

@@ -3,7 +3,7 @@ import { omit } from 'lodash';
import { import {
ISaleInvoice, ISaleInvoice,
IPaymentReceivePageEntry, IPaymentReceivePageEntry,
IPaymentReceive, IPaymentReceived,
ISystemUser, ISystemUser,
} from '@/interfaces'; } from '@/interfaces';
import TenancyService from '@/services/Tenancy/TenancyService'; import TenancyService from '@/services/Tenancy/TenancyService';
@@ -65,7 +65,7 @@ export default class PaymentsReceivedPages {
tenantId: number, tenantId: number,
paymentReceiveId: number paymentReceiveId: number
): Promise<{ ): Promise<{
paymentReceive: Omit<IPaymentReceive, 'entries'>; paymentReceive: Omit<IPaymentReceived, 'entries'>;
entries: IPaymentReceivePageEntry[]; entries: IPaymentReceivePageEntry[];
}> { }> {
const { PaymentReceive, SaleInvoice } = this.tenancy.models(tenantId); const { PaymentReceive, SaleInvoice } = this.tenancy.models(tenantId);

View File

@@ -5,9 +5,9 @@ import {
ISaleInvoiceCreatingPaylaod, ISaleInvoiceCreatingPaylaod,
ISaleReceiptDeletingPayload, ISaleReceiptDeletingPayload,
ICreditNoteDeletingPayload, ICreditNoteDeletingPayload,
IPaymentReceiveCreatingPayload, IPaymentReceivedCreatingPayload,
IRefundCreditNoteDeletingPayload, IRefundCreditNoteDeletingPayload,
IPaymentReceiveDeletingPayload, IPaymentReceivedDeletingPayload,
ISaleEstimateDeletingPayload, ISaleEstimateDeletingPayload,
ISaleEstimateCreatingPayload, ISaleEstimateCreatingPayload,
ISaleEstimateEditingPayload, ISaleEstimateEditingPayload,
@@ -17,7 +17,7 @@ import {
ISaleInvoiceWrittenOffCancelPayload, ISaleInvoiceWrittenOffCancelPayload,
ICreditNoteEditingPayload, ICreditNoteEditingPayload,
ISaleReceiptEditingPayload, ISaleReceiptEditingPayload,
IPaymentReceiveEditingPayload, IPaymentReceivedEditingPayload,
ISaleReceiptEventClosingPayload, ISaleReceiptEventClosingPayload,
ICreditNoteCreatingPayload, ICreditNoteCreatingPayload,
} from '@/interfaces'; } from '@/interfaces';
@@ -454,13 +454,13 @@ export default class SalesTransactionLockingGuardSubscriber {
/** /**
* Transaction locking guard on payment receive editing. * Transaction locking guard on payment receive editing.
* @param {IPaymentReceiveEditingPayload} * @param {IPaymentReceivedEditingPayload}
*/ */
private transactionLockingGuardOnPaymentEditing = async ({ private transactionLockingGuardOnPaymentEditing = async ({
tenantId, tenantId,
oldPaymentReceive, oldPaymentReceive,
paymentReceiveDTO, paymentReceiveDTO,
}: IPaymentReceiveEditingPayload) => { }: IPaymentReceivedEditingPayload) => {
// Validate the old payment date. // Validate the old payment date.
await this.salesLockingGuard.transactionLockingGuard( await this.salesLockingGuard.transactionLockingGuard(
tenantId, tenantId,
@@ -475,12 +475,12 @@ export default class SalesTransactionLockingGuardSubscriber {
/** /**
* Transaction locking guard on payment creating. * Transaction locking guard on payment creating.
* @param {IPaymentReceiveCreatingPayload} * @param {IPaymentReceivedCreatingPayload}
*/ */
private transactionLockingGuardOnPaymentCreating = async ({ private transactionLockingGuardOnPaymentCreating = async ({
tenantId, tenantId,
paymentReceiveDTO, paymentReceiveDTO,
}: IPaymentReceiveCreatingPayload) => { }: IPaymentReceivedCreatingPayload) => {
await this.salesLockingGuard.transactionLockingGuard( await this.salesLockingGuard.transactionLockingGuard(
tenantId, tenantId,
paymentReceiveDTO.paymentDate paymentReceiveDTO.paymentDate
@@ -489,12 +489,12 @@ export default class SalesTransactionLockingGuardSubscriber {
/** /**
* Transaction locking guard on payment deleting. * Transaction locking guard on payment deleting.
* @param {IPaymentReceiveDeletingPayload} payload - * @param {IPaymentReceivedDeletingPayload} payload -
*/ */
private transactionLockingGuardPaymentDeleting = async ({ private transactionLockingGuardPaymentDeleting = async ({
oldPaymentReceive, oldPaymentReceive,
tenantId, tenantId,
}: IPaymentReceiveDeletingPayload) => { }: IPaymentReceivedDeletingPayload) => {
await this.salesLockingGuard.transactionLockingGuard( await this.salesLockingGuard.transactionLockingGuard(
tenantId, tenantId,
oldPaymentReceive.paymentDate oldPaymentReceive.paymentDate

View File

@@ -2,7 +2,7 @@ import { Service, Inject } from 'typedi';
import events from '@/subscribers/events'; import events from '@/subscribers/events';
import { EventSubscriber } from '@/lib/EventPublisher/EventPublisher'; import { EventSubscriber } from '@/lib/EventPublisher/EventPublisher';
import { PaymentReceivedIncrement } from '@/services/Sales/PaymentReceived/PaymentReceivedIncrement'; import { PaymentReceivedIncrement } from '@/services/Sales/PaymentReceived/PaymentReceivedIncrement';
import { IPaymentReceiveCreatedPayload } from '@/interfaces'; import { IPaymentReceivedCreatedPayload } from '@/interfaces';
@Service() @Service()
export default class PaymentReceiveAutoSerialSubscriber extends EventSubscriber { export default class PaymentReceiveAutoSerialSubscriber extends EventSubscriber {
@@ -22,13 +22,13 @@ export default class PaymentReceiveAutoSerialSubscriber extends EventSubscriber
/** /**
* Handles increment next number of payment receive once be created. * Handles increment next number of payment receive once be created.
* @param {IPaymentReceiveCreatedPayload} payload - * @param {IPaymentReceivedCreatedPayload} payload -
*/ */
private handlePaymentNextNumberIncrement = async ({ private handlePaymentNextNumberIncrement = async ({
tenantId, tenantId,
paymentReceiveId, paymentReceiveId,
trx, trx,
}: IPaymentReceiveCreatedPayload) => { }: IPaymentReceivedCreatedPayload) => {
await this.paymentIncrement.incrementNextPaymentReceiveNumber(tenantId); await this.paymentIncrement.incrementNextPaymentReceiveNumber(tenantId);
}; };
} }

View File

@@ -2,9 +2,9 @@ import { Inject, Service } from 'typedi';
import events from '@/subscribers/events'; import events from '@/subscribers/events';
import { PaymentReceivedInvoiceSync } from '@/services/Sales/PaymentReceived/PaymentReceivedInvoiceSync'; import { PaymentReceivedInvoiceSync } from '@/services/Sales/PaymentReceived/PaymentReceivedInvoiceSync';
import { import {
IPaymentReceiveCreatedPayload, IPaymentReceivedCreatedPayload,
IPaymentReceiveDeletedPayload, IPaymentReceivedDeletedPayload,
IPaymentReceiveEditedPayload, IPaymentReceivedEditedPayload,
} from '@/interfaces'; } from '@/interfaces';
@Service() @Service()
@@ -39,7 +39,7 @@ export default class PaymentReceiveSyncInvoicesSubscriber {
tenantId, tenantId,
paymentReceive, paymentReceive,
trx, trx,
}: IPaymentReceiveCreatedPayload) => { }: IPaymentReceivedCreatedPayload) => {
await this.paymentSyncInvoice.saveChangeInvoicePaymentAmount( await this.paymentSyncInvoice.saveChangeInvoicePaymentAmount(
tenantId, tenantId,
paymentReceive.entries, paymentReceive.entries,
@@ -57,7 +57,7 @@ export default class PaymentReceiveSyncInvoicesSubscriber {
paymentReceive, paymentReceive,
oldPaymentReceive, oldPaymentReceive,
trx, trx,
}: IPaymentReceiveEditedPayload) => { }: IPaymentReceivedEditedPayload) => {
await this.paymentSyncInvoice.saveChangeInvoicePaymentAmount( await this.paymentSyncInvoice.saveChangeInvoicePaymentAmount(
tenantId, tenantId,
paymentReceive.entries, paymentReceive.entries,
@@ -74,7 +74,7 @@ export default class PaymentReceiveSyncInvoicesSubscriber {
paymentReceiveId, paymentReceiveId,
oldPaymentReceive, oldPaymentReceive,
trx, trx,
}: IPaymentReceiveDeletedPayload) => { }: IPaymentReceivedDeletedPayload) => {
await this.paymentSyncInvoice.saveChangeInvoicePaymentAmount( await this.paymentSyncInvoice.saveChangeInvoicePaymentAmount(
tenantId, tenantId,
oldPaymentReceive.entries.map((entry) => ({ oldPaymentReceive.entries.map((entry) => ({

View File

@@ -1,7 +1,7 @@
import { Service, Inject } from 'typedi'; import { Service, Inject } from 'typedi';
import events from '@/subscribers/events'; import events from '@/subscribers/events';
import { PaymentReceiveNotifyBySms } from '@/services/Sales/PaymentReceived/PaymentReceivedSmsNotify'; import { PaymentReceiveNotifyBySms } from '@/services/Sales/PaymentReceived/PaymentReceivedSmsNotify';
import { IPaymentReceiveCreatedPayload } from '@/interfaces'; import { IPaymentReceivedCreatedPayload } from '@/interfaces';
import { runAfterTransaction } from '@/services/UnitOfWork/TransactionsHooks'; import { runAfterTransaction } from '@/services/UnitOfWork/TransactionsHooks';
@Service() @Service()
@@ -26,7 +26,7 @@ export default class SendSmsNotificationPaymentReceive {
tenantId, tenantId,
paymentReceiveId, paymentReceiveId,
trx, trx,
}: IPaymentReceiveCreatedPayload) => { }: IPaymentReceivedCreatedPayload) => {
// Notify via Sms after transactions complete running. // Notify via Sms after transactions complete running.
runAfterTransaction(trx, async () => { runAfterTransaction(trx, async () => {
try { try {

View File

@@ -1,8 +1,8 @@
import { Inject, Service } from 'typedi'; import { Inject, Service } from 'typedi';
import { import {
IPaymentReceiveCreatedPayload, IPaymentReceivedCreatedPayload,
IPaymentReceiveDeletedPayload, IPaymentReceivedDeletedPayload,
IPaymentReceiveEditedPayload, IPaymentReceivedEditedPayload,
} from '@/interfaces'; } from '@/interfaces';
import events from '@/subscribers/events'; import events from '@/subscribers/events';
import { PaymentReceivedGLEntries } from '@/services/Sales/PaymentReceived/PaymentReceivedGLEntries'; import { PaymentReceivedGLEntries } from '@/services/Sales/PaymentReceived/PaymentReceivedGLEntries';
@@ -37,7 +37,7 @@ export default class PaymentReceivesWriteGLEntriesSubscriber {
tenantId, tenantId,
paymentReceiveId, paymentReceiveId,
trx, trx,
}: IPaymentReceiveCreatedPayload) => { }: IPaymentReceivedCreatedPayload) => {
await this.paymentReceiveGLEntries.writePaymentGLEntries( await this.paymentReceiveGLEntries.writePaymentGLEntries(
tenantId, tenantId,
paymentReceiveId, paymentReceiveId,
@@ -52,7 +52,7 @@ export default class PaymentReceivesWriteGLEntriesSubscriber {
tenantId, tenantId,
paymentReceive, paymentReceive,
trx, trx,
}: IPaymentReceiveEditedPayload) => { }: IPaymentReceivedEditedPayload) => {
await this.paymentReceiveGLEntries.rewritePaymentGLEntries( await this.paymentReceiveGLEntries.rewritePaymentGLEntries(
tenantId, tenantId,
paymentReceive.id, paymentReceive.id,
@@ -67,7 +67,7 @@ export default class PaymentReceivesWriteGLEntriesSubscriber {
tenantId, tenantId,
paymentReceiveId, paymentReceiveId,
trx, trx,
}: IPaymentReceiveDeletedPayload) => { }: IPaymentReceivedDeletedPayload) => {
await this.paymentReceiveGLEntries.revertPaymentGLEntries( await this.paymentReceiveGLEntries.revertPaymentGLEntries(
tenantId, tenantId,
paymentReceiveId, paymentReceiveId,