fix: issues related to PUT operations

This commit is contained in:
Ahmed Bouhuolia
2025-10-28 18:12:08 +02:00
parent 368c85a01a
commit f736c3f9eb
23 changed files with 48 additions and 37 deletions

View File

@@ -8,6 +8,7 @@ import { BranchTransactionDTOTransformer } from '@/modules/Branches/integrations
import { WarehouseTransactionDTOTransform } from '@/modules/Warehouses/Integrations/WarehouseTransactionDTOTransform';
import { VendorCredit } from '../models/VendorCredit';
import { assocItemEntriesDefaultIndex } from '@/utils/associate-item-entries-index';
import { formatDateFields } from '@/utils/format-date-fields';
import { VendorCreditAutoIncrementService } from './VendorCreditAutoIncrement.service';
import { ServiceError } from '@/modules/Items/ServiceError';
import { Injectable } from '@nestjs/common';
@@ -30,7 +31,7 @@ export class VendorCreditDTOTransformService {
private branchDTOTransform: BranchTransactionDTOTransformer,
private warehouseDTOTransform: WarehouseTransactionDTOTransform,
private vendorCreditAutoIncrement: VendorCreditAutoIncrementService,
) {}
) { }
/**
* Transforms the credit/edit vendor credit DTO to model.
@@ -70,7 +71,10 @@ export class VendorCreditDTOTransformService {
autoNextNumber;
const initialDTO = {
...omit(vendorCreditDTO, ['open', 'attachments']),
...formatDateFields(
omit(vendorCreditDTO, ['open', 'attachments']),
['vendorCreditDate'],
),
amount,
currencyCode: vendorCurrencyCode,
exchangeRate: vendorCreditDTO.exchangeRate || 1,
@@ -78,8 +82,8 @@ export class VendorCreditDTOTransformService {
entries,
...(vendorCreditDTO.open &&
!oldVendorCredit?.openedAt && {
openedAt: moment().toMySqlDateTime(),
}),
openedAt: moment().toMySqlDateTime(),
}),
};
return composeAsync(
this.branchDTOTransform.transformDTO<VendorCredit>,