feat: wip UI upload attachments

This commit is contained in:
Ahmed Bouhuolia
2024-05-28 23:34:51 +02:00
parent fcd61c6159
commit cfdbcea9c0
49 changed files with 286 additions and 67 deletions

View File

@@ -64,7 +64,7 @@ export default class BaseVendorCredit {
autoNextNumber;
const initialDTO = {
...omit(vendorCreditDTO, ['open']),
...omit(vendorCreditDTO, ['open', 'attachments']),
amount,
currencyCode: vendorCurrencyCode,
exchangeRate: vendorCreditDTO.exchangeRate || 1,

View File

@@ -26,7 +26,8 @@ export default class GetVendorCredit {
.findById(vendorCreditId)
.withGraphFetched('entries.item')
.withGraphFetched('vendor')
.withGraphFetched('branch');
.withGraphFetched('branch')
.withGraphFetched('attachments');
if (!vendorCredit) {
throw new ServiceError(ERRORS.VENDOR_CREDIT_NOT_FOUND);

View File

@@ -1,5 +1,6 @@
import { IVendorCredit } from '@/interfaces';
import { Transformer } from '@/lib/Transformer/Transformer';
import { AttachmentTransformer } from '@/services/Attachments/AttachmentTransformer';
import { ItemEntryTransformer } from '@/services/Sales/Invoices/ItemEntryTransformer';
import { formatNumber } from 'utils';
@@ -16,6 +17,7 @@ export class VendorCreditTransformer extends Transformer {
'formattedCreditsRemaining',
'formattedInvoicedAmount',
'entries',
'attachments',
];
};
@@ -80,4 +82,13 @@ export class VendorCreditTransformer extends Transformer {
currencyCode: vendorCredit.currencyCode,
});
};
/**
* Retrieves the vendor credit attachments.
* @param {IVendorCredit} invoice
* @returns
*/
protected attachments = (vendorCredit) => {
return this.item(vendorCredit.attachments, new AttachmentTransformer());
};
}