feat: wip upload attachmentsx

This commit is contained in:
Ahmed Bouhuolia
2024-05-29 13:58:08 +02:00
parent cfdbcea9c0
commit e7871e34a9
7 changed files with 33 additions and 12 deletions

View File

@@ -27,23 +27,23 @@ export class AttachmentsOnVendorCredits {
*/
public attach(bus) {
bus.subscribe(
events.saleInvoice.onCreating,
events.vendorCredit.onCreating,
this.validateAttachmentsOnVendorCreditCreate.bind(this)
);
bus.subscribe(
events.saleInvoice.onCreated,
events.vendorCredit.onCreated,
this.handleAttachmentsOnVendorCreditCreated.bind(this)
);
bus.subscribe(
events.saleInvoice.onEdited,
events.vendorCredit.onEdited,
this.handleUnlinkUnpresentedKeysOnVendorCreditEdited.bind(this)
);
bus.subscribe(
events.saleInvoice.onEdited,
events.vendorCredit.onEdited,
this.handleLinkPresentedKeysOnVendorCreditEdited.bind(this)
);
bus.subscribe(
events.saleInvoice.onDeleting,
events.vendorCredit.onDeleting,
this.handleUnlinkAttachmentsOnVendorCreditDeleted.bind(this)
);
}

View File

@@ -28,7 +28,8 @@ export default class GetCreditNote extends BaseCreditNotes {
.findById(creditNoteId)
.withGraphFetched('entries.item')
.withGraphFetched('customer')
.withGraphFetched('branch');
.withGraphFetched('branch')
.withGraphFetched('attachments');
if (!creditNote) {
throw new ServiceError(ERRORS.CREDIT_NOTE_NOT_FOUND);

View File

@@ -25,7 +25,8 @@ export default class BillPaymentsPages {
const { BillPayment, Bill } = this.tenancy.models(tenantId);
const billPayment = await BillPayment.query()
.findById(billPaymentId)
.withGraphFetched('entries.bill');
.withGraphFetched('entries.bill')
.withGraphFetched('attachments');
// Throw not found the bill payment.
if (!billPayment) {

View File

@@ -112,7 +112,6 @@ export class CreateBillPayment {
const billPayment = await BillPayment.query(trx).insertGraphAndFetch({
...billPaymentObj,
});
// Triggers `onBillPaymentCreated` event.
await this.eventPublisher.emitAsync(events.billPayment.onCreated, {
tenantId,

View File

@@ -51,7 +51,7 @@ export class PaymentReceiveDTOTransformer {
this.validators.validatePaymentNoRequire(paymentReceiveNo);
const initialDTO = {
...formatDateFields(omit(paymentReceiveDTO, ['entries']), [
...formatDateFields(omit(paymentReceiveDTO, ['entries', 'attachments']), [
'paymentDate',
]),
amount: paymentAmount,

View File

@@ -66,7 +66,7 @@ export default class PaymentReceivesPages {
*/
public async getPaymentReceiveEditPage(
tenantId: number,
paymentReceiveId: number,
paymentReceiveId: number
): Promise<{
paymentReceive: Omit<IPaymentReceive, 'entries'>;
entries: IPaymentReceivePageEntry[];
@@ -76,7 +76,8 @@ export default class PaymentReceivesPages {
// Retrieve payment receive.
const paymentReceive = await PaymentReceive.query()
.findById(paymentReceiveId)
.withGraphFetched('entries.invoice');
.withGraphFetched('entries.invoice')
.withGraphFetched('attachments');
// Throw not found the payment receive.
if (!paymentReceive) {