From 2e90e3cc5b664f279aa2b7891bcd7920cbd4949c Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Thu, 26 Mar 2026 18:04:33 +0200 Subject: [PATCH] wip --- ...0326120000_add_contact_code_to_contacts.ts | 12 ++++++++++++ .../Customers/dtos/CreateCustomer.dto.ts | 9 +++++++++ .../Customers/dtos/EditCustomer.dto.ts | 5 +++++ .../src/modules/Customers/models/Customer.ts | 2 ++ .../Customers/types/Customers.types.ts | 2 ++ .../modules/Vendors/dtos/CreateVendor.dto.ts | 9 +++++++++ .../modules/Vendors/dtos/EditVendor.dto.ts | 5 +++++ .../src/modules/Vendors/models/Vendor.ts | 2 ++ .../modules/Vendors/types/Vendors.types.ts | 2 ++ .../CustomerForm/CustomerFormBasicSection.tsx | 5 ++--- .../CustomerForm/CustomerFormPage.tsx | 19 +++---------------- .../VendorForm/VendorFormBasicSection.tsx | 12 ++++++++++++ 12 files changed, 65 insertions(+), 19 deletions(-) create mode 100644 packages/server/src/database/tenant/migrations/20250326120000_add_contact_code_to_contacts.ts diff --git a/packages/server/src/database/tenant/migrations/20250326120000_add_contact_code_to_contacts.ts b/packages/server/src/database/tenant/migrations/20250326120000_add_contact_code_to_contacts.ts new file mode 100644 index 000000000..28caa2762 --- /dev/null +++ b/packages/server/src/database/tenant/migrations/20250326120000_add_contact_code_to_contacts.ts @@ -0,0 +1,12 @@ + +exports.up = function(knex) { + return knex.schema.alterTable('contacts', table => { + table.string('code').nullable().unique(); + }); +}; + +exports.down = function(knex) { + return knex.schema.alterTable('contacts', table => { + table.dropColumn('code'); + }); +}; diff --git a/packages/server/src/modules/Customers/dtos/CreateCustomer.dto.ts b/packages/server/src/modules/Customers/dtos/CreateCustomer.dto.ts index 9569d9da4..fa1032e56 100644 --- a/packages/server/src/modules/Customers/dtos/CreateCustomer.dto.ts +++ b/packages/server/src/modules/Customers/dtos/CreateCustomer.dto.ts @@ -155,4 +155,13 @@ export class CreateCustomerDto extends ContactAddressDto { @IsOptional() @IsBoolean() active?: boolean; + + @ApiProperty({ + required: false, + description: 'Customer code', + example: 'CUST-001', + }) + @IsOptional() + @IsString() + code?: string; } diff --git a/packages/server/src/modules/Customers/dtos/EditCustomer.dto.ts b/packages/server/src/modules/Customers/dtos/EditCustomer.dto.ts index 44f7b31d6..f94ea4032 100644 --- a/packages/server/src/modules/Customers/dtos/EditCustomer.dto.ts +++ b/packages/server/src/modules/Customers/dtos/EditCustomer.dto.ts @@ -63,4 +63,9 @@ export class EditCustomerDto extends ContactAddressDto { @IsOptional() @IsBoolean() active?: boolean; + + @ApiProperty({ required: false, description: 'Customer code' }) + @IsOptional() + @IsString() + code?: string; } diff --git a/packages/server/src/modules/Customers/models/Customer.ts b/packages/server/src/modules/Customers/models/Customer.ts index 47aa6f59e..3c478c07f 100644 --- a/packages/server/src/modules/Customers/models/Customer.ts +++ b/packages/server/src/modules/Customers/models/Customer.ts @@ -70,6 +70,8 @@ export class Customer extends TenantBaseModel { note: string; active: boolean; + code?: string; + /** * Query builder. */ diff --git a/packages/server/src/modules/Customers/types/Customers.types.ts b/packages/server/src/modules/Customers/types/Customers.types.ts index 5bb0b85f2..3ac45a3a7 100644 --- a/packages/server/src/modules/Customers/types/Customers.types.ts +++ b/packages/server/src/modules/Customers/types/Customers.types.ts @@ -32,6 +32,7 @@ export interface ICustomerNewDTO extends IContactAddressDTO { note?: string; active?: boolean; + code?: string; } export interface ICustomerEditDTO extends IContactAddressDTO { @@ -50,6 +51,7 @@ export interface ICustomerEditDTO extends IContactAddressDTO { note?: string; active?: boolean; + code?: string; } export interface ICustomersFilter extends IDynamicListFilter { diff --git a/packages/server/src/modules/Vendors/dtos/CreateVendor.dto.ts b/packages/server/src/modules/Vendors/dtos/CreateVendor.dto.ts index 65cf9fe4e..fd97a23fb 100644 --- a/packages/server/src/modules/Vendors/dtos/CreateVendor.dto.ts +++ b/packages/server/src/modules/Vendors/dtos/CreateVendor.dto.ts @@ -115,4 +115,13 @@ export class CreateVendorDto extends ContactAddressDto { @IsOptional() @IsBoolean() active?: boolean; + + @ApiProperty({ + required: false, + description: 'Vendor code', + example: 'VEND-001', + }) + @IsOptional() + @IsString() + code?: string; } diff --git a/packages/server/src/modules/Vendors/dtos/EditVendor.dto.ts b/packages/server/src/modules/Vendors/dtos/EditVendor.dto.ts index 7497c6064..cc5a29a3f 100644 --- a/packages/server/src/modules/Vendors/dtos/EditVendor.dto.ts +++ b/packages/server/src/modules/Vendors/dtos/EditVendor.dto.ts @@ -60,4 +60,9 @@ export class EditVendorDto extends ContactAddressDto { @IsOptional() @IsBoolean() active?: boolean; + + @ApiProperty({ required: false, description: 'Vendor code' }) + @IsOptional() + @IsString() + code?: string; } diff --git a/packages/server/src/modules/Vendors/models/Vendor.ts b/packages/server/src/modules/Vendors/models/Vendor.ts index 8ccd81640..c03a39c68 100644 --- a/packages/server/src/modules/Vendors/models/Vendor.ts +++ b/packages/server/src/modules/Vendors/models/Vendor.ts @@ -71,6 +71,8 @@ export class Vendor extends TenantBaseModel { note: string; active: boolean; + code?: string; + /** * Query builder. */ diff --git a/packages/server/src/modules/Vendors/types/Vendors.types.ts b/packages/server/src/modules/Vendors/types/Vendors.types.ts index 381e3abc9..47a8d360f 100644 --- a/packages/server/src/modules/Vendors/types/Vendors.types.ts +++ b/packages/server/src/modules/Vendors/types/Vendors.types.ts @@ -31,6 +31,7 @@ export interface IVendorNewDTO extends IContactAddressDTO { note?: string; active?: boolean; + code?: string; } export interface IVendorEditDTO extends IContactAddressDTO { salutation?: string; @@ -46,6 +47,7 @@ export interface IVendorEditDTO extends IContactAddressDTO { note?: string; active?: boolean; + code?: string; } export interface IVendorsFilter extends IDynamicListFilter { diff --git a/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormBasicSection.tsx b/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormBasicSection.tsx index 44145eb99..e8ea912df 100644 --- a/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormBasicSection.tsx +++ b/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormBasicSection.tsx @@ -79,9 +79,8 @@ export function CustomerFormBasicSection({}) { {/*----------- Display Name -----------*/} - } + label={} + helperText="This is the name that appears on invoices and emails." inline fill > diff --git a/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormPage.tsx b/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormPage.tsx index 8ab5e1a42..8e9b8ff49 100644 --- a/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormPage.tsx +++ b/packages/webapp/src/containers/Customers/CustomerForm/CustomerFormPage.tsx @@ -9,20 +9,6 @@ import { useCustomerFormContext, } from './CustomerFormProvider'; -/** - * Customer form page loading. - * @returns {JSX} - */ -function CustomerFormPageLoading({ children }) { - const { isFormLoading } = useCustomerFormContext(); - - return ( - - {children} - - ); -} - /** * Customer form page. * @returns {JSX} @@ -30,6 +16,7 @@ function CustomerFormPageLoading({ children }) { export default function CustomerFormPage() { const history = useHistory(); const { id } = useParams(); + const { isFormLoading } = useCustomerFormContext(); const customerId = parseInt(id, 10); @@ -46,14 +33,14 @@ export default function CustomerFormPage() { return ( - + - + ); } \ No newline at end of file diff --git a/packages/webapp/src/containers/Vendors/VendorForm/VendorFormBasicSection.tsx b/packages/webapp/src/containers/Vendors/VendorForm/VendorFormBasicSection.tsx index 35a314fd9..6c3507c24 100644 --- a/packages/webapp/src/containers/Vendors/VendorForm/VendorFormBasicSection.tsx +++ b/packages/webapp/src/containers/Vendors/VendorForm/VendorFormBasicSection.tsx @@ -49,6 +49,18 @@ export function VendorFormBasicSection({}) { + + + + {/*----------- Company Name -----------*/}