Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: update pricing

Brad Barbin9b0c3abd85ee
diff --git a/apps/carbon/app/modules/sales/sales.service.ts b/apps/carbon/app/modules/sales/sales.service.ts
index 7490eb635f..e0c464e951 100644
--- a/apps/carbon/app/modules/sales/sales.service.ts
+++ b/apps/carbon/app/modules/sales/sales.service.ts
@@ -1348,10 +1348,19 @@ export async function upsertQuoteLinePrices(
quoteLineId: string;
unitPrice: number;
leadTime: number;
+ discountPercent: number;
quantity: number;
createdBy: string;
}[]
) {
+ const existingPrices = await client
+ .from("quoteLinePrice")
+ .select("*")
+ .eq("quoteLineId", lineId);
+ if (existingPrices.error) {
+ return existingPrices;
+ }
+
const deletePrices = await client
.from("quoteLinePrice")
.delete()
@@ -1360,7 +1369,27 @@ export async function upsertQuoteLinePrices(
return deletePrices;
}
- return client.from("quoteLinePrice").insert(quoteLinePrices);
+ const pricesByQuantity = existingPrices.data.reduce<
+ Record<number, { discountPercent: number; leadTime: number }>
+ >((acc, price) => {
+ acc[price.quantity] = price;
+ return acc;
+ }, {});
+
+ const pricesWithExistingDiscountsAndLeadTimes = quoteLinePrices.map((p) => {
+ if (p.quantity in pricesByQuantity) {
+ return {
+ ...p,
+ discountPercent: pricesByQuantity[p.quantity].discountPercent,
+ leadTime: pricesByQuantity[p.quantity].leadTime,
+ };
+ }
+ return p;
+ });
+
+ return client
+ .from("quoteLinePrice")
+ .insert(pricesWithExistingDiscountsAndLeadTimes);
}
export async function updateQuoteLinePrice(
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteLineCosting.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteLineCosting.tsx
index 9dc41e0eb2..acc4bd7f6f 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteLineCosting.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteLineCosting.tsx
@@ -146,8 +146,8 @@ const QuoteLineCosting = ({
</Tr>
</Thead>
<Tbody>
- <Tr>
- <Td className="border-r border-border">
+ <Tr className="[&>td]:bg-muted/60">
+ <Td className="border-r border-border group-hover:bg-muted/50">
<HStack className="w-full justify-between ">
<span>Total Material Cost</span>
<Enumerable value="Material" />
@@ -163,7 +163,10 @@ const QuoteLineCosting = ({
costs.serviceCost;
return (
- <Td key={quantity.toString()}>
+ <Td
+ key={quantity.toString()}
+ className="group-hover:bg-muted/50"
+ >
<VStack spacing={0}>
<span>
{totalMaterialCost
@@ -180,8 +183,8 @@ const QuoteLineCosting = ({
);
})}
</Tr>
- <Tr>
- <Td className="border-r border-border pl-10">
+ <Tr className="[&>td]:bg-muted/60">
+ <Td className="border-r border-border pl-10 group-hover:bg-muted/50">
<HStack className="w-full justify-between ">
<span className="whitespace-nowrap flex items-center justify-start gap-2">
Part Cost{" "}
@@ -201,7 +204,10 @@ const QuoteLineCosting = ({
</Td>
{quantityCosts.map(({ quantity, costs }) => {
return (
- <Td key={quantity.toString()}>
+ <Td
+ key={quantity.toString()}
+ className="group-hover:bg-muted/50"
+ >
<VStack spacing={0}>
<span>
{costs.partCost
@@ -218,8 +224,8 @@ const QuoteLineCosting = ({
);
})}
</Tr>
- <Tr>
- <Td className="border-r border-border pl-10">
+ <Tr className="[&>td]:bg-muted/60">
+ <Td className="border-r border-border pl-10 group-hover:bg-muted/50">
<HStack className="w-full justify-between ">
<span className="whitespace-nowrap">Material Cost</span>
<Badge variant="secondary">
@@ -229,7 +235,10 @@ const QuoteLineCosting = ({
</Td>
{quantityCosts.map(({ quantity, costs }) => {
return (
- <Td key={quantity.toString()}>
+ <Td
+ key={quantity.toString()}
+ className="group-hover:bg-muted/50"
+ >
<VStack spacing={0}>
<span>
{costs.materialCost
@@ -246,8 +255,8 @@ const QuoteLineCosting = ({
);
})}
</Tr>
- <Tr>
- <Td className="border-r border-border pl-10">
+ <Tr className="[&>td]:bg-muted/60">
+ <Td className="border-r border-border pl-10 group-hover:bg-muted/50">
<HStack className="w-full justify-between ">
<span className="whitespace-nowrap">Tooling Cost</span>
<Badge variant="secondary">
@@ -257,7 +266,10 @@ const QuoteLineCosting = ({
</Td>
{quantityCosts.map(({ quantity, costs }) => {
return (
- <Td key={quantity.toString()}>
+ <Td
+ key={quantity.toString()}
+ className="group-hover:bg-muted/50"
+ >
<VStack spacing={0}>
<span>
{costs.toolCost
@@ -274,8 +286,8 @@ const QuoteLineCosting = ({
);
})}
</Tr>
- <Tr>
- <Td className="border-r border-border pl-10">
+ <Tr className="[&>td]:bg-muted/60">
+ <Td className="border-r border-border pl-10 group-hover:bg-muted/50">
<HStack className="w-full justify-between ">
<span className="whitespace-nowrap">Fixture Cost</span>
<Badge variant="secondary">
@@ -285,7 +297,10 @@ const QuoteLineCosting = ({
</Td>
{quantityCosts.map(({ quantity, costs }) => {
return (
- <Td key={quantity.toString()}>
+ <Td
+ key={quantity.toString()}
+ className="group-hover:bg-muted/50"
+ >
<VStack spacing={0}>
<span>
{costs.fixtureCost
@@ -302,8 +317,8 @@ const QuoteLineCosting = ({
);
})}
</Tr>
- <Tr>
- <Td className="border-r border-border pl-10">
+ <Tr className="[&>td]:bg-muted/60">
+ <Td className="border-r border-border pl-10 group-hover:bg-muted/50">
<HStack className="w-full justify-between ">
<span className="whitespace-nowrap">Consumable Cost</span>
<Badge variant="secondary">
@@ -313,7 +328,10 @@ const QuoteLineCosting = ({
</Td>
{quantityCosts.map(({ quantity, costs }) => {
return (
- <Td key={quantity.toString()}>
+ <Td
+ key={quantity.toString()}
+ className="group-hover:bg-muted/50"
+ >
<VStack spacing={0}>
<span>
{costs.consumableCost
@@ -330,8 +348,8 @@ const QuoteLineCosting = ({
);
})}
</Tr>
- <Tr>
- <Td className="border-r border-border pl-10">
+ <Tr className="[&>td]:bg-muted/60">
+ <Td className="border-r border-border pl-10 group-hover:bg-muted/50">
<HStack className="w-full justify-between ">
<span className="whitespace-nowrap">Service Cost</span>
<Badge variant="secondary">
@@ -341,7 +359,10 @@ const QuoteLineCosting = ({
</Td>
{quantityCosts.map(({ quantity, costs }) => {
return (
- <Td key={quantity.toString()}>
+ <Td
+ key={quantity.toString()}
+ className="group-hover:bg-muted/50"
+ >
<VStack spacing={0}>
<span>
{costs.serviceCost
@@ -358,8 +379,8 @@ const QuoteLineCosting = ({
);
})}
</Tr>
- <Tr>
- <Td className="border-r border-border">
+ <Tr className="[&>td]:bg-muted/60">
+ <Td className="border-r border-border group-hover:bg-muted/50">
<HStack className="w-full justify-between ">
<span className="whitespace-nowrap">
Total Labor &amp; Overhead
@@ -369,7 +390,10 @@ const QuoteLineCosting = ({
</Td>
{quantityCosts.map(({ quantity, costs }) => {
return (
- <Td key={quantity.toString()}>
+ <Td
+ key={quantity.toString()}
+ className="group-hover:bg-muted/50"
+ >
<VStack spacing={0}>
<span>
{costs.overheadCost
@@ -391,7 +415,7 @@ const QuoteLineCosting = ({
})}
</Tr>
{/* <Tr>
- <Td className="border-r border-border">
+ <Td className="border-r border-border group-hover:bg-muted/50">
<HStack className="w-full justify-between ">
<span>Total Outside Processing</span>
<Enumerable value="Subcontract" />
@@ -399,7 +423,7 @@ const QuoteLineCosting = ({
</Td>
{quantityCosts.map(({ quantity, costs }) => {
return (
- <Td key={quantity.toString()} >
+ <Td key={quantity.toString()} className="group-hover:bg-muted/50" >
<VStack spacing={0}>
<span>
{costs.outsideCost
@@ -431,7 +455,10 @@ const QuoteLineCosting = ({
size="sm"
className="border-0 -ml-3 shadow-none"
onBlur={(e) => {
- if (e.target.value !== charge.description) {
+ if (
+ e.target.value &&
+ e.target.value !== charge.description
+ ) {
onUpdateChargeDescription(chargeId, e.target.value);
}
}}
@@ -474,7 +501,7 @@ const QuoteLineCosting = ({
currency: "USD",
}}
onChange={(value) => {
- if (value !== amount) {
+ if (value && value !== amount) {
onUpdateChargeAmount(chargeId, quantity, value);
}
}}
@@ -529,8 +556,8 @@ const QuoteLineCosting = ({
return <Td key={quantity.toString()}></Td>;
})}
</Tr>
- <Tr className="font-bold">
- <Td className="border-r border-border">
+ <Tr className="font-bold [&>td]:bg-muted/60">
+ <Td className="border-r border-border group-hover:bg-muted/50">
<HStack className="w-full justify-between ">
<span>Total Estimated Cost</span>
<Enumerable value="Total" />
@@ -549,7 +576,10 @@ const QuoteLineCosting = ({
costs.outsideCost +
additionalChargesByQuantity[index];
return (
- <Td key={quantity.toString()}>
+ <Td
+ key={quantity.toString()}
+ className="group-hover:bg-muted/50"
+ >
<VStack spacing={0}>
<span>
{totalCost
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx
index 2646204e53..8b33601687 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx
@@ -6,7 +6,13 @@ import {
CardContent,
CardHeader,
CardTitle,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
HStack,
+ NumberField,
+ NumberInput,
Table,
Tbody,
Td,
@@ -19,9 +25,10 @@ import {
VStack,
} from "@carbon/react";
import { useFetcher, useParams } from "@remix-run/react";
-import { useMemo } from "react";
-import { LuInfo, LuRefreshCcw } from "react-icons/lu";
+import { useEffect, useMemo, useState } from "react";
+import { LuChevronDown, LuInfo, LuRefreshCcw } from "react-icons/lu";
import type { z } from "zod";
+import { useSupabase } from "~/lib/supabase";
import { path } from "~/utils/path";
import { quoteLineAdditionalChargesValidator } from "../../sales.models";
import type { Costs, QuotationPrice } from "../../types";
@@ -40,7 +47,13 @@ const QuoteLinePricing = ({
const { quoteId, lineId } = useParams();
if (!quoteId) throw new Error("Could not find quoteId");
if (!lineId) throw new Error("Could not find lineId");
+ const [prices, setPrices] =
+ useState<Record<number, QuotationPrice>>(pricesByQuantity);
+ useEffect(() => {
+ setPrices(pricesByQuantity);
+ }, [pricesByQuantity]);
+ const { supabase } = useSupabase();
const fetcher = useFetcher<{ id: string }>();
// TODO: factor in default currency or quote currency
@@ -95,22 +108,52 @@ const QuoteLinePricing = ({
});
const netPricesByQuantity = quantities.map((quantity, index) => {
- const price = pricesByQuantity[quantity]?.unitPrice ?? 0;
- const discount = (pricesByQuantity[quantity]?.discountPercent ?? 0) / 100;
+ const price = prices[quantity]?.unitPrice ?? 0;
+ const discount = prices[quantity]?.discountPercent ?? 0;
const netPrice = price * (1 - discount / 100);
return netPrice;
});
- const onRecalculate = () => {
+ const onRecalculate = (markup: number) => {
const formData = new FormData();
+ formData.append("markup", markup.toString());
formData.append("unitCostsByQuantity", JSON.stringify(unitCostsByQuantity));
formData.append("quantities", JSON.stringify(quantities));
fetcher.submit(formData, {
method: "post",
- action: path.to.quoteLineRecaluclatePrice(quoteId, lineId),
+ action: path.to.quoteLineRecalculatePrice(quoteId, lineId),
});
};
+ const onUpdate = async (
+ key: "leadTime" | "unitPrice" | "discountPercent",
+ quantity: number,
+ value: number
+ ) => {
+ if (!supabase) return;
+
+ const oldPrices = { ...prices };
+ const newPrices = { ...oldPrices };
+ if (!newPrices[quantity]) {
+ newPrices[quantity] = {
+ leadTime: 0,
+ unitPrice: 0,
+ discountPercent: 0,
+ } as QuotationPrice;
+ }
+ newPrices[quantity] = { ...newPrices[quantity], [key]: value };
+ setPrices(newPrices);
+
+ const { error } = await supabase
+ .from("quoteLinePrice")
+ .update({ [key]: value })
+ .eq("quoteLineId", lineId)
+ .eq("quantity", quantity);
+ if (error) {
+ setPrices(oldPrices);
+ }
+ };
+
return (
<Card>
<HStack className="justify-between">
@@ -118,23 +161,44 @@ const QuoteLinePricing = ({
<CardTitle>Pricing</CardTitle>
</CardHeader>
<CardAction>
- <Button
- variant="secondary"
- leftIcon={<LuRefreshCcw />}
- onClick={onRecalculate}
- isLoading={
- fetcher.state === "loading" &&
- fetcher.formAction ===
- path.to.quoteLineRecaluclatePrice(quoteId, lineId)
- }
- isDisabled={
- fetcher.state === "loading" &&
- fetcher.formAction ===
- path.to.quoteLineRecaluclatePrice(quoteId, lineId)
- }
- >
- Recalculate
- </Button>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ variant="secondary"
+ leftIcon={<LuRefreshCcw />}
+ rightIcon={<LuChevronDown />}
+ isLoading={
+ fetcher.state === "loading" &&
+ fetcher.formAction ===
+ path.to.quoteLineRecalculatePrice(quoteId, lineId)
+ }
+ isDisabled={
+ fetcher.state === "loading" &&
+ fetcher.formAction ===
+ path.to.quoteLineRecalculatePrice(quoteId, lineId)
+ }
+ >
+ Recalculate
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem onClick={() => onRecalculate(0)}>
+ 0% Markup
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={() => onRecalculate(10)}>
+ 10% Markup
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={() => onRecalculate(15)}>
+ 15% Markup
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={() => onRecalculate(20)}>
+ 20% Markup
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={() => onRecalculate(30)}>
+ 30% Markup
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
</CardAction>
</HStack>
<CardContent>
@@ -148,34 +212,55 @@ const QuoteLinePricing = ({
</Tr>
</Thead>
<Tbody>
- <Tr className="[&>td]:bg-muted/80 [&>td]:group-hover:bg-muted/70">
- <Td className="border-r border-border">
+ <Tr>
+ <Td className="border-r border-border group-hover:bg-muted/50">
<HStack className="w-full justify-between ">
- <span>Unit Cost</span>
+ <span>Lead Time</span>
</HStack>
</Td>
- {unitCostsByQuantity.map((cost, index) => {
+ {quantities.map((quantity) => {
+ const leadTime = prices[quantity]?.leadTime ?? 0;
return (
- <Td key={index}>
- <VStack spacing={0}>
- <span>{formatter.format(cost ?? 0)}</span>
- </VStack>
+ <Td
+ key={quantity.toString()}
+ className="group-hover:bg-muted/50"
+ >
+ <NumberField
+ value={leadTime}
+ formatOptions={{
+ style: "unit",
+ unit: "day",
+ unitDisplay: "long",
+ }}
+ minValue={0}
+ isDisabled
+ onChange={(value) => {
+ if (Number.isFinite(value) && value !== leadTime) {
+ onUpdate("leadTime", quantity, value);
+ }
+ }}
+ >
+ <NumberInput
+ className="border-0 -ml-3 shadow-none"
+ size="sm"
+ min={0}
+ />
+ </NumberField>
</Td>
);
})}
</Tr>
- <Tr>
- <Td className="border-r border-border">
+ <Tr className="[&>td]:bg-muted/60">
+ <Td className="border-r border-border group-hover:bg-muted/50">
<HStack className="w-full justify-between ">
- <span>Unit Price</span>
+ <span>Unit Cost</span>
</HStack>
</Td>
- {quantities.map((quantity) => {
- const price = pricesByQuantity[quantity]?.unitPrice;
+ {unitCostsByQuantity.map((cost, index) => {
return (
- <Td key={quantity.toString()}>
+ <Td key={index} className="group-hover:bg-muted/50">
<VStack spacing={0}>
- <span>{formatter.format(price ?? 0)}</span>
+ <span>{formatter.format(cost ?? 0)}</span>
</VStack>
</Td>
);
@@ -184,20 +269,37 @@ const QuoteLinePricing = ({
<Tr>
<Td className="border-r border-border">
<HStack className="w-full justify-between ">
- <span>Lead Time</span>
+ <span>Unit Price</span>
</HStack>
</Td>
{quantities.map((quantity) => {
- const leadTime = pricesByQuantity[quantity]?.leadTime ?? 0;
+ const price = prices[quantity]?.unitPrice;
return (
<Td key={quantity.toString()}>
- <VStack spacing={0}>
- <span>{leadTime} days</span>
- </VStack>
+ <NumberField
+ value={price}
+ formatOptions={{
+ style: "currency",
+ currency: "USD",
+ }}
+ minValue={0}
+ onChange={(value) => {
+ if (Number.isFinite(value) && value !== price) {
+ onUpdate("unitPrice", quantity, value);
+ }
+ }}
+ >
+ <NumberInput
+ className="border-0 -ml-3 shadow-none"
+ size="sm"
+ min={0}
+ />
+ </NumberField>
</Td>
);
})}
</Tr>
+
<Tr>
<Td className="border-r border-border">
<HStack className="w-full justify-between ">
@@ -205,26 +307,42 @@ const QuoteLinePricing = ({
</HStack>
</Td>
{quantities.map((quantity, index) => {
- const discount = pricesByQuantity[quantity]?.discountPercent;
+ const discount = prices[quantity]?.discountPercent;
return (
<Td key={index}>
- <VStack spacing={0}>
- <span>{(discount ?? 0).toFixed(2)}%</span>
- </VStack>
+ <NumberField
+ value={discount}
+ formatOptions={{
+ style: "percent",
+ currency: "USD",
+ }}
+ minValue={0}
+ maxValue={1}
+ onChange={(value) => {
+ if (Number.isFinite(value) && value !== discount) {
+ onUpdate("discountPercent", quantity, value);
+ }
+ }}
+ >
+ <NumberInput
+ className="border-0 -ml-3 shadow-none"
+ size="sm"
+ />
+ </NumberField>
</Td>
);
})}
</Tr>
- <Tr className="[&>td]:bg-muted/80 [&>td]:group-hover:bg-muted/70">
- <Td className="border-r border-border">
+ <Tr className="[&>td]:bg-muted/60">
+ <Td className="border-r border-border group-hover:bg-muted/50">
<HStack className="w-full justify-between ">
<span>Net Price</span>
</HStack>
</Td>
{netPricesByQuantity.map((price, index) => {
return (
- <Td key={index}>
+ <Td key={index} className="group-hover:bg-muted/50">
<VStack spacing={0}>
<span>{formatter.format(price)}</span>
</VStack>
@@ -232,8 +350,8 @@ const QuoteLinePricing = ({
);
})}
</Tr>
- <Tr className="[&>td]:bg-muted/80 [&>td]:group-hover:bg-muted/70">
- <Td className="border-r border-border">
+ <Tr className="[&>td]:bg-muted/60">
+ <Td className="border-r border-border group-hover:bg-muted/50">
<HStack className="w-full justify-between ">
<span className="flex items-center justify-start gap-2">
Markup Percent
@@ -250,7 +368,7 @@ const QuoteLinePricing = ({
const cost = unitCostsByQuantity[index];
const markup = ((price - cost) / cost) * 100;
return (
- <Td key={index}>
+ <Td key={index} className="group-hover:bg-muted/50">
<VStack spacing={0}>
{Number.isFinite(markup) ? (
<span>{(markup ?? 0).toFixed(2)}%</span>
@@ -262,8 +380,8 @@ const QuoteLinePricing = ({
);
})}
</Tr>
- <Tr className="[&>td]:bg-muted/80 [&>td]:group-hover:bg-muted/70">
- <Td className="border-r border-border">
+ <Tr className="[&>td]:bg-muted/60">
+ <Td className="border-r border-border group-hover:bg-muted/50">
<HStack className="w-full justify-between ">
<span className="flex items-center justify-start gap-2">
Profit Percent
@@ -280,7 +398,7 @@ const QuoteLinePricing = ({
const cost = unitCostsByQuantity[index];
const profit = ((price - cost) / price) * 100;
return (
- <Td key={index}>
+ <Td key={index} className="group-hover:bg-muted/50">
<VStack spacing={0}>
{Number.isFinite(profit) ? (
<span>{profit.toFixed(2)}%</span>
@@ -293,8 +411,8 @@ const QuoteLinePricing = ({
})}
</Tr>
- <Tr className="[&>td]:bg-muted/80 [&>td]:group-hover:bg-muted/70">
- <Td className="border-r border-border">
+ <Tr className="[&>td]:bg-muted/60">
+ <Td className="border-r border-border group-hover:bg-muted/50">
<HStack className="w-full justify-between ">
<span>Total Profit</span>
</HStack>
@@ -304,7 +422,7 @@ const QuoteLinePricing = ({
const cost = unitCostsByQuantity[index];
const profit = (price - cost) * quantity;
return (
- <Td key={index}>
+ <Td key={index} className="group-hover:bg-muted/50">
<VStack spacing={0}>
<span>{formatter.format(profit)}</span>
</VStack>
@@ -312,8 +430,8 @@ const QuoteLinePricing = ({
);
})}
</Tr>
- <Tr className="font-bold">
- <Td className="border-r border-border">
+ <Tr className="font-bold [&>td]:bg-muted/60">
+ <Td className="border-r border-border group-hover:bg-muted/50">
<HStack className="w-full justify-between ">
<span>Total Price</span>
</HStack>
@@ -321,7 +439,7 @@ const QuoteLinePricing = ({
{quantities.map((quantity, index) => {
const price = netPricesByQuantity[index];
return (
- <Td key={index}>
+ <Td key={index} className="group-hover:bg-muted/50">
<VStack spacing={0}>
<span>{formatter.format(price * quantity)}</span>
</VStack>
diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.details.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
index d2d9de347b..1659488e8d 100644
--- a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.details.tsx
@@ -112,7 +112,7 @@ export default function QuoteLine() {
if (!quoteId) throw new Error("Could not find quoteId");
if (!lineId) throw new Error("Could not find lineId");
- useRealtime("quoteLine", `id=eq.${lineId}`);
+ // useRealtime("quoteLine", `id=eq.${lineId}`);
useRealtime("quoteMaterial", `quoteLineId=eq.${lineId}`);
useRealtime("quoteOperation", `quoteLineId=eq.${lineId}`);
@@ -168,6 +168,7 @@ export default function QuoteLine() {
modelUpload={line ?? undefined}
/>
</div>
+ <QuoteLineNotes line={line} />
{line.methodType === "Make" && (
<QuoteLineCosting
quantities={line.quantity ?? [1]}
@@ -181,7 +182,6 @@ export default function QuoteLine() {
pricesByQuantity={pricesByQuantity}
getLineCosts={getLineCosts}
/>
- <QuoteLineNotes line={line} />
<Outlet />
</Fragment>
)}
diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.recalculate-price.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.recalculate-price.tsx
index 4102499d92..de8a27cea3 100644
--- a/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.recalculate-price.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.$lineId.recalculate-price.tsx
@@ -19,6 +19,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
const formData = await request.formData();
+ const markup = Number.parseInt((formData.get("markup") as string) ?? "15");
const unitCostsByQuantity = numberArrayValidator.safeParse(
JSON.parse((formData.get("unitCostsByQuantity") ?? "[]") as string)
);
@@ -45,7 +46,8 @@ export async function action({ request, params }: ActionFunctionArgs) {
quoteId,
quoteLineId: lineId,
quantity: quantities.data[index],
- unitPrice: unitCost * 1.15,
+ unitPrice: unitCost * (1 + markup / 100),
+ discountPercent: 0,
leadTime: 0,
createdBy: userId,
}));
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index b9504ef71e..a1ecb24ac5 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -582,7 +582,7 @@ export const path = {
quoteOperation: (quoteId: string, lineId: string, id: string) =>
generatePath(`${x}/quote/methods/${quoteId}/${lineId}/operation/${id}`),
quoteOperationsOrder: `${x}/quote/methods/operation/order`,
- quoteLineRecaluclatePrice: (quoteId: string, lineId: string) =>
+ quoteLineRecalculatePrice: (quoteId: string, lineId: string) =>
generatePath(`${x}/quote/${quoteId}/${lineId}/recalculate-price`),
quoteRelease: (id: string) => generatePath(`${x}/quote/${id}/release`),
quotes: `${x}/sales/quotes`,