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 CRUD for purchase invoice lines

Brad Barbin6e143da55065
diff --git a/apps/carbon/app/components/Form/Account.tsx b/apps/carbon/app/components/Form/Account.tsx
index 1e28ffec34..c7db2efd3c 100644
--- a/apps/carbon/app/components/Form/Account.tsx
+++ b/apps/carbon/app/components/Form/Account.tsx
@@ -6,7 +6,7 @@ import {
FormLabel,
} from "@chakra-ui/react";
import { useFetcher } from "@remix-run/react";
-import { useEffect, useMemo } from "react";
+import { useMemo } from "react";
import { useControlField, useField } from "remix-validated-form";
import type { AccountClass, getAccountsList } from "~/modules/accounting";
import { path } from "~/utils/path";
@@ -27,7 +27,7 @@ const Account = ({
onChange,
...props
}: AccountSelectProps) => {
- const { error, defaultValue } = useField(name);
+ const { error } = useField(name);
const [value, setValue] = useControlField<string | undefined>(name);
const accountFetcher =
@@ -68,14 +68,6 @@ const Account = ({
[value, options]
);
- // so that we can call onChange on load
- useEffect(() => {
- if (controlledValue && controlledValue.value === defaultValue) {
- handleChange(controlledValue);
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [controlledValue?.value]);
-
return (
<FormControl isInvalid={!!error}>
{label && <FormLabel htmlFor={name}>{label}</FormLabel>}
diff --git a/apps/carbon/app/modules/invoicing/invoicing.models.ts b/apps/carbon/app/modules/invoicing/invoicing.models.ts
index 36174ed9aa..7dcdc70b9a 100644
--- a/apps/carbon/app/modules/invoicing/invoicing.models.ts
+++ b/apps/carbon/app/modules/invoicing/invoicing.models.ts
@@ -2,6 +2,13 @@ import { withZod } from "@remix-validated-form/with-zod";
import { z } from "zod";
import { zfd } from "zod-form-data";
+export const purchaseInvoiceLineType = [
+ "Part",
+ "G/L Account",
+ "Fixed Asset",
+ "Comment",
+] as const;
+
export const purchaseInvoiceStatusType = [
"Draft",
"Pending",
@@ -30,3 +37,55 @@ export const purchaseInvoiceValidator = withZod(
status: z.enum(purchaseInvoiceStatusType).optional(),
})
);
+
+export const purchaseInvoiceLineValidator = withZod(
+ z
+ .object({
+ id: zfd.text(z.string().optional()),
+ invoiceId: z.string().min(20, { message: "Invoice is required" }),
+ invoiceLineType: z.enum(purchaseInvoiceLineType, {
+ errorMap: (issue, ctx) => ({
+ message: "Type is required",
+ }),
+ }),
+ purchaseOrderId: zfd.text(z.string().optional()),
+ purchaseOrderLineId: zfd.text(z.string().optional()),
+ partId: zfd.text(z.string().optional()),
+ accountNumber: zfd.text(z.string().optional()),
+ assetId: zfd.text(z.string().optional()),
+ description: zfd.text(z.string().optional()),
+ quantity: zfd.numeric(z.number().optional()),
+ unitPrice: zfd.numeric(z.number().optional()),
+ locationId: zfd.text(z.string().optional()),
+ shelfId: zfd.text(z.string().optional()),
+ unitOfMeasureCode: zfd.text(z.string().optional()),
+ currencyCode: zfd.text(z.string().optional()),
+ exchangeRate: zfd.numeric(z.number().optional()),
+ })
+ .refine((data) => (data.invoiceLineType === "Part" ? data.partId : true), {
+ message: "Part is required",
+ path: ["partId"], // path of error
+ })
+ .refine(
+ (data) =>
+ data.invoiceLineType === "G/L Account" ? data.accountNumber : true,
+ {
+ message: "Account is required",
+ path: ["accountNumber"], // path of error
+ }
+ )
+ .refine(
+ (data) => (data.invoiceLineType === "Fixed Asset" ? data.assetId : true),
+ {
+ message: "Asset is required",
+ path: ["assetId"], // path of error
+ }
+ )
+ .refine(
+ (data) => (data.invoiceLineType === "Comment" ? data.description : true),
+ {
+ message: "Comment is required",
+ path: ["description"], // path of error
+ }
+ )
+);
diff --git a/apps/carbon/app/modules/invoicing/invoicing.service.ts b/apps/carbon/app/modules/invoicing/invoicing.service.ts
index c340f6d23e..8aa9c5a089 100644
--- a/apps/carbon/app/modules/invoicing/invoicing.service.ts
+++ b/apps/carbon/app/modules/invoicing/invoicing.service.ts
@@ -5,7 +5,10 @@ import type { TypeOfValidator } from "~/types/validators";
import type { GenericQueryFilters } from "~/utils/query";
import { setGenericQueryFilters } from "~/utils/query";
import { sanitize } from "~/utils/supabase";
-import type { purchaseInvoiceValidator } from "./invoicing.models";
+import type {
+ purchaseInvoiceLineValidator,
+ purchaseInvoiceValidator,
+} from "./invoicing.models";
export async function deletePurchaseInvoice(
client: SupabaseClient<Database>,
@@ -17,6 +20,16 @@ export async function deletePurchaseInvoice(
return client.from("purchaseInvoice").delete().eq("id", purchaseInvoiceId);
}
+export async function deletePurchaseInvoiceLine(
+ client: SupabaseClient<Database>,
+ purchaseInvoiceLineId: string
+) {
+ return client
+ .from("purchaseInvoiceLine")
+ .delete()
+ .eq("id", purchaseInvoiceLineId);
+}
+
export async function getPurchaseInvoice(
client: SupabaseClient<Database>,
purchaseInvoiceId: string
@@ -68,6 +81,17 @@ export async function getPurchaseInvoiceLines(
.eq("invoiceId", purchaseInvoiceId);
}
+export async function getPurchaseInvoiceLine(
+ client: SupabaseClient<Database>,
+ purchaseInvoiceLineId: string
+) {
+ return client
+ .from("purchaseInvoiceLine")
+ .select("*")
+ .eq("id", purchaseInvoiceLineId)
+ .single();
+}
+
export async function upsertPurchaseInvoice(
client: SupabaseClient<Database>,
purchaseInvoice:
@@ -118,3 +142,35 @@ export async function upsertPurchaseInvoice(
return invoice;
}
+
+export async function upsertPurchaseInvoiceLine(
+ client: SupabaseClient<Database>,
+ purchaseInvoiceLine:
+ | (Omit<TypeOfValidator<typeof purchaseInvoiceLineValidator>, "id"> & {
+ createdBy: string;
+ })
+ | (Omit<TypeOfValidator<typeof purchaseInvoiceLineValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
+) {
+ if ("id" in purchaseInvoiceLine) {
+ return client
+ .from("purchaseInvoiceLine")
+ .update(sanitize(purchaseInvoiceLine))
+ .eq("id", purchaseInvoiceLine.id)
+ .select("id")
+ .single();
+ }
+
+ return client
+ .from("purchaseInvoiceLine")
+ .insert([
+ {
+ ...purchaseInvoiceLine,
+ currencyCode: purchaseInvoiceLine.currencyCode ?? "USD",
+ },
+ ])
+ .select("id")
+ .single();
+}
diff --git a/apps/carbon/app/modules/invoicing/types.ts b/apps/carbon/app/modules/invoicing/types.ts
index dfd870e335..f36add4bd1 100644
--- a/apps/carbon/app/modules/invoicing/types.ts
+++ b/apps/carbon/app/modules/invoicing/types.ts
@@ -1,4 +1,7 @@
-import type { purchaseInvoiceStatusType } from "./invoicing.models";
+import type {
+ purchaseInvoiceLineType,
+ purchaseInvoiceStatusType,
+} from "./invoicing.models";
import type {
getPurchaseInvoiceLines,
getPurchaseInvoices,
@@ -12,4 +15,6 @@ export type PurchaseInvoiceLine = NonNullable<
Awaited<ReturnType<typeof getPurchaseInvoiceLines>>["data"]
>[number];
+export type PurchaseInvoiceLineType = (typeof purchaseInvoiceLineType)[number];
+
export type PurchaseInvoiceStatus = (typeof purchaseInvoiceStatusType)[number];
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm/PurchaseInvoiceLineForm.tsx b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm/PurchaseInvoiceLineForm.tsx
new file mode 100644
index 0000000000..0cdc08d106
--- /dev/null
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm/PurchaseInvoiceLineForm.tsx
@@ -0,0 +1,328 @@
+import {
+ Button,
+ Input as ChakraInput,
+ Drawer,
+ DrawerBody,
+ DrawerCloseButton,
+ DrawerContent,
+ DrawerFooter,
+ DrawerHeader,
+ DrawerOverlay,
+ FormControl,
+ FormLabel,
+ HStack,
+ NumberDecrementStepper,
+ NumberIncrementStepper,
+ NumberInput,
+ NumberInputField,
+ NumberInputStepper,
+ VStack,
+} from "@chakra-ui/react";
+import { useFetcher, useNavigate, useParams } from "@remix-run/react";
+import { useEffect, useMemo, useState } from "react";
+import { ValidatedForm } from "remix-validated-form";
+import {
+ Account,
+ Hidden,
+ Number,
+ Part,
+ Select,
+ SelectControlled,
+ Submit,
+} from "~/components/Form";
+import { usePermissions, useRouteData, useUser } from "~/hooks";
+import { useSupabase } from "~/lib/supabase";
+import type {
+ PurchaseInvoice,
+ PurchaseInvoiceLineType,
+} from "~/modules/invoicing";
+import {
+ purchaseInvoiceLineType,
+ purchaseInvoiceLineValidator,
+} from "~/modules/invoicing";
+import type { getShelvesList } from "~/modules/parts";
+import type { ListItem } from "~/types";
+import type { TypeOfValidator } from "~/types/validators";
+import { path } from "~/utils/path";
+
+type PurchaseInvoiceLineFormProps = {
+ initialValues: TypeOfValidator<typeof purchaseInvoiceLineValidator>;
+};
+
+const PurchaseInvoiceLineForm = ({
+ initialValues,
+}: PurchaseInvoiceLineFormProps) => {
+ const permissions = usePermissions();
+ const { supabase } = useSupabase();
+ const navigate = useNavigate();
+ const { defaults } = useUser();
+ const { invoiceId } = useParams();
+
+ if (!invoiceId) throw new Error("invoiceId not found");
+
+ const routeData = useRouteData<{
+ locations: ListItem[];
+ purchaseInvoice: PurchaseInvoice;
+ }>(path.to.purchaseInvoice(invoiceId));
+
+ const locations = routeData?.locations ?? [];
+ const locationOptions = locations.map((location) => ({
+ label: location.name,
+ value: location.id,
+ }));
+
+ const isEditable = ["Draft"].includes(
+ routeData?.purchaseInvoice?.status ?? ""
+ );
+
+ const [type, setType] = useState(initialValues.invoiceLineType);
+ const [locationId, setLocationId] = useState(defaults.locationId ?? "");
+ const [partData, setPartData] = useState<{
+ partId: string;
+ description: string;
+ unitPrice: string;
+ uom: string;
+ shelfId: string;
+ }>({
+ partId: initialValues.partId ?? "",
+ description: initialValues.description ?? "",
+ unitPrice: initialValues.unitPrice?.toString() ?? "0",
+ uom: initialValues.unitOfMeasureCode ?? "",
+ shelfId: initialValues.shelfId ?? "",
+ });
+
+ const shelfFetcher = useFetcher<Awaited<ReturnType<typeof getShelvesList>>>();
+
+ useEffect(() => {
+ if (locationId) {
+ shelfFetcher.load(path.to.api.shelves(locationId));
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [locationId]);
+
+ const shelfOptions = useMemo(
+ () =>
+ shelfFetcher.data?.data?.map((shelf) => ({
+ label: shelf.id,
+ value: shelf.id,
+ })) ?? [],
+ [shelfFetcher.data]
+ );
+
+ const isEditing = initialValues.id !== undefined;
+ const isDisabled = !isEditable
+ ? true
+ : isEditing
+ ? !permissions.can("update", "purchasing")
+ : !permissions.can("create", "purchasing");
+
+ const purchaseInvoiceLineTypeOptions = purchaseInvoiceLineType.map(
+ (type) => ({
+ label: type,
+ value: type,
+ })
+ );
+
+ const onClose = () => navigate(-1);
+
+ const onTypeChange = (type: PurchaseInvoiceLineType) => {
+ setType(type);
+ setPartData({
+ partId: "",
+ description: "",
+ unitPrice: "0",
+ uom: "EA",
+ shelfId: "",
+ });
+ };
+
+ const onPartChange = async (partId: string) => {
+ if (!supabase) return;
+ const [part, shelf, cost] = await Promise.all([
+ supabase
+ .from("part")
+ .select("name, unitOfMeasureCode")
+ .eq("id", partId)
+ .single(),
+ supabase
+ .from("partInventory")
+ .select("defaultShelfId")
+ .eq("partId", partId)
+ .eq("locationId", locationId)
+ .maybeSingle(),
+ supabase
+ .from("partCost")
+ .select("unitCost")
+ .eq("partId", partId)
+ .single(),
+ ]);
+
+ setPartData({
+ partId,
+ description: part.data?.name ?? "",
+ unitPrice: cost.data?.unitCost?.toString() ?? "0",
+ uom: part.data?.unitOfMeasureCode ?? "EA",
+ shelfId: shelf.data?.defaultShelfId ?? "",
+ });
+ };
+
+ const onLocationChange = async (
+ newLocationId: string | number | undefined
+ ) => {
+ if (!supabase) throw new Error("supabase is not defined");
+ if (typeof newLocationId !== "string")
+ throw new Error("locationId is not a string");
+
+ setLocationId(newLocationId);
+ if (!partData.partId) return;
+ const shelf = await supabase
+ .from("partInventory")
+ .select("defaultShelfId")
+ .eq("partId", partData.partId)
+ .eq("locationId", newLocationId)
+ .maybeSingle();
+
+ setPartData((d) => ({
+ ...d,
+ shelfId: shelf?.data?.defaultShelfId ?? "",
+ }));
+ };
+
+ return (
+ <Drawer onClose={onClose} isOpen={true} size="sm">
+ <ValidatedForm
+ defaultValues={initialValues}
+ validator={purchaseInvoiceLineValidator}
+ method="post"
+ action={
+ isEditing
+ ? path.to.purchaseInvoiceLine(invoiceId, initialValues.id!)
+ : path.to.newPurchaseInvoiceLine(invoiceId)
+ }
+ >
+ <DrawerOverlay />
+ <DrawerContent>
+ <DrawerCloseButton />
+ <DrawerHeader>
+ {isEditing ? "Edit" : "New"} Purchase Invoice Line
+ </DrawerHeader>
+ <DrawerBody pb={8}>
+ <Hidden name="id" />
+ <Hidden name="invoiceId" />
+ <Hidden name="description" value={partData.description} />
+ <VStack spacing={4} alignItems="start">
+ <Select
+ name="invoiceLineType"
+ label="Type"
+ options={purchaseInvoiceLineTypeOptions}
+ onChange={({ value }) => {
+ onTypeChange(value as PurchaseInvoiceLineType);
+ }}
+ />
+ {type === "Part" && (
+ <Part
+ name="partId"
+ label="Part"
+ partReplenishmentSystem="Buy"
+ onChange={({ value }) => {
+ onPartChange(value as string);
+ }}
+ />
+ )}
+
+ {type === "G/L Account" && (
+ <Account
+ name="accountNumber"
+ label="Account"
+ classes={["Expense", "Asset"]}
+ onChange={({ label }) => {
+ setPartData((d) => ({
+ ...d,
+ partId: "",
+ description: label,
+ uom: "EA",
+ shelfId: "",
+ }));
+ }}
+ />
+ )}
+ {type === "Fixed Asset" && (
+ // TODO: implement Fixed Asset
+ <Select name="assetId" label="Asset" options={[]} />
+ )}
+ <FormControl>
+ <FormLabel>Description</FormLabel>
+ <ChakraInput
+ value={partData.description}
+ onChange={(e) =>
+ setPartData((d) => ({ ...d, description: e.target.value }))
+ }
+ />
+ </FormControl>
+ {type !== "Comment" && (
+ <>
+ <Number name="quantity" label="Quantity" />
+ {/*
+ // TODO: implement this and replace the UoM in PartForm */}
+ {/* <UnitOfMeasure name="unitOfMeasureCode" label="Unit of Measure" value={uom} /> */}
+ <FormControl>
+ <FormLabel htmlFor="unitPrice">Unit Price</FormLabel>
+ <NumberInput
+ name="unitPrice"
+ value={partData.unitPrice}
+ onChange={(value) =>
+ setPartData((d) => ({
+ ...d,
+ unitPrice: value,
+ }))
+ }
+ >
+ <NumberInputField />
+ <NumberInputStepper>
+ <NumberIncrementStepper />
+ <NumberDecrementStepper />
+ </NumberInputStepper>
+ </NumberInput>
+ </FormControl>
+ {type === "Part" && (
+ <>
+ <SelectControlled
+ name="locationId"
+ label="Location"
+ options={locationOptions}
+ value={locationId}
+ onChange={onLocationChange}
+ />
+ <SelectControlled
+ name="shelfId"
+ label="Shelf"
+ options={shelfOptions}
+ value={partData.shelfId}
+ onChange={(newValue) =>
+ setPartData((d) => ({
+ ...d,
+ shelfId: newValue as string,
+ }))
+ }
+ />
+ </>
+ )}
+ </>
+ )}
+ </VStack>
+ </DrawerBody>
+ <DrawerFooter>
+ <HStack>
+ <Submit isDisabled={isDisabled}>Save</Submit>
+ <Button size="md" variant="ghost" onClick={onClose}>
+ Cancel
+ </Button>
+ </HStack>
+ </DrawerFooter>
+ </DrawerContent>
+ </ValidatedForm>
+ </Drawer>
+ );
+};
+
+export default PurchaseInvoiceLineForm;
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm/index.ts b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm/index.ts
new file mode 100644
index 0000000000..7306512f89
--- /dev/null
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/PurchaseInvoiceLineForm/index.ts
@@ -0,0 +1,3 @@
+import PurchaseInvoiceLineForm from "./PurchaseInvoiceLineForm";
+
+export default PurchaseInvoiceLineForm;
diff --git a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/index.ts b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/index.ts
index 2caa96de98..c37e4dbb1c 100644
--- a/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/index.ts
+++ b/apps/carbon/app/modules/invoicing/ui/PurchaseInvoice/index.ts
@@ -1,5 +1,6 @@
import PurchaseInvoiceForm from "./PurchaseInvoiceForm";
import PurchaseInvoiceHeader from "./PurchaseInvoiceHeader";
+import PurchaseInvoiceLineForm from "./PurchaseInvoiceLineForm";
import PurchaseInvoiceLines from "./PurchaseInvoiceLines";
import PurchaseInvoiceSidebar from "./PurchaseInvoiceSidebar";
import PurchaseInvoicingStatus from "./PurchaseInvoicingStatus";
@@ -8,6 +9,7 @@ import { usePurchaseInvoiceTotals } from "./usePurchaseInvoiceTotals";
export {
PurchaseInvoiceForm,
PurchaseInvoiceHeader,
+ PurchaseInvoiceLineForm,
PurchaseInvoiceLines,
PurchaseInvoiceSidebar,
PurchaseInvoicingStatus,
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm/PurchaseOrderLineForm.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm/PurchaseOrderLineForm.tsx
index 9b92ec28f3..4808fef5ae 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm/PurchaseOrderLineForm.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm/PurchaseOrderLineForm.tsx
@@ -282,25 +282,29 @@ const PurchaseOrderLineForm = ({
</NumberInputStepper>
</NumberInput>
</FormControl>
- <SelectControlled
- name="locationId"
- label="Location"
- options={locationOptions}
- value={locationId}
- onChange={onLocationChange}
- />
- <SelectControlled
- name="shelfId"
- label="Shelf"
- options={shelfOptions}
- value={partData.shelfId}
- onChange={(newValue) =>
- setPartData((d) => ({
- ...d,
- shelfId: newValue as string,
- }))
- }
- />
+ {type === "Part" && (
+ <>
+ <SelectControlled
+ name="locationId"
+ label="Location"
+ options={locationOptions}
+ value={locationId}
+ onChange={onLocationChange}
+ />
+ <SelectControlled
+ name="shelfId"
+ label="Shelf"
+ options={shelfOptions}
+ value={partData.shelfId}
+ onChange={(newValue) =>
+ setPartData((d) => ({
+ ...d,
+ shelfId: newValue as string,
+ }))
+ }
+ />
+ </>
+ )}
</>
)}
</VStack>
diff --git a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchasingStatus/PurchasingStatus.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchasingStatus/PurchasingStatus.tsx
index de7afc5b73..f34a806003 100644
--- a/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchasingStatus/PurchasingStatus.tsx
+++ b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchasingStatus/PurchasingStatus.tsx
@@ -9,7 +9,7 @@ const PurchasingStatus = ({ status }: PurchasingStatusProps) => {
switch (status) {
case "Draft":
case "To Review":
- return <Status color="gray">{status}</Status>;
+ return <Status color="yellow">{status}</Status>;
case "To Receive":
case "To Receive and Invoice":
case "To Invoice":
diff --git a/apps/carbon/app/routes/x+/purchase-invoice+/$invoiceId.details.$lineId.tsx b/apps/carbon/app/routes/x+/purchase-invoice+/$invoiceId.details.$lineId.tsx
new file mode 100644
index 0000000000..77502d5b20
--- /dev/null
+++ b/apps/carbon/app/routes/x+/purchase-invoice+/$invoiceId.details.$lineId.tsx
@@ -0,0 +1,112 @@
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
+import { json, redirect } from "@remix-run/node";
+import { useLoaderData } from "@remix-run/react";
+import { validationError } from "remix-validated-form";
+import type { PurchaseInvoiceLineType } from "~/modules/invoicing";
+import {
+ PurchaseInvoiceLineForm,
+ getPurchaseInvoiceLine,
+ purchaseInvoiceLineValidator,
+ upsertPurchaseInvoiceLine,
+} from "~/modules/invoicing";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import { assertIsPost, notFound } from "~/utils/http";
+import { path } from "~/utils/path";
+import { error } from "~/utils/result";
+
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ const { client } = await requirePermissions(request, {
+ view: "parts",
+ role: "employee",
+ });
+
+ const { lineId } = params;
+ if (!lineId) throw notFound("lineId not found");
+
+ const purchaseInvoiceLine = await getPurchaseInvoiceLine(client, lineId);
+
+ return json({
+ purchaseInvoiceLine: purchaseInvoiceLine?.data ?? null,
+ });
+}
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client, userId } = await requirePermissions(request, {
+ create: "invoicing",
+ });
+
+ const { invoiceId, lineId } = params;
+ if (!invoiceId) throw new Error("Could not find invoiceId");
+ if (!lineId) throw new Error("Could not find lineId");
+
+ const validation = await purchaseInvoiceLineValidator.validate(
+ await request.formData()
+ );
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const { id, ...data } = validation.data;
+
+ if (data.invoiceLineType === "Part") {
+ data.accountNumber = undefined;
+ data.assetId = undefined;
+ } else if (data.invoiceLineType === "G/L Account") {
+ data.assetId = undefined;
+ data.partId = undefined;
+ } else if (data.invoiceLineType === "Fixed Asset") {
+ data.accountNumber = undefined;
+ data.partId = undefined;
+ } else if (data.invoiceLineType === "Comment") {
+ data.accountNumber = undefined;
+ data.assetId = undefined;
+ data.partId = undefined;
+ }
+
+ const updatePurchaseInvoiceLine = await upsertPurchaseInvoiceLine(client, {
+ id: lineId,
+ ...data,
+ updatedBy: userId,
+ });
+
+ if (updatePurchaseInvoiceLine.error) {
+ return redirect(
+ path.to.purchaseInvoiceDetails(invoiceId),
+ await flash(
+ request,
+ error(
+ updatePurchaseInvoiceLine.error,
+ "Failed to update purchase invoice line"
+ )
+ )
+ );
+ }
+
+ return redirect(path.to.purchaseInvoiceDetails(invoiceId));
+}
+
+export default function EditPurchaseInvoiceLineRoute() {
+ const { purchaseInvoiceLine } = useLoaderData<typeof loader>();
+
+ const initialValues = {
+ id: purchaseInvoiceLine?.id ?? undefined,
+ invoiceId: purchaseInvoiceLine?.invoiceId ?? "",
+ invoiceLineType:
+ purchaseInvoiceLine?.invoiceLineType ??
+ ("Part" as PurchaseInvoiceLineType),
+ partId: purchaseInvoiceLine?.partId ?? "",
+ accountNumber: purchaseInvoiceLine?.accountNumber ?? "",
+ assetId: purchaseInvoiceLine?.assetId ?? "",
+ description: purchaseInvoiceLine?.description ?? "",
+ quantity: purchaseInvoiceLine?.quantity ?? 1,
+ unitPrice: purchaseInvoiceLine?.unitPrice ?? 0,
+ currencyCode: purchaseInvoiceLine?.currencyCode ?? "USD",
+ unitOfMeasureCode: purchaseInvoiceLine?.unitOfMeasureCode ?? "",
+ shelfId: purchaseInvoiceLine?.shelfId ?? "",
+ };
+
+ return <PurchaseInvoiceLineForm initialValues={initialValues} />;
+}
diff --git a/apps/carbon/app/routes/x+/purchase-invoice+/$invoiceId.details.delete.$lineId.tsx b/apps/carbon/app/routes/x+/purchase-invoice+/$invoiceId.details.delete.$lineId.tsx
new file mode 100644
index 0000000000..f406db9af5
--- /dev/null
+++ b/apps/carbon/app/routes/x+/purchase-invoice+/$invoiceId.details.delete.$lineId.tsx
@@ -0,0 +1,87 @@
+import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
+import { json, redirect } from "@remix-run/node";
+import { useLoaderData, useNavigate, useParams } from "@remix-run/react";
+import { ConfirmDelete } from "~/components/Modals";
+import {
+ deletePurchaseInvoiceLine,
+ getPurchaseInvoiceLine,
+} from "~/modules/invoicing";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import { notFound } from "~/utils/http";
+import { path } from "~/utils/path";
+import { error, success } from "~/utils/result";
+
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ const { client } = await requirePermissions(request, {
+ delete: "invoicing",
+ });
+ const { lineId, invoiceId } = params;
+ if (!lineId) throw notFound("lineId not found");
+ if (!invoiceId) throw notFound("invoiceId not found");
+
+ const purchaseInvoiceLine = await getPurchaseInvoiceLine(client, lineId);
+ if (purchaseInvoiceLine.error) {
+ return redirect(
+ path.to.purchaseInvoiceDetails(invoiceId),
+ await flash(
+ request,
+ error(purchaseInvoiceLine.error, "Failed to get purchase invoice line")
+ )
+ );
+ }
+
+ return json({ purchaseInvoiceLine: purchaseInvoiceLine.data });
+}
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ const { client } = await requirePermissions(request, {
+ delete: "invoicing",
+ });
+
+ const { lineId, invoiceId } = params;
+ if (!lineId) throw notFound("Could not find lineId");
+ if (!invoiceId) throw notFound("Could not find invoiceId");
+
+ const { error: deleteTypeError } = await deletePurchaseInvoiceLine(
+ client,
+ lineId
+ );
+ if (deleteTypeError) {
+ return redirect(
+ path.to.purchaseInvoiceDetails(invoiceId),
+ await flash(
+ request,
+ error(deleteTypeError, "Failed to delete purchase invoice line")
+ )
+ );
+ }
+
+ return redirect(
+ path.to.purchaseInvoiceDetails(invoiceId),
+ await flash(request, success("Successfully deleted purchase invoice line"))
+ );
+}
+
+export default function DeletePurchaseInvoiceLineRoute() {
+ const { lineId, invoiceId } = useParams();
+ const { purchaseInvoiceLine } = useLoaderData<typeof loader>();
+ const navigate = useNavigate();
+
+ if (!purchaseInvoiceLine) return null;
+ if (!lineId) throw notFound("Could not find lineId");
+ if (!invoiceId) throw notFound("Could not find invoiceId");
+
+ const onCancel = () => navigate(path.to.purchaseInvoiceDetails(invoiceId));
+
+ return (
+ <ConfirmDelete
+ action={path.to.deletePurchaseInvoiceLine(invoiceId, lineId)}
+ name="Purchase Invoice Line"
+ text={`Are you sure you want to delete the purchase invoice line for ${
+ purchaseInvoiceLine.quantity ?? 0
+ } ${purchaseInvoiceLine.description ?? ""}? This cannot be undone.`}
+ onCancel={onCancel}
+ />
+ );
+}
diff --git a/apps/carbon/app/routes/x+/purchase-invoice+/$invoiceId.details.new.tsx b/apps/carbon/app/routes/x+/purchase-invoice+/$invoiceId.details.new.tsx
new file mode 100644
index 0000000000..25f42d4132
--- /dev/null
+++ b/apps/carbon/app/routes/x+/purchase-invoice+/$invoiceId.details.new.tsx
@@ -0,0 +1,74 @@
+import type { ActionFunctionArgs } from "@remix-run/node";
+import { redirect } from "@remix-run/node";
+import { useParams } from "@remix-run/react";
+import { validationError } from "remix-validated-form";
+import type { PurchaseInvoiceLineType } from "~/modules/invoicing";
+import {
+ PurchaseInvoiceLineForm,
+ purchaseInvoiceLineValidator,
+ upsertPurchaseInvoiceLine,
+} from "~/modules/invoicing";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import { assertIsPost } from "~/utils/http";
+import { path } from "~/utils/path";
+import { error } from "~/utils/result";
+
+export async function action({ request, params }: ActionFunctionArgs) {
+ assertIsPost(request);
+ const { client, userId } = await requirePermissions(request, {
+ create: "invoicing",
+ });
+
+ const { invoiceId } = params;
+ if (!invoiceId) throw new Error("Could not find invoiceId");
+
+ const validation = await purchaseInvoiceLineValidator.validate(
+ await request.formData()
+ );
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const { id, ...data } = validation.data;
+
+ const createPurchaseInvoiceLine = await upsertPurchaseInvoiceLine(client, {
+ ...data,
+ createdBy: userId,
+ });
+
+ if (createPurchaseInvoiceLine.error) {
+ return redirect(
+ path.to.purchaseInvoiceDetails(invoiceId),
+ await flash(
+ request,
+ error(
+ createPurchaseInvoiceLine.error,
+ "Failed to create purchase invoice line."
+ )
+ )
+ );
+ }
+
+ return redirect(path.to.purchaseInvoiceDetails(invoiceId));
+}
+
+export default function NewPurchaseInvoiceLineRoute() {
+ const { invoiceId } = useParams();
+
+ if (!invoiceId) throw new Error("Could not find purchase invoice id");
+
+ const initialValues = {
+ invoiceId: invoiceId,
+ invoiceLineType: "Part" as PurchaseInvoiceLineType,
+ partId: "",
+ purchaseQuantity: 1,
+ unitPrice: 0,
+ setupPrice: 0,
+ unitOfMeasureCode: "",
+ shelfId: "",
+ };
+
+ return <PurchaseInvoiceLineForm initialValues={initialValues} />;
+}
diff --git a/apps/carbon/app/routes/x+/purchase-order+/$orderId.details.$lineId.tsx b/apps/carbon/app/routes/x+/purchase-order+/$orderId.details.$lineId.tsx
index e823872630..a069f80016 100644
--- a/apps/carbon/app/routes/x+/purchase-order+/$orderId.details.$lineId.tsx
+++ b/apps/carbon/app/routes/x+/purchase-order+/$orderId.details.$lineId.tsx
@@ -4,8 +4,8 @@ import { useLoaderData } from "@remix-run/react";
import { validationError } from "remix-validated-form";
import type { PurchaseOrderLineType } from "~/modules/purchasing";
import {
- getPurchaseOrderLine,
PurchaseOrderLineForm,
+ getPurchaseOrderLine,
purchaseOrderLineValidator,
upsertPurchaseOrderLine,
} from "~/modules/purchasing";
@@ -79,7 +79,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
request,
error(
updatePurchaseOrderLine.error,
- "Failed to update purchaseOrderLine."
+ "Failed to update purchase order line"
)
)
);
@@ -98,6 +98,8 @@ export default function EditPurchaseOrderLineRoute() {
purchaseOrderLine?.purchaseOrderLineType ??
("Part" as PurchaseOrderLineType),
partId: purchaseOrderLine?.partId ?? "",
+ accountNumber: purchaseOrderLine?.accountNumber ?? "",
+ assetId: purchaseOrderLine?.assetId ?? "",
description: purchaseOrderLine?.description ?? "",
purchaseQuantity: purchaseOrderLine?.purchaseQuantity ?? 1,
unitPrice: purchaseOrderLine?.unitPrice ?? 0,
diff --git a/apps/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.ts
index 8e90b99439..9c96e4c520 100644
--- a/apps/carbon/app/utils/path.ts
+++ b/apps/carbon/app/utils/path.ts
@@ -142,6 +142,10 @@ export const path = {
generatePath(`${x}/accounting/payment-terms/delete/${id}`),
deletePurchaseInvoice: (id: string) =>
generatePath(`${x}/purchase-invoice/delete/${id}`),
+ deletePurchaseInvoiceLine: (invoiceId: string, lineId: string) =>
+ generatePath(
+ `${x}/purchase-invoice/${invoiceId}/details/delete/${lineId}`
+ ),
deletePurchaseOrder: (id: string) =>
generatePath(`${x}/purchase-order/delete/${id}`),
deletePurchaseOrderLine: (orderId: string, lineId: string) =>
@@ -240,6 +244,8 @@ export const path = {
newPartner: `${x}/resources/partners/new`,
newPaymentTerm: `${x}/accounting/payment-terms/new`,
newPurchaseInvoice: `${x}/purchase-invoice/new`,
+ newPurchaseInvoiceLine: (id: string) =>
+ generatePath(`${x}/purchase-invoice/${id}/details/new`),
newPurchaseOrder: `${x}/purchase-order/new`,
newPurchaseOrderLine: (id: string) =>
generatePath(`${x}/purchase-order/${id}/details/new`),
@@ -291,6 +297,8 @@ export const path = {
generatePath(`${x}/purchase-invoice/${id}`),
purchaseInvoiceDetails: (id: string) =>
generatePath(`${x}/purchase-invoice/${id}/details`),
+ purchaseInvoiceLine: (invoiceId: string, id: string) =>
+ generatePath(`${x}/purchase-invoice/${invoiceId}/details/${id}`),
purchaseInvoicePost: (id: string) =>
generatePath(`${x}/purchase-invoice/${id}/post`),
purchaseInvoiceRoot: `${x}/purchase-invoice`,
diff --git a/package-lock.json b/package-lock.json
index a4e420efe8..accbc39a57 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,8 +1,8 @@
{
"name": "carbon",
- "description": "Carbon ERP is an open-source, high performance ERP",
"lockfileVersion": 3,
"requires": true,
+ "description": "Carbon ERP is an open-source, high performance ERP",
"packages": {
"": {
"license": "Apache-2.0",
@@ -26784,6 +26784,7 @@
"www": {
"version": "0.0.1",
"dependencies": {
+ "framer-motion": "^10.13.1",
"next": "^13.4.16",
"nextra": "^2.5.2",
"nextra-theme-docs": "^2.5.2",
diff --git a/packages/database/SCHEMA.md b/packages/database/SCHEMA.md
index cb3a8f7ff1..b09bacf914 100644
--- a/packages/database/SCHEMA.md
+++ b/packages/database/SCHEMA.md
@@ -6609,6 +6609,7 @@ CREATE TABLE "purchaseInvoiceLine" (
"purchaseOrderLineId" TEXT,
"partId" TEXT,
"locationId" TEXT,
+ "shelfId" TEXT,
"accountNumber" TEXT,
"assetId" TEXT,
"description" TEXT,
@@ -6617,6 +6618,7 @@ CREATE TABLE "purchaseInvoiceLine" (
"totalAmount" NUMERIC(10, 2) GENERATED ALWAYS AS ("quantity" * "unitPrice") STORED,
"currencyCode" TEXT NOT NULL,
"exchangeRate" NUMERIC(10, 4) NOT NULL DEFAULT 1,
+ "unitOfMeasureCode" TEXT,
"createdBy" TEXT NOT NULL,
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
"updatedBy" TEXT,
@@ -6628,9 +6630,11 @@ CREATE TABLE "purchaseInvoiceLine" (
CONSTRAINT "purchaseInvoiceLines_purchaseOrderLineId_fkey" FOREIGN KEY ("purchaseOrderLineId") REFERENCES "purchaseOrderLine" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,
CONSTRAINT "purchaseInvoiceLines_partId_fkey" FOREIGN KEY ("partId") REFERENCES "part" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,
CONSTRAINT "purchaseInvoiceLines_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,
+ CONSTRAINT "purchaseInvoiceLines_shelfId_fkey" FOREIGN KEY ("shelfId", "locationId") REFERENCES "shelf" ("id", "locationId") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT "purchaseInvoiceLines_accountNumber_fkey" FOREIGN KEY ("accountNumber") REFERENCES "account" ("number") ON UPDATE CASCADE ON DELETE RESTRICT,
-- CONSTRAINT "purchaseInvoiceLines_assetId_fkey" FOREIGN KEY ("assetId") REFERENCES "fixedAsset" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,
CONSTRAINT "purchaseInvoiceLines_currencyCode_fkey" FOREIGN KEY ("currencyCode") REFERENCES "currency" ("code") ON UPDATE CASCADE ON DELETE RESTRICT,
+ CONSTRAINT "purchaseInvoiceLines_unitOfMeasureCode_fkey" FOREIGN KEY ("unitOfMeasureCode") REFERENCES "unitOfMeasure" ("code") ON UPDATE CASCADE ON DELETE RESTRICT,
CONSTRAINT "purchaseInvoiceLines_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,
CONSTRAINT "purchaseInvoiceLines_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON UPDATE CASCADE ON DELETE RESTRICT
);
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 8f61c23a9d..9dcb42e187 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -4948,7 +4948,9 @@ export interface Database {
purchaseOrderId: string | null
purchaseOrderLineId: string | null
quantity: number
+ shelfId: string | null
totalAmount: number | null
+ unitOfMeasureCode: string | null
unitPrice: number
updatedAt: string | null
updatedBy: string | null
@@ -4969,7 +4971,9 @@ export interface Database {
purchaseOrderId?: string | null
purchaseOrderLineId?: string | null
quantity?: number
+ shelfId?: string | null
totalAmount?: number | null
+ unitOfMeasureCode?: string | null
unitPrice?: number
updatedAt?: string | null
updatedBy?: string | null
@@ -4990,7 +4994,9 @@ export interface Database {
purchaseOrderId?: string | null
purchaseOrderLineId?: string | null
quantity?: number
+ shelfId?: string | null
totalAmount?: number | null
+ unitOfMeasureCode?: string | null
unitPrice?: number
updatedAt?: string | null
updatedBy?: string | null
@@ -5092,6 +5098,18 @@ export interface Database {
referencedRelation: "purchaseOrderLine"
referencedColumns: ["id"]
},
+ {
+ foreignKeyName: "purchaseInvoiceLines_shelfId_fkey"
+ columns: ["shelfId", "locationId"]
+ referencedRelation: "shelf"
+ referencedColumns: ["id", "locationId"]
+ },
+ {
+ foreignKeyName: "purchaseInvoiceLines_unitOfMeasureCode_fkey"
+ columns: ["unitOfMeasureCode"]
+ referencedRelation: "unitOfMeasure"
+ referencedColumns: ["code"]
+ },
{
foreignKeyName: "purchaseInvoiceLines_updatedBy_fkey"
columns: ["updatedBy"]
diff --git a/packages/database/supabase/functions/create-purchase-invoice-from-purchase-order/index.ts b/packages/database/supabase/functions/create-purchase-invoice-from-purchase-order/index.ts
index 94311779cc..432dec4df1 100644
--- a/packages/database/supabase/functions/create-purchase-invoice-from-purchase-order/index.ts
+++ b/packages/database/supabase/functions/create-purchase-invoice-from-purchase-order/index.ts
@@ -115,6 +115,7 @@ serve(async (req: Request) => {
purchaseOrderLineId: line.id,
partId: line.partId,
locationId: line.locationId,
+ shelfId: line.shelfId,
accountNumber: line.accountNumber,
assetId: line.assetId,
description: line.description,
diff --git a/packages/database/supabase/migrations/20230924004608_accounts-payable.sql b/packages/database/supabase/migrations/20230924004608_accounts-payable.sql
index 0e3726f27a..3e9e0d2642 100644
--- a/packages/database/supabase/migrations/20230924004608_accounts-payable.sql
+++ b/packages/database/supabase/migrations/20230924004608_accounts-payable.sql
@@ -122,6 +122,7 @@ CREATE TABLE "purchaseInvoiceLine" (
"purchaseOrderLineId" TEXT,
"partId" TEXT,
"locationId" TEXT,
+ "shelfId" TEXT,
"accountNumber" TEXT,
"assetId" TEXT,
"description" TEXT,
@@ -130,6 +131,7 @@ CREATE TABLE "purchaseInvoiceLine" (
"totalAmount" NUMERIC(10, 2) GENERATED ALWAYS AS ("quantity" * "unitPrice") STORED,
"currencyCode" TEXT NOT NULL,
"exchangeRate" NUMERIC(10, 4) NOT NULL DEFAULT 1,
+ "unitOfMeasureCode" TEXT,
"createdBy" TEXT NOT NULL,
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
"updatedBy" TEXT,
@@ -141,9 +143,11 @@ CREATE TABLE "purchaseInvoiceLine" (
CONSTRAINT "purchaseInvoiceLines_purchaseOrderLineId_fkey" FOREIGN KEY ("purchaseOrderLineId") REFERENCES "purchaseOrderLine" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,
CONSTRAINT "purchaseInvoiceLines_partId_fkey" FOREIGN KEY ("partId") REFERENCES "part" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,
CONSTRAINT "purchaseInvoiceLines_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,
+ CONSTRAINT "purchaseInvoiceLines_shelfId_fkey" FOREIGN KEY ("shelfId", "locationId") REFERENCES "shelf" ("id", "locationId") ON DELETE SET NULL ON UPDATE CASCADE,
CONSTRAINT "purchaseInvoiceLines_accountNumber_fkey" FOREIGN KEY ("accountNumber") REFERENCES "account" ("number") ON UPDATE CASCADE ON DELETE RESTRICT,
-- CONSTRAINT "purchaseInvoiceLines_assetId_fkey" FOREIGN KEY ("assetId") REFERENCES "fixedAsset" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,
CONSTRAINT "purchaseInvoiceLines_currencyCode_fkey" FOREIGN KEY ("currencyCode") REFERENCES "currency" ("code") ON UPDATE CASCADE ON DELETE RESTRICT,
+ CONSTRAINT "purchaseInvoiceLines_unitOfMeasureCode_fkey" FOREIGN KEY ("unitOfMeasureCode") REFERENCES "unitOfMeasure" ("code") ON UPDATE CASCADE ON DELETE RESTRICT,
CONSTRAINT "purchaseInvoiceLines_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user" ("id") ON UPDATE CASCADE ON DELETE RESTRICT,
CONSTRAINT "purchaseInvoiceLines_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON UPDATE CASCADE ON DELETE RESTRICT
);
diff --git a/www/components/pages/Home.tsx b/www/components/pages/Home.tsx
index ab7257dd4d..50bdc0fde3 100644
--- a/www/components/pages/Home.tsx
+++ b/www/components/pages/Home.tsx
@@ -13,7 +13,7 @@ export default function Home() {
/>
</Head>
<div className="absolute inset-0 overflow-hidden">
- <div className="jumbo absolute -inset-[10px] opacity-50"></div>
+ {/* <div className="jumbo absolute -inset-[10px] opacity-50"></div> */}
</div>
<div className="relative px-4 py-16 mx-auto sm:pt-20 sm:pb-24 lg:max-w-7xl lg:pt-24">
<div className="flex flex-col justify-between text-center">
@@ -22,13 +22,13 @@ export default function Home() {
ERP for the builders
</h1>
<p className="mt-6 nx-text-xl font-medium leading-tight text-black/60 dark:text-white/60 sm:nx-text-2xl md:nx-text-3xl lg:nx-text-4xl">
- Carbon ERP is an open-source, high performance ERP
+ Carbon ERP is an open-source ERP starting point
</p>
</div>
<div className="flex fix-flex-col h-32 mt-4 md:mt-0 mb-6 md:mb-0 items-center justify-center gap-3 md:flex-row xl:flex-row">
<div className="rounded-md fix-width-auto xl:w-auto">
<a
- className="flex items-center justify-center w-full px-8 py-3 text-base font-medium text-black no-underline bg-white border border-transparent rounded-md dark:bg-black dark:text-white betterhover:dark:hover:bg-gray-800 betterhover:hover:bg-gray-100 md:py-3 md:text-lg md:px-10 md:leading-6"
+ 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"
href="/learn/introduction"
>
Learn
@@ -36,7 +36,7 @@ export default function Home() {
</div>
<div className="rounded-md fix-width-auto xl:w-auto">
<a
- className="flex items-center justify-center w-full px-8 py-3 text-base font-medium text-white no-underline bg-black border border-transparent rounded-md dark:bg-white 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"
+ 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"
href="/develop/getting-started"
>
Develop
diff --git a/www/package.json b/www/package.json
index f23011a65c..978cc84ece 100644
--- a/www/package.json
+++ b/www/package.json
@@ -10,6 +10,7 @@
"start": "next start "
},
"dependencies": {
+ "framer-motion": "^10.13.1",
"next": "^13.4.16",
"nextra": "^2.5.2",
"nextra-theme-docs": "^2.5.2",
diff --git a/www/pages/learn/introduction.mdx b/www/pages/learn/introduction.mdx
index fa54cc6aa2..2aa768f519 100644
--- a/www/pages/learn/introduction.mdx
+++ b/www/pages/learn/introduction.mdx
@@ -7,17 +7,17 @@ import { Features } from "../../components";
# Carbon ERP
+The major difference between Carbon and other open-source ERPs is the license. ERPs like [Odoo](https://www.odoo.com/) and [ERPNext](https://erpnext.com/) require that you open-source your code if you use their code. With Carbon, you can use the code as a starting point for your own ERP without having to open-source your code. This is known as a "permissive" license.
+
<Features />
Carbon ERP is a high permformance, [open-source](https://github.com/barbinbrad/carbon), single-tenant (incomplete) ERP. It allows customers, suppliers, and employees to share a common platform.
## Why Carbon ERP?
-We built Carbon ERP because we wanted a real solution to manufacturing scheduling. But in order to solve this problem, we needed to build a complete ERP (and more).
-
-Currently you shouldn't use Carbon ERP for your business. It is incomplete and not ready for the big time. However, it is currently a great learning tool for those who want to learn about business software. It is also a great opportunity for anyone who wants to make better business software with the [latest technologies](../develop/tech-stack).
+We built Carbon ERP because we wanted a real solution to manufacturing scheduling. But in order to solve scheduling, we needed to build routing, which required bill of materials, which required inventory, which required purchasing, and so on. So we built Carbon ERP.
-By the time it's ready for production, it will have stable support the following modules:
+Currently Carbon is missing big chunks of neccessary functionality. By the time it's ready for production, it will have stable support the following modules:
- [x] Accounting
- [x] Inventory
@@ -31,19 +31,3 @@ By the time it's ready for production, it will have stable support the following
- [x] Customer Accounts
We'll then be able to focus on the original goal of scheduling and planning.
-
-## What about other open-source ERPs?
-
-The major difference between Carbon and other open-source ERPs is the license. ERPs like [Odoo](https://www.odoo.com/) and [ERPNext](https://erpnext.com/) are licensed under the "copyleft" GPL-family of licenses where Carbon uses a "permissive" (Apache 2.0) license.
-
-The big difference between a permissive license and a copyleft license is in the obligation of the user when modifications have been made to the code.
-
-A permissive license may require that you make the original source code available to your users, but that does not necessarily apply to your modifications. So if, for example, I have written project X, and license it as Apache 2.0, and you add some features to it, and now a user wants to see the source code, then you can give them the original code to project X, but you are not required to provide the code for your privately developed features.
-
-Conversely, with a copyleft license, in the same scenario, you would be required to release the code for your privately developed feature as well to your customer. Moreover, they would then be able to freely distribute that source code as well, including your privately developed features. That is why the copyleft licenses are often defined as being viral or infectious, because they propagate to whatever code they come into contact with.
-
-So then, the question of boundaries comes into play. What if the software is on another system? For example, you write program Y, and it calls system X across the network. With the GPL version 2, the copy left license does not cross the network barrier. AGPL, however, removes this barrier, making the virality of project X extend to program Y.
-
-Copyleft is generally hostile to any proprietary use, and many companies won't touch it for any software that must be distributed to customers. Again, this aligns with some people's political and philosophical wishes, so they do not see a problem with this.
-
-In short, permissive versus copyleft is a fundamental difference in how freedom is defined. The permissive license gives you the freedom to use software however you see fit. The copyleft license tries to eliminate the possibility of proprietary control. It's really two different sides of freedom. Permissive is freedom of the individual from control of the many. Copyleft is freedom of the many from control of the one.
diff --git a/www/styles.css b/www/styles.css
index 8e8a1302dc..883f6a9bcd 100644
--- a/www/styles.css
+++ b/www/styles.css
@@ -92,70 +92,6 @@ code[data-language="sh"] {
font-size: 0.85em;
}
-@keyframes jumbo {
- from {
- background-position: 50% 50%, 50% 50%;
- }
- to {
- background-position: 350% 50%, 350% 50%;
- }
-}
-
-.jumbo {
- --stripes: repeating-linear-gradient(
- 100deg,
- #fff 0%,
- #fff 7%,
- transparent 10%,
- transparent 12%,
- #fff 16%
- );
- --stripesDark: repeating-linear-gradient(
- 100deg,
- #000 0%,
- #000 7%,
- transparent 10%,
- transparent 12%,
- #000 16%
- );
- --rainbow: repeating-linear-gradient(
- 100deg,
- #60a5fa 10%,
- #e879f9 15%,
- #60a5fa 20%,
- #5eead4 25%,
- #60a5fa 30%
- );
- background-image: var(--stripes), var(--rainbow);
- background-size: 300%, 200%;
- background-position: 50% 50%, 50% 50%;
-
- filter: blur(10px) invert(100%);
-
- mask-image: radial-gradient(ellipse at 100% 0%, black 40%, transparent 70%);
-
- pointer-events: none;
-}
-
-.jumbo::after {
- content: "";
- position: absolute;
- inset: 0;
- background-image: var(--stripes), var(--rainbow);
- background-size: 200%, 100%;
- animation: jumbo 60s linear infinite;
- background-attachment: fixed;
- mix-blend-mode: difference;
-}
-
-.dark .jumbo {
- background-image: var(--stripesDark), var(--rainbow);
- filter: blur(10px) opacity(50%) saturate(200%);
-}
-.dark .jumbo::after {
- background-image: var(--stripesDark), var(--rainbow);
-}
-
.light .nx-text-primary-600 {
--tw-text-opacity: 1;
color: hsl(
diff --git a/www/theme.config.js b/www/theme.config.js
index a01c92b7fe..6425056867 100644
--- a/www/theme.config.js
+++ b/www/theme.config.js
@@ -42,7 +42,6 @@ export default {
src={`/logo${isDark ? "-light" : "-dark"}.png`}
alt="Carbon Logo"
/>
- <span className="w-full font-bold pl-2 text-lg">Carbon ERP</span>
</>
);
},