From df6ff314500525573449bb349f6dd8794d944539 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Thu, 3 Oct 2024 13:58:11 +0700 Subject: [PATCH] feat: type quotation --- src/stores/quotations/types.ts | 354 +++++++++++++++++---------------- 1 file changed, 182 insertions(+), 172 deletions(-) diff --git a/src/stores/quotations/types.ts b/src/stores/quotations/types.ts index 3f0632a7..7cc7620a 100644 --- a/src/stores/quotations/types.ts +++ b/src/stores/quotations/types.ts @@ -1,65 +1,160 @@ import { Status } from '../types'; -export type Quotation = { - customerBranch: { - customerCode?: string; - wageRateText: string; - wageRate: number; - payDateEN: string; - payDate: string; - jobDescription: string; - jobPosition: string; - businessType: string; - agent: string; - contactName: string; - officeTel: string; - contactTel: string; - email: string; - subDistrictId: string; - districtId: string; - provinceId: string; - streetEN: string; - street: string; - mooEN: string; - moo: string; - soiEN: string; - soi: string; - addressEN: string; - address: string; - employmentOfficeEN: string; - employmentOffice: string; - homeCode: string; - authorizedNameEN: string; - authorizedName: string; - authorizedCapital: string; - registerDate: string | Date | null; - registerNameEN: string; - registerName: string; - legalPersonNo: string; - citizenId: string; - birthDate: string; - gender: string; - lastNameEN: string; - lastName: string; - firstNameEN: string; - firstName: string; - namePrefix: string; - telephoneNo: string; - codeCustomer: string; - customerName: string; - updatedByUserId: string; - createdByUserId: string; - code: string; - statusOrder: 0; - customerId: string; - id: string; +type CustomerBranchRelation = { + customerCode?: string; + wageRateText: string; + wageRate: number; + payDateEN: string; + payDate: string; + jobDescription: string; + jobPosition: string; + businessType: string; + agent: string; + contactName: string; + officeTel: string; + contactTel: string; + email: string; + subDistrictId: string; + districtId: string; + provinceId: string; + streetEN: string; + street: string; + mooEN: string; + moo: string; + soiEN: string; + soi: string; + addressEN: string; + address: string; + employmentOfficeEN: string; + employmentOffice: string; + homeCode: string; + authorizedNameEN: string; + authorizedName: string; + authorizedCapital: string; + registerDate: string | Date | null; + registerNameEN: string; + registerName: string; + legalPersonNo: string; + citizenId: string; + birthDate: string; + gender: string; + lastNameEN: string; + lastName: string; + firstNameEN: string; + firstName: string; + namePrefix: string; + telephoneNo: string; + codeCustomer: string; + customerName: string; + updatedByUserId: string; + createdByUserId: string; + code: string; + statusOrder: 0; + customerId: string; + id: string; - status: Status; - createdBy: string | null; - createdAt: string; - updatedBy: string | null; - updatedAt: string; - }; + status: Status; + createdBy: string | null; + createdAt: string; + updatedBy: string | null; + updatedAt: string; +}; + +type EmployeeRelation = { + workerStatus: string; + workerType: string; + nationality: string; + dateOfBirth: string; + nrcNo: string; + selectedImage?: string; + middleNameEN: string; + middleName: string; + subDistrictId: string; + districtId: string; + provinceId: string; + streetEN: string; + street: string; + mooEN: string; + moo: string; + soiEN: string; + soi: string; + addressEN: string; + address: string; + gender: string; + lastNameEN: string; + lastName: string; + firstNameEN: string; + firstName: string; + namePrefix: string; + updatedByUserId: string; + updatedAt: string; + createdByUserId: string; + createdAt: string; + code: string; + statusOrder: 0; + status: Status; + customerBranchId: string; + id: string; +}; + +type ProductRelation = { + id: string; + code: string; + name: string; + detail: string; + process: number; + price: number; + agentPrice: number; + serviceCharge: number; + vatIncluded: boolean; + expenseType: string; + status: Status; + statusOrder: number; + shared: boolean; + remark: string; + selectedImage?: string; + productGroupId: string; + createdAt: string; + createdByUserId: string; + updatedAt: string; + updatedByUserId: string; +}; + +type WorkRelation = { + id: string; + order: number; + name: string; + attributes: any; + status: Status; + statusOrder: number; + serviceId: string; + createdAt: string; + createdByUserId?: string; + updatedAt: string; + updatedByUserId?: string; +}; + +type ServiceRelation = { + id: string; + code: string; + name: string; + detail: string; + attributes: any; + status: Status; + statusOrder: 0; + shared: string; + selectedImage?: string; + productGroupId: string; + createdAt: string; + createdByUserId: string; + updatedAt: string; + updatedByUserId: string; +}; + +export type Quotation = { + _count: { worker: number }; + + customerBranch: CustomerBranchRelation; worker: { id: string; @@ -69,31 +164,18 @@ export type Quotation = { no: number; }[]; - service: { - _count: { work: number }; + productServiceList: { + vat: number; + pricePerUnit: number; + discount: number; + amount: number; + productId: string; + workId: string; + serviceId: string; + }[]; - work: { - id: string; - serviceId: string; - name: string; - order: number; - attributes: any; - - _count: { productOnWork: number }; - }[]; - - id: string; - refServiceId: string; // Can be used to get image if still exists - quotationId: string; - - code: string; - name: string; - detail: string; - attributes: any; - }; id: string; finalPrice: number; - vatExcluded: number; vat: number; totalDiscount: number; totalPrice: number; @@ -101,6 +183,10 @@ export type Quotation = { workerCount: number; payBillDate: string | Date; paySplitCount: number; + paySplit: { + date: string | Date; + amount: number; + }[]; payCondition: 'Full' | 'Split' | 'BillFull' | 'BillSplit'; date: string | Date; dueDate: string | Date; @@ -126,103 +212,26 @@ export type QuotationFull = { id: string; quotationId: string; employeeId: string; + employee: EmployeeRelation; code: string; no: number; - employee: { - workerStatus: string; - workerType: string; - nationality: string; - dateOfBirth: string; - nrcNo: string; - selectedImage: string; - middleNameEN: string; - middleName: string; - subDistrictId: string; - districtId: string; - provinceId: string; - streetEN: string; - street: string; - mooEN: string; - moo: string; - soiEN: string; - soi: string; - addressEN: string; - address: string; - gender: string; - lastNameEN: string; - lastName: string; - firstNameEN: string; - firstName: string; - namePrefix: string; - updatedByUserId: string; - updatedAt: string; - createdByUserId: string; - createdAt: string; - code: string; - statusOrder: 0; - status: Status; - customerBranchId: string; - id: string; - }; }[]; - service: { - _count: { work: number }; + productServiceList: { + vat: number; + pricePerUnit: number; + discount: number; + amount: number; + productId: string; + product: ProductRelation; + workId: string; + work: WorkRelation; + serviceId: string; + service: ServiceRelation; + }[]; - work: { - id: string; - serviceId: string; - name: string; - order: number; - attributes: any; - - productOnWork: { - product: { - productGroupId: string; - shared: boolean; - expenseType: string; - vatIncluded: boolean; - serviceCharge: number; - agentPrice: number; - price: number; - process: number; - detail: string; - remark: string; - selectedImage: string; - name: string; - updatedByUserId: string; - updatedAt: string; - createdByUserId: string; - createdAt: string; - code: string; - statusOrder: 0; - status: Status; - id: string; - }; - pricePerUnit: number; - discount: number; - amount: number; - productId: string; - workId: string; - order: number; - vat: number; - }[]; - - _count: { productOnWork: number }; - }[]; - - id: string; - refServiceId: string; // Can be used to get image if still exists - quotationId: string; - - code: string; - name: string; - detail: string; - attributes: any; - }; id: string; finalPrice: number; - vatExcluded: number; vat: number; totalDiscount: number; totalPrice: number; @@ -262,7 +271,7 @@ export type QuotationPayload = { }[]; urgent: boolean; customerBranchId: string; - worker: (string | EmployeeWorker)[]; + worker: EmployeeWorker[]; workerCount: 0; payBillDate: Date; paySplit: Date[]; @@ -278,6 +287,7 @@ export type QuotationPayload = { }; export type EmployeeWorker = { + id?: string; alienReferencNumber: string; documentExpireDate: Date | undefined; lastNameEN: string;