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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
style: cosmetic improvements to the quote line pricing history component
Rob Carringtone7825b36e7c6
diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricing.tsxindex d4db040565..d863d2f2d4 100644--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricing.tsx@@ -48,12 +48,12 @@ import { path } from "~/utils/path";import { quoteLineAdditionalChargesValidator } from "../../sales.models";import type {Costs,+ HistoricalQuotationPrice,Quotation,QuotationLine,QuotationPrice,SalesOrderLine,} from "../../types";-import QuoteLinePricingHistory from "./QuoteLinePricingHistory";const QuoteLinePricing = ({line,@@ -68,7 +68,7 @@ const QuoteLinePricing = ({exchangeRate: number;getLineCosts: (quantity: number) => Costs;relatedSalesOrderLines: SalesOrderLine[];- historicalQuoteLinePrices: QuotationPrice[];+ historicalQuoteLinePrices: HistoricalQuotationPrice[];}) => {const permissions = usePermissions();@@ -401,13 +401,6 @@ const QuoteLinePricing = ({)}</HStack><CardContent>- {relatedSalesOrderLines.length > 0 && (- <QuoteLinePricingHistory- relatedSalesOrderLines={relatedSalesOrderLines}- historicalQuoteLinePrices={historicalQuoteLinePrices}- baseCurrency={baseCurrency}- />- )}<Table><Thead><Tr>diff --git a/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricingHistory.tsx b/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricingHistory.tsxindex 3451fc1d19..8b6af7ace6 100644--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricingHistory.tsx+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteLinePricingHistory.tsx@@ -1,9 +1,7 @@+import { Table, Tbody, Td, Tr } from "@carbon/react";import { Link } from "@remix-run/react";-import { useState } from "react";-import { LuChevronDown } from "react-icons/lu";import { CustomerAvatar, Empty } from "~/components";import { path } from "~/utils/path";-import { Button } from "../../../../../../../packages/react/src/Button";import {Card,CardContent,@@ -17,11 +15,6 @@ import {CarouselNext,CarouselPrevious,} from "../../../../../../../packages/react/src/Carousel";-import {- Collapsible,- CollapsibleContent,- CollapsibleTrigger,-} from "../../../../../../../packages/react/src/Collapsible";import { HStack } from "../../../../../../../packages/react/src/HStack";import {Tabs,@@ -29,7 +22,7 @@ import {TabsList,TabsTrigger,} from "../../../../../../../packages/react/src/Tabs";-import { cn } from "../../../../../../../packages/react/src/utils/cn";+import { formatDate } from "../../../../../../../packages/utils/src/date";import type { HistoricalQuotationPrice, SalesOrderLine } from "../../types";const QuoteLinePricingHistory = ({@@ -41,8 +34,6 @@ const QuoteLinePricingHistory = ({relatedSalesOrderLines: SalesOrderLine[];historicalQuoteLinePrices: HistoricalQuotationPrice[];}) => {- const [isOpen, setIsOpen] = useState(false);-const historicalQuoteLines = historicalQuoteLinePrices.reduce<Record<string,@@ -58,188 +49,183 @@ const QuoteLinePricingHistory = ({return acc;}, {});- const historyCount =- relatedSalesOrderLines.length + Object.keys(historicalQuoteLines).length;+ const orderLineCount = relatedSalesOrderLines.length;+ const quoteLineCount = Object.keys(historicalQuoteLines).length;+ const historyCount = orderLineCount + quoteLineCount;return (- <div>- <Card>- <Collapsible>- <CardHeader className="p-3">- <HStack>- <CardTitle>History ({historyCount})</CardTitle>- <CollapsibleTrigger asChild>- <Button variant="ghost" size="sm">- <LuChevronDown- className={cn("h-4 w-4 transition-transform", {- "rotate-180": isOpen,- })}- onClick={() => setIsOpen(!isOpen)}- />- <span className="sr-only">Toggle history</span>- </Button>- </CollapsibleTrigger>- </HStack>- </CardHeader>- <CardContent className="p-3">- <CollapsibleContent>- <div className="w-full">- <Tabs defaultValue="salesOrderLines">- <TabsList>- <TabsTrigger value="salesOrderLines">Orders</TabsTrigger>- <TabsTrigger value="quoteLines">Quotes</TabsTrigger>- </TabsList>- <TabsContent value="salesOrderLines">- <div className="flex overflow-x-auto space-x-4 pb-4">- {relatedSalesOrderLines.length === 0 && (- <Empty className="py-6" />- )}- <Carousel className="w-full">- <CarouselContent className="-ml-4">- {relatedSalesOrderLines.map((line) => (- <CarouselItem- key={line.id}- className="pl-4 basis-full md:basis-1/2 lg:basis-1/3"- >- <Card className="w-full">- <CardContent className="p-4">- <HStack className="flex justify-between mb-2">- <Link- to={path.to.salesOrderLine(- line.salesOrderId!,- line.id!- )}- className="text-sm font-medium hover:underline"- >- {line.salesOrderReadableId}- </Link>- <div>- <span className="text-sm text-muted-foreground">- {new Date(- line.orderDate!- ).toLocaleDateString()}- </span>- </div>- </HStack>- <div className="space-y-2">- <div className="flex justify-between">- <span className="text-sm font-medium">- <CustomerAvatar- customerId={line.customerId}- />- </span>- </div>+ <Card isCollapsible defaultCollapsed>+ <CardHeader className="p-3">+ <HStack>+ <CardTitle>History ({historyCount})</CardTitle>+ </HStack>+ </CardHeader>+ <CardContent className="p-3">+ <div className="w-full">+ <Tabs defaultValue="salesOrderLines">+ <TabsList>+ <TabsTrigger value="salesOrderLines">+ Orders ({orderLineCount})+ </TabsTrigger>+ <TabsTrigger value="quoteLines">+ Quotes ({quoteLineCount})+ </TabsTrigger>+ </TabsList>+ <TabsContent value="salesOrderLines">+ <div className="flex overflow-x-auto space-x-4 pb-4">+ {relatedSalesOrderLines.length === 0 && (+ <Empty className="py-6" />+ )}+ <Carousel className="w-full">+ <CarouselContent className="-ml-4">+ {relatedSalesOrderLines.map((line) => (+ <CarouselItem+ key={line.id}+ className="pl-4 basis-full md:basis-1 lg:basis-1/2 xl:basis-1/3"+ >+ <Card className="w-full">+ <CardContent className="p-4">+ <HStack className="flex justify-between mb-2">+ <Link+ to={path.to.salesOrderLine(+ line.salesOrderId!,+ line.id!+ )}+ className="text-sm font-medium hover:underline"+ >+ {line.salesOrderReadableId}+ </Link>+ <div>+ <span className="text-sm text-muted-foreground">+ {formatDate(line.orderDate!)}+ </span>+ </div>+ </HStack>+ <div className="space-y-4">+ <div className="flex justify-between">+ <span className="text-sm font-medium">+ <CustomerAvatar+ customerId={line.customerId}+ />+ </span>+ </div>- <div className="grid grid-cols-2">- <div className="text-sm font-medium border p-2">+ <Table>+ <Tbody>+ <Tr>+ <Td>+ <span className="font-medium">Quantity- </div>- <div className="text-sm font-medium border p-2">- Unit Price- </div>- <div className="text-sm text-muted-foreground border p-2">- {line.saleQuantity}- </div>- <div className="text-sm text-muted-foreground border p-2">- {new Intl.NumberFormat("en-US", {- style: "currency",- currency: baseCurrency,- }).format(line.unitPrice ?? 0)}- </div>- </div>- </div>- </CardContent>- </Card>- </CarouselItem>- ))}- </CarouselContent>- <CarouselPrevious />- <CarouselNext />- </Carousel>- </div>- </TabsContent>- <TabsContent value="quoteLines">- <div className="flex overflow-x-auto space-x-4 pb-4">- {Object.keys(historicalQuoteLines).length === 0 && (- <Empty className="py-6" />- )}- <Carousel className="w-full">- <CarouselContent className="-ml-4">- {Object.values(historicalQuoteLines).map((line) => (- <CarouselItem- key={line.id}- className="pl-4 basis-full md:basis-1/2 lg:basis-1/3"- >- <Card className="w-full">- <CardContent className="p-4">- <HStack className="flex justify-between mb-2">- <Link- to={path.to.quoteLine(- line.quoteId!,- line.id!- )}- className="text-sm font-medium hover:underline"- >- {line.quoteReadableId}- </Link>- <div>- <span className="text-sm text-muted-foreground">- {new Date(- line.quoteCreatedAt!- ).toLocaleDateString()}</span>- </div>- </HStack>- <div className="space-y-2">- <div className="flex justify-between">- <span className="text-sm font-medium">- <CustomerAvatar- customerId={line.customerId}- />+ </Td>+ <Td>+ <span className="font-medium">+ Unit Price</span>- </div>+ </Td>+ </Tr>+ <Tr>+ <Td>{line.saleQuantity}</Td>+ <Td>+ {new Intl.NumberFormat("en-US", {+ style: "currency",+ currency: baseCurrency,+ }).format(line.unitPrice ?? 0)}+ </Td>+ </Tr>+ </Tbody>+ </Table>+ </div>+ </CardContent>+ </Card>+ </CarouselItem>+ ))}+ </CarouselContent>+ <CarouselPrevious />+ <CarouselNext />+ </Carousel>+ </div>+ </TabsContent>+ <TabsContent value="quoteLines">+ <div className="flex overflow-x-auto space-x-4 pb-4">+ {Object.keys(historicalQuoteLines).length === 0 && (+ <Empty className="py-6" />+ )}+ <Carousel className="w-full">+ <CarouselContent className="-ml-4">+ {Object.values(historicalQuoteLines).map((line) => (+ <CarouselItem+ key={line.id}+ className="pl-4 basis-full md:basis-1 lg:basis-1/2 xl:basis-1/3"+ >+ <Card className="w-full">+ <CardContent className="p-4">+ <HStack className="flex justify-between mb-2">+ <Link+ to={path.to.quoteLine(line.quoteId!, line.id!)}+ className="text-sm font-medium hover:underline"+ >+ {line.quoteReadableId}+ </Link>+ <div>+ <span className="text-sm text-muted-foreground">+ {formatDate(line.quoteCreatedAt!)}+ </span>+ </div>+ </HStack>+ <div className="space-y-4">+ <div className="flex justify-between">+ <span className="text-sm font-medium">+ <CustomerAvatar+ customerId={line.customerId}+ />+ </span>+ </div>- <div className="grid grid-cols-2">- <div className="text-sm font-medium border p-2">+ <Table>+ <Tbody>+ <Tr>+ <Td>+ <span className="font-medium">Quantity- </div>- <div className="text-sm font-medium border p-2">+ </span>+ </Td>+ <Td>+ <span className="font-medium">Unit Price- </div>- {Object.entries(line.quantities).map(- ([quantity, price]) => (- <>- <div className="text-sm text-muted-foreground border p-2">- {quantity}- </div>- <div className="text-sm text-muted-foreground border p-2">- {new Intl.NumberFormat("en-US", {- style: "currency",- currency: baseCurrency,- }).format(price)}- </div>- </>- )- )}- </div>- </div>- </CardContent>- </Card>- </CarouselItem>- ))}- </CarouselContent>- <CarouselPrevious />- <CarouselNext />- </Carousel>- </div>- </TabsContent>- </Tabs>+ </span>+ </Td>+ </Tr>+ {Object.entries(line.quantities).map(+ ([quantity, price]) => (+ <Tr key={quantity}>+ <Td>{quantity}</Td>+ <Td>+ {new Intl.NumberFormat("en-US", {+ style: "currency",+ currency: baseCurrency,+ }).format(price)}+ </Td>+ </Tr>+ )+ )}+ </Tbody>+ </Table>+ </div>+ </CardContent>+ </Card>+ </CarouselItem>+ ))}+ </CarouselContent>+ <CarouselPrevious />+ <CarouselNext />+ </Carousel></div>- </CollapsibleContent>- </CardContent>- </Collapsible>- </Card>- </div>+ </TabsContent>+ </Tabs>+ </div>+ </CardContent>+ </Card>);};diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsxindex 5b8ad9ceef..855e5c8c75 100644--- a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx+++ b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx@@ -10,7 +10,7 @@ import { defer, redirect } from "@vercel/remix";import { Fragment, Suspense, useMemo } from "react";import { CadModel } from "~/components";import type { Tree } from "~/components/TreeView";-import { usePermissions, useRealtime, useRouteData } from "~/hooks";+import { usePermissions, useRealtime, useRouteData, useUser } from "~/hooks";import type {Quotation,QuotationOperation,@@ -37,6 +37,7 @@ import {QuoteLinePricing,useLineCosts,} from "~/modules/sales/ui/Quotes";+import QuoteLinePricingHistory from "~/modules/sales/ui/Quotes/QuoteLinePricingHistory";import { getCustomFields, setCustomFields } from "~/utils/form";import { path } from "~/utils/path";@@ -154,6 +155,9 @@ export default function QuoteLine() {if (!quoteId) throw new Error("Could not find quoteId");if (!lineId) throw new Error("Could not find lineId");+ const { company } = useUser();+ const baseCurrency = company?.baseCurrencyCode ?? "USD";+// useRealtime("quoteLine", `id=eq.${lineId}`);useRealtime("quoteMaterial", `quoteLineId=eq.${lineId}`);useRealtime("quoteOperation", `quoteLineId=eq.${lineId}`);@@ -206,15 +210,22 @@ export default function QuoteLine() {/>)}{line.status !== "No Quote" && (- <QuoteLinePricing- key={lineId}- line={line}- exchangeRate={quoteData?.quote?.exchangeRate ?? 1}- pricesByQuantity={pricesByQuantity}- getLineCosts={getLineCosts}- relatedSalesOrderLines={relatedSalesOrderLines}- historicalQuoteLinePrices={historicalQuoteLinePrices}- />+ <>+ <QuoteLinePricingHistory+ relatedSalesOrderLines={relatedSalesOrderLines}+ historicalQuoteLinePrices={historicalQuoteLinePrices}+ baseCurrency={baseCurrency}+ />+ <QuoteLinePricing+ key={lineId}+ line={line}+ exchangeRate={quoteData?.quote?.exchangeRate ?? 1}+ pricesByQuantity={pricesByQuantity}+ getLineCosts={getLineCosts}+ relatedSalesOrderLines={relatedSalesOrderLines}+ historicalQuoteLinePrices={historicalQuoteLinePrices}+ />+ </>)}<OpportunityLineNotesid={line.id}