mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
fix:create customer/vendor
This commit is contained in:
@@ -6,8 +6,8 @@ import {
|
||||
IsString,
|
||||
} from 'class-validator';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsOptional, ToNumber } from '@/common/decorators/Validators';
|
||||
import { ContactAddressDto } from './ContactAddress.dto';
|
||||
import { IsOptional } from '@/common/decorators/Validators';
|
||||
|
||||
export class CreateCustomerDto extends ContactAddressDto {
|
||||
@ApiProperty({
|
||||
@@ -35,6 +35,7 @@ export class CreateCustomerDto extends ContactAddressDto {
|
||||
})
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@ToNumber()
|
||||
openingBalance?: number;
|
||||
|
||||
@ApiProperty({
|
||||
@@ -53,6 +54,7 @@ export class CreateCustomerDto extends ContactAddressDto {
|
||||
})
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@ToNumber()
|
||||
openingBalanceExchangeRate?: number;
|
||||
|
||||
@ApiProperty({
|
||||
@@ -62,6 +64,7 @@ export class CreateCustomerDto extends ContactAddressDto {
|
||||
})
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@ToNumber()
|
||||
openingBalanceBranchId?: number;
|
||||
|
||||
@ApiProperty({
|
||||
|
||||
@@ -40,7 +40,7 @@ export class DeleteItemService {
|
||||
const oldItem = await this.itemModel()
|
||||
.query()
|
||||
.findOne('id', itemId)
|
||||
.deleteIfNoRelations();
|
||||
.throwIfNotFound();
|
||||
|
||||
// Delete item in unit of work.
|
||||
return this.uow.withTransaction(async (trx: Knex.Transaction) => {
|
||||
@@ -51,8 +51,9 @@ export class DeleteItemService {
|
||||
} as IItemEventDeletingPayload);
|
||||
|
||||
// Deletes the item.
|
||||
await this.itemModel().query(trx).findById(itemId).delete();
|
||||
|
||||
await this.itemModel().query(trx).findById(itemId).deleteIfNoRelations({
|
||||
type: ERRORS.ITEM_HAS_ASSOCIATED_TRANSACTINS,
|
||||
});
|
||||
// Triggers `onItemDeleted` event.
|
||||
await this.eventEmitter.emitAsync(events.item.onDeleted, {
|
||||
itemId,
|
||||
|
||||
@@ -9,13 +9,14 @@ import {
|
||||
IsString,
|
||||
} from 'class-validator';
|
||||
import { ContactAddressDto } from '@/modules/Customers/dtos/ContactAddress.dto';
|
||||
import { IsOptional } from '@/common/decorators/Validators';
|
||||
import { IsOptional, ToNumber } from '@/common/decorators/Validators';
|
||||
|
||||
export class CreateVendorDto extends ContactAddressDto {
|
||||
@ApiProperty({ required: false, description: 'Vendor opening balance' })
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
@ToNumber()
|
||||
openingBalance?: number;
|
||||
|
||||
@ApiProperty({
|
||||
@@ -26,6 +27,7 @@ export class CreateVendorDto extends ContactAddressDto {
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@Min(0.01)
|
||||
@ToNumber()
|
||||
openingBalanceExchangeRate?: number;
|
||||
|
||||
@ApiProperty({ required: false, description: 'Date of the opening balance' })
|
||||
@@ -39,6 +41,7 @@ export class CreateVendorDto extends ContactAddressDto {
|
||||
})
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@ToNumber()
|
||||
openingBalanceBranchId?: number;
|
||||
|
||||
@ApiProperty({ description: 'Currency code for the vendor' })
|
||||
|
||||
Reference in New Issue
Block a user