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.

fix: hide discount in quote pdf if there are no discounts

Brad Barbin894b9a7653b8
diff --git a/apps/erp/app/components/Table/components/Filter/ActiveFilters.tsx b/apps/erp/app/components/Table/components/Filter/ActiveFilters.tsx
index a985fc1c26..e9d38bfc5b 100644
--- a/apps/erp/app/components/Table/components/Filter/ActiveFilters.tsx
+++ b/apps/erp/app/components/Table/components/Filter/ActiveFilters.tsx
@@ -164,7 +164,7 @@ const ActiveFilter = ({ filter, operator, value }: ActiveFilterProps) => {
const isChecked = hasFilter(filter.accessorKey, option.value);
return (
<CommandItem
- value={option.value}
+ value={reactNodeToString(option.label).replace(/"/g, '\\"')}
key={option.value}
onSelect={() => {
toggleFilter(
diff --git a/apps/erp/app/modules/inventory/ui/Inventory/InventoryTable.tsx b/apps/erp/app/modules/inventory/ui/Inventory/InventoryTable.tsx
index 8271680ba0..97113bc7e7 100644
--- a/apps/erp/app/modules/inventory/ui/Inventory/InventoryTable.tsx
+++ b/apps/erp/app/modules/inventory/ui/Inventory/InventoryTable.tsx
@@ -145,7 +145,7 @@ const InventoryTable = memo(
},
{
accessorKey: "materialFormId",
- header: "Form",
+ header: "Shape",
cell: ({ row }) => {
const form = forms.find(
(f) => f.id === row.original.materialFormId
diff --git a/apps/erp/app/modules/items/ui/Materials/MaterialsTable.tsx b/apps/erp/app/modules/items/ui/Materials/MaterialsTable.tsx
index d4281bab51..57d2e6d15d 100644
--- a/apps/erp/app/modules/items/ui/Materials/MaterialsTable.tsx
+++ b/apps/erp/app/modules/items/ui/Materials/MaterialsTable.tsx
@@ -142,7 +142,7 @@ const MaterialsTable = memo(({ data, tags, count }: MaterialsTableProps) => {
},
{
accessorKey: "materialFormId",
- header: "Form",
+ header: "Shape",
cell: (item) => <Enumerable value={item.getValue<string>()} />,
meta: {
filter: {
@@ -193,7 +193,7 @@ const MaterialsTable = memo(({ data, tags, count }: MaterialsTableProps) => {
},
{
accessorKey: "dimensions",
- header: "Dimensions",
+ header: "Dimension",
cell: (item) => item.getValue(),
meta: {
icon: <LuExpand />,
diff --git a/packages/documents/src/pdf/QuotePDF.tsx b/packages/documents/src/pdf/QuotePDF.tsx
index 5324697187..b7b3c3ac1b 100644
--- a/packages/documents/src/pdf/QuotePDF.tsx
+++ b/packages/documents/src/pdf/QuotePDF.tsx
@@ -92,6 +92,11 @@ const QuotePDF = ({
return line.quantity.length === 1;
});
+ // Check if any quote lines have discounts
+ const hasDiscounts = quoteLinePrices.some(
+ (price) => (price.discountPercent ?? 0) > 0
+ );
+
const getTotal = () => {
return quoteLines.reduce((total, line) => {
if (line.status === "No Quote") return total;
@@ -205,10 +210,24 @@ const QuotePDF = ({
<View style={tw("w-2/3 flex flex-row")}>
<Text style={tw("w-1/6 text-right")}>Qty</Text>
<Text style={tw("w-1/6 text-right")}>Unit Price</Text>
- <Text style={tw("w-1/6 text-right")}>Discount</Text>
- <Text style={tw("w-1/6 text-right")}>Tax & Fees</Text>
- <Text style={tw("w-1/6 text-right")}>Lead Time</Text>
- <Text style={tw("w-1/6 text-right")}>Total Price</Text>
+ {hasDiscounts && (
+ <Text style={tw("w-1/6 text-right")}>Discount</Text>
+ )}
+ <Text
+ style={tw(`${hasDiscounts ? "w-1/6" : "w-1/5"} text-right`)}
+ >
+ Tax & Fees
+ </Text>
+ <Text
+ style={tw(`${hasDiscounts ? "w-1/6" : "w-1/5"} text-right`)}
+ >
+ Lead Time
+ </Text>
+ <Text
+ style={tw(`${hasDiscounts ? "w-1/6" : "w-1/5"} text-right`)}
+ >
+ Total Price
+ </Text>
</View>
</View>
@@ -341,20 +360,34 @@ const QuotePDF = ({
? unitPriceFormatter.format(unitPrice)
: "-"}
</Text>
- <Text style={tw("w-1/6 text-right")}>
- {discountPercent > 0
- ? `${(discountPercent * 100).toFixed(1)}%`
- : "-"}
- </Text>
- <Text style={tw("w-1/6 text-right")}>
+ {hasDiscounts && (
+ <Text style={tw("w-1/6 text-right")}>
+ {discountPercent > 0
+ ? `${(discountPercent * 100).toFixed(1)}%`
+ : "-"}
+ </Text>
+ )}
+ <Text
+ style={tw(
+ `${hasDiscounts ? "w-1/6" : "w-1/5"} text-right`
+ )}
+ >
{totalTaxAndFees > 0
? formatter.format(totalTaxAndFees)
: "-"}
</Text>
- <Text style={tw("w-1/6 text-right")}>
+ <Text
+ style={tw(
+ `${hasDiscounts ? "w-1/6" : "w-1/5"} text-right`
+ )}
+ >
{price ? `${price.leadTime} days` : "-"}
</Text>
- <Text style={tw("w-1/6 text-right")}>
+ <Text
+ style={tw(
+ `${hasDiscounts ? "w-1/6" : "w-1/5"} text-right`
+ )}
+ >
{netUnitPrice
? formatter.format(totalPrice)
: "-"}