feat: shipping warehouse and cost

This commit is contained in:
2024-07-18 04:56:20 +03:00
parent c4dc887305
commit 5c6e7cf5f5
21 changed files with 192 additions and 33 deletions

View File

@@ -30,18 +30,15 @@ export const useDealServicesTableColumns = (props: Props) => {
accessorKey: "price",
header: "Цена",
},
{
enableGrouping: false,
accessorKey: "service.cost",
header: "Себестоимость"
},
{
enableGrouping: false,
accessorKey: "quantity",
header: "Количество",
// Cell: ({row}) => {
// return (
// <PlusMinusInput
// value={row.original.quantity}
// onChange={(value) => onChange(row.original, value)}
// />
// )
// }
},
{
enableGrouping: false,

View File

@@ -287,7 +287,6 @@ const DealEditDrawerProductsTable = () => {
const useDealStatusChangeState = () => {
const {selectedDeal} = useDealPageContext();
return {
statusHistory: selectedDeal?.statusHistory || []
}
@@ -342,12 +341,6 @@ const DealEditDrawer: FC = () => {
<Tabs.Tab value={"servicesAndProducts"} leftSection={<IconBox/>}>
Товары и услуги
</Tabs.Tab>
{/*<Tabs.Tab value={"services"} leftSection={<IconBox/>}>*/}
{/* Услуги*/}
{/*</Tabs.Tab>*/}
{/*<Tabs.Tab value={"products"} leftSection={<IconBarcode/>}>*/}
{/* Товары*/}
{/*</Tabs.Tab>*/}
</Tabs.List>
<Tabs.Panel value={"general"}>
<Box h={"100%"} w={"100%"} p={rem(10)}>

View File

@@ -64,7 +64,6 @@ const Content: FC<Props> = ({deal}) => {
return (
<form onSubmit={form.onSubmit((values) => handleSubmit(values))}>
<Flex direction={'column'}>
<Fieldset legend={"Общие параметры"}>
<Flex direction={"column"} gap={rem(10)}>
<TextInput
@@ -83,12 +82,17 @@ const Content: FC<Props> = ({deal}) => {
placeholder={"Текущий статус"}
label={"Текущий статус"}
value={DealStatusDictionary[deal.currentStatus as DealStatus]}/>
<Textarea
label={'Коментарий к сделке'}
placeholder={'Введите коментарий к сделке'}
{...form.getInputProps('comment')}
/>
<TextInput
disabled
placeholder={"Введите склад отгрузки"}
label={"Склад отгрузки"}
value={form.values.shippingWarehouse?.name}
/>
</Flex>
</Fieldset>
<Fieldset legend={"Клиент"}>

View File

@@ -58,7 +58,7 @@ const ProductAndServiceTab: FC = () => {
</div>
</Flex>
<Flex direction={"column"} className={styles['deal-container-wrapper']}>
<Title order={3}>Общая стоимость всех услуг: {getTotalPrice()}</Title>
<Title order={3}>Общая стоимость всех услуг: {getTotalPrice().toLocaleString("ru")}</Title>
</Flex>
</div>

View File

@@ -9,15 +9,21 @@ type Props = {
const useProductServicesTableColumns = (props: Props) => {
const {data, quantity} = props;
const totalPrice = useMemo(() => data.reduce((acc, row) => acc + (row.price * quantity), 0), [data, quantity]);
const totalCost = useMemo(() => data.reduce((acc, row) => acc + ((row.service.cost || 0) * quantity), 0), [data, quantity]);
return useMemo<MRT_ColumnDef<DealProductServiceSchema>[]>(() => [
{
accessorKey: "service.name",
header: "Услуга",
},
{
accessorKey: "service.cost",
header: "Себестоимость",
Footer: () => <>Итоговая себестоимость: {totalCost.toLocaleString("ru")}</>,
},
{
accessorKey: "price",
header: "Цена",
Footer: () => <>Итог: {totalPrice}</>,
Footer: () => <>Итог: {totalPrice.toLocaleString("ru")}</>,
}
], [totalPrice]);
}