Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
// SPDX-License-Identifier: AGPL-3.0-only
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { ValidatedForm } from "@carbon/form";
import {
Card,
CardContent,
CardFooter,
CardHeader,
CardTitle,
HStack
} from "@carbon/react";
import { Trans, useLingui } from "@lingui/react/macro";
import { useState } from "react";
import type { z } from "zod";
import {
Customer,
CustomerContact,
CustomerLocation,
CustomFormFields,
Hidden,
Submit
} from "~/components/Form";
import PaymentTerm from "~/components/Form/PaymentTerm";
import { usePermissions } from "~/hooks";
import { customerPaymentValidator } from "../../sales.models";
type CustomerPaymentFormProps = {
initialValues: z.infer<typeof customerPaymentValidator>;
};
const CustomerPaymentForm = ({ initialValues }: CustomerPaymentFormProps) => {
const { t } = useLingui();
const permissions = usePermissions();
const [customer, setCustomer] = useState<string | undefined>(
initialValues.invoiceCustomerId
);
const isDisabled = !permissions.can("update", "sales");
return (
<ValidatedForm
method="post"
validator={customerPaymentValidator}
defaultValues={initialValues}
>
<Card>
<CardHeader>
<CardTitle>
<Trans>Payment Terms</Trans>
</CardTitle>
</CardHeader>
<CardContent>
<Hidden name="customerId" />
<div className="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-4 w-full">
<Customer
name="invoiceCustomerId"
label={t`Invoice Customer`}
termId="invoice-customer"
onChange={(value) => setCustomer(value?.value as string)}
/>
<CustomerLocation
name="invoiceCustomerLocationId"
label={t`Invoice Location`}
customer={customer}
/>
<CustomerContact
name="invoiceCustomerContactId"
label={t`Invoice Contact`}
customer={customer}
/>
<PaymentTerm
name="paymentTermId"
label={t`Payment Term`}
termId="customer-payment-term"
/>
<CustomFormFields table="customerPayment" />
</div>
</CardContent>
<CardFooter className="max-md:[&>*]:flex-1 max-md:[&>div>*]:flex-1 max-md:[&_button]:h-11">
<HStack>
<Submit isDisabled={isDisabled}>
<Trans>Save</Trans>
</Submit>
</HStack>
</CardFooter>
</Card>
</ValidatedForm>
);
};
export default CustomerPaymentForm;