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: add purchase order lines to report

Brad Barbind68366b5d9aa
diff --git a/apps/carbon/app/modules/parts/parts.service.ts b/apps/carbon/app/modules/parts/parts.service.ts
index 8b7603ae8a..b08e23528c 100644
--- a/apps/carbon/app/modules/parts/parts.service.ts
+++ b/apps/carbon/app/modules/parts/parts.service.ts
@@ -173,7 +173,7 @@ export async function getPartsList(
);
}
- return query;
+ return query.order("name");
}
export async function getPartQuantities(
@@ -273,7 +273,8 @@ export async function getServicesList(
.from("service")
.select("id, name")
.eq("blocked", false)
- .eq("active", true);
+ .eq("active", true)
+ .order("name");
if (type) {
query = query.eq("serviceType", type);
@@ -301,7 +302,8 @@ export async function getShelvesList(
.from("shelf")
.select("id")
.eq("active", true)
- .eq("locationId", locationId);
+ .eq("locationId", locationId)
+ .order("id");
}
export async function getUnitOfMeasure(
@@ -332,7 +334,7 @@ export async function getUnitOfMeasures(
}
export async function getUnitOfMeasuresList(client: SupabaseClient<Database>) {
- return client.from("unitOfMeasure").select("name, code");
+ return client.from("unitOfMeasure").select("name, code").order("name");
}
export async function insertShelf(
diff --git a/apps/carbon/app/modules/parts/ui/Services/ServicesTable/ServicesTable.tsx b/apps/carbon/app/modules/parts/ui/Services/ServicesTable/ServicesTable.tsx
index 97e5e75341..243e04191b 100644
--- a/apps/carbon/app/modules/parts/ui/Services/ServicesTable/ServicesTable.tsx
+++ b/apps/carbon/app/modules/parts/ui/Services/ServicesTable/ServicesTable.tsx
@@ -20,14 +20,19 @@ const ServicesTable = memo(({ data, count }: ServicesTableProps) => {
const columns = useMemo<ColumnDef<Service>[]>(() => {
return [
{
- accessorKey: "name",
- header: "Name",
+ accessorKey: "id",
+ header: "Service ID",
cell: ({ row }) => (
<Link onClick={() => navigate(path.to.service(row.original.id!))}>
- {row.original.name}
+ {row.original.id}
</Link>
),
},
+ {
+ accessorKey: "name",
+ header: "Name",
+ cell: (item) => item.getValue(),
+ },
{
accessorKey: "description",
header: "Description",
diff --git a/apps/carbon/app/modules/purchasing/purchasing.service.ts b/apps/carbon/app/modules/purchasing/purchasing.service.ts
index 0b2f475709..01b271ce93 100644
--- a/apps/carbon/app/modules/purchasing/purchasing.service.ts
+++ b/apps/carbon/app/modules/purchasing/purchasing.service.ts
@@ -165,7 +165,7 @@ export async function getPurchaseOrderLines(
purchaseOrderId: string
) {
return client
- .from("purchaseOrderLine")
+ .from("purchaseOrderLines")
.select("*")
.eq("purchaseOrderId", purchaseOrderId);
}
@@ -295,7 +295,7 @@ export async function getSuppliers(
}
export async function getSuppliersList(client: SupabaseClient<Database>) {
- return client.from("supplier").select("id, name");
+ return client.from("supplier").select("id, name").order("name");
}
export async function getSupplierStatuses(
@@ -348,7 +348,7 @@ export async function getSupplierTypes(
}
export async function getSupplierTypesList(client: SupabaseClient<Database>) {
- return client.from("supplierType").select("id, name");
+ return client.from("supplierType").select("id, name").order("name");
}
export async function insertSupplier(
diff --git a/apps/carbon/app/modules/resources/resources.service.ts b/apps/carbon/app/modules/resources/resources.service.ts
index f8d30755db..c1847c3fae 100644
--- a/apps/carbon/app/modules/resources/resources.service.ts
+++ b/apps/carbon/app/modules/resources/resources.service.ts
@@ -153,7 +153,7 @@ export async function getAbilities(
}
export async function getAbilitiesList(client: SupabaseClient<Database>) {
- return client.from("ability").select(`id, name`);
+ return client.from("ability").select(`id, name`).order("name");
}
export async function getAbility(
@@ -326,7 +326,7 @@ export async function getDepartments(
}
export async function getDepartmentsList(client: SupabaseClient<Database>) {
- return client.from("department").select(`id, name`);
+ return client.from("department").select(`id, name`).order("name");
}
export async function getEmployeeAbility(
@@ -486,7 +486,7 @@ export async function getLocations(
}
export async function getLocationsList(client: SupabaseClient<Database>) {
- return client.from("location").select(`id, name`);
+ return client.from("location").select(`id, name`).order("name");
}
export async function getPartner(
@@ -576,7 +576,7 @@ export async function getShiftsList(
query = query.eq("locationId", locationId);
}
- return query;
+ return query.order("name");
}
type UserAttributeId = string;
@@ -705,7 +705,7 @@ export async function getWorkCellList(
query = query.eq("workCellTypeId", workCellTypeId);
}
- return query;
+ return query.order("name");
}
export async function getWorkCellType(
diff --git a/apps/carbon/app/modules/sales/sales.service.ts b/apps/carbon/app/modules/sales/sales.service.ts
index 8cb903b116..1501eab77d 100644
--- a/apps/carbon/app/modules/sales/sales.service.ts
+++ b/apps/carbon/app/modules/sales/sales.service.ts
@@ -151,7 +151,7 @@ export async function getCustomers(
}
export async function getCustomersList(client: SupabaseClient<Database>) {
- return client.from("customer").select("id, name");
+ return client.from("customer").select("id, name").order("name");
}
export async function getCustomerStatuses(
@@ -204,7 +204,7 @@ export async function getCustomerTypes(
}
export async function getCustomerTypesList(client: SupabaseClient<Database>) {
- return client.from("customerType").select("id, name");
+ return client.from("customerType").select("id, name").order("name");
}
export async function insertCustomer(
diff --git a/apps/carbon/app/modules/settings/settings.service.ts b/apps/carbon/app/modules/settings/settings.service.ts
index cc7da4229b..c48e5a5f0d 100644
--- a/apps/carbon/app/modules/settings/settings.service.ts
+++ b/apps/carbon/app/modules/settings/settings.service.ts
@@ -105,7 +105,7 @@ export async function getSequencesList(
client: SupabaseClient<Database>,
table: string
) {
- return client.from("sequence").select("id").eq("table", table);
+ return client.from("sequence").select("id").eq("table", table).order("table");
}
export async function insertCompany(
diff --git a/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx b/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx
index 1250a2e1a3..230f693201 100644
--- a/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx
+++ b/apps/carbon/app/modules/shared/ui/Realtime/RealtimeDataProvider.tsx
@@ -20,9 +20,10 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
.from("part")
.select("id, name, replenishmentSystem")
.eq("active", true)
- .eq("blocked", false),
- supabase.from("supplier").select("id, name"),
- supabase.from("customer").select("id, name"),
+ .eq("blocked", false)
+ .order("name"),
+ supabase.from("supplier").select("id, name").order("name"),
+ supabase.from("customer").select("id, name").order("name"),
]);
if (parts.error || suppliers.error || customers.error) {
@@ -54,28 +55,32 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
switch (payload.eventType) {
case "INSERT":
const { new: inserted } = payload;
- setParts((parts) => [
- ...parts,
- {
- id: inserted.id,
- name: inserted.name,
- replenishmentSystem: inserted.replenishmentSystem,
- },
- ]);
+ setParts((parts) =>
+ [
+ ...parts,
+ {
+ id: inserted.id,
+ name: inserted.name,
+ replenishmentSystem: inserted.replenishmentSystem,
+ },
+ ].sort((a, b) => a.name.localeCompare(b.name))
+ );
break;
case "UPDATE":
const { new: updated } = payload;
setParts((parts) =>
- parts.map((p) => {
- if (p.id === updated.id) {
- return {
- ...p,
- name: updated.name,
- replenishmentSystem: updated.replenishmentSystem,
- };
- }
- return p;
- })
+ parts
+ .map((p) => {
+ if (p.id === updated.id) {
+ return {
+ ...p,
+ name: updated.name,
+ replenishmentSystem: updated.replenishmentSystem,
+ };
+ }
+ return p;
+ })
+ .sort((a, b) => a.name.localeCompare(b.name))
);
break;
case "DELETE":
@@ -98,26 +103,30 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
switch (payload.eventType) {
case "INSERT":
const { new: inserted } = payload;
- setCustomers((customers) => [
- ...customers,
- {
- id: inserted.id,
- name: inserted.name,
- },
- ]);
+ setCustomers((customers) =>
+ [
+ ...customers,
+ {
+ id: inserted.id,
+ name: inserted.name,
+ },
+ ].sort((a, b) => a.name.localeCompare(b.name))
+ );
break;
case "UPDATE":
const { new: updated } = payload;
setCustomers((customers) =>
- customers.map((p) => {
- if (p.id === updated.id) {
- return {
- ...p,
- name: updated.name,
- };
- }
- return p;
- })
+ customers
+ .map((p) => {
+ if (p.id === updated.id) {
+ return {
+ ...p,
+ name: updated.name,
+ };
+ }
+ return p;
+ })
+ .sort((a, b) => a.name.localeCompare(b.name))
);
break;
case "DELETE":
@@ -142,26 +151,30 @@ const RealtimeDataProvider = ({ children }: { children: React.ReactNode }) => {
switch (payload.eventType) {
case "INSERT":
const { new: inserted } = payload;
- setSuppliers((suppliers) => [
- ...suppliers,
- {
- id: inserted.id,
- name: inserted.name,
- },
- ]);
+ setSuppliers((suppliers) =>
+ [
+ ...suppliers,
+ {
+ id: inserted.id,
+ name: inserted.name,
+ },
+ ].sort((a, b) => a.name.localeCompare(b.name))
+ );
break;
case "UPDATE":
const { new: updated } = payload;
setSuppliers((suppliers) =>
- suppliers.map((p) => {
- if (p.id === updated.id) {
- return {
- ...p,
- name: updated.name,
- };
- }
- return p;
- })
+ suppliers
+ .map((p) => {
+ if (p.id === updated.id) {
+ return {
+ ...p,
+ name: updated.name,
+ };
+ }
+ return p;
+ })
+ .sort((a, b) => a.name.localeCompare(b.name))
);
break;
case "DELETE":
diff --git a/apps/carbon/app/routes/x+/index.tsx b/apps/carbon/app/routes/x+/index.tsx
index ae41f647c2..ec8ff18ed1 100644
--- a/apps/carbon/app/routes/x+/index.tsx
+++ b/apps/carbon/app/routes/x+/index.tsx
@@ -8,7 +8,7 @@ import { requirePermissions } from "~/services/auth";
export async function loader({ request }: LoaderFunctionArgs) {
const { client } = await requirePermissions(request, {});
- const orderId = "cm2mban560l148d36up0";
+ const orderId = "cm2ttji240kgaqs4q1vg";
const [company, purchaseOrder, purchaseOrderLines] = await Promise.all([
getCompany(client),
diff --git a/apps/carbon/package.json b/apps/carbon/package.json
index c6cbc5b4b5..ba24db0a43 100644
--- a/apps/carbon/package.json
+++ b/apps/carbon/package.json
@@ -58,7 +58,7 @@
"performant-array-to-tree": "1.11.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
- "react-icons": "^4.10.1",
+ "react-icons": "^4.12.0",
"reactflow": "^11.7.4",
"remix-flat-routes": "^0.5.10",
"remix-validated-form": "^5.1.5",
diff --git a/package-lock.json b/package-lock.json
index d65fbafd80..b72320d353 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -76,7 +76,7 @@
"performant-array-to-tree": "1.11.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
- "react-icons": "^4.10.1",
+ "react-icons": "^4.12.0",
"reactflow": "^11.7.4",
"remix-flat-routes": "^0.5.10",
"remix-validated-form": "^5.1.5",
@@ -20958,9 +20958,9 @@
}
},
"node_modules/react-icons": {
- "version": "4.11.0",
- "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.11.0.tgz",
- "integrity": "sha512-V+4khzYcE5EBk/BvcuYRq6V/osf11ODUM2J8hg2FDSswRrGvqiYUYPRy4OdrWaQOBj4NcpJfmHZLNaD+VH0TyA==",
+ "version": "4.12.0",
+ "resolved": "https://registry.npmjs.org/react-icons/-/react-icons-4.12.0.tgz",
+ "integrity": "sha512-IBaDuHiShdZqmfc/TwHu6+d6k2ltNCf3AszxNmjJc1KUfXdEeRJOKyNvLmAHaarhzGmTSVygNdyu8/opXv2gaw==",
"peerDependencies": {
"react": "*"
}
@@ -26992,7 +26992,8 @@
"version": "0.0.0",
"license": "Apache-2.0",
"dependencies": {
- "@react-pdf/renderer": "^3.1.14"
+ "@react-pdf/renderer": "^3.1.14",
+ "react-icons": "^4.12.0"
},
"devDependencies": {
"@carbon/database": "*",
@@ -27172,7 +27173,7 @@
"framer-motion": "^10.13.1",
"is-hotkey": "^0.2.0",
"react-colorful": "^5.6.1",
- "react-icons": "^4.10.1",
+ "react-icons": "^4.12.0",
"react-select": "^5.5.1",
"react-window": "^1.8.9"
},
@@ -27325,7 +27326,7 @@
"nextra-theme-docs": "^2.5.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
- "react-icons": "^4.10.1",
+ "react-icons": "^4.12.0",
"tailwindcss-animate": "1.0.7"
},
"devDependencies": {
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 55c5ddfd64..7f796a65fa 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -5167,6 +5167,12 @@ export interface Database {
referencedRelation: "purchaseOrderLine";
referencedColumns: ["id"];
},
+ {
+ foreignKeyName: "purchaseInvoiceLines_purchaseOrderLineId_fkey";
+ columns: ["purchaseOrderLineId"];
+ referencedRelation: "purchaseOrderLines";
+ referencedColumns: ["id"];
+ },
{
foreignKeyName: "purchaseInvoiceLines_serviceId_fkey";
columns: ["serviceId"];
@@ -8779,6 +8785,166 @@ export interface Database {
}
];
};
+ purchaseOrderLines: {
+ Row: {
+ accountNumber: string | null;
+ assetId: string | null;
+ createdAt: string | null;
+ createdBy: string | null;
+ description: string | null;
+ id: string | null;
+ invoicedComplete: boolean | null;
+ locationId: string | null;
+ partDescription: string | null;
+ partId: string | null;
+ partName: string | null;
+ purchaseOrderId: string | null;
+ purchaseOrderLineType:
+ | Database["public"]["Enums"]["purchaseOrderLineType"]
+ | null;
+ purchaseQuantity: number | null;
+ quantityInvoiced: number | null;
+ quantityReceived: number | null;
+ quantityToInvoice: number | null;
+ quantityToReceive: number | null;
+ receivedComplete: boolean | null;
+ requiresInspection: boolean | null;
+ serviceDescription: string | null;
+ serviceId: string | null;
+ serviceName: string | null;
+ setupPrice: number | null;
+ shelfId: string | null;
+ supplierId: string | null;
+ supplierPartId: string | null;
+ supplierServiceId: string | null;
+ unitOfMeasureCode: string | null;
+ unitPrice: number | null;
+ updatedAt: string | null;
+ updatedBy: string | null;
+ };
+ Relationships: [
+ {
+ foreignKeyName: "purchaseOrder_supplierId_fkey";
+ columns: ["supplierId"];
+ referencedRelation: "supplier";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "purchaseOrder_supplierId_fkey";
+ columns: ["supplierId"];
+ referencedRelation: "contractors";
+ referencedColumns: ["supplierId"];
+ },
+ {
+ foreignKeyName: "purchaseOrder_supplierId_fkey";
+ columns: ["supplierId"];
+ referencedRelation: "partners";
+ referencedColumns: ["supplierId"];
+ },
+ {
+ foreignKeyName: "purchaseOrder_supplierId_fkey";
+ columns: ["supplierId"];
+ referencedRelation: "purchaseOrderSuppliers";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "purchaseOrder_supplierId_fkey";
+ columns: ["supplierId"];
+ referencedRelation: "suppliers";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_accountNumber_fkey";
+ columns: ["accountNumber"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_accountNumber_fkey";
+ columns: ["accountNumber"];
+ referencedRelation: "accounts";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_createdBy_fkey";
+ columns: ["createdBy"];
+ referencedRelation: "user";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_createdBy_fkey";
+ columns: ["createdBy"];
+ referencedRelation: "userDefaults";
+ referencedColumns: ["userId"];
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_partId_fkey";
+ columns: ["partId"];
+ referencedRelation: "part";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_partId_fkey";
+ columns: ["partId"];
+ referencedRelation: "partQuantities";
+ referencedColumns: ["partId"];
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_partId_fkey";
+ columns: ["partId"];
+ referencedRelation: "parts";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_purchaseOrderId_fkey";
+ columns: ["purchaseOrderId"];
+ referencedRelation: "purchaseOrder";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_purchaseOrderId_fkey";
+ columns: ["purchaseOrderId"];
+ referencedRelation: "purchaseOrders";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_serviceId_fkey";
+ columns: ["serviceId"];
+ referencedRelation: "service";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_serviceId_fkey";
+ columns: ["serviceId"];
+ referencedRelation: "services";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_shelfId_fkey";
+ columns: ["shelfId", "locationId"];
+ referencedRelation: "shelf";
+ referencedColumns: ["id", "locationId"];
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_unitOfMeasureCode_fkey";
+ columns: ["unitOfMeasureCode"];
+ referencedRelation: "unitOfMeasure";
+ referencedColumns: ["code"];
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_updatedBy_fkey";
+ columns: ["updatedBy"];
+ referencedRelation: "user";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "purchaseOrderLine_updatedBy_fkey";
+ columns: ["updatedBy"];
+ referencedRelation: "userDefaults";
+ referencedColumns: ["userId"];
+ }
+ ];
+ };
purchaseOrders: {
Row: {
closedAt: string | null;
diff --git a/packages/database/supabase/migrations/20230330024716_parts.sql b/packages/database/supabase/migrations/20230330024716_parts.sql
index 9c26782990..e5031b6805 100644
--- a/packages/database/supabase/migrations/20230330024716_parts.sql
+++ b/packages/database/supabase/migrations/20230330024716_parts.sql
@@ -339,10 +339,13 @@ CREATE INDEX "partSupplier_partId_index" ON "partSupplier"("partId");
ALTER TABLE "partSupplier" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Employees with part_view can view part suppliers" ON "partSupplier"
+CREATE POLICY "Employees with part/purchasing_view can view part suppliers" ON "partSupplier"
FOR SELECT
USING (
- coalesce(get_my_claim('parts_view')::boolean,false)
+ OR(
+ coalesce(get_my_claim('parts_view')::boolean,false),
+ coalesce(get_my_claim('purchasing_view')::boolean,false)
+ )
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
diff --git a/packages/database/supabase/migrations/20230412120726_services.sql b/packages/database/supabase/migrations/20230412120726_services.sql
index 819ff0f4f2..c8de870451 100644
--- a/packages/database/supabase/migrations/20230412120726_services.sql
+++ b/packages/database/supabase/migrations/20230412120726_services.sql
@@ -78,10 +78,13 @@ CREATE INDEX "serviceSupplier_serviceId_index" ON "serviceSupplier"("serviceId")
ALTER TABLE "serviceSupplier" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Employees with part_view can view service suppliers" ON "serviceSupplier"
+CREATE POLICY "Employees with part/purchasing_view can view service suppliers" ON "serviceSupplier"
FOR SELECT
USING (
- coalesce(get_my_claim('parts_view')::boolean,false)
+ OR(
+ coalesce(get_my_claim('parts_view')::boolean,false),
+ coalesce(get_my_claim('purchasing_view')::boolean,false)
+ )
AND (get_my_claim('role'::text)) = '"employee"'::jsonb
);
diff --git a/packages/database/supabase/migrations/20231222200612_purchase-order-document.sql b/packages/database/supabase/migrations/20231222200612_purchase-order-document.sql
new file mode 100644
index 0000000000..7ddeb3de08
--- /dev/null
+++ b/packages/database/supabase/migrations/20231222200612_purchase-order-document.sql
@@ -0,0 +1,21 @@
+CREATE OR REPLACE VIEW "purchaseOrderLines" WITH(SECURITY_INVOKER=true) AS
+ SELECT
+ pol.*,
+ po."supplierId" ,
+ p.name AS "partName",
+ p.description AS "partDescription",
+ ps."supplierPartId",
+ s.name AS "serviceName",
+ s.description AS "serviceDescription",
+ ss."supplierServiceId"
+ FROM "purchaseOrderLine" pol
+ INNER JOIN "purchaseOrder" po
+ ON po.id = pol."purchaseOrderId"
+ LEFT OUTER JOIN "part" p
+ ON p.id = pol."partId"
+ LEFT OUTER JOIN "partSupplier" ps
+ ON p.id = ps."partId" AND po."supplierId" = ps."supplierId"
+ LEFT OUTER JOIN "service" s
+ ON s.id = pol."serviceId"
+ LEFT OUTER JOIN "serviceSupplier" ss
+ ON s.id = ss."serviceId" AND po."supplierId" = ss."supplierId";
\ No newline at end of file
diff --git a/packages/documents/package.json b/packages/documents/package.json
index 222bf61f58..880c5cb7f0 100644
--- a/packages/documents/package.json
+++ b/packages/documents/package.json
@@ -21,7 +21,8 @@
"preset": "@carbon/jest/node"
},
"dependencies": {
- "@react-pdf/renderer": "^3.1.14"
+ "@react-pdf/renderer": "^3.1.14",
+ "react-icons": "^4.12.0"
},
"devDependencies": {
"@carbon/database": "*",
diff --git a/packages/documents/src/PurchaseOrderPDF/PurchaseOrderPDF.tsx b/packages/documents/src/PurchaseOrderPDF/PurchaseOrderPDF.tsx
index b3ab1feefb..1343ac4c7b 100644
--- a/packages/documents/src/PurchaseOrderPDF/PurchaseOrderPDF.tsx
+++ b/packages/documents/src/PurchaseOrderPDF/PurchaseOrderPDF.tsx
@@ -6,7 +6,7 @@ import type { PDF } from "../types";
interface PurchaseOrderPDFProps extends PDF {
purchaseOrder: Database["public"]["Views"]["purchaseOrders"]["Row"];
- purchaseOrderLines: Database["public"]["Tables"]["purchaseOrderLine"]["Row"][];
+ purchaseOrderLines: Database["public"]["Views"]["purchaseOrderLines"]["Row"][];
}
// TODO: format currency based on settings
@@ -54,13 +54,13 @@ const PurchaseOrderPDF = ({
label: {
color: "#7d7d7d",
},
- total: {
+ bold: {
fontWeight: 700,
color: "#000000",
},
table: {
marginBottom: 20,
- fontSize: 9,
+ fontSize: 10,
},
thead: {
flexGrow: 1,
@@ -102,16 +102,16 @@ const PurchaseOrderPDF = ({
textTransform: "uppercase",
},
tableCol1: {
- width: "40%",
+ width: "50%",
textAlign: "left",
},
tableCol2: {
- width: "20%",
- textAlign: "center",
+ width: "15%",
+ textAlign: "right",
},
tableCol3: {
- width: "20%",
- textAlign: "center",
+ width: "15%",
+ textAlign: "right",
},
tableCol4: {
width: "20%",
@@ -152,6 +152,7 @@ const PurchaseOrderPDF = ({
</View>
<View style={styles.colThird}>
<Text style={styles.label}>Ship To</Text>
+ <Text>Headquarters</Text>
<Text>Barry Mantelow</Text>
<Text>123 Strange Rd</Text>
<Text>Bazooka, AL 12345</Text>
@@ -195,11 +196,11 @@ const PurchaseOrderPDF = ({
{purchaseOrderLines.map((line) => (
<View style={styles.tr} key={line.id}>
<View style={styles.tableCol1}>
- <Text style={{ marginBottom: 4 }}>
- {getLineDescription(purchaseOrder, line)}
+ <Text style={{ ...styles.bold, marginBottom: 4 }}>
+ {getLineDescription(line)}
</Text>
- <Text style={{ fontSize: 9, opacity: 0.8, width: "95%" }}>
- {line.description}
+ <Text style={{ fontSize: 9, opacity: 0.8 }}>
+ {getLineDescriptionDetails(line)}
</Text>
</View>
<Text style={styles.tableCol2}>
@@ -229,7 +230,7 @@ const PurchaseOrderPDF = ({
))}
<View style={styles.tfoot}>
<Text>Total</Text>
- <Text style={styles.total}>
+ <Text style={styles.bold}>
<Text>$</Text>
<Text>{getTotal(purchaseOrderLines)}</Text>
</Text>
@@ -248,22 +249,56 @@ const PurchaseOrderPDF = ({
);
};
-function getTotal(
- lines: Database["public"]["Tables"]["purchaseOrderLine"]["Row"][]
+function getLineDescription(
+ line: Database["public"]["Views"]["purchaseOrderLines"]["Row"]
) {
- let total = 0;
-
- lines.forEach((line) => {
- if (line?.purchaseQuantity && line?.unitPrice) {
- total += line.purchaseQuantity * line.unitPrice;
- }
- });
+ switch (line?.purchaseOrderLineType) {
+ case "Part":
+ const supplierPartNumber = line.supplierPartId
+ ? ` (${line.supplierPartId})`
+ : "";
+ return line?.partId + supplierPartNumber;
+ case "Service":
+ const supplierServiceNumber = line.supplierServiceId
+ ? ` (${line.supplierServiceId})`
+ : "";
+ return line?.serviceId + supplierServiceNumber;
+ case "Fixed Asset":
+ return line?.assetId;
+ case "G/L Account":
+ case "Comment":
+ return line?.description;
+ default:
+ return "";
+ }
+}
- return total.toFixed(2);
+function getLineDescriptionDetails(
+ line: Database["public"]["Views"]["purchaseOrderLines"]["Row"]
+) {
+ switch (line?.purchaseOrderLineType) {
+ case "Part":
+ const partDescription = line?.partDescription
+ ? `\n${line.partDescription}`
+ : "";
+ return line?.description + partDescription;
+ case "Service":
+ const serviceDescription = line?.serviceDescription
+ ? `\n${line.serviceDescription}`
+ : "";
+ return line?.description + serviceDescription;
+ case "Fixed Asset":
+ return line?.description;
+ case "G/L Account":
+ return `GL Account: ${line?.accountNumber}`;
+ case "Comment":
+ default:
+ return "";
+ }
}
function getLineTotal(
- line: Database["public"]["Tables"]["purchaseOrderLine"]["Row"]
+ line: Database["public"]["Views"]["purchaseOrderLines"]["Row"]
) {
if (line?.purchaseQuantity && line?.unitPrice) {
return (line.purchaseQuantity * line.unitPrice).toFixed(2);
@@ -272,22 +307,18 @@ function getLineTotal(
return "";
}
-function getLineDescription(
- purchaseOrder: Database["public"]["Views"]["purchaseOrders"]["Row"],
- line: Database["public"]["Tables"]["purchaseOrderLine"]["Row"]
+function getTotal(
+ lines: Database["public"]["Views"]["purchaseOrderLines"]["Row"][]
) {
- switch (line?.purchaseOrderLineType) {
- case "Comment":
- return line?.description;
- case "Part":
- return line?.description;
- case "Service":
- return line?.description;
- case "Fixed Asset":
- return line?.description;
- default:
- return "";
- }
+ let total = 0;
+
+ lines.forEach((line) => {
+ if (line?.purchaseQuantity && line?.unitPrice) {
+ total += line.purchaseQuantity * line.unitPrice;
+ }
+ });
+
+ return total.toFixed(2);
}
const PurchaseOrderPDFView = (props: PurchaseOrderPDFProps) => (
diff --git a/packages/documents/src/components/Summary.tsx b/packages/documents/src/components/Summary.tsx
index efecee863b..4ab3f1fd89 100644
--- a/packages/documents/src/components/Summary.tsx
+++ b/packages/documents/src/components/Summary.tsx
@@ -28,8 +28,8 @@ const Summary = ({ company, items }: SummaryProps) => {
},
companyName: {
fontSize: 13,
- color: "#4d4d4d",
- fontWeight: 700,
+ color: "#000000",
+ fontWeight: 900,
},
documentSummary: {
display: "flex",
@@ -46,7 +46,7 @@ const Summary = ({ company, items }: SummaryProps) => {
marginBottom: 5,
},
documentSummaryLabel: {
- color: "#4d4d4d",
+ color: "#7d7d7d",
fontWeight: 700,
width: "30%",
},
diff --git a/packages/react/package.json b/packages/react/package.json
index 465df51365..da0bc266d7 100644
--- a/packages/react/package.json
+++ b/packages/react/package.json
@@ -44,7 +44,7 @@
"framer-motion": "^10.13.1",
"is-hotkey": "^0.2.0",
"react-colorful": "^5.6.1",
- "react-icons": "^4.10.1",
+ "react-icons": "^4.12.0",
"react-select": "^5.5.1",
"react-window": "^1.8.9"
},
diff --git a/www/components/features.tsx b/www/components/features.tsx
index 982add4495..1e84f335f5 100644
--- a/www/components/features.tsx
+++ b/www/components/features.tsx
@@ -58,7 +58,7 @@ function Features({ showIcons = false }) {
{features.map(({ icon: Icon, ...feature }, i) => (
<div
data-glow
- className="flex items-start p-8 space-x-4 bg-black/[0.03] dark:bg-zinc-900 sm:-inset-x-6 round shadow-sm transition-all duration-300 ease-in-out"
+ className="flex items-start p-8 space-x-4 bg-black/[0.03] dark:bg-zinc-900 round shadow-sm transition-all duration-300 ease-in-out"
key={feature.name.split(" ").join("-")}
>
<div data-glow />
diff --git a/www/components/pages/Home.tsx b/www/components/pages/Home.tsx
index 6624f61499..74971d99de 100644
--- a/www/components/pages/Home.tsx
+++ b/www/components/pages/Home.tsx
@@ -3,7 +3,6 @@
import { clamp, motion, useMotionValueEvent, useScroll } from "framer-motion";
import Head from "next/head";
import React, { useState } from "react";
-import { useGlowPointer } from "../../hooks/useGlowPointer";
import { useWindowSize } from "../../hooks/useWindowSize";
import Features from "../features";
import Sticky from "../sticky";
@@ -28,7 +27,6 @@ function Gradient() {
}
function Hero() {
- useGlowPointer();
const { height, width } = useWindowSize();
if (!height) return null;
@@ -88,7 +86,7 @@ function Hero() {
delay: 3.0,
ease: "easeInOut",
}}
- className="flex items-center justify-center w-full px-8 py-3 text-base font-medium text-black no-underline bg-zinc-200 border border-transparent rounded-md dark:bg-zinc-800 dark:text-white betterhover:dark:hover:bg-gray-800 betterhover:hover:bg-zinc-300 md:py-3 md:text-lg md:px-10 md:leading-6 fix-width-auto xl:w-auto"
+ className="flex items-center justify-center w-full px-8 py-3 text-base font-medium text-black no-underline bg-zinc-200 border border-zinc-300 dark:border-zinc-700 rounded-md dark:bg-zinc-800 dark:text-white betterhover:dark:hover:bg-gray-800 betterhover:hover:bg-zinc-300 md:text-lg md:px-12 md:leading-6 fix-width-auto xl:w-auto"
href="/learn/introduction"
>
Learn
@@ -100,7 +98,7 @@ function Hero() {
delay: 3.2,
ease: "easeInOut",
}}
- className="flex items-center justify-center w-full px-8 py-3 text-base font-medium text-white no-underline bg-zinc-800 border border-transparent rounded-md dark:bg-zinc-100 dark:text-black betterhover:dark:hover:bg-gray-300 betterhover:hover:bg-gray-700 md:py-3 md:text-lg md:px-10 md:leading-6 fix-width-auto xl:w-auto"
+ className="flex items-center justify-center w-full px-8 py-3 text-base font-medium text-white no-underline bg-zinc-800 border border-zinc-700 dark:border-zinc-200 rounded-md dark:bg-zinc-100 dark:text-black betterhover:dark:hover:bg-gray-300 betterhover:hover:bg-gray-700 md:text-lg md:px-12 md:leading-6 fix-width-auto xl:w-auto"
href="/develop/getting-started"
>
Develop
diff --git a/www/package.json b/www/package.json
index 4e2b1ce06f..d5e1345ffb 100644
--- a/www/package.json
+++ b/www/package.json
@@ -18,7 +18,7 @@
"nextra-theme-docs": "^2.5.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
- "react-icons": "^4.10.1",
+ "react-icons": "^4.12.0",
"tailwindcss-animate": "1.0.7"
},
"devDependencies": {