From 70aff26dcd07004aba5363c3cdfa997d101cd158 Mon Sep 17 00:00:00 2001 From: AlexSserb Date: Fri, 15 Nov 2024 20:29:59 +0400 Subject: [PATCH] feat: billing for groups of deals --- src/client/index.ts | 2 ++ src/client/models/BillStatusUpdateRequest.ts | 2 +- src/client/models/DealGroupSchema.ts | 2 ++ src/client/models/DealSchema.ts | 2 ++ src/client/models/GroupBillRequestSchema.ts | 12 ++++++++++++ .../Dnd/DealSummaryCard/DealSummaryCard.tsx | 8 ++++---- .../DealEditDrawer/tabs/DealEditDrawerGeneralTab.tsx | 8 +++++--- .../ProductAndServiceTab/ProductAndServiceTab.tsx | 2 +- 8 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 src/client/models/GroupBillRequestSchema.ts diff --git a/src/client/index.ts b/src/client/index.ts index 16fcf4f..d8ff464 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -25,6 +25,7 @@ export type { BaseEnumListSchema } from './models/BaseEnumListSchema'; export type { BaseEnumSchema } from './models/BaseEnumSchema'; export type { BaseMarketplaceSchema } from './models/BaseMarketplaceSchema'; export type { BaseShippingWarehouseSchema } from './models/BaseShippingWarehouseSchema'; +export type { BillPaymentInfo } from './models/BillPaymentInfo'; export type { BillPaymentStatus } from './models/BillPaymentStatus'; export type { BillStatusUpdateRequest } from './models/BillStatusUpdateRequest'; export type { Body_upload_product_barcode_image } from './models/Body_upload_product_barcode_image'; @@ -169,6 +170,7 @@ export type { GetProductBarcodeResponse } from './models/GetProductBarcodeRespon export type { GetServiceKitSchema } from './models/GetServiceKitSchema'; export type { GetTimeTrackingRecordsRequest } from './models/GetTimeTrackingRecordsRequest'; export type { GetTimeTrackingRecordsResponse } from './models/GetTimeTrackingRecordsResponse'; +export type { GroupBillRequestSchema } from './models/GroupBillRequestSchema'; export type { HTTPValidationError } from './models/HTTPValidationError'; export type { MarketplaceCreateSchema } from './models/MarketplaceCreateSchema'; export type { MarketplaceSchema } from './models/MarketplaceSchema'; diff --git a/src/client/models/BillStatusUpdateRequest.ts b/src/client/models/BillStatusUpdateRequest.ts index e1a5848..767e275 100644 --- a/src/client/models/BillStatusUpdateRequest.ts +++ b/src/client/models/BillStatusUpdateRequest.ts @@ -5,7 +5,7 @@ import type { BillPaymentStatus } from './BillPaymentStatus'; import type { NotificationChannel } from './NotificationChannel'; export type BillStatusUpdateRequest = { - listenerTransactionId: number; + listenerTransactionId: (number | string); channel: NotificationChannel; info: BillPaymentStatus; }; diff --git a/src/client/models/DealGroupSchema.ts b/src/client/models/DealGroupSchema.ts index 49b9c43..1e2af96 100644 --- a/src/client/models/DealGroupSchema.ts +++ b/src/client/models/DealGroupSchema.ts @@ -2,9 +2,11 @@ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ +import type { GroupBillRequestSchema } from './GroupBillRequestSchema'; export type DealGroupSchema = { id: number; name?: (string | null); lexorank: string; + billRequest?: (GroupBillRequestSchema | null); }; diff --git a/src/client/models/DealSchema.ts b/src/client/models/DealSchema.ts index da00c3c..439ff03 100644 --- a/src/client/models/DealSchema.ts +++ b/src/client/models/DealSchema.ts @@ -4,6 +4,7 @@ /* eslint-disable */ import type { ClientSchema } from './ClientSchema'; import type { DealBillRequestSchema } from './DealBillRequestSchema'; +import type { DealGroupSchema } from './DealGroupSchema'; import type { DealProductSchema } from './DealProductSchema'; import type { DealServiceSchema } from './DealServiceSchema'; import type { DealStatusHistorySchema } from './DealStatusHistorySchema'; @@ -26,6 +27,7 @@ export type DealSchema = { shippingWarehouse?: (ShippingWarehouseSchema | string | null); billRequest?: (DealBillRequestSchema | null); category?: (ServicePriceCategorySchema | null); + group?: (DealGroupSchema | null); deliveryDate?: (string | null); receivingSlotDate?: (string | null); }; diff --git a/src/client/models/GroupBillRequestSchema.ts b/src/client/models/GroupBillRequestSchema.ts new file mode 100644 index 0000000..96a52af --- /dev/null +++ b/src/client/models/GroupBillRequestSchema.ts @@ -0,0 +1,12 @@ +/* generated using openapi-typescript-codegen -- do not edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +export type GroupBillRequestSchema = { + groupId: number; + createdAt: string; + paid: boolean; + pdfUrl: (string | null); + invoiceNumber: (string | null); +}; + diff --git a/src/components/Dnd/DealSummaryCard/DealSummaryCard.tsx b/src/components/Dnd/DealSummaryCard/DealSummaryCard.tsx index 5e9b45f..285e685 100644 --- a/src/components/Dnd/DealSummaryCard/DealSummaryCard.tsx +++ b/src/components/Dnd/DealSummaryCard/DealSummaryCard.tsx @@ -66,6 +66,9 @@ const DealSummaryCard: FC = ({ dealSummary, color }) => { } return { disabled: true }; }; + const isPaid = () => { + return dealSummary.billRequest?.paid || dealSummary.group?.billRequest?.paid; + } return ( = ({ dealSummary, color }) => { )} - {dealSummary.billRequest?.paid && ( + {isPaid() && ( - - - )} diff --git a/src/pages/LeadsPage/drawers/DealEditDrawer/tabs/DealEditDrawerGeneralTab.tsx b/src/pages/LeadsPage/drawers/DealEditDrawer/tabs/DealEditDrawerGeneralTab.tsx index 70d253e..ba4b291 100644 --- a/src/pages/LeadsPage/drawers/DealEditDrawer/tabs/DealEditDrawerGeneralTab.tsx +++ b/src/pages/LeadsPage/drawers/DealEditDrawer/tabs/DealEditDrawerGeneralTab.tsx @@ -121,6 +121,8 @@ const Content: FC = ({ deal }) => { clipboard.copy(`${window.location.origin}/${url}`); }); }; + const billRequestPdfUrl = deal?.billRequest?.pdfUrl || deal?.group?.billRequest?.pdfUrl; + return (
handleSubmit(values))}> = ({ deal }) => { - {deal.billRequest && deal.billRequest.pdfUrl ? ( + {billRequestPdfUrl ? ( + value={billRequestPdfUrl}> Ссылка на оплату ) : ( @@ -308,7 +310,7 @@ const Content: FC = ({ deal }) => { { const { dealState, dealServicesState, dealProductsState } = useDealProductAndServiceTabState(); - const isLocked = Boolean(dealState.deal?.billRequest); + const isLocked = Boolean(dealState.deal?.billRequest || dealState.deal?.group?.billRequest); const onAddProductClick = () => { if (!dealProductsState.onCreate || !dealState.deal) return; const productIds = dealState.deal.products.map(