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.

refactor: use timestamp for exchangeRateUpdatedAt

Rob Carringtoned219f785473
diff --git a/apps/carbon/app/components/Form/ExchangeRate.tsx b/apps/carbon/app/components/Form/ExchangeRate.tsx
index 935473ca63..0a98f7b730 100644
--- a/apps/carbon/app/components/Form/ExchangeRate.tsx
+++ b/apps/carbon/app/components/Form/ExchangeRate.tsx
@@ -13,12 +13,12 @@ import { Input } from "~/components/Form";
interface ExchangeRateProps extends React.ComponentProps<typeof Input> {
onRefresh?: () => void;
- exchangeRateDate: string | undefined;
+ exchangeRateUpdatedAt: string | undefined;
}
const ExchangeRate: React.FC<ExchangeRateProps> = ({
onRefresh,
- exchangeRateDate,
+ exchangeRateUpdatedAt,
...props
}) => {
const { locale } = useLocale();
@@ -32,8 +32,8 @@ const ExchangeRate: React.FC<ExchangeRateProps> = ({
[locale]
);
- const formattedDate = exchangeRateDate
- ? formatter.format(new Date(exchangeRateDate))
+ const formattedDate = exchangeRateUpdatedAt
+ ? formatter.format(new Date(exchangeRateUpdatedAt))
: "";
return (
@@ -43,7 +43,7 @@ const ExchangeRate: React.FC<ExchangeRateProps> = ({
label={
<HStack spacing={1}>
<span>Exchange Rate</span>
- {exchangeRateDate && onRefresh && (
+ {exchangeRateUpdatedAt && onRefresh && (
<Tooltip>
<TooltipTrigger tabIndex={-1}>
<LuInfo className="w-4 h-4" />
diff --git a/apps/carbon/app/modules/sales/sales.models.ts b/apps/carbon/app/modules/sales/sales.models.ts
index f9b438b268..6898441dbf 100644
--- a/apps/carbon/app/modules/sales/sales.models.ts
+++ b/apps/carbon/app/modules/sales/sales.models.ts
@@ -118,7 +118,7 @@ export const quoteValidator = z.object({
expirationDate: zfd.text(z.string().optional()),
currencyCode: zfd.text(z.string().optional()),
exchangeRate: zfd.numeric(z.number().optional()),
- exchangeRateDate: zfd.text(z.string().optional()),
+ exchangeRateUpdatedAt: zfd.text(z.string().optional()),
});
export const quoteLineAdditionalChargesValidator = z.record(
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsx
index ad6a99ce5d..01a7520d9a 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsx
@@ -154,7 +154,12 @@ const QuoteForm = ({ initialValues }: QuoteFormProps) => {
name="currencyCode"
label="Currency"
value={customer.currencyCode}
- onChange={(newValue) => {
+ onChange={(
+ newValue: {
+ value: string | undefined;
+ label: string;
+ } | null
+ ) => {
if (newValue?.value) {
setCustomer((prevCustomer) => ({
...prevCustomer,
@@ -166,7 +171,7 @@ const QuoteForm = ({ initialValues }: QuoteFormProps) => {
{isEditing && (
<ExchangeRate
name="exchangeRate"
- exchangeRateDate={initialValues.exchangeRateDate}
+ exchangeRateUpdatedAt={initialValues.exchangeRateUpdatedAt}
isReadOnly
onRefresh={() => {
console.log("refresh");
diff --git a/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx b/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx
index 63dd52dba3..080e5f4104 100644
--- a/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx
+++ b/apps/carbon/app/routes/x+/quote+/$quoteId.details.tsx
@@ -104,7 +104,7 @@ export default function QuoteDetailsRoute() {
status: quoteData?.quote?.status ?? "Draft",
currencyCode: quoteData?.quote?.currencyCode ?? undefined,
exchangeRate: quoteData?.quote?.exchangeRate ?? undefined,
- exchangeRateDate: quoteData?.quote?.exchangeRateDate ?? "",
+ exchangeRateUpdatedAt: quoteData?.quote?.exchangeRateUpdatedAt ?? "",
};
const shipmentInitialValues = {
diff --git a/apps/carbon/app/routes/x+/quote+/new.tsx b/apps/carbon/app/routes/x+/quote+/new.tsx
index 48c2aab9fb..9e608ba771 100644
--- a/apps/carbon/app/routes/x+/quote+/new.tsx
+++ b/apps/carbon/app/routes/x+/quote+/new.tsx
@@ -79,7 +79,7 @@ export default function QuoteNewRoute() {
status: "Draft" as QuotationStatusType,
currencyCode: undefined,
exchangeRate: undefined,
- exchangeRateDate: "",
+ exchangeRateUpdatedAt: "",
};
return (
diff --git a/packages/database/src/swagger-docs-schema.ts b/packages/database/src/swagger-docs-schema.ts
index 84a1e7d36c..59a00b6f95 100644
--- a/packages/database/src/swagger-docs-schema.ts
+++ b/packages/database/src/swagger-docs-schema.ts
@@ -2440,7 +2440,7 @@ export default {
$ref: "#/parameters/rowFilter.quotes.exchangeRate",
},
{
- $ref: "#/parameters/rowFilter.quotes.exchangeRateDate",
+ $ref: "#/parameters/rowFilter.quotes.exchangeRateUpdatedAt",
},
{
$ref: "#/parameters/rowFilter.quotes.locationName",
@@ -8509,7 +8509,7 @@ export default {
$ref: "#/parameters/rowFilter.purchaseOrder.exchangeRate",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrder.exchangeRateDate",
+ $ref: "#/parameters/rowFilter.purchaseOrder.exchangeRateUpdatedAt",
},
{
$ref: "#/parameters/select",
@@ -8637,7 +8637,7 @@ export default {
$ref: "#/parameters/rowFilter.purchaseOrder.exchangeRate",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrder.exchangeRateDate",
+ $ref: "#/parameters/rowFilter.purchaseOrder.exchangeRateUpdatedAt",
},
{
$ref: "#/parameters/preferReturn",
@@ -8719,7 +8719,7 @@ export default {
$ref: "#/parameters/rowFilter.purchaseOrder.exchangeRate",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrder.exchangeRateDate",
+ $ref: "#/parameters/rowFilter.purchaseOrder.exchangeRateUpdatedAt",
},
{
$ref: "#/parameters/body.purchaseOrder",
@@ -14797,7 +14797,7 @@ export default {
$ref: "#/parameters/rowFilter.salesOrders.exchangeRate",
},
{
- $ref: "#/parameters/rowFilter.salesOrders.exchangeRateDate",
+ $ref: "#/parameters/rowFilter.salesOrders.exchangeRateUpdatedAt",
},
{
$ref: "#/parameters/rowFilter.salesOrders.shippingMethodName",
@@ -18259,7 +18259,7 @@ export default {
$ref: "#/parameters/rowFilter.quote.exchangeRate",
},
{
- $ref: "#/parameters/rowFilter.quote.exchangeRateDate",
+ $ref: "#/parameters/rowFilter.quote.exchangeRateUpdatedAt",
},
{
$ref: "#/parameters/select",
@@ -18393,7 +18393,7 @@ export default {
$ref: "#/parameters/rowFilter.quote.exchangeRate",
},
{
- $ref: "#/parameters/rowFilter.quote.exchangeRateDate",
+ $ref: "#/parameters/rowFilter.quote.exchangeRateUpdatedAt",
},
{
$ref: "#/parameters/preferReturn",
@@ -18481,7 +18481,7 @@ export default {
$ref: "#/parameters/rowFilter.quote.exchangeRate",
},
{
- $ref: "#/parameters/rowFilter.quote.exchangeRateDate",
+ $ref: "#/parameters/rowFilter.quote.exchangeRateUpdatedAt",
},
{
$ref: "#/parameters/body.quote",
@@ -26323,7 +26323,7 @@ export default {
$ref: "#/parameters/rowFilter.salesOrder.exchangeRate",
},
{
- $ref: "#/parameters/rowFilter.salesOrder.exchangeRateDate",
+ $ref: "#/parameters/rowFilter.salesOrder.exchangeRateUpdatedAt",
},
{
$ref: "#/parameters/select",
@@ -26451,7 +26451,7 @@ export default {
$ref: "#/parameters/rowFilter.salesOrder.exchangeRate",
},
{
- $ref: "#/parameters/rowFilter.salesOrder.exchangeRateDate",
+ $ref: "#/parameters/rowFilter.salesOrder.exchangeRateUpdatedAt",
},
{
$ref: "#/parameters/preferReturn",
@@ -26533,7 +26533,7 @@ export default {
$ref: "#/parameters/rowFilter.salesOrder.exchangeRate",
},
{
- $ref: "#/parameters/rowFilter.salesOrder.exchangeRateDate",
+ $ref: "#/parameters/rowFilter.salesOrder.exchangeRateUpdatedAt",
},
{
$ref: "#/parameters/body.salesOrder",
@@ -29887,7 +29887,7 @@ export default {
$ref: "#/parameters/rowFilter.purchaseOrders.exchangeRate",
},
{
- $ref: "#/parameters/rowFilter.purchaseOrders.exchangeRateDate",
+ $ref: "#/parameters/rowFilter.purchaseOrders.exchangeRateUpdatedAt",
},
{
$ref: "#/parameters/rowFilter.purchaseOrders.shippingMethodName",
@@ -37141,8 +37141,8 @@ export default {
format: "numeric",
type: "number",
},
- exchangeRateDate: {
- format: "date",
+ exchangeRateUpdatedAt: {
+ format: "timestamp with time zone",
type: "string",
},
locationName: {
@@ -40208,8 +40208,8 @@ export default {
format: "numeric",
type: "number",
},
- exchangeRateDate: {
- format: "date",
+ exchangeRateUpdatedAt: {
+ format: "timestamp with time zone",
type: "string",
},
},
@@ -43087,8 +43087,8 @@ export default {
format: "numeric",
type: "number",
},
- exchangeRateDate: {
- format: "date",
+ exchangeRateUpdatedAt: {
+ format: "timestamp with time zone",
type: "string",
},
shippingMethodName: {
@@ -44690,8 +44690,8 @@ export default {
format: "numeric",
type: "number",
},
- exchangeRateDate: {
- format: "date",
+ exchangeRateUpdatedAt: {
+ format: "timestamp with time zone",
type: "string",
},
},
@@ -48328,8 +48328,8 @@ export default {
format: "numeric",
type: "number",
},
- exchangeRateDate: {
- format: "date",
+ exchangeRateUpdatedAt: {
+ format: "timestamp with time zone",
type: "string",
},
},
@@ -49907,8 +49907,8 @@ export default {
format: "numeric",
type: "number",
},
- exchangeRateDate: {
- format: "date",
+ exchangeRateUpdatedAt: {
+ format: "timestamp with time zone",
type: "string",
},
shippingMethodName: {
@@ -53145,10 +53145,10 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.quotes.exchangeRateDate": {
- name: "exchangeRateDate",
+ "rowFilter.quotes.exchangeRateUpdatedAt": {
+ name: "exchangeRateUpdatedAt",
required: false,
- format: "date",
+ format: "timestamp with time zone",
in: "query",
type: "string",
},
@@ -57008,10 +57008,10 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.purchaseOrder.exchangeRateDate": {
- name: "exchangeRateDate",
+ "rowFilter.purchaseOrder.exchangeRateUpdatedAt": {
+ name: "exchangeRateUpdatedAt",
required: false,
- format: "date",
+ format: "timestamp with time zone",
in: "query",
type: "string",
},
@@ -60879,10 +60879,10 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.salesOrders.exchangeRateDate": {
- name: "exchangeRateDate",
+ "rowFilter.salesOrders.exchangeRateUpdatedAt": {
+ name: "exchangeRateUpdatedAt",
required: false,
- format: "date",
+ format: "timestamp with time zone",
in: "query",
type: "string",
},
@@ -62898,10 +62898,10 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.quote.exchangeRateDate": {
- name: "exchangeRateDate",
+ "rowFilter.quote.exchangeRateUpdatedAt": {
+ name: "exchangeRateUpdatedAt",
required: false,
- format: "date",
+ format: "timestamp with time zone",
in: "query",
type: "string",
},
@@ -67688,10 +67688,10 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.salesOrder.exchangeRateDate": {
- name: "exchangeRateDate",
+ "rowFilter.salesOrder.exchangeRateUpdatedAt": {
+ name: "exchangeRateUpdatedAt",
required: false,
- format: "date",
+ format: "timestamp with time zone",
in: "query",
type: "string",
},
@@ -69804,10 +69804,10 @@ export default {
in: "query",
type: "string",
},
- "rowFilter.purchaseOrders.exchangeRateDate": {
- name: "exchangeRateDate",
+ "rowFilter.purchaseOrders.exchangeRateUpdatedAt": {
+ name: "exchangeRateUpdatedAt",
required: false,
- format: "date",
+ format: "timestamp with time zone",
in: "query",
type: "string",
},
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index f4260cac51..e70dc4f4ac 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -12688,7 +12688,7 @@ export type Database = {
currencyCode: string | null
customFields: Json | null
exchangeRate: number | null
- exchangeRateDate: string | null
+ exchangeRateUpdatedAt: string | null
id: string
notes: string | null
orderDate: string
@@ -12713,7 +12713,7 @@ export type Database = {
currencyCode?: string | null
customFields?: Json | null
exchangeRate?: number | null
- exchangeRateDate?: string | null
+ exchangeRateUpdatedAt?: string | null
id?: string
notes?: string | null
orderDate?: string
@@ -12738,7 +12738,7 @@ export type Database = {
currencyCode?: string | null
customFields?: Json | null
exchangeRate?: number | null
- exchangeRateDate?: string | null
+ exchangeRateUpdatedAt?: string | null
id?: string
notes?: string | null
orderDate?: string
@@ -13942,7 +13942,7 @@ export type Database = {
dueDate: string | null
estimatorId: string | null
exchangeRate: number | null
- exchangeRateDate: string | null
+ exchangeRateUpdatedAt: string | null
expirationDate: string | null
externalNotes: Json | null
id: string
@@ -13969,7 +13969,7 @@ export type Database = {
dueDate?: string | null
estimatorId?: string | null
exchangeRate?: number | null
- exchangeRateDate?: string | null
+ exchangeRateUpdatedAt?: string | null
expirationDate?: string | null
externalNotes?: Json | null
id?: string
@@ -13996,7 +13996,7 @@ export type Database = {
dueDate?: string | null
estimatorId?: string | null
exchangeRate?: number | null
- exchangeRateDate?: string | null
+ exchangeRateUpdatedAt?: string | null
expirationDate?: string | null
externalNotes?: Json | null
id?: string
@@ -16209,7 +16209,7 @@ export type Database = {
customerReference: string | null
customFields: Json | null
exchangeRate: number | null
- exchangeRateDate: string | null
+ exchangeRateUpdatedAt: string | null
id: string
locationId: string | null
notes: string | null
@@ -16234,7 +16234,7 @@ export type Database = {
customerReference?: string | null
customFields?: Json | null
exchangeRate?: number | null
- exchangeRateDate?: string | null
+ exchangeRateUpdatedAt?: string | null
id?: string
locationId?: string | null
notes?: string | null
@@ -16259,7 +16259,7 @@ export type Database = {
customerReference?: string | null
customFields?: Json | null
exchangeRate?: number | null
- exchangeRateDate?: string | null
+ exchangeRateUpdatedAt?: string | null
id?: string
locationId?: string | null
notes?: string | null
@@ -25527,7 +25527,7 @@ export type Database = {
customFields: Json | null
dropShipment: boolean | null
exchangeRate: number | null
- exchangeRateDate: string | null
+ exchangeRateUpdatedAt: string | null
favorite: boolean | null
id: string | null
locationId: string | null
@@ -26501,7 +26501,7 @@ export type Database = {
dueDate: string | null
estimatorId: string | null
exchangeRate: number | null
- exchangeRateDate: string | null
+ exchangeRateUpdatedAt: string | null
expirationDate: string | null
externalNotes: Json | null
favorite: boolean | null
@@ -27295,7 +27295,7 @@ export type Database = {
customFields: Json | null
dropShipment: boolean | null
exchangeRate: number | null
- exchangeRateDate: string | null
+ exchangeRateUpdatedAt: string | null
favorite: boolean | null
id: string | null
locationId: string | null
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index f4260cac51..e70dc4f4ac 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -12688,7 +12688,7 @@ export type Database = {
currencyCode: string | null
customFields: Json | null
exchangeRate: number | null
- exchangeRateDate: string | null
+ exchangeRateUpdatedAt: string | null
id: string
notes: string | null
orderDate: string
@@ -12713,7 +12713,7 @@ export type Database = {
currencyCode?: string | null
customFields?: Json | null
exchangeRate?: number | null
- exchangeRateDate?: string | null
+ exchangeRateUpdatedAt?: string | null
id?: string
notes?: string | null
orderDate?: string
@@ -12738,7 +12738,7 @@ export type Database = {
currencyCode?: string | null
customFields?: Json | null
exchangeRate?: number | null
- exchangeRateDate?: string | null
+ exchangeRateUpdatedAt?: string | null
id?: string
notes?: string | null
orderDate?: string
@@ -13942,7 +13942,7 @@ export type Database = {
dueDate: string | null
estimatorId: string | null
exchangeRate: number | null
- exchangeRateDate: string | null
+ exchangeRateUpdatedAt: string | null
expirationDate: string | null
externalNotes: Json | null
id: string
@@ -13969,7 +13969,7 @@ export type Database = {
dueDate?: string | null
estimatorId?: string | null
exchangeRate?: number | null
- exchangeRateDate?: string | null
+ exchangeRateUpdatedAt?: string | null
expirationDate?: string | null
externalNotes?: Json | null
id?: string
@@ -13996,7 +13996,7 @@ export type Database = {
dueDate?: string | null
estimatorId?: string | null
exchangeRate?: number | null
- exchangeRateDate?: string | null
+ exchangeRateUpdatedAt?: string | null
expirationDate?: string | null
externalNotes?: Json | null
id?: string
@@ -16209,7 +16209,7 @@ export type Database = {
customerReference: string | null
customFields: Json | null
exchangeRate: number | null
- exchangeRateDate: string | null
+ exchangeRateUpdatedAt: string | null
id: string
locationId: string | null
notes: string | null
@@ -16234,7 +16234,7 @@ export type Database = {
customerReference?: string | null
customFields?: Json | null
exchangeRate?: number | null
- exchangeRateDate?: string | null
+ exchangeRateUpdatedAt?: string | null
id?: string
locationId?: string | null
notes?: string | null
@@ -16259,7 +16259,7 @@ export type Database = {
customerReference?: string | null
customFields?: Json | null
exchangeRate?: number | null
- exchangeRateDate?: string | null
+ exchangeRateUpdatedAt?: string | null
id?: string
locationId?: string | null
notes?: string | null
@@ -25527,7 +25527,7 @@ export type Database = {
customFields: Json | null
dropShipment: boolean | null
exchangeRate: number | null
- exchangeRateDate: string | null
+ exchangeRateUpdatedAt: string | null
favorite: boolean | null
id: string | null
locationId: string | null
@@ -26501,7 +26501,7 @@ export type Database = {
dueDate: string | null
estimatorId: string | null
exchangeRate: number | null
- exchangeRateDate: string | null
+ exchangeRateUpdatedAt: string | null
expirationDate: string | null
externalNotes: Json | null
favorite: boolean | null
@@ -27295,7 +27295,7 @@ export type Database = {
customFields: Json | null
dropShipment: boolean | null
exchangeRate: number | null
- exchangeRateDate: string | null
+ exchangeRateUpdatedAt: string | null
favorite: boolean | null
id: string | null
locationId: string | null
diff --git a/packages/database/supabase/migrations/20241010193506_quote-order-presentation-currency.sql b/packages/database/supabase/migrations/20241010193506_quote-order-presentation-currency.sql
index edc47f3140..d4a46fbd84 100644
--- a/packages/database/supabase/migrations/20241010193506_quote-order-presentation-currency.sql
+++ b/packages/database/supabase/migrations/20241010193506_quote-order-presentation-currency.sql
@@ -1,7 +1,7 @@
-- Quote currency
ALTER TABLE "quote" ADD COLUMN "currencyCode" TEXT;
ALTER TABLE "quote" ADD COLUMN "exchangeRate" NUMERIC(10,4);
-ALTER TABLE "quote" ADD COLUMN "exchangeRateDate" DATE;
+ALTER TABLE "quote" ADD COLUMN "exchangeRateUpdatedAt" TIMESTAMP WITH TIME ZONE;
ALTER TABLE "quote" ADD CONSTRAINT "quote_currencyCode_fkey"
FOREIGN KEY ("currencyCode") REFERENCES "currencyCode"("code")
ON DELETE SET NULL ON UPDATE CASCADE;
@@ -33,7 +33,7 @@ CREATE OR REPLACE VIEW "quotes" WITH(SECURITY_INVOKER=true) AS
-- Sales Order currency
ALTER TABLE "salesOrder" ALTER COLUMN "currencyCode" DROP DEFAULT;
ALTER TABLE "salesOrder" ADD COLUMN "exchangeRate" NUMERIC(10,4);
-ALTER TABLE "salesOrder" ADD COLUMN "exchangeRateDate" DATE;
+ALTER TABLE "salesOrder" ADD COLUMN "exchangeRateUpdatedAt" TIMESTAMP WITH TIME ZONE;
ALTER TABLE "salesOrder" DROP CONSTRAINT "salesOrder_currencyCode_fkey";
ALTER TABLE "salesOrder" ADD CONSTRAINT "salesOrder_currencyCode_fkey"
FOREIGN KEY ("currencyCode") REFERENCES "currencyCode"("code")
@@ -73,7 +73,7 @@ CREATE OR REPLACE VIEW "salesOrders" WITH(SECURITY_INVOKER=true) AS
-- Purchase Order currency
ALTER TABLE "purchaseOrder" ADD COLUMN "currencyCode" TEXT;
ALTER TABLE "purchaseOrder" ADD COLUMN "exchangeRate" NUMERIC(10,4);
-ALTER TABLE "purchaseOrder" ADD COLUMN "exchangeRateDate" DATE;
+ALTER TABLE "purchaseOrder" ADD COLUMN "exchangeRateUpdatedAt" TIMESTAMP WITH TIME ZONE;
ALTER TABLE "purchaseOrder" ADD CONSTRAINT "purchaseOrder_currencyCode_fkey"
FOREIGN KEY ("currencyCode") REFERENCES "currencyCode"("code")
ON DELETE SET NULL ON UPDATE CASCADE;