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.

Merge branch 'main' into feat/add-quantity-price-breaks

Gaurav Bhatt446fa4a76a4d
diff --cc .gitignore
index cdb11f59f0,cdb11f59f0..ccbc8074a9
--- a/.gitignore
+++ b/.gitignore
@@@ -37,3 -37,3 +37,6 @@@ packages/database/supabase/seed.sq
.env*.local
.react-router
++
++packages/cad-rust
++packages/cad-engine
diff --cc .vscode/settings.json
index cdc2c1e7c4,cdc2c1e7c4..11814b2b60
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@@ -2,5 -2,5 +2,6 @@@
"deno.cacheOnSave": true,
"deno.enablePaths": ["./packages/database"],
"typescript.tsdk": "node_modules/typescript/lib",
-- "deno.enable": true
++"deno.enable": true,
++"git.ignoreLimitWarning": true
}
diff --cc apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteCompareDrawer.tsx
index 6c8947b716,55b6d40195..da3a5ff5d8
--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteCompareDrawer.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteCompareDrawer.tsx
@@@ -620,7 -621,7 +621,8 @@@ const ComparisonView = (
</span>
</HStack>
<span className="text-xs text-muted-foreground">
- {linePrice.leadTime ?? 0} days
- {linePrice.leadTime ?? 0} {pluralize(linePrice.leadTime ?? 0, "day")}
++ {linePrice.leadTime ?? 0}{" "}
++ {pluralize(linePrice.leadTime ?? 0, "day")}
</span>
</VStack>
</Td>
@@@ -791,7 -792,7 +793,10 @@@ const LinePricingOptions = (
<Td>{option.quantity}</Td>
<Td>{formatter.format(option.supplierUnitPrice ?? 0)}</Td>
<Td>{formatter.format(option.supplierShippingCost ?? 0)}</Td>
- <Td>{option.leadTime ?? 0} days</Td>
- <Td>{option.leadTime ?? 0} {pluralize(option.leadTime ?? 0, "day")}</Td>
++ <Td>
++ {option.leadTime ?? 0}{" "}
++ {pluralize(option.leadTime ?? 0, "day")}
++ </Td>
<Td>{formatter.format(option.supplierTaxAmount ?? 0)}</Td>
<Td>
{formatter.format(
diff --cc apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteToOrderDrawer.tsx
index 34884083ac,6dc5f8c6e7..be515bf469
--- a/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteToOrderDrawer.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierQuote/SupplierQuoteToOrderDrawer.tsx
@@@ -342,7 -343,7 +343,9 @@@ const LinePricingOptions = (
option.supplierShippingCost ?? 0
)}
</Td>
- <Td>{option.leadTime} days</Td>
- <Td>{option.leadTime} {pluralize(option.leadTime, "day")}</Td>
++ <Td>
++ {option.leadTime} {pluralize(option.leadTime, "day")}
++ </Td>
<Td>
{presentationCurrencyFormatter.format(
option.supplierTaxAmount ?? 0
diff --cc apps/erp/app/modules/sales/ui/Quotes/QuoteToOrderDrawer.tsx
index 4f7a717a21,c689b6643d..5e4aac3d77
--- a/apps/erp/app/modules/sales/ui/Quotes/QuoteToOrderDrawer.tsx
+++ b/apps/erp/app/modules/sales/ui/Quotes/QuoteToOrderDrawer.tsx
@@@ -595,7 -595,7 +595,9 @@@ const LinePricingOptions = (
convertedAdditionalChargesByQuantity[option.quantity]
)}
</Td>
- <Td>{option.leadTime} days</Td>
- <Td>{option.leadTime} {pluralize(option.leadTime, "day")}</Td>
++ <Td>
++ {option.leadTime} {pluralize(option.leadTime, "day")}
++ </Td>
<Td>
{formatter.format(
(option.convertedNetExtendedPrice ?? 0) +
diff --cc apps/erp/app/routes/x+/procedure+/update.tsx
index 5003be1603,1dfe41a004..932ec3dbc9
--- a/apps/erp/app/routes/x+/procedure+/update.tsx
+++ b/apps/erp/app/routes/x+/procedure+/update.tsx
@@@ -1,6 -1,6 +1,8 @@@
import { requirePermissions } from "@carbon/auth/auth.server";
--import type { ClientActionFunctionArgs } from "react-router";
- import { type ActionFunctionArgs } from "react-router";
-import type { ActionFunctionArgs } from "react-router";
++import type {
++ ActionFunctionArgs,
++ ClientActionFunctionArgs
++} from "react-router";
import { getCompanyId, proceduresQuery } from "~/utils/react-query";
export async function action({ request }: ActionFunctionArgs) {
diff --cc apps/erp/app/utils/path.ts
index da35fb3c6f,e0332a6a2c..6b895f4168
--- a/apps/erp/app/utils/path.ts
+++ b/apps/erp/app/utils/path.ts
@@@ -1165,36 -1163,22 +1163,22 @@@ export const path =
generatePath(`${x}/sales/no-quote-reasons/${id}`),
notificationSettings: `${x}/account/notifications`,
part: (id: string) => generatePath(`${x}/part/${id}`),
- partCosting: (id: string) => generatePath(`${x}/part/${id}/view/costing`),
- partDetails: (id: string) => generatePath(`${x}/part/${id}/view/details`),
- partInventory: (id: string) =>
- generatePath(`${x}/part/${id}/view/inventory`),
+ partCosting: (id: string) => generatePath(`${x}/part/${id}/costing`),
+ partDetails: (id: string) => generatePath(`${x}/part/${id}/details`),
+ partMake: (id: string, makeMethodId: string) =>
+ generatePath(`${x}/part/${id}/make/${makeMethodId}`),
+ partInventory: (id: string) => generatePath(`${x}/part/${id}/inventory`),
partInventoryLocation: (id: string, locationId: string) =>
- generatePath(`${x}/part/${id}/view/inventory?location=${locationId}`),
- partMethod: (id: string, methodId: string) =>
- generatePath(`${x}/part/${id}/manufacturing/${methodId}`),
- partMakeMethod: (id: string, methodId: string) =>
- generatePath(`${x}/part/${id}/manufacturing/${methodId}/method`),
- partManufacturing: (id: string) =>
- generatePath(`${x}/part/${id}/manufacturing/methods`),
- partManufacturingMaterial: (
- itemId: string,
- methodId: string,
- makeMethodId: string
- ) =>
- generatePath(
- `${x}/part/${itemId}/manufacturing/${methodId}/make/${makeMethodId}`
- ),
- partPlanning: (id: string) => generatePath(`${x}/part/${id}/view/planning`),
+ generatePath(`${x}/part/${id}/inventory?location=${locationId}`),
+ partPlanning: (id: string) => generatePath(`${x}/part/${id}/planning`),
partPlanningLocation: (id: string, locationId: string) =>
- generatePath(`${x}/part/${id}/view/planning?location=${locationId}`),
- partPricing: (id: string) => generatePath(`${x}/part/${id}/view/pricing`),
- partPurchasing: (id: string) =>
- generatePath(`${x}/part/${id}/view/purchasing`),
+ generatePath(`${x}/part/${id}/planning?location=${locationId}`),
+ partPricing: (id: string) => generatePath(`${x}/part/${id}/pricing`),
+ partPurchasing: (id: string) => generatePath(`${x}/part/${id}/purchasing`),
partRoot: `${x}/part`,
- partSales: (id: string) => generatePath(`${x}/part/${id}/view/sales`),
+ partSales: (id: string) => generatePath(`${x}/part/${id}/sales`),
partSupplier: (itemId: string, id: string) =>
- generatePath(`${x}/part/${itemId}/suppliers/${id}`),
+ generatePath(`${x}/part/${itemId}/view/purchasing/${id}`),
parts: `${x}/items/parts`,
partner: (id: string, abilityId: string) =>
generatePath(`${x}/resources/partners/${id}/${abilityId}`),
@@@ -1571,35 -1555,21 +1555,21 @@@
theme: `${x}/account/theme`,
timecards: `${x}/timecards`,
tool: (id: string) => generatePath(`${x}/tool/${id}`),
- toolCosting: (id: string) => generatePath(`${x}/tool/${id}/view/costing`),
- toolDetails: (id: string) => generatePath(`${x}/tool/${id}/view/details`),
- toolInventory: (id: string) =>
- generatePath(`${x}/tool/${id}/view/inventory`),
+ toolCosting: (id: string) => generatePath(`${x}/tool/${id}/costing`),
+ toolDetails: (id: string) => generatePath(`${x}/tool/${id}/details`),
+ toolInventory: (id: string) => generatePath(`${x}/tool/${id}/inventory`),
toolInventoryLocation: (id: string, locationId: string) =>
- generatePath(`${x}/tool/${id}/view/inventory?location=${locationId}`),
- toolMethod: (id: string, methodId: string) =>
- generatePath(`${x}/tool/${id}/manufacturing/${methodId}`),
- toolMakeMethod: (id: string, methodId: string) =>
- generatePath(`${x}/tool/${id}/manufacturing/${methodId}/method`),
- toolManufacturing: (id: string) =>
- generatePath(`${x}/tool/${id}/manufacturing/methods`),
- toolManufacturingMaterial: (
- itemId: string,
- methodId: string,
- makeMethodId: string
- ) =>
- generatePath(
- `${x}/tool/${itemId}/manufacturing/${methodId}/make/${makeMethodId}`
- ),
- toolPlanning: (id: string) => generatePath(`${x}/tool/${id}/view/planning`),
+ generatePath(`${x}/tool/${id}/inventory?location=${locationId}`),
+ toolMake: (id: string, makeMethodId: string) =>
+ generatePath(`${x}/tool/${id}/make/${makeMethodId}`),
+ toolPlanning: (id: string) => generatePath(`${x}/tool/${id}/planning`),
toolPlanningLocation: (id: string, locationId: string) =>
- generatePath(`${x}/tool/${id}/view/planning?location=${locationId}`),
- toolPricing: (id: string) => generatePath(`${x}/tool/${id}/view/pricing`),
- toolPurchasing: (id: string) =>
- generatePath(`${x}/tool/${id}/view/purchasing`),
+ generatePath(`${x}/tool/${id}/planning?location=${locationId}`),
+ toolPricing: (id: string) => generatePath(`${x}/tool/${id}/pricing`),
+ toolPurchasing: (id: string) => generatePath(`${x}/tool/${id}/purchasing`),
toolRoot: `${x}/tool`,
toolSupplier: (itemId: string, id: string) =>
- generatePath(`${x}/tool/${itemId}/view/suppliers/${id}`),
+ generatePath(`${x}/tool/${itemId}/view/purchasing/${id}`),
toolSuppliers: (id: string) =>
generatePath(`${x}/tool/${id}/view/suppliers`),
tools: `${x}/items/tools`,
diff --cc packages/documents/src/pdf/IssuePDF.tsx
index 5519171812,65cb1d642d..a7329583f7
--- a/packages/documents/src/pdf/IssuePDF.tsx
+++ b/packages/documents/src/pdf/IssuePDF.tsx
@@@ -146,16 -181,22 +181,20 @@@ const IssuePDF = (
{associations.items?.map((item: any) => (
<View
key={item.id}
- style={tw("flex flex-row gap-2 text-sm py-1")}
+ style={tw(
+ "flex flex-row gap-2 text-[10px] py-1 border-b border-gray-200"
+ )}
>
- <View style={tw("w-1/4")}>
- <Text style={tw("font-bold text-[#7d7d7d]")}>Item:</Text>
- </View>
- <Text>{item.documentReadableId}</Text>
- <Text style={tw("w-1/4 font-bold text-gray-600")}>
- Item:
- </Text>
++ <Text style={tw("w-1/4 font-bold text-gray-600")}>Item:</Text>
+ <Text style={tw("text-gray-800")}>
+ {item.documentReadableId}
+ </Text>
{item.disposition && (
<>
- <Text>-</Text>
- <Text>{item.disposition}</Text>
+ <Text style={tw("text-gray-400")}>-</Text>
+ <Text style={tw("text-gray-800")}>
+ {item.disposition}
+ </Text>
</>
)}
{item.quantity && (
@@@ -389,16 -463,22 +459,18 @@@
</Text>
</View>
<View style={tw("flex flex-col")}>
- <Text style={tw("font-medium")}>
+ <Text style={tw("text-gray-800")}>
{step.name}
</Text>
- <Text style={tw("text-xs")}>
+ <Text
- style={tw(
- "text-[8px] text-gray-400 mt-0.5"
- )}
++ style={tw("text-[8px] text-gray-400 mt-0.5")}
+ >
{operationToJobId[step.operationId] && (
<>
- Job{" "}
- {operationToJobId[step.operationId]} •{" "}
+ Job {operationToJobId[step.operationId]} •{" "}
</>
)}
- {assignees[record.createdBy] || "Unknown"}{" "}
- •{" "}
+ {assignees[record.createdBy] || "Unknown"} •{" "}
{
new Date(record.createdAt)
.toISOString()
diff --cc packages/documents/src/pdf/PackingSlipPDF.tsx
index f91136b2f5,6e1049cc94..419993391a
--- a/packages/documents/src/pdf/PackingSlipPDF.tsx
+++ b/packages/documents/src/pdf/PackingSlipPDF.tsx
@@@ -104,157 -98,198 +98,189 @@@ const PackingSlipPDF = (
subject: meta?.subject ?? "Packing Slip"
}}
>
- <View style={tw("flex flex-col")}>
- {/* Header Section - Always at the top */}
- <View style={tw("mb-4")}>
- <Header title={title} company={company} />
- <Summary company={company} items={details} />
- {shipment?.trackingNumber && (
- <View style={tw("flex flex-col gap-2 justify-between mb-5")}>
- <Text style={tw("text-gray-500 text-xs")}>Tracking Number</Text>
- <Text style={tw("text-sm")}>{shipment?.trackingNumber}</Text>
- </View>
- )}
- </View>
+ <Header
+ company={company}
+ title="Packing Slip"
+ documentId={shipment?.shipmentId}
+ />
- {/* Shipping Information Section */}
- <View
- style={tw(
- "flex flex-row justify-between mb-6 page-break-inside-avoid"
- )}
- >
- <View style={tw("flex flex-col gap-2 w-1/3")}>
- <Text style={tw("text-gray-500 text-xs")}>Ship To</Text>
- <View style={tw("flex flex-col")}>
- <Text style={tw("text-sm")}>{customer.name}</Text>
- {shippingAddress && (
- <>
- {addressLine1 && (
- <Text style={tw("text-sm")}>{addressLine1}</Text>
- )}
- {addressLine2 && (
- <Text style={tw("text-sm")}>{addressLine2}</Text>
- )}
- <Text style={tw("text-sm")}>
- {formatCityStatePostalCode(city, stateProvince, postalCode)}
- </Text>
- <Text style={tw("text-sm")}>{countryCode}</Text>
- </>
+ {/* Ship To */}
+ <View style={tw("border border-gray-200 mb-4")}>
+ <View style={tw("flex flex-row")}>
+ <View style={tw("w-1/2 p-3 border-r border-gray-200")}>
+ <Text
+ style={tw("text-[9px] font-bold text-gray-600 mb-1 uppercase")}
+ >
+ Ship To
+ </Text>
+ <View style={tw("text-[10px] text-gray-800")}>
+ {customer.name && (
+ <Text style={tw("font-bold")}>{customer.name}</Text>
)}
- {addressLine1 && (
- <Text style={tw("mt-1")}>{addressLine1}</Text>
- )}
++ {addressLine1 && <Text style={tw("mt-1")}>{addressLine1}</Text>}
+ {addressLine2 && <Text>{addressLine2}</Text>}
+ {(city || stateProvince || postalCode) && (
+ <Text>
+ {formatCityStatePostalCode(city, stateProvince, postalCode)}
+ </Text>
+ )}
+ {countryCode && <Text>{countryCode}</Text>}
</View>
</View>
-
- <View style={tw("flex flex-col gap-2 w-1/3")}>
- <Text style={tw("text-gray-500 text-xs")}>Shipping Method</Text>
- <Text style={tw("text-sm")}>{shippingMethod.name}</Text>
- </View>
-
- <View style={tw("flex flex-col gap-2 w-1/3")}>
- <Text style={tw("text-gray-500 text-xs")}>Payment Term</Text>
- <Text style={tw("text-sm")}>{paymentTerm.name}</Text>
+ <View style={tw("w-1/2 p-3")}>
+ <Text
+ style={tw("text-[9px] font-bold text-gray-600 mb-1 uppercase")}
+ >
+ Shipment Details
+ </Text>
+ <View style={tw("text-[10px] text-gray-800")}>
+ {shipment?.postingDate && (
+ <Text>Date: {formatDate(shipment.postingDate)}</Text>
+ )}
+ {sourceDocument && sourceDocumentId && (
+ <Text>
+ {sourceDocument}: {sourceDocumentId}
+ </Text>
+ )}
+ {customerReference && (
+ <Text>Customer PO #: {customerReference}</Text>
+ )}
+ {shipment?.trackingNumber && (
+ <Text>Tracking: {shipment.trackingNumber}</Text>
+ )}
+ </View>
</View>
</View>
+ </View>
- {/* Line Items Section */}
- <View style={tw("mb-6 text-xs")}>
- <View
- style={tw(
- "flex flex-row justify-between items-center mt-5 py-3 px-[6px] border-t border-b border-gray-300 font-bold uppercase page-break-inside-avoid"
- )}
- >
+ {/* Shipping & Payment */}
+ <View style={tw("border border-gray-200 mb-4")}>
+ <View style={tw("flex flex-row")}>
+ <View style={tw("w-1/2 p-3 border-r border-gray-200")}>
<Text
- style={tw(`w-${hasTrackedEntities ? "7/12" : "9/12"} text-left`)}
+ style={tw("text-[9px] font-bold text-gray-600 mb-1 uppercase")}
>
- Description
+ Shipping
</Text>
+ <View style={tw("text-[10px] text-gray-800")}>
+ {shippingMethod?.name && (
+ <Text>Method: {shippingMethod.name}</Text>
+ )}
+ </View>
+ </View>
+ <View style={tw("w-1/2 p-3")}>
<Text
- style={tw(`w-${hasTrackedEntities ? "1/6" : "3/12"} text-center`)}
+ style={tw("text-[9px] font-bold text-gray-600 mb-1 uppercase")}
>
- Qty
+ Payment
</Text>
- {hasTrackedEntities && (
- <Text style={tw("w-1/4 text-right")}>Serial/Batch</Text>
- )}
+ <View style={tw("text-[10px] text-gray-800")}>
- {paymentTerm?.name && (
- <Text>Terms: {paymentTerm.name}</Text>
- )}
++ {paymentTerm?.name && <Text>Terms: {paymentTerm.name}</Text>}
+ </View>
</View>
+ </View>
+ </View>
+
+ {/* Line Items Table */}
+ <View style={tw("mb-4")}>
+ {/* Header */}
+ <View
+ style={tw(
+ "flex flex-row bg-gray-800 py-2 px-3 text-white text-[9px] font-bold"
+ )}
+ >
+ <Text
+ style={tw(`w-${hasTrackedEntities ? "5/12" : "7/12"} text-left`)}
+ >
+ Description
+ </Text>
+ <Text style={tw("w-2/12 text-right")}>Qty</Text>
+ {hasTrackedEntities && (
+ <Text style={tw("w-5/12 text-right")}>Serial/Batch</Text>
+ )}
+ </View>
- {shipmentLines
- .filter((line) => line.shippedQuantity > 0)
- .map((line) => {
- const barcodeDataUrl = generateBarcode(line.itemReadableId);
- const trackedEntitiesForLine = trackedEntities.filter(
- (entity) =>
- (entity.attributes as TrackedEntityAttributes)?.[
- "Shipment Line"
- ] === line.id
- );
- return (
+ {/* Rows */}
+ {shipmentLines
+ .filter((line) => line.shippedQuantity > 0)
+ .map((line) => {
+ const barcodeDataUrl = generateBarcode(line.itemReadableId);
+ const trackedEntitiesForLine = trackedEntities.filter(
+ (entity) =>
+ (entity.attributes as TrackedEntityAttributes)?.[
+ "Shipment Line"
+ ] === line.id
+ );
+ const isEven = rowIndex % 2 === 0;
+ rowIndex++;
+
+ return (
+ <View
+ key={line.id}
+ style={tw(
+ `flex flex-row py-2 px-3 border-b border-gray-200 text-[10px] ${
+ isEven ? "bg-white" : "bg-gray-50"
+ }`
+ )}
+ wrap={false}
+ >
<View
-- style={tw(
- "flex flex-row justify-between py-3 px-[6px] border-b border-gray-300 page-break-inside-avoid"
- `w-${hasTrackedEntities ? "5/12" : "7/12"} pr-2`
-- )}
- key={line.id}
- wrap={false}
++ style={tw(`w-${hasTrackedEntities ? "5/12" : "7/12"} pr-2`)}
>
- <View style={tw(`w-${hasTrackedEntities ? "7/12" : "9/12"}`)}>
- <Text style={tw("font-bold mb-1")}>
- {getLineDescription(line)}
- </Text>
- <Text style={tw("text-[9px] opacity-80 mb-2")}>
- {getLineDescriptionDetails(line)}
- </Text>
+ <Text style={tw("text-gray-800")}>
+ {getLineDescription(line)}
+ </Text>
+ <Text style={tw("text-[8px] text-gray-400 mt-0.5")}>
+ {getLineDescriptionDetails(line)}
+ </Text>
- {thumbnails &&
- line.id in thumbnails &&
- thumbnails[line.id] && (
- <View style={tw("mt-2 mb-2")}>
- <Image
- src={thumbnails[line.id]!}
- style={tw("w-1/4 h-auto max-w-[25%]")}
- />
- </View>
- )}
+ {thumbnails &&
+ line.id in thumbnails &&
+ thumbnails[line.id] && (
+ <View style={tw("mt-1 w-16")}>
+ <Image
+ src={thumbnails[line.id]!}
+ style={tw("w-full h-auto")}
+ />
+ </View>
+ )}
+ <View style={tw("mt-1")}>
- <Image
- src={barcodeDataUrl}
- style={tw("max-w-[50%]")}
- />
+ <Image src={barcodeDataUrl} style={tw("max-w-[50%]")} />
</View>
- <Text
- style={tw(
- `w-${hasTrackedEntities ? "1/6" : "3/12"} text-center`
- )}
- >
- {getLineQuantity(line)}
- </Text>
- {hasTrackedEntities && (
- <View style={tw("flex flex-col gap-2 w-1/4 text-right")}>
- {trackedEntitiesForLine.length > 0 && (
- <View>
- {trackedEntitiesForLine.map((entity) => {
- const qrCodeDataUrl = generateQRCode(entity.id, 8);
- return (
- <View
- key={entity.id}
- style={tw("mb-2 text-right")}
- >
- <Text style={tw("text-[8px] mb-1")}>
- {entity.id}
- </Text>
- <Image
- src={qrCodeDataUrl}
- style={tw("max-w-[80%] ml-auto")}
- />
- </View>
- );
- })}
- </View>
- )}
- </View>
- )}
</View>
- );
- })}
- </View>
+ <Text style={tw("w-2/12 text-right text-gray-600")}>
+ {getLineQuantity(line)}
+ </Text>
+ {hasTrackedEntities && (
+ <View style={tw("w-5/12 flex flex-col gap-1 items-end")}>
+ {trackedEntitiesForLine.map((entity) => {
+ const qrCodeDataUrl = generateQRCode(entity.id, 8);
+ return (
+ <View
+ key={entity.id}
+ style={tw("mb-1 flex flex-row items-center gap-1")}
+ >
+ <Text style={tw("text-[8px] text-gray-600")}>
+ {entity.id}
+ </Text>
+ <Image
+ src={qrCodeDataUrl}
+ style={{ width: 24, height: 24 }}
+ />
+ </View>
+ );
+ })}
+ </View>
+ )}
+ </View>
+ );
+ })}
+ </View>
- {/* Notes and Terms Section */}
- <View style={tw("flex flex-col gap-4 w-full")}>
+ {/* Notes & Terms */}
+ <View style={tw("flex flex-col gap-3 w-full")}>
+ {Object.keys(shipment.externalNotes ?? {}).length > 0 && (
<Note
title="Notes"
content={(shipment.externalNotes ?? {}) as JSONContent}
diff --cc packages/documents/src/pdf/QuotePDF.tsx
index 482ffe92ba,8426f54761..2f2d278051
--- a/packages/documents/src/pdf/QuotePDF.tsx
+++ b/packages/documents/src/pdf/QuotePDF.tsx
@@@ -246,209 -319,179 +319,181 @@@ const QuotePDF = (
amount *= exchangeRate;
}
return acc + amount;
- },
- 0
- );
- return charges;
- }
- );
-
- const unitPriceFormatter = getCurrencyFormatter(
- currencyCode,
- locale,
- line.unitPricePrecision
- );
-
- return (
- <View
- style={tw(
- "flex flex-col gap-2 py-3 px-[6px] border-b border-gray-300 mb-2"
- )}
- key={line.id}
- wrap={false}
- >
- <View style={tw("flex flex-row justify-between")}>
- <View style={tw("w-1/3")}>
- <View>
- <Text style={tw("font-bold mb-1")}>
- {getLineDescription(line)}
- </Text>
- <Text style={tw("text-[9px] opacity-80")}>
- {getLineDescriptionDetails(line)}
- </Text>
- </View>
+ }, 0);
+ const shippingCost = price?.convertedShippingCost ?? 0;
+ const taxPercent = line.taxPercent ?? 0;
+ const totalBeforeTax =
+ netExtendedPrice + additionalCharge + shippingCost;
+ const taxAmount = totalBeforeTax * taxPercent;
+ const totalTaxAndFees =
+ additionalCharge + shippingCost + taxAmount;
+ const totalPrice = netExtendedPrice + totalTaxAndFees;
- {thumbnails && line.id in thumbnails && (
- <View style={tw("mt-2")}>
- <Image
- src={thumbnails[line.id]!}
- style={tw("w-full h-auto")}
- />
+ return (
+ <View
+ key={`${line.id}-${quantity}`}
+ style={tw(
+ `flex flex-row py-2 px-3 border-b border-gray-200 text-[10px] ${
+ isEven ? "bg-white" : "bg-gray-50"
+ }`
+ )}
+ >
+ <View style={tw("w-1/3 pr-2")}>
+ <Text style={tw("text-gray-800")}>
+ {getLineDescription(line)}
+ </Text>
+ <Text style={tw("text-[8px] text-gray-400 mt-0.5")}>
+ {getLineDescriptionDetails(line)}
+ </Text>
+ {thumbnails && line.id in thumbnails && (
+ <View style={tw("mt-2")}>
+ <Image
+ src={thumbnails[line.id]!}
+ style={{ width: 60, height: 60 }}
+ />
+ </View>
+ )}
</View>
- )}
-
- {line.status !== "No Quote" &&
- (Object.keys(additionalCharges).length > 0 ||
- pricesByLine[line.id]?.some(
- (price) => (price.shippingCost ?? 0) > 0
- ) ||
- line.taxPercent) && (
- <View style={tw("mt-2.5")}>
- <Text style={tw("text-[9px] font-bold")}>
- Tax & Fees
- </Text>
- {pricesByLine[line.id]?.some(
- (price) => (price.shippingCost ?? 0) > 0
- ) && (
- <Text style={tw("text-[9px] opacity-80")}>
- - Shipping
- </Text>
+ <View style={tw("w-2/3 flex flex-row")}>
+ <Text
+ style={tw(
+ `${colWidth} text-right text-gray-600 pr-3`
)}
- {Object.values(additionalCharges)
- .sort((a, b) =>
- a.description.localeCompare(b.description)
- )
- .map((charge) => {
- return charge.description ? (
- <Text
- key={charge.description}
- style={tw("text-[9px] opacity-80")}
- >
- - {charge.description}
- </Text>
- ) : null;
- })}
- {line.taxPercent && (
- <Text style={tw("text-[9px] opacity-80")}>
- - Tax ({line.taxPercent * 100}%)
- </Text>
+ >
+ {quantity} EA
+ </Text>
+ <Text
+ style={tw(
+ `${colWidth} text-right text-gray-600 pr-3`
)}
- </View>
- )}
- </View>
- <View style={tw("flex flex-col w-2/3 gap-2")}>
- {line.status !== "No Quote" ? (
- line.quantity.map((quantity, index) => {
- const prices = pricesByLine[line.id] ?? [];
- const price = prices.find(
- (price) => price.quantity === quantity
- );
- const unitPrice = price?.convertedUnitPrice ?? 0;
- const netUnitPrice = price?.convertedNetUnitPrice ?? 0;
- const netExtendedPrice =
- price?.convertedNetExtendedPrice ?? 0;
- const discountPercent = price?.discountPercent ?? 0;
-
- const additionalCharge =
- additionalChargesByQuantity[index] ?? 0;
-
- const additionalChargePlusShipping =
- additionalCharge +
- (price?.convertedShippingCost ?? 0);
-
- const taxPercent = line.taxPercent ?? 0;
- const totalBeforeTax =
- netExtendedPrice + additionalChargePlusShipping;
- const taxAmount = totalBeforeTax * taxPercent;
- const totalTaxAndFees =
- additionalChargePlusShipping + taxAmount;
-
- const totalPrice = netExtendedPrice + totalTaxAndFees;
-
- return (
- <View key={quantity} style={tw("flex flex-row")}>
- <Text style={tw("w-1/6 text-right")}>
- {quantity}
- </Text>
- <Text style={tw("w-1/6 text-right")}>
- {unitPrice
- ? unitPriceFormatter.format(unitPrice)
- : "-"}
- </Text>
- {hasDiscounts && (
- <Text style={tw("w-1/6 text-right")}>
- {discountPercent > 0
- ? `${(discountPercent * 100).toFixed(1)}%`
- : "-"}
- </Text>
+ >
+ {unitPrice
+ ? unitPriceFormatter.format(unitPrice)
+ : "-"}
+ </Text>
+ {!hasSinglePricePerLine && (
+ <Text
+ style={tw(
+ `${colWidth} text-right text-gray-600 pr-3`
)}
- <Text
- style={tw(
- `${hasDiscounts ? "w-1/6" : "w-1/5"} text-right`
- )}
- >
- {totalTaxAndFees > 0
- ? formatter.format(totalTaxAndFees)
- : "-"}
- </Text>
- <Text
- style={tw(
- `${hasDiscounts ? "w-1/6" : "w-1/5"} text-right`
- )}
- >
- {price ? `${price.leadTime} days` : "-"}
- </Text>
- <Text
- style={tw(
- `${hasDiscounts ? "w-1/6" : "w-1/5"} text-right`
- )}
- >
- {netUnitPrice
- ? formatter.format(totalPrice)
- : "-"}
- </Text>
- </View>
- );
- })
- ) : (
- <View>
- <View style={tw("flex flex-row")}>
- <Text style={tw("w-1/5 text-right font-bold")}>
- No Quote
+ >
+ {totalTaxAndFees > 0
+ ? formatter.format(totalTaxAndFees)
+ : "-"}
</Text>
- <View style={tw("w-3/5 ml-auto")}>
- {line.noQuoteReason && (
- <Text style={tw("text-sm")}>
- {line.noQuoteReason}
- </Text>
+ )}
+ {hasAnyLeadTime && (
+ <Text
+ style={tw(
+ `${colWidth} text-right text-gray-600 pr-3`
)}
- </View>
- </View>
+ >
- {leadTime > 0 ? `${leadTime} ${pluralize(leadTime, "day")}` : "-"}
++ {leadTime > 0
++ ? `${leadTime} ${pluralize(leadTime, "day")}`
++ : "-"}
+ </Text>
+ )}
+ <Text
+ style={tw(
+ `${colWidth} text-right text-gray-800 font-medium`
+ )}
+ >
+ {hasSinglePricePerLine
+ ? netExtendedPrice > 0
+ ? formatter.format(netExtendedPrice)
+ : "-"
+ : totalPrice > 0
+ ? formatter.format(totalPrice)
+ : "-"}
+ </Text>
</View>
- )}
+ </View>
+ );
+ })
+ ) : (
+ <View
+ style={tw(
+ `flex flex-row py-2 px-3 border-b border-gray-200 text-[10px] ${
+ rowIndex++ % 2 === 0 ? "bg-white" : "bg-gray-50"
+ }`
+ )}
+ >
+ <View style={tw("w-1/3 pr-2")}>
+ <Text style={tw("text-gray-800")}>
+ {getLineDescription(line)}
+ </Text>
+ <Text style={tw("text-[8px] text-gray-400 mt-0.5")}>
+ {getLineDescriptionDetails(line)}
+ </Text>
+ </View>
+ <View style={tw("w-2/3 flex flex-row")}>
+ <Text
+ style={tw(
+ `${colWidth} text-right text-gray-600 font-bold`
+ )}
+ >
+ No Quote
+ </Text>
+ <View style={tw("flex-1 text-right")}>
+ <Text style={tw("text-gray-400 text-[8px] text-right")}>
+ {line.noQuoteReason ?? ""}
+ </Text>
+ </View>
</View>
</View>
- {Object.keys(line.externalNotes ?? {}).length > 0 && (
- <Note
- key={`${line.id}-notes`}
- content={line.externalNotes as JSONContent}
- />
- )}
- </View>
- );
- })}
- {shipment?.shippingCost && (
- <View
- style={tw(
- "flex flex-row justify-between items-center py-3 px-[6px] border-b border-gray-300 font-bold uppercase"
)}
+ </View>
+ );
+ })}
+
+ {/* Summary - only show when single price per line */}
+ {hasSinglePricePerLine && (
+ <View>
+ <View
+ style={tw("flex flex-row py-1.5 px-3 bg-gray-50 text-[10px]")}
>
- <Text>Shipping</Text>
- <Text style={tw("text-black")}>
- {formatter.format(
- (shipment.shippingCost ?? 0) * (exchangeRate ?? 1)
- )}
+ <View style={tw("w-4/6")} />
+ <Text style={tw("w-1/6 text-right text-gray-600")}>Subtotal</Text>
+ <Text style={tw("w-1/6 text-right text-gray-800")}>
+ {formatter.format(getTotalSubtotal())}
</Text>
</View>
- )}
- {hasSinglePricePerLine && (
<View
- style={tw(
- "flex flex-row justify-between items-center py-3 px-[6px] border-b border-gray-300 font-bold uppercase"
- )}
+ style={tw("flex flex-row py-1.5 px-3 bg-gray-50 text-[10px]")}
+ >
+ <View style={tw("w-4/6")} />
+ <Text style={tw("w-1/6 text-right text-gray-600")}>Shipping</Text>
+ <Text style={tw("w-1/6 text-right text-gray-800")}>
+ {formatter.format(getTotalShipping())}
+ </Text>
+ </View>
+ {getTotalFees() > 0 && (
+ <View
+ style={tw("flex flex-row py-1.5 px-3 bg-gray-50 text-[10px]")}
+ >
+ <View style={tw("w-4/6")} />
+ <Text style={tw("w-1/6 text-right text-gray-600")}>Fees</Text>
+ <Text style={tw("w-1/6 text-right text-gray-800")}>
+ {formatter.format(getTotalFees())}
+ </Text>
+ </View>
+ )}
+ <View
+ style={tw("flex flex-row py-1.5 px-3 bg-gray-50 text-[10px]")}
>
- <Text>Total</Text>
- <Text style={tw("font-bold text-black")}>
+ <View style={tw("w-4/6")} />
+ <Text style={tw("w-1/6 text-right text-gray-600")}>Taxes</Text>
+ <Text style={tw("w-1/6 text-right text-gray-800")}>
+ {formatter.format(getTotalTaxes())}
+ </Text>
+ </View>
+ <View style={tw("h-[1px] bg-gray-200")} />
+ <View style={tw("flex flex-row py-2 px-3 text-[11px]")}>
+ <View style={tw("w-4/6")} />
+ <Text style={tw("w-1/6 text-right text-gray-800 font-bold")}>
+ Total
+ </Text>
+ <Text style={tw("w-1/6 text-right text-gray-800 font-bold")}>
{formatter.format(getTotal())}
</Text>
</View>