mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
fix:create customer/vendor
This commit is contained in:
0
packages/server/public/pdf/.gitignore
vendored
Normal file
0
packages/server/public/pdf/.gitignore
vendored
Normal file
@@ -40,7 +40,7 @@ export class PaginationQueryBuilder<
|
|||||||
}: {
|
}: {
|
||||||
type?: string;
|
type?: string;
|
||||||
message?: string;
|
message?: string;
|
||||||
}) {
|
} = {}) {
|
||||||
const relationMappings = this.modelClass().relationMappings;
|
const relationMappings = this.modelClass().relationMappings;
|
||||||
const relationNames = Object.keys(relationMappings || {});
|
const relationNames = Object.keys(relationMappings || {});
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import {
|
|||||||
IsString,
|
IsString,
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
import { ApiProperty } from '@nestjs/swagger';
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsOptional, ToNumber } from '@/common/decorators/Validators';
|
||||||
import { ContactAddressDto } from './ContactAddress.dto';
|
import { ContactAddressDto } from './ContactAddress.dto';
|
||||||
import { IsOptional } from '@/common/decorators/Validators';
|
|
||||||
|
|
||||||
export class CreateCustomerDto extends ContactAddressDto {
|
export class CreateCustomerDto extends ContactAddressDto {
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
@@ -35,6 +35,7 @@ export class CreateCustomerDto extends ContactAddressDto {
|
|||||||
})
|
})
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
|
@ToNumber()
|
||||||
openingBalance?: number;
|
openingBalance?: number;
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
@@ -53,6 +54,7 @@ export class CreateCustomerDto extends ContactAddressDto {
|
|||||||
})
|
})
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
|
@ToNumber()
|
||||||
openingBalanceExchangeRate?: number;
|
openingBalanceExchangeRate?: number;
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
@@ -62,6 +64,7 @@ export class CreateCustomerDto extends ContactAddressDto {
|
|||||||
})
|
})
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
|
@ToNumber()
|
||||||
openingBalanceBranchId?: number;
|
openingBalanceBranchId?: number;
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export class DeleteItemService {
|
|||||||
const oldItem = await this.itemModel()
|
const oldItem = await this.itemModel()
|
||||||
.query()
|
.query()
|
||||||
.findOne('id', itemId)
|
.findOne('id', itemId)
|
||||||
.deleteIfNoRelations();
|
.throwIfNotFound();
|
||||||
|
|
||||||
// Delete item in unit of work.
|
// Delete item in unit of work.
|
||||||
return this.uow.withTransaction(async (trx: Knex.Transaction) => {
|
return this.uow.withTransaction(async (trx: Knex.Transaction) => {
|
||||||
@@ -51,8 +51,9 @@ export class DeleteItemService {
|
|||||||
} as IItemEventDeletingPayload);
|
} as IItemEventDeletingPayload);
|
||||||
|
|
||||||
// Deletes the item.
|
// 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.
|
// Triggers `onItemDeleted` event.
|
||||||
await this.eventEmitter.emitAsync(events.item.onDeleted, {
|
await this.eventEmitter.emitAsync(events.item.onDeleted, {
|
||||||
itemId,
|
itemId,
|
||||||
|
|||||||
@@ -9,13 +9,14 @@ import {
|
|||||||
IsString,
|
IsString,
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
import { ContactAddressDto } from '@/modules/Customers/dtos/ContactAddress.dto';
|
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 {
|
export class CreateVendorDto extends ContactAddressDto {
|
||||||
@ApiProperty({ required: false, description: 'Vendor opening balance' })
|
@ApiProperty({ required: false, description: 'Vendor opening balance' })
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsInt()
|
@IsInt()
|
||||||
@Min(0)
|
@Min(0)
|
||||||
|
@ToNumber()
|
||||||
openingBalance?: number;
|
openingBalance?: number;
|
||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
@@ -26,6 +27,7 @@ export class CreateVendorDto extends ContactAddressDto {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
@Min(0.01)
|
@Min(0.01)
|
||||||
|
@ToNumber()
|
||||||
openingBalanceExchangeRate?: number;
|
openingBalanceExchangeRate?: number;
|
||||||
|
|
||||||
@ApiProperty({ required: false, description: 'Date of the opening balance' })
|
@ApiProperty({ required: false, description: 'Date of the opening balance' })
|
||||||
@@ -39,6 +41,7 @@ export class CreateVendorDto extends ContactAddressDto {
|
|||||||
})
|
})
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsInt()
|
@IsInt()
|
||||||
|
@ToNumber()
|
||||||
openingBalanceBranchId?: number;
|
openingBalanceBranchId?: number;
|
||||||
|
|
||||||
@ApiProperty({ description: 'Currency code for the vendor' })
|
@ApiProperty({ description: 'Currency code for the vendor' })
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export function useEditCustomer(props) {
|
|||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation(
|
return useMutation(
|
||||||
([id, values]) => apiRequest.post(`customers/${id}`, values),
|
([id, values]) => apiRequest.put(`customers/${id}`, values),
|
||||||
{
|
{
|
||||||
onSuccess: (res, [id, values]) => {
|
onSuccess: (res, [id, values]) => {
|
||||||
// Invalidate specific customer.
|
// Invalidate specific customer.
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ export function useInvoiceSMSDetail(invoiceId, query, props) {
|
|||||||
params: query,
|
params: query,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
select: (res) => res.data.data,
|
select: (res) => res.data,
|
||||||
defaultData: {},
|
defaultData: {},
|
||||||
...props,
|
...props,
|
||||||
},
|
},
|
||||||
@@ -341,7 +341,7 @@ export function useInvoicePaymentTransactions(invoiceId, props) {
|
|||||||
url: `sale-invoices/${invoiceId}/payments`,
|
url: `sale-invoices/${invoiceId}/payments`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
select: (res) => res.data.data,
|
select: (res) => res.data,
|
||||||
defaultData: [],
|
defaultData: [],
|
||||||
...props,
|
...props,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export function useEditVendor(props) {
|
|||||||
const apiRequest = useApiRequest();
|
const apiRequest = useApiRequest();
|
||||||
|
|
||||||
return useMutation(
|
return useMutation(
|
||||||
([id, values]) => apiRequest.post(`vendors/${id}`, values),
|
([id, values]) => apiRequest.put(`vendors/${id}`, values),
|
||||||
{
|
{
|
||||||
onSuccess: (res, [id, values]) => {
|
onSuccess: (res, [id, values]) => {
|
||||||
// Invalidate specific vendor.
|
// Invalidate specific vendor.
|
||||||
|
|||||||
Reference in New Issue
Block a user