mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
fix: issues related to PUT operations
This commit is contained in:
@@ -28,8 +28,9 @@ export class EditBillService {
|
||||
private transformerDTO: BillDTOTransformer,
|
||||
|
||||
@Inject(Bill.name) private billModel: TenantModelProxy<typeof Bill>,
|
||||
@Inject(Vendor.name) private contactModel: TenantModelProxy<typeof Vendor>,
|
||||
) {}
|
||||
@Inject(Vendor.name) private vendorModel: TenantModelProxy<typeof Vendor>,
|
||||
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Edits details of the given bill id with associated entries.
|
||||
@@ -58,10 +59,9 @@ export class EditBillService {
|
||||
this.validators.validateBillExistance(oldBill);
|
||||
|
||||
// Retrieve vendor details or throw not found service error.
|
||||
const vendor = await this.contactModel()
|
||||
const vendor = await this.vendorModel()
|
||||
.query()
|
||||
.findById(billDTO.vendorId)
|
||||
.modify('vendor')
|
||||
.throwIfNotFound();
|
||||
|
||||
// Validate bill number uniqiness on the storage.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ToNumber } from '@/common/decorators/Validators';
|
||||
import { ItemEntryDto } from '@/modules/TransactionItemEntry/dto/ItemEntry.dto';
|
||||
import { Type } from 'class-transformer';
|
||||
import { Type, Transform } from 'class-transformer';
|
||||
import { parseBoolean } from '@/utils/parse-boolean';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import {
|
||||
ArrayMinSize,
|
||||
@@ -31,6 +32,7 @@ export class BillEntryDto extends ItemEntryDto {
|
||||
})
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
@Transform(({ value }) => parseBoolean(value, false))
|
||||
landedCost?: boolean;
|
||||
}
|
||||
|
||||
@@ -211,5 +213,5 @@ export class CommandBillDto {
|
||||
adjustment?: number;
|
||||
}
|
||||
|
||||
export class CreateBillDto extends CommandBillDto {}
|
||||
export class EditBillDto extends CommandBillDto {}
|
||||
export class CreateBillDto extends CommandBillDto { }
|
||||
export class EditBillDto extends CommandBillDto { }
|
||||
|
||||
@@ -10,6 +10,7 @@ import { BranchTransactionDTOTransformer } from '@/modules/Branches/integrations
|
||||
import { WarehouseTransactionDTOTransform } from '@/modules/Warehouses/Integrations/WarehouseTransactionDTOTransform';
|
||||
import { BrandingTemplateDTOTransformer } from '../../PdfTemplate/BrandingTemplateDTOTransformer';
|
||||
import { assocItemEntriesDefaultIndex } from '@/utils/associate-item-entries-index';
|
||||
import { formatDateFields } from '@/utils/format-date-fields';
|
||||
import { CreditNoteAutoIncrementService } from './CreditNoteAutoIncrement.service';
|
||||
import { CreditNote } from '../models/CreditNote';
|
||||
import {
|
||||
@@ -33,7 +34,7 @@ export class CommandCreditNoteDTOTransform {
|
||||
private readonly warehouseDTOTransform: WarehouseTransactionDTOTransform,
|
||||
private readonly brandingTemplatesTransformer: BrandingTemplateDTOTransformer,
|
||||
private readonly creditNoteAutoIncrement: CreditNoteAutoIncrementService,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Transforms the credit/edit DTO to model.
|
||||
@@ -70,7 +71,10 @@ export class CommandCreditNoteDTOTransform {
|
||||
autoNextNumber;
|
||||
|
||||
const initialDTO = {
|
||||
...omit(creditNoteDTO, ['open', 'attachments']),
|
||||
...formatDateFields(
|
||||
omit(creditNoteDTO, ['open', 'attachments']),
|
||||
['creditNoteDate'],
|
||||
),
|
||||
creditNoteNumber,
|
||||
amount,
|
||||
currencyCode: customerCurrencyCode,
|
||||
@@ -78,8 +82,8 @@ export class CommandCreditNoteDTOTransform {
|
||||
entries,
|
||||
...(creditNoteDTO.open &&
|
||||
!oldCreditNote?.openedAt && {
|
||||
openedAt: moment().toMySqlDateTime(),
|
||||
}),
|
||||
openedAt: moment().toMySqlDateTime(),
|
||||
}),
|
||||
refundedAmount: 0,
|
||||
invoicesAmount: 0,
|
||||
};
|
||||
|
||||
@@ -185,5 +185,5 @@ export class CommandExpenseDto {
|
||||
attachments?: AttachmentDto[];
|
||||
}
|
||||
|
||||
export class CreateExpenseDto extends CommandExpenseDto {}
|
||||
export class EditExpenseDto extends CommandExpenseDto {}
|
||||
export class CreateExpenseDto extends CommandExpenseDto { }
|
||||
export class EditExpenseDto extends CommandExpenseDto { }
|
||||
|
||||
@@ -21,7 +21,7 @@ enum DiscountType {
|
||||
Amount = 'amount',
|
||||
}
|
||||
|
||||
class SaleEstimateEntryDto extends ItemEntryDto {}
|
||||
class SaleEstimateEntryDto extends ItemEntryDto { }
|
||||
|
||||
class AttachmentDto {
|
||||
@IsString()
|
||||
@@ -140,6 +140,7 @@ export class CommandSaleEstimateDto {
|
||||
},
|
||||
],
|
||||
})
|
||||
attachments?: AttachmentDto[];
|
||||
|
||||
@IsOptional()
|
||||
@ToNumber()
|
||||
@@ -177,5 +178,5 @@ export class CommandSaleEstimateDto {
|
||||
adjustment?: number;
|
||||
}
|
||||
|
||||
export class CreateSaleEstimateDto extends CommandSaleEstimateDto {}
|
||||
export class EditSaleEstimateDto extends CommandSaleEstimateDto {}
|
||||
export class CreateSaleEstimateDto extends CommandSaleEstimateDto { }
|
||||
export class EditSaleEstimateDto extends CommandSaleEstimateDto { }
|
||||
|
||||
@@ -24,7 +24,7 @@ import { ApiCommonHeaders } from '@/common/decorators/ApiCommonHeaders';
|
||||
@ApiExtraModels(TaxRateResponseDto)
|
||||
@ApiCommonHeaders()
|
||||
export class TaxRatesController {
|
||||
constructor(private readonly taxRatesApplication: TaxRatesApplication) {}
|
||||
constructor(private readonly taxRatesApplication: TaxRatesApplication) { }
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'Create a new tax rate.' })
|
||||
|
||||
@@ -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>,
|
||||
|
||||
Reference in New Issue
Block a user