mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
fix: rename interfaces to PaymentReceived
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { isEmpty } from 'lodash';
|
||||
import {
|
||||
IPaymentReceiveCreatedPayload,
|
||||
IPaymentReceiveCreatingPayload,
|
||||
IPaymentReceiveDeletingPayload,
|
||||
IPaymentReceiveEditedPayload,
|
||||
IPaymentReceivedCreatedPayload,
|
||||
IPaymentReceivedCreatingPayload,
|
||||
IPaymentReceivedDeletingPayload,
|
||||
IPaymentReceivedEditedPayload,
|
||||
} from '@/interfaces';
|
||||
import events from '@/subscribers/events';
|
||||
import { LinkAttachment } from '../LinkAttachment';
|
||||
@@ -50,13 +50,13 @@ export class AttachmentsOnPaymentsReceived {
|
||||
|
||||
/**
|
||||
* Validates the attachment keys on creating payment.
|
||||
* @param {IPaymentReceiveCreatingPayload}
|
||||
* @param {IPaymentReceivedCreatingPayload}
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
private async validateAttachmentsOnPaymentCreate({
|
||||
paymentReceiveDTO,
|
||||
tenantId,
|
||||
}: IPaymentReceiveCreatingPayload): Promise<void> {
|
||||
}: IPaymentReceivedCreatingPayload): Promise<void> {
|
||||
if (isEmpty(paymentReceiveDTO.attachments)) {
|
||||
return;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ export class AttachmentsOnPaymentsReceived {
|
||||
|
||||
/**
|
||||
* Handles linking the attachments of the created payment.
|
||||
* @param {IPaymentReceiveCreatedPayload}
|
||||
* @param {IPaymentReceivedCreatedPayload}
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
private async handleAttachmentsOnPaymentCreated({
|
||||
@@ -75,7 +75,7 @@ export class AttachmentsOnPaymentsReceived {
|
||||
paymentReceiveDTO,
|
||||
paymentReceive,
|
||||
trx,
|
||||
}: IPaymentReceiveCreatedPayload): Promise<void> {
|
||||
}: IPaymentReceivedCreatedPayload): Promise<void> {
|
||||
if (isEmpty(paymentReceiveDTO.attachments)) return;
|
||||
|
||||
const keys = paymentReceiveDTO.attachments?.map(
|
||||
@@ -92,14 +92,14 @@ export class AttachmentsOnPaymentsReceived {
|
||||
|
||||
/**
|
||||
* Handles unlinking all the unpresented keys of the edited payment.
|
||||
* @param {IPaymentReceiveEditedPayload}
|
||||
* @param {IPaymentReceivedEditedPayload}
|
||||
*/
|
||||
private async handleUnlinkUnpresentedKeysOnPaymentEdited({
|
||||
tenantId,
|
||||
paymentReceiveDTO,
|
||||
oldPaymentReceive,
|
||||
trx,
|
||||
}: IPaymentReceiveEditedPayload) {
|
||||
}: IPaymentReceivedEditedPayload) {
|
||||
const keys = paymentReceiveDTO.attachments?.map(
|
||||
(attachment) => attachment.key
|
||||
);
|
||||
@@ -114,7 +114,7 @@ export class AttachmentsOnPaymentsReceived {
|
||||
|
||||
/**
|
||||
* Handles linking all the presented keys of the edited payment.
|
||||
* @param {IPaymentReceiveEditedPayload}
|
||||
* @param {IPaymentReceivedEditedPayload}
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
private async handleLinkPresentedKeysOnPaymentEdited({
|
||||
@@ -122,7 +122,7 @@ export class AttachmentsOnPaymentsReceived {
|
||||
paymentReceiveDTO,
|
||||
oldPaymentReceive,
|
||||
trx,
|
||||
}: IPaymentReceiveEditedPayload) {
|
||||
}: IPaymentReceivedEditedPayload) {
|
||||
if (isEmpty(paymentReceiveDTO.attachments)) return;
|
||||
|
||||
const keys = paymentReceiveDTO.attachments?.map(
|
||||
@@ -146,7 +146,7 @@ export class AttachmentsOnPaymentsReceived {
|
||||
tenantId,
|
||||
oldPaymentReceive,
|
||||
trx,
|
||||
}: IPaymentReceiveDeletingPayload) {
|
||||
}: IPaymentReceivedDeletingPayload) {
|
||||
await this.unlinkAttachmentService.unlinkAllModelKeys(
|
||||
tenantId,
|
||||
'PaymentReceive',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import {
|
||||
IBillPaymentEventDeletedPayload,
|
||||
IPaymentReceiveDeletedPayload,
|
||||
IPaymentReceivedDeletedPayload,
|
||||
} from '@/interfaces';
|
||||
import { ValidateTransactionMatched } from '../ValidateTransactionsMatched';
|
||||
import events from '@/subscribers/events';
|
||||
@@ -23,7 +23,7 @@ export class ValidateMatchingOnPaymentMadeDelete {
|
||||
|
||||
/**
|
||||
* Validates the payment made transaction whether matched with bank transaction on deleting.
|
||||
* @param {IPaymentReceiveDeletedPayload}
|
||||
* @param {IPaymentReceivedDeletedPayload}
|
||||
*/
|
||||
public async validateMatchingOnPaymentMadeDeleting({
|
||||
tenantId,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { IPaymentReceiveDeletedPayload } from '@/interfaces';
|
||||
import { IPaymentReceivedDeletedPayload } from '@/interfaces';
|
||||
import { ValidateTransactionMatched } from '../ValidateTransactionsMatched';
|
||||
import events from '@/subscribers/events';
|
||||
|
||||
@@ -20,13 +20,13 @@ export class ValidateMatchingOnPaymentReceivedDelete {
|
||||
|
||||
/**
|
||||
* Validates the payment received transaction whether matched with bank transaction on deleting.
|
||||
* @param {IPaymentReceiveDeletedPayload}
|
||||
* @param {IPaymentReceivedDeletedPayload}
|
||||
*/
|
||||
public async validateMatchingOnPaymentReceivedDeleting({
|
||||
tenantId,
|
||||
oldPaymentReceive,
|
||||
trx,
|
||||
}: IPaymentReceiveDeletedPayload) {
|
||||
}: IPaymentReceivedDeletedPayload) {
|
||||
await this.validateNoMatchingLinkedService.validateTransactionNoMatchLinking(
|
||||
tenantId,
|
||||
'PaymentReceive',
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import events from '@/subscribers/events';
|
||||
import {
|
||||
IPaymentReceiveCreatingPayload,
|
||||
IPaymentReceiveEditingPayload,
|
||||
IPaymentReceivedCreatingPayload,
|
||||
IPaymentReceivedEditingPayload,
|
||||
} from '@/interfaces';
|
||||
import { ValidateBranchExistance } from '../../Integrations/ValidateBranchExistance';
|
||||
|
||||
@@ -28,12 +28,12 @@ export class PaymentReceiveBranchValidateSubscriber {
|
||||
|
||||
/**
|
||||
* Validate branch existance on estimate creating.
|
||||
* @param {IPaymentReceiveCreatingPayload} payload
|
||||
* @param {IPaymentReceivedCreatingPayload} payload
|
||||
*/
|
||||
private validateBranchExistanceOnPaymentCreating = async ({
|
||||
tenantId,
|
||||
paymentReceiveDTO,
|
||||
}: IPaymentReceiveCreatingPayload) => {
|
||||
}: IPaymentReceivedCreatingPayload) => {
|
||||
await this.validateBranchExistance.validateTransactionBranchWhenActive(
|
||||
tenantId,
|
||||
paymentReceiveDTO.branchId
|
||||
@@ -42,12 +42,12 @@ export class PaymentReceiveBranchValidateSubscriber {
|
||||
|
||||
/**
|
||||
* Validate branch existance once estimate editing.
|
||||
* @param {IPaymentReceiveEditingPayload} payload
|
||||
* @param {IPaymentReceivedEditingPayload} payload
|
||||
*/
|
||||
private validateBranchExistanceOnPaymentEditing = async ({
|
||||
paymentReceiveDTO,
|
||||
tenantId,
|
||||
}: IPaymentReceiveEditingPayload) => {
|
||||
}: IPaymentReceivedEditingPayload) => {
|
||||
await this.validateBranchExistance.validateTransactionBranchWhenActive(
|
||||
tenantId,
|
||||
paymentReceiveDTO.branchId
|
||||
|
||||
@@ -6,7 +6,7 @@ import SaleNotifyBySms from '../SaleNotifyBySms';
|
||||
import SmsNotificationsSettingsService from '@/services/Settings/SmsNotificationsSettings';
|
||||
import {
|
||||
ICustomer,
|
||||
IPaymentReceiveSmsDetails,
|
||||
IPaymentReceivedSmsDetails,
|
||||
ISaleEstimate,
|
||||
SMS_NOTIFICATION_KEY,
|
||||
} from '@/interfaces';
|
||||
@@ -173,12 +173,12 @@ export class SaleEstimateNotifyBySms {
|
||||
* Retrieve the SMS details of the given payment receive transaction.
|
||||
* @param {number} tenantId
|
||||
* @param {number} saleEstimateId
|
||||
* @returns {Promise<IPaymentReceiveSmsDetails>}
|
||||
* @returns {Promise<IPaymentReceivedSmsDetails>}
|
||||
*/
|
||||
public smsDetails = async (
|
||||
tenantId: number,
|
||||
saleEstimateId: number
|
||||
): Promise<IPaymentReceiveSmsDetails> => {
|
||||
): Promise<IPaymentReceivedSmsDetails> => {
|
||||
const { SaleEstimate } = this.tenancy.models(tenantId);
|
||||
|
||||
// Retrieve the sale invoice or throw not found service error.
|
||||
|
||||
@@ -3,7 +3,7 @@ import { CreateSaleEstimate } from './CreateSaleEstimate';
|
||||
import {
|
||||
IFilterMeta,
|
||||
IPaginationMeta,
|
||||
IPaymentReceiveSmsDetails,
|
||||
IPaymentReceivedSmsDetails,
|
||||
ISaleEstimate,
|
||||
ISaleEstimateDTO,
|
||||
ISalesEstimatesFilter,
|
||||
@@ -191,12 +191,12 @@ export class SaleEstimatesApplication {
|
||||
* Retrieve the SMS details of the given payment receive transaction.
|
||||
* @param {number} tenantId
|
||||
* @param {number} saleEstimateId
|
||||
* @returns {Promise<IPaymentReceiveSmsDetails>}
|
||||
* @returns {Promise<IPaymentReceivedSmsDetails>}
|
||||
*/
|
||||
public getSaleEstimateSmsDetails = (
|
||||
tenantId: number,
|
||||
saleEstimateId: number
|
||||
): Promise<IPaymentReceiveSmsDetails> => {
|
||||
): Promise<IPaymentReceivedSmsDetails> => {
|
||||
return this.saleEstimateNotifyBySmsService.smsDetails(
|
||||
tenantId,
|
||||
saleEstimateId
|
||||
|
||||
@@ -2,9 +2,9 @@ import { Inject, Service } from 'typedi';
|
||||
import { Knex } from 'knex';
|
||||
import {
|
||||
ICustomer,
|
||||
IPaymentReceiveCreateDTO,
|
||||
IPaymentReceiveCreatedPayload,
|
||||
IPaymentReceiveCreatingPayload,
|
||||
IPaymentReceivedCreateDTO,
|
||||
IPaymentReceivedCreatedPayload,
|
||||
IPaymentReceivedCreatingPayload,
|
||||
ISystemUser,
|
||||
} from '@/interfaces';
|
||||
import { PaymentReceivedValidators } from './PaymentReceivedValidators';
|
||||
@@ -37,11 +37,11 @@ export class CreatePaymentReceived {
|
||||
* with associated invoices payment and journal transactions.
|
||||
* @async
|
||||
* @param {number} tenantId - Tenant id.
|
||||
* @param {IPaymentReceive} paymentReceive
|
||||
* @param {IPaymentReceived} paymentReceive
|
||||
*/
|
||||
public async createPaymentReceived(
|
||||
tenantId: number,
|
||||
paymentReceiveDTO: IPaymentReceiveCreateDTO,
|
||||
paymentReceiveDTO: IPaymentReceivedCreateDTO,
|
||||
authorizedUser: ISystemUser,
|
||||
trx?: Knex.Transaction
|
||||
) {
|
||||
@@ -97,7 +97,7 @@ export class CreatePaymentReceived {
|
||||
trx,
|
||||
paymentReceiveDTO,
|
||||
tenantId,
|
||||
} as IPaymentReceiveCreatingPayload);
|
||||
} as IPaymentReceivedCreatingPayload);
|
||||
|
||||
// Inserts the payment receive transaction.
|
||||
const paymentReceive = await PaymentReceive.query(
|
||||
@@ -113,7 +113,7 @@ export class CreatePaymentReceived {
|
||||
paymentReceiveDTO,
|
||||
authorizedUser,
|
||||
trx,
|
||||
} as IPaymentReceiveCreatedPayload);
|
||||
} as IPaymentReceivedCreatedPayload);
|
||||
|
||||
return paymentReceive;
|
||||
},
|
||||
@@ -125,13 +125,13 @@ export class CreatePaymentReceived {
|
||||
* Transform the create payment receive DTO.
|
||||
* @param {number} tenantId
|
||||
* @param {ICustomer} customer
|
||||
* @param {IPaymentReceiveCreateDTO} paymentReceiveDTO
|
||||
* @param {IPaymentReceivedCreateDTO} paymentReceiveDTO
|
||||
* @returns
|
||||
*/
|
||||
private transformCreateDTOToModel = async (
|
||||
tenantId: number,
|
||||
customer: ICustomer,
|
||||
paymentReceiveDTO: IPaymentReceiveCreateDTO
|
||||
paymentReceiveDTO: IPaymentReceivedCreateDTO
|
||||
) => {
|
||||
return this.transformer.transformPaymentReceiveDTOToModel(
|
||||
tenantId,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { Knex } from 'knex';
|
||||
import {
|
||||
IPaymentReceiveDeletedPayload,
|
||||
IPaymentReceiveDeletingPayload,
|
||||
IPaymentReceivedDeletedPayload,
|
||||
IPaymentReceivedDeletingPayload,
|
||||
ISystemUser,
|
||||
} from '@/interfaces';
|
||||
import UnitOfWork from '@/services/UnitOfWork';
|
||||
@@ -33,7 +33,7 @@ export class DeletePaymentReceived {
|
||||
* @async
|
||||
* @param {number} tenantId - Tenant id.
|
||||
* @param {Integer} paymentReceiveId - Payment receive id.
|
||||
* @param {IPaymentReceive} paymentReceive - Payment receive object.
|
||||
* @param {IPaymentReceived} paymentReceive - Payment receive object.
|
||||
*/
|
||||
public async deletePaymentReceive(
|
||||
tenantId: number,
|
||||
@@ -56,7 +56,7 @@ export class DeletePaymentReceived {
|
||||
tenantId,
|
||||
oldPaymentReceive,
|
||||
trx,
|
||||
} as IPaymentReceiveDeletingPayload);
|
||||
} as IPaymentReceivedDeletingPayload);
|
||||
|
||||
// Deletes the payment receive associated entries.
|
||||
await PaymentReceiveEntry.query(trx)
|
||||
@@ -73,7 +73,7 @@ export class DeletePaymentReceived {
|
||||
oldPaymentReceive,
|
||||
authorizedUser,
|
||||
trx,
|
||||
} as IPaymentReceiveDeletedPayload);
|
||||
} as IPaymentReceivedDeletedPayload);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Inject, Service } from 'typedi';
|
||||
import { Knex } from 'knex';
|
||||
import {
|
||||
ICustomer,
|
||||
IPaymentReceive,
|
||||
IPaymentReceiveEditDTO,
|
||||
IPaymentReceiveEditedPayload,
|
||||
IPaymentReceiveEditingPayload,
|
||||
IPaymentReceived,
|
||||
IPaymentReceivedEditDTO,
|
||||
IPaymentReceivedEditedPayload,
|
||||
IPaymentReceivedEditingPayload,
|
||||
ISystemUser,
|
||||
} from '@/interfaces';
|
||||
import { PaymentReceiveDTOTransformer } from './PaymentReceivedDTOTransformer';
|
||||
@@ -46,12 +46,12 @@ export class EditPaymentReceived {
|
||||
* @async
|
||||
* @param {number} tenantId -
|
||||
* @param {Integer} paymentReceiveId -
|
||||
* @param {IPaymentReceive} paymentReceive -
|
||||
* @param {IPaymentReceived} paymentReceive -
|
||||
*/
|
||||
public async editPaymentReceive(
|
||||
tenantId: number,
|
||||
paymentReceiveId: number,
|
||||
paymentReceiveDTO: IPaymentReceiveEditDTO,
|
||||
paymentReceiveDTO: IPaymentReceivedEditDTO,
|
||||
authorizedUser: ISystemUser
|
||||
) {
|
||||
const { PaymentReceive, Contact } = this.tenancy.models(tenantId);
|
||||
@@ -131,7 +131,7 @@ export class EditPaymentReceived {
|
||||
tenantId,
|
||||
oldPaymentReceive,
|
||||
paymentReceiveDTO,
|
||||
} as IPaymentReceiveEditingPayload);
|
||||
} as IPaymentReceivedEditingPayload);
|
||||
|
||||
// Update the payment receive transaction.
|
||||
const paymentReceive = await PaymentReceive.query(
|
||||
@@ -149,7 +149,7 @@ export class EditPaymentReceived {
|
||||
paymentReceiveDTO,
|
||||
authorizedUser,
|
||||
trx,
|
||||
} as IPaymentReceiveEditedPayload);
|
||||
} as IPaymentReceivedEditedPayload);
|
||||
|
||||
return paymentReceive;
|
||||
});
|
||||
@@ -159,15 +159,15 @@ export class EditPaymentReceived {
|
||||
* Transform the edit payment receive DTO.
|
||||
* @param {number} tenantId
|
||||
* @param {ICustomer} customer
|
||||
* @param {IPaymentReceiveEditDTO} paymentReceiveDTO
|
||||
* @param {IPaymentReceive} oldPaymentReceive
|
||||
* @param {IPaymentReceivedEditDTO} paymentReceiveDTO
|
||||
* @param {IPaymentReceived} oldPaymentReceive
|
||||
* @returns
|
||||
*/
|
||||
private transformEditDTOToModel = async (
|
||||
tenantId: number,
|
||||
customer: ICustomer,
|
||||
paymentReceiveDTO: IPaymentReceiveEditDTO,
|
||||
oldPaymentReceive: IPaymentReceive
|
||||
paymentReceiveDTO: IPaymentReceivedEditDTO,
|
||||
oldPaymentReceive: IPaymentReceived
|
||||
) => {
|
||||
return this.transformer.transformPaymentReceiveDTOToModel(
|
||||
tenantId,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ServiceError } from '@/exceptions';
|
||||
import { IPaymentReceive } from '@/interfaces';
|
||||
import { IPaymentReceived } from '@/interfaces';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { ERRORS } from './constants';
|
||||
@@ -18,12 +18,12 @@ export class GetPaymentReceived {
|
||||
* Retrieve payment receive details.
|
||||
* @param {number} tenantId - Tenant id.
|
||||
* @param {number} paymentReceiveId - Payment receive id.
|
||||
* @return {Promise<IPaymentReceive>}
|
||||
* @return {Promise<IPaymentReceived>}
|
||||
*/
|
||||
public async getPaymentReceive(
|
||||
tenantId: number,
|
||||
paymentReceiveId: number
|
||||
): Promise<IPaymentReceive> {
|
||||
): Promise<IPaymentReceived> {
|
||||
const { PaymentReceive } = this.tenancy.models(tenantId);
|
||||
|
||||
const paymentReceive = await PaymentReceive.query()
|
||||
|
||||
@@ -4,7 +4,7 @@ import { TemplateInjectable } from '@/services/TemplateInjectable/TemplateInject
|
||||
import { GetPaymentReceived } from './GetPaymentReceived';
|
||||
|
||||
@Service()
|
||||
export default class GetPaymentReceivePdf {
|
||||
export default class GetPaymentReceivedPdf {
|
||||
@Inject()
|
||||
private chromiumlyTenancy: ChromiumlyTenancy;
|
||||
|
||||
@@ -17,7 +17,7 @@ export default class GetPaymentReceivePdf {
|
||||
/**
|
||||
* Retrieve sale invoice pdf content.
|
||||
* @param {number} tenantId -
|
||||
* @param {IPaymentReceive} paymentReceive -
|
||||
* @param {IPaymentReceived} paymentReceive -
|
||||
* @returns {Promise<Buffer>}
|
||||
*/
|
||||
async getPaymentReceivePdf(
|
||||
|
||||
@@ -3,8 +3,8 @@ import * as R from 'ramda';
|
||||
import {
|
||||
IFilterMeta,
|
||||
IPaginationMeta,
|
||||
IPaymentReceive,
|
||||
IPaymentReceivesFilter,
|
||||
IPaymentReceived,
|
||||
IPaymentsReceivedFilter,
|
||||
} from '@/interfaces';
|
||||
import { PaymentReceiveTransfromer } from './PaymentReceivedTransformer';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
@@ -25,13 +25,13 @@ export class GetPaymentReceives {
|
||||
/**
|
||||
* Retrieve payment receives paginated and filterable list.
|
||||
* @param {number} tenantId
|
||||
* @param {IPaymentReceivesFilter} paymentReceivesFilter
|
||||
* @param {IPaymentsReceivedFilter} paymentReceivesFilter
|
||||
*/
|
||||
public async getPaymentReceives(
|
||||
tenantId: number,
|
||||
filterDTO: IPaymentReceivesFilter
|
||||
filterDTO: IPaymentsReceivedFilter
|
||||
): Promise<{
|
||||
paymentReceives: IPaymentReceive[];
|
||||
paymentReceives: IPaymentReceived[];
|
||||
pagination: IPaginationMeta;
|
||||
filterMeta: IFilterMeta;
|
||||
}> {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import {
|
||||
IFilterMeta,
|
||||
IPaginationMeta,
|
||||
IPaymentReceive,
|
||||
IPaymentReceiveCreateDTO,
|
||||
IPaymentReceiveEditDTO,
|
||||
IPaymentReceiveSmsDetails,
|
||||
IPaymentReceivesFilter,
|
||||
IPaymentReceived,
|
||||
IPaymentReceivedCreateDTO,
|
||||
IPaymentReceivedEditDTO,
|
||||
IPaymentReceivedSmsDetails,
|
||||
IPaymentsReceivedFilter,
|
||||
ISystemUser,
|
||||
PaymentReceiveMailOptsDTO,
|
||||
} from '@/interfaces';
|
||||
@@ -17,7 +17,7 @@ import { GetPaymentReceives } from './GetPaymentsReceived';
|
||||
import { GetPaymentReceived } from './GetPaymentReceived';
|
||||
import { GetPaymentReceivedInvoices } from './GetPaymentReceivedInvoices';
|
||||
import { PaymentReceiveNotifyBySms } from './PaymentReceivedSmsNotify';
|
||||
import GetPaymentReceivePdf from './GetPaymentReceivedPdf';
|
||||
import GetPaymentReceivedPdf from './GetPaymentReceivedPdf';
|
||||
import { SendPaymentReceiveMailNotification } from './PaymentReceivedMailNotification';
|
||||
|
||||
@Service()
|
||||
@@ -47,18 +47,18 @@ export class PaymentReceivesApplication {
|
||||
private paymentMailNotify: SendPaymentReceiveMailNotification;
|
||||
|
||||
@Inject()
|
||||
private getPaymentReceivePdfService: GetPaymentReceivePdf;
|
||||
private getPaymentReceivePdfService: GetPaymentReceivedPdf;
|
||||
|
||||
/**
|
||||
* Creates a new payment receive.
|
||||
* @param {number} tenantId
|
||||
* @param {IPaymentReceiveCreateDTO} paymentReceiveDTO
|
||||
* @param {IPaymentReceivedCreateDTO} paymentReceiveDTO
|
||||
* @param {ISystemUser} authorizedUser
|
||||
* @returns
|
||||
*/
|
||||
public createPaymentReceived(
|
||||
tenantId: number,
|
||||
paymentReceiveDTO: IPaymentReceiveCreateDTO,
|
||||
paymentReceiveDTO: IPaymentReceivedCreateDTO,
|
||||
authorizedUser: ISystemUser
|
||||
) {
|
||||
return this.createPaymentReceivedService.createPaymentReceived(
|
||||
@@ -72,14 +72,14 @@ export class PaymentReceivesApplication {
|
||||
* Edit details the given payment receive with associated entries.
|
||||
* @param {number} tenantId
|
||||
* @param {number} paymentReceiveId
|
||||
* @param {IPaymentReceiveEditDTO} paymentReceiveDTO
|
||||
* @param {IPaymentReceivedEditDTO} paymentReceiveDTO
|
||||
* @param {ISystemUser} authorizedUser
|
||||
* @returns
|
||||
*/
|
||||
public editPaymentReceive(
|
||||
tenantId: number,
|
||||
paymentReceiveId: number,
|
||||
paymentReceiveDTO: IPaymentReceiveEditDTO,
|
||||
paymentReceiveDTO: IPaymentReceivedEditDTO,
|
||||
authorizedUser: ISystemUser
|
||||
) {
|
||||
return this.editPaymentReceivedService.editPaymentReceive(
|
||||
@@ -112,14 +112,14 @@ export class PaymentReceivesApplication {
|
||||
/**
|
||||
* Retrieve payment receives paginated and filterable.
|
||||
* @param {number} tenantId
|
||||
* @param {IPaymentReceivesFilter} filterDTO
|
||||
* @param {IPaymentsReceivedFilter} filterDTO
|
||||
* @returns
|
||||
*/
|
||||
public async getPaymentReceives(
|
||||
tenantId: number,
|
||||
filterDTO: IPaymentReceivesFilter
|
||||
filterDTO: IPaymentsReceivedFilter
|
||||
): Promise<{
|
||||
paymentReceives: IPaymentReceive[];
|
||||
paymentReceives: IPaymentReceived[];
|
||||
pagination: IPaginationMeta;
|
||||
filterMeta: IFilterMeta;
|
||||
}> {
|
||||
@@ -133,12 +133,12 @@ export class PaymentReceivesApplication {
|
||||
* Retrieves the given payment receive.
|
||||
* @param {number} tenantId
|
||||
* @param {number} paymentReceiveId
|
||||
* @returns {Promise<IPaymentReceive>}
|
||||
* @returns {Promise<IPaymentReceived>}
|
||||
*/
|
||||
public async getPaymentReceive(
|
||||
tenantId: number,
|
||||
paymentReceiveId: number
|
||||
): Promise<IPaymentReceive> {
|
||||
): Promise<IPaymentReceived> {
|
||||
return this.getPaymentReceivedService.getPaymentReceive(
|
||||
tenantId,
|
||||
paymentReceiveId
|
||||
@@ -175,7 +175,7 @@ export class PaymentReceivesApplication {
|
||||
public getPaymentSmsDetails = async (
|
||||
tenantId: number,
|
||||
paymentReceiveId: number
|
||||
): Promise<IPaymentReceiveSmsDetails> => {
|
||||
): Promise<IPaymentReceivedSmsDetails> => {
|
||||
return this.paymentSmsNotify.smsDetails(tenantId, paymentReceiveId);
|
||||
};
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ import { Inject, Service } from 'typedi';
|
||||
import { omit, sumBy } from 'lodash';
|
||||
import {
|
||||
ICustomer,
|
||||
IPaymentReceive,
|
||||
IPaymentReceiveCreateDTO,
|
||||
IPaymentReceiveEditDTO,
|
||||
IPaymentReceived,
|
||||
IPaymentReceivedCreateDTO,
|
||||
IPaymentReceivedEditDTO,
|
||||
} from '@/interfaces';
|
||||
import { PaymentReceivedValidators } from './PaymentReceivedValidators';
|
||||
import { PaymentReceivedIncrement } from './PaymentReceivedIncrement';
|
||||
@@ -26,16 +26,16 @@ export class PaymentReceiveDTOTransformer {
|
||||
/**
|
||||
* Transformes the create payment receive DTO to model object.
|
||||
* @param {number} tenantId
|
||||
* @param {IPaymentReceiveCreateDTO|IPaymentReceiveEditDTO} paymentReceiveDTO - Payment receive DTO.
|
||||
* @param {IPaymentReceive} oldPaymentReceive -
|
||||
* @return {IPaymentReceive}
|
||||
* @param {IPaymentReceivedCreateDTO|IPaymentReceivedEditDTO} paymentReceiveDTO - Payment receive DTO.
|
||||
* @param {IPaymentReceived} oldPaymentReceive -
|
||||
* @return {IPaymentReceived}
|
||||
*/
|
||||
public async transformPaymentReceiveDTOToModel(
|
||||
tenantId: number,
|
||||
customer: ICustomer,
|
||||
paymentReceiveDTO: IPaymentReceiveCreateDTO | IPaymentReceiveEditDTO,
|
||||
oldPaymentReceive?: IPaymentReceive
|
||||
): Promise<IPaymentReceive> {
|
||||
paymentReceiveDTO: IPaymentReceivedCreateDTO | IPaymentReceivedEditDTO,
|
||||
oldPaymentReceive?: IPaymentReceived
|
||||
): Promise<IPaymentReceived> {
|
||||
const amount =
|
||||
paymentReceiveDTO.amount ??
|
||||
sumBy(paymentReceiveDTO.entries, 'paymentAmount');
|
||||
@@ -65,7 +65,7 @@ export class PaymentReceiveDTOTransformer {
|
||||
})),
|
||||
};
|
||||
return R.compose(
|
||||
this.branchDTOTransform.transformDTO<IPaymentReceive>(tenantId)
|
||||
this.branchDTOTransform.transformDTO<IPaymentReceived>(tenantId)
|
||||
)(initialDTO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Knex } from 'knex';
|
||||
import Ledger from '@/services/Accounting/Ledger';
|
||||
import TenancyService from '@/services/Tenancy/TenancyService';
|
||||
import {
|
||||
IPaymentReceive,
|
||||
IPaymentReceived,
|
||||
ILedgerEntry,
|
||||
AccountNormal,
|
||||
IPaymentReceiveGLCommonEntry,
|
||||
@@ -93,14 +93,14 @@ export class PaymentReceivedGLEntries {
|
||||
/**
|
||||
* Retrieves the payment receive general ledger.
|
||||
* @param {number} tenantId -
|
||||
* @param {IPaymentReceive} paymentReceive -
|
||||
* @param {IPaymentReceived} paymentReceive -
|
||||
* @param {string} baseCurrencyCode -
|
||||
* @param {Knex.Transaction} trx -
|
||||
* @returns {Ledger}
|
||||
*/
|
||||
public getPaymentReceiveGLedger = async (
|
||||
tenantId: number,
|
||||
paymentReceive: IPaymentReceive,
|
||||
paymentReceive: IPaymentReceived,
|
||||
baseCurrencyCode: string,
|
||||
trx?: Knex.Transaction
|
||||
): Promise<Ledger> => {
|
||||
@@ -132,7 +132,7 @@ export class PaymentReceivedGLEntries {
|
||||
* @returns {number}
|
||||
*/
|
||||
private getPaymentExGainOrLoss = (
|
||||
paymentReceive: IPaymentReceive
|
||||
paymentReceive: IPaymentReceived
|
||||
): number => {
|
||||
return sumBy(paymentReceive.entries, (entry) => {
|
||||
const paymentLocalAmount =
|
||||
@@ -145,11 +145,11 @@ export class PaymentReceivedGLEntries {
|
||||
|
||||
/**
|
||||
* Retrieves the common entry of payment receive.
|
||||
* @param {IPaymentReceive} paymentReceive
|
||||
* @param {IPaymentReceived} paymentReceive
|
||||
* @returns {}
|
||||
*/
|
||||
private getPaymentReceiveCommonEntry = (
|
||||
paymentReceive: IPaymentReceive
|
||||
paymentReceive: IPaymentReceived
|
||||
): IPaymentReceiveGLCommonEntry => {
|
||||
return {
|
||||
debit: 0,
|
||||
@@ -174,14 +174,14 @@ export class PaymentReceivedGLEntries {
|
||||
|
||||
/**
|
||||
* Retrieves the payment exchange gain/loss entry.
|
||||
* @param {IPaymentReceive} paymentReceive -
|
||||
* @param {IPaymentReceived} paymentReceive -
|
||||
* @param {number} ARAccountId -
|
||||
* @param {number} exchangeGainOrLossAccountId -
|
||||
* @param {string} baseCurrencyCode -
|
||||
* @returns {ILedgerEntry[]}
|
||||
*/
|
||||
private getPaymentExchangeGainLossEntry = (
|
||||
paymentReceive: IPaymentReceive,
|
||||
paymentReceive: IPaymentReceived,
|
||||
ARAccountId: number,
|
||||
exchangeGainOrLossAccountId: number,
|
||||
baseCurrencyCode: string
|
||||
@@ -219,11 +219,11 @@ export class PaymentReceivedGLEntries {
|
||||
|
||||
/**
|
||||
* Retrieves the payment deposit GL entry.
|
||||
* @param {IPaymentReceive} paymentReceive
|
||||
* @param {IPaymentReceived} paymentReceive
|
||||
* @returns {ILedgerEntry}
|
||||
*/
|
||||
private getPaymentDepositGLEntry = (
|
||||
paymentReceive: IPaymentReceive
|
||||
paymentReceive: IPaymentReceived
|
||||
): ILedgerEntry => {
|
||||
const commonJournal = this.getPaymentReceiveCommonEntry(paymentReceive);
|
||||
|
||||
@@ -238,12 +238,12 @@ export class PaymentReceivedGLEntries {
|
||||
|
||||
/**
|
||||
* Retrieves the payment receivable entry.
|
||||
* @param {IPaymentReceive} paymentReceive
|
||||
* @param {IPaymentReceived} paymentReceive
|
||||
* @param {number} ARAccountId
|
||||
* @returns {ILedgerEntry}
|
||||
*/
|
||||
private getPaymentReceivableEntry = (
|
||||
paymentReceive: IPaymentReceive,
|
||||
paymentReceive: IPaymentReceived,
|
||||
ARAccountId: number
|
||||
): ILedgerEntry => {
|
||||
const commonJournal = this.getPaymentReceiveCommonEntry(paymentReceive);
|
||||
@@ -267,14 +267,14 @@ export class PaymentReceivedGLEntries {
|
||||
* - Payment account [current asset] -> Credit
|
||||
*
|
||||
* @param {number} tenantId
|
||||
* @param {IPaymentReceive} paymentRecieve - Payment receive model.
|
||||
* @param {IPaymentReceived} paymentRecieve - Payment receive model.
|
||||
* @param {number} ARAccountId - A/R account id.
|
||||
* @param {number} exGainOrLossAccountId - Exchange gain/loss account id.
|
||||
* @param {string} baseCurrency - Base currency code.
|
||||
* @returns {Promise<ILedgerEntry>}
|
||||
*/
|
||||
public getPaymentReceiveGLEntries = (
|
||||
paymentReceive: IPaymentReceive,
|
||||
paymentReceive: IPaymentReceived,
|
||||
ARAccountId: number,
|
||||
exGainOrLossAccountId: number,
|
||||
baseCurrency: string
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { Knex } from 'knex';
|
||||
import { IPaymentReceiveEntryDTO } from '@/interfaces';
|
||||
import { IPaymentReceivedEntryDTO } from '@/interfaces';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
import { entriesAmountDiff } from '@/utils';
|
||||
|
||||
@@ -19,8 +19,8 @@ export class PaymentReceivedInvoiceSync {
|
||||
*/
|
||||
public async saveChangeInvoicePaymentAmount(
|
||||
tenantId: number,
|
||||
newPaymentReceiveEntries: IPaymentReceiveEntryDTO[],
|
||||
oldPaymentReceiveEntries?: IPaymentReceiveEntryDTO[],
|
||||
newPaymentReceiveEntries: IPaymentReceivedEntryDTO[],
|
||||
oldPaymentReceiveEntries?: IPaymentReceivedEntryDTO[],
|
||||
trx?: Knex.Transaction
|
||||
): Promise<void> {
|
||||
const { SaleInvoice } = this.tenancy.models(tenantId);
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Service, Inject } from 'typedi';
|
||||
import HasTenancyService from '@/services/Tenancy/TenancyService';
|
||||
import events from '@/subscribers/events';
|
||||
import {
|
||||
IPaymentReceiveSmsDetails,
|
||||
IPaymentReceivedSmsDetails,
|
||||
SMS_NOTIFICATION_KEY,
|
||||
IPaymentReceive,
|
||||
IPaymentReceiveEntry,
|
||||
IPaymentReceived,
|
||||
IPaymentReceivedEntry,
|
||||
} from '@/interfaces';
|
||||
import SmsNotificationsSettingsService from '@/services/Settings/SmsNotificationsSettings';
|
||||
import { formatNumber, formatSmsMessage } from 'utils';
|
||||
@@ -71,12 +71,12 @@ export class PaymentReceiveNotifyBySms {
|
||||
/**
|
||||
* Sends the payment details sms notification of the given customer.
|
||||
* @param {number} tenantId
|
||||
* @param {IPaymentReceive} paymentReceive
|
||||
* @param {IPaymentReceived} paymentReceive
|
||||
* @param {ICustomer} customer
|
||||
*/
|
||||
private sendSmsNotification = async (
|
||||
tenantId: number,
|
||||
paymentReceive: IPaymentReceive
|
||||
paymentReceive: IPaymentReceived
|
||||
) => {
|
||||
const smsClient = this.tenancy.smsClient(tenantId);
|
||||
const tenantMetadata = await TenantMetadata.query().findOne({ tenantId });
|
||||
@@ -116,12 +116,12 @@ export class PaymentReceiveNotifyBySms {
|
||||
/**
|
||||
* Formates the payment receive details sms message.
|
||||
* @param {number} tenantId -
|
||||
* @param {IPaymentReceive} payment -
|
||||
* @param {IPaymentReceived} payment -
|
||||
* @param {ICustomer} customer -
|
||||
*/
|
||||
private formattedPaymentDetailsMessage = (
|
||||
tenantId: number,
|
||||
payment: IPaymentReceive,
|
||||
payment: IPaymentReceived,
|
||||
tenantMetadata: TenantMetadata
|
||||
) => {
|
||||
const notification = this.smsNotificationsSettings.getSmsNotificationMeta(
|
||||
@@ -138,14 +138,14 @@ export class PaymentReceiveNotifyBySms {
|
||||
/**
|
||||
* Formattes the payment details sms notification messafge.
|
||||
* @param {string} smsMessage
|
||||
* @param {IPaymentReceive} payment
|
||||
* @param {IPaymentReceived} payment
|
||||
* @param {ICustomer} customer
|
||||
* @param {TenantMetadata} tenantMetadata
|
||||
* @returns {string}
|
||||
*/
|
||||
private formatPaymentDetailsMessage = (
|
||||
smsMessage: string,
|
||||
payment: IPaymentReceive,
|
||||
payment: IPaymentReceived,
|
||||
tenantMetadata: any
|
||||
): string => {
|
||||
const invoiceNumbers = this.stringifyPaymentInvoicesNumber(payment);
|
||||
@@ -167,12 +167,12 @@ export class PaymentReceiveNotifyBySms {
|
||||
|
||||
/**
|
||||
* Stringify payment receive invoices to numbers as string.
|
||||
* @param {IPaymentReceive} payment
|
||||
* @param {IPaymentReceived} payment
|
||||
* @returns {string}
|
||||
*/
|
||||
private stringifyPaymentInvoicesNumber(payment: IPaymentReceive) {
|
||||
private stringifyPaymentInvoicesNumber(payment: IPaymentReceived) {
|
||||
const invoicesNumberes = payment.entries.map(
|
||||
(entry: IPaymentReceiveEntry) => entry.invoice.invoiceNo
|
||||
(entry: IPaymentReceivedEntry) => entry.invoice.invoiceNo
|
||||
);
|
||||
return invoicesNumberes.join(', ');
|
||||
}
|
||||
@@ -185,7 +185,7 @@ export class PaymentReceiveNotifyBySms {
|
||||
public smsDetails = async (
|
||||
tenantId: number,
|
||||
paymentReceiveid: number
|
||||
): Promise<IPaymentReceiveSmsDetails> => {
|
||||
): Promise<IPaymentReceivedSmsDetails> => {
|
||||
const { PaymentReceive } = this.tenancy.models(tenantId);
|
||||
|
||||
// Retrieve the payment receive or throw not found service error.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IPaymentReceive, IPaymentReceiveEntry } from '@/interfaces';
|
||||
import { IPaymentReceived, IPaymentReceivedEntry } from '@/interfaces';
|
||||
import { Transformer } from '@/lib/Transformer/Transformer';
|
||||
import { formatNumber } from 'utils';
|
||||
import { PaymentReceivedEntryTransfromer } from './PaymentReceivedEntryTransformer';
|
||||
@@ -24,25 +24,25 @@ export class PaymentReceiveTransfromer extends Transformer {
|
||||
* @param {ISaleInvoice} invoice
|
||||
* @returns {String}
|
||||
*/
|
||||
protected formattedPaymentDate = (payment: IPaymentReceive): string => {
|
||||
protected formattedPaymentDate = (payment: IPaymentReceived): string => {
|
||||
return this.formatDate(payment.paymentDate);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the formatted created at date.
|
||||
* @param {IPaymentReceive} payment
|
||||
* @param {IPaymentReceived} payment
|
||||
* @returns {string}
|
||||
*/
|
||||
protected formattedCreatedAt = (payment: IPaymentReceive): string => {
|
||||
protected formattedCreatedAt = (payment: IPaymentReceived): string => {
|
||||
return this.formatDate(payment.createdAt);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve the formatted payment subtotal.
|
||||
* @param {IPaymentReceive} payment
|
||||
* @param {IPaymentReceived} payment
|
||||
* @returns {string}
|
||||
*/
|
||||
protected subtotalFormatted = (payment: IPaymentReceive): string => {
|
||||
protected subtotalFormatted = (payment: IPaymentReceived): string => {
|
||||
return formatNumber(payment.amount, {
|
||||
currencyCode: payment.currencyCode,
|
||||
money: false,
|
||||
@@ -54,25 +54,25 @@ export class PaymentReceiveTransfromer extends Transformer {
|
||||
* @param {ISaleInvoice} invoice
|
||||
* @returns {string}
|
||||
*/
|
||||
protected formattedAmount = (payment: IPaymentReceive): string => {
|
||||
protected formattedAmount = (payment: IPaymentReceived): string => {
|
||||
return formatNumber(payment.amount, { currencyCode: payment.currencyCode });
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve the formatted exchange rate.
|
||||
* @param {IPaymentReceive} payment
|
||||
* @param {IPaymentReceived} payment
|
||||
* @returns {string}
|
||||
*/
|
||||
protected formattedExchangeRate = (payment: IPaymentReceive): string => {
|
||||
protected formattedExchangeRate = (payment: IPaymentReceived): string => {
|
||||
return formatNumber(payment.exchangeRate, { money: false });
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the payment entries.
|
||||
* @param {IPaymentReceive} payment
|
||||
* @returns {IPaymentReceiveEntry[]}
|
||||
* @param {IPaymentReceived} payment
|
||||
* @returns {IPaymentReceivedEntry[]}
|
||||
*/
|
||||
protected entries = (payment: IPaymentReceive): IPaymentReceiveEntry[] => {
|
||||
protected entries = (payment: IPaymentReceived): IPaymentReceivedEntry[] => {
|
||||
return this.item(payment.entries, new PaymentReceivedEntryTransfromer());
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Inject, Service } from 'typedi';
|
||||
import { difference, sumBy } from 'lodash';
|
||||
import {
|
||||
IAccount,
|
||||
IPaymentReceive,
|
||||
IPaymentReceiveEditDTO,
|
||||
IPaymentReceiveEntry,
|
||||
IPaymentReceiveEntryDTO,
|
||||
IPaymentReceived,
|
||||
IPaymentReceivedEditDTO,
|
||||
IPaymentReceivedEntry,
|
||||
IPaymentReceivedEntryDTO,
|
||||
ISaleInvoice,
|
||||
} from '@/interfaces';
|
||||
import { ServiceError } from '@/exceptions';
|
||||
@@ -58,7 +58,7 @@ export class PaymentReceivedValidators {
|
||||
* Validates the invoices IDs existance.
|
||||
* @param {number} tenantId -
|
||||
* @param {number} customerId -
|
||||
* @param {IPaymentReceiveEntryDTO[]} paymentReceiveEntries -
|
||||
* @param {IPaymentReceivedEntryDTO[]} paymentReceiveEntries -
|
||||
*/
|
||||
public async validateInvoicesIDsExistance(
|
||||
tenantId: number,
|
||||
@@ -100,12 +100,12 @@ export class PaymentReceivedValidators {
|
||||
*/
|
||||
public async validateInvoicesPaymentsAmount(
|
||||
tenantId: number,
|
||||
paymentReceiveEntries: IPaymentReceiveEntryDTO[],
|
||||
oldPaymentEntries: IPaymentReceiveEntry[] = []
|
||||
paymentReceiveEntries: IPaymentReceivedEntryDTO[],
|
||||
oldPaymentEntries: IPaymentReceivedEntry[] = []
|
||||
) {
|
||||
const { SaleInvoice } = this.tenancy.models(tenantId);
|
||||
const invoicesIds = paymentReceiveEntries.map(
|
||||
(e: IPaymentReceiveEntryDTO) => e.invoiceId
|
||||
(e: IPaymentReceivedEntryDTO) => e.invoiceId
|
||||
);
|
||||
|
||||
const storedInvoices = await SaleInvoice.query().whereIn('id', invoicesIds);
|
||||
@@ -124,7 +124,7 @@ export class PaymentReceivedValidators {
|
||||
const hasWrongPaymentAmount: any[] = [];
|
||||
|
||||
paymentReceiveEntries.forEach(
|
||||
(entry: IPaymentReceiveEntryDTO, index: number) => {
|
||||
(entry: IPaymentReceivedEntryDTO, index: number) => {
|
||||
const entryInvoice = storedInvoicesMap.get(entry.invoiceId);
|
||||
const { dueAmount } = entryInvoice;
|
||||
|
||||
@@ -140,9 +140,9 @@ export class PaymentReceivedValidators {
|
||||
|
||||
/**
|
||||
* Validate the payment receive number require.
|
||||
* @param {IPaymentReceive} paymentReceiveObj
|
||||
* @param {IPaymentReceived} paymentReceiveObj
|
||||
*/
|
||||
public validatePaymentReceiveNoRequire(paymentReceiveObj: IPaymentReceive) {
|
||||
public validatePaymentReceiveNoRequire(paymentReceiveObj: IPaymentReceived) {
|
||||
if (!paymentReceiveObj.paymentReceiveNo) {
|
||||
throw new ServiceError(ERRORS.PAYMENT_RECEIVE_NO_IS_REQUIRED);
|
||||
}
|
||||
@@ -152,12 +152,12 @@ export class PaymentReceivedValidators {
|
||||
* Validate the payment receive entries IDs existance.
|
||||
* @param {number} tenantId
|
||||
* @param {number} paymentReceiveId
|
||||
* @param {IPaymentReceiveEntryDTO[]} paymentReceiveEntries
|
||||
* @param {IPaymentReceivedEntryDTO[]} paymentReceiveEntries
|
||||
*/
|
||||
public async validateEntriesIdsExistance(
|
||||
tenantId: number,
|
||||
paymentReceiveId: number,
|
||||
paymentReceiveEntries: IPaymentReceiveEntryDTO[]
|
||||
paymentReceiveEntries: IPaymentReceivedEntryDTO[]
|
||||
) {
|
||||
const { PaymentReceiveEntry } = this.tenancy.models(tenantId);
|
||||
|
||||
@@ -189,12 +189,12 @@ export class PaymentReceivedValidators {
|
||||
|
||||
/**
|
||||
* Validate the payment customer whether modified.
|
||||
* @param {IPaymentReceiveEditDTO} paymentReceiveDTO
|
||||
* @param {IPaymentReceive} oldPaymentReceive
|
||||
* @param {IPaymentReceivedEditDTO} paymentReceiveDTO
|
||||
* @param {IPaymentReceived} oldPaymentReceive
|
||||
*/
|
||||
public validateCustomerNotModified(
|
||||
paymentReceiveDTO: IPaymentReceiveEditDTO,
|
||||
oldPaymentReceive: IPaymentReceive
|
||||
paymentReceiveDTO: IPaymentReceivedEditDTO,
|
||||
oldPaymentReceive: IPaymentReceived
|
||||
) {
|
||||
if (paymentReceiveDTO.customerId !== oldPaymentReceive.customerId) {
|
||||
throw new ServiceError(ERRORS.PAYMENT_CUSTOMER_SHOULD_NOT_UPDATE);
|
||||
@@ -230,7 +230,7 @@ export class PaymentReceivedValidators {
|
||||
async getPaymentReceiveOrThrowError(
|
||||
tenantId: number,
|
||||
paymentReceiveId: number
|
||||
): Promise<IPaymentReceive> {
|
||||
): Promise<IPaymentReceived> {
|
||||
const { PaymentReceive } = this.tenancy.models(tenantId);
|
||||
const paymentReceive = await PaymentReceive.query()
|
||||
.withGraphFetched('entries')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { IAccountsStructureType, IPaymentReceivesFilter } from '@/interfaces';
|
||||
import { IAccountsStructureType, IPaymentsReceivedFilter } from '@/interfaces';
|
||||
import { Exportable } from '@/services/Export/Exportable';
|
||||
import { PaymentReceivesApplication } from './PaymentReceivedApplication';
|
||||
|
||||
@@ -11,17 +11,17 @@ export class PaymentsReceivedExportable extends Exportable {
|
||||
/**
|
||||
* Retrieves the accounts data to exportable sheet.
|
||||
* @param {number} tenantId
|
||||
* @param {IPaymentReceivesFilter} query -
|
||||
* @param {IPaymentsReceivedFilter} query -
|
||||
* @returns
|
||||
*/
|
||||
public exportable(tenantId: number, query: IPaymentReceivesFilter) {
|
||||
public exportable(tenantId: number, query: IPaymentsReceivedFilter) {
|
||||
const parsedQuery = {
|
||||
sortOrder: 'desc',
|
||||
columnSortBy: 'created_at',
|
||||
inactiveMode: false,
|
||||
...query,
|
||||
structure: IAccountsStructureType.Flat,
|
||||
} as IPaymentReceivesFilter;
|
||||
} as IPaymentsReceivedFilter;
|
||||
|
||||
return this.paymentReceivedApp
|
||||
.getPaymentReceives(tenantId, parsedQuery)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { Knex } from 'knex';
|
||||
import { IPaymentReceiveCreateDTO } from '@/interfaces';
|
||||
import { IPaymentReceivedCreateDTO } from '@/interfaces';
|
||||
import { Importable } from '@/services/Import/Importable';
|
||||
import { CreatePaymentReceived } from './CreatePaymentReceived';
|
||||
import { PaymentsReceiveSampleData } from './constants';
|
||||
@@ -18,7 +18,7 @@ export class PaymentsReceivedImportable extends Importable {
|
||||
*/
|
||||
public importable(
|
||||
tenantId: number,
|
||||
createPaymentDTO: IPaymentReceiveCreateDTO,
|
||||
createPaymentDTO: IPaymentReceivedCreateDTO,
|
||||
trx?: Knex.Transaction
|
||||
) {
|
||||
return this.createPaymentReceiveService.createPaymentReceived(
|
||||
|
||||
@@ -3,7 +3,7 @@ import { omit } from 'lodash';
|
||||
import {
|
||||
ISaleInvoice,
|
||||
IPaymentReceivePageEntry,
|
||||
IPaymentReceive,
|
||||
IPaymentReceived,
|
||||
ISystemUser,
|
||||
} from '@/interfaces';
|
||||
import TenancyService from '@/services/Tenancy/TenancyService';
|
||||
@@ -65,7 +65,7 @@ export default class PaymentsReceivedPages {
|
||||
tenantId: number,
|
||||
paymentReceiveId: number
|
||||
): Promise<{
|
||||
paymentReceive: Omit<IPaymentReceive, 'entries'>;
|
||||
paymentReceive: Omit<IPaymentReceived, 'entries'>;
|
||||
entries: IPaymentReceivePageEntry[];
|
||||
}> {
|
||||
const { PaymentReceive, SaleInvoice } = this.tenancy.models(tenantId);
|
||||
|
||||
@@ -5,9 +5,9 @@ import {
|
||||
ISaleInvoiceCreatingPaylaod,
|
||||
ISaleReceiptDeletingPayload,
|
||||
ICreditNoteDeletingPayload,
|
||||
IPaymentReceiveCreatingPayload,
|
||||
IPaymentReceivedCreatingPayload,
|
||||
IRefundCreditNoteDeletingPayload,
|
||||
IPaymentReceiveDeletingPayload,
|
||||
IPaymentReceivedDeletingPayload,
|
||||
ISaleEstimateDeletingPayload,
|
||||
ISaleEstimateCreatingPayload,
|
||||
ISaleEstimateEditingPayload,
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
ISaleInvoiceWrittenOffCancelPayload,
|
||||
ICreditNoteEditingPayload,
|
||||
ISaleReceiptEditingPayload,
|
||||
IPaymentReceiveEditingPayload,
|
||||
IPaymentReceivedEditingPayload,
|
||||
ISaleReceiptEventClosingPayload,
|
||||
ICreditNoteCreatingPayload,
|
||||
} from '@/interfaces';
|
||||
@@ -454,13 +454,13 @@ export default class SalesTransactionLockingGuardSubscriber {
|
||||
|
||||
/**
|
||||
* Transaction locking guard on payment receive editing.
|
||||
* @param {IPaymentReceiveEditingPayload}
|
||||
* @param {IPaymentReceivedEditingPayload}
|
||||
*/
|
||||
private transactionLockingGuardOnPaymentEditing = async ({
|
||||
tenantId,
|
||||
oldPaymentReceive,
|
||||
paymentReceiveDTO,
|
||||
}: IPaymentReceiveEditingPayload) => {
|
||||
}: IPaymentReceivedEditingPayload) => {
|
||||
// Validate the old payment date.
|
||||
await this.salesLockingGuard.transactionLockingGuard(
|
||||
tenantId,
|
||||
@@ -475,12 +475,12 @@ export default class SalesTransactionLockingGuardSubscriber {
|
||||
|
||||
/**
|
||||
* Transaction locking guard on payment creating.
|
||||
* @param {IPaymentReceiveCreatingPayload}
|
||||
* @param {IPaymentReceivedCreatingPayload}
|
||||
*/
|
||||
private transactionLockingGuardOnPaymentCreating = async ({
|
||||
tenantId,
|
||||
paymentReceiveDTO,
|
||||
}: IPaymentReceiveCreatingPayload) => {
|
||||
}: IPaymentReceivedCreatingPayload) => {
|
||||
await this.salesLockingGuard.transactionLockingGuard(
|
||||
tenantId,
|
||||
paymentReceiveDTO.paymentDate
|
||||
@@ -489,12 +489,12 @@ export default class SalesTransactionLockingGuardSubscriber {
|
||||
|
||||
/**
|
||||
* Transaction locking guard on payment deleting.
|
||||
* @param {IPaymentReceiveDeletingPayload} payload -
|
||||
* @param {IPaymentReceivedDeletingPayload} payload -
|
||||
*/
|
||||
private transactionLockingGuardPaymentDeleting = async ({
|
||||
oldPaymentReceive,
|
||||
tenantId,
|
||||
}: IPaymentReceiveDeletingPayload) => {
|
||||
}: IPaymentReceivedDeletingPayload) => {
|
||||
await this.salesLockingGuard.transactionLockingGuard(
|
||||
tenantId,
|
||||
oldPaymentReceive.paymentDate
|
||||
|
||||
Reference in New Issue
Block a user