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.

Posting groups (#37)

Brad Barbin1d5df742c6ce
diff --git a/SCHEMA.md b/SCHEMA.md
index 5826fa6bf6..d4eb8820a1 100644
--- a/SCHEMA.md
+++ b/SCHEMA.md
@@ -285,9 +285,6 @@ CREATE TABLE "user" (
CONSTRAINT "user_pkey" PRIMARY KEY ("id")
);
-INSERT INTO "user" ("id", "email", "firstName", "lastName")
-VALUES ('system', '[email protected]', 'System', 'Operation');
-
CREATE UNIQUE INDEX "index_user_email_key" ON "user"("email");
CREATE INDEX "index_user_fullName" ON "user"("fullName");
@@ -515,16 +512,6 @@ CREATE TABLE "attributeDataType" (
)
);
-INSERT INTO "attributeDataType" ("label", "isBoolean", "isDate", "isList", "isNumeric", "isText", "isUser")
-VALUES
- ('Yes/No', true, false, false, false, false, false),
- ('Date', false, true, false, false, false, false),
- ('List', false, false, true, false, false, false),
- ('Numeric', false, false, false, true, false, false),
- ('Text', false, false, false, false, true, false),
- ('User', false, false, false, false, false, true);
-
-
-- ALTER TABLE "attributeDataType" ENABLE ROW LEVEL SECURITY;
CREATE TABLE "userAttribute" (
@@ -716,21 +703,25 @@ CREATE TABLE "supplierStatus" (
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
"updatedAt" TIMESTAMP WITH TIME ZONE,
- CONSTRAINT "supplierStatus_pkey" PRIMARY KEY ("id")
+ CONSTRAINT "supplierStatus_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "supplierStatus_name_unique" UNIQUE ("name")
);
-INSERT INTO "supplierStatus" ("name") VALUES ('Active'), ('Inactive'), ('Pending'), ('Rejected');
-
CREATE TABLE "supplierType" (
"id" TEXT NOT NULL DEFAULT uuid_generate_v4(),
"name" TEXT NOT NULL,
"color" TEXT DEFAULT '#000000',
"protected" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ "createdBy" TEXT NOT NULL,
+ "updatedBy" TEXT,
"updatedAt" TIMESTAMP WITH TIME ZONE,
CONSTRAINT "supplierType_pkey" PRIMARY KEY ("id"),
- CONSTRAINT "supplierType_colorCheck" CHECK ("color" is null or "color" ~* '^#[a-f0-9]{6}$')
+ CONSTRAINT "supplierType_name_unique" UNIQUE ("name"),
+ CONSTRAINT "supplierType_colorCheck" CHECK ("color" is null or "color" ~* '^#[a-f0-9]{6}$'),
+ CONSTRAINT "supplierType_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON UPDATE CASCADE ON DELETE RESTRICT,
+ CONSTRAINT "supplierType_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON UPDATE CASCADE ON DELETE SET NULL
);
CREATE TABLE "supplier" (
@@ -798,21 +789,25 @@ CREATE TABLE "customerStatus" (
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
"updatedAt" TIMESTAMP WITH TIME ZONE,
- CONSTRAINT "customerStatus_pkey" PRIMARY KEY ("id")
+ CONSTRAINT "customerStatus_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "customerStatus_name_unique" UNIQUE ("name")
);
-INSERT INTO "customerStatus" ("name") VALUES ('Active'), ('Inactive'), ('Prospect'), ('Lead'), ('On Hold'), ('Cancelled'), ('Archived');
-
CREATE TABLE "customerType" (
"id" TEXT NOT NULL DEFAULT uuid_generate_v4(),
"name" TEXT NOT NULL,
"color" TEXT DEFAULT '#000000',
"protected" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ "createdBy" TEXT NOT NULL,
+ "updatedBy" TEXT,
"updatedAt" TIMESTAMP WITH TIME ZONE,
CONSTRAINT "customerType_pkey" PRIMARY KEY ("id"),
- CONSTRAINT "customerType_colorCheck" CHECK ("color" is null or "color" ~* '^#[a-f0-9]{6}$')
+ CONSTRAINT "customerType_name_unique" UNIQUE ("name"),
+ CONSTRAINT "customerType_colorCheck" CHECK ("color" is null or "color" ~* '^#[a-f0-9]{6}$'),
+ CONSTRAINT "customerType_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON UPDATE CASCADE ON DELETE RESTRICT,
+ CONSTRAINT "customerType_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON UPDATE CASCADE ON DELETE SET NULL
);
CREATE TABLE "customer" (
@@ -2954,9 +2949,6 @@ CREATE TABLE "currency" (
CONSTRAINT "currency_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
-INSERT INTO "currency" ("name", "code", "symbol", "exchangeRate", "isBaseCurrency", "createdBy")
-VALUES ('US Dollar', 'USD', '$', 1.0000, true, 'system');
-
CREATE INDEX "currency_code_index" ON "currency" ("code");
ALTER TABLE "currency" ENABLE ROW LEVEL SECURITY;
@@ -3044,27 +3036,6 @@ CREATE TABLE "accountCategory" (
CONSTRAINT "accountCategory_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
-INSERT INTO "accountCategory" ("category", "incomeBalance", "normalBalance", "createdBy")
-VALUES
- ('Bank', 'Balance Sheet', 'Credit', 'system'),
- ('Accounts Receivable', 'Balance Sheet', 'Credit', 'system'),
- ('Inventory', 'Balance Sheet', 'Debit', 'system'),
- ('Other Current Asset', 'Balance Sheet', 'Debit', 'system'),
- ('Fixed Asset', 'Balance Sheet', 'Debit', 'system'),
- ('Accumulated Depreciation', 'Balance Sheet', 'Credit', 'system'),
- ('Other Asset', 'Balance Sheet', 'Debit', 'system'),
- ('Accounts Payable', 'Balance Sheet', 'Debit', 'system'),
- ('Other Current Liability', 'Balance Sheet', 'Debit', 'system'),
- ('Long Term Liability', 'Balance Sheet', 'Debit', 'system'),
- ('Equity - No Close', 'Balance Sheet', 'Credit', 'system'),
- ('Equity - Close', 'Balance Sheet', 'Credit', 'system'),
- ('Retained Earnings', 'Balance Sheet', 'Credit', 'system'),
- ('Income', 'Income Statement', 'Credit', 'system'),
- ('Cost of Goods Sold', 'Income Statement', 'Debit', 'system'),
- ('Expense', 'Income Statement', 'Debit', 'system'),
- ('Other Income', 'Income Statement', 'Credit', 'system'),
- ('Other Expense', 'Income Statement', 'Debit', 'system');
-
ALTER TABLE "accountCategory" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with accounting_view can view account categories" ON "accountCategory"
@@ -3267,13 +3238,6 @@ CREATE TABLE "partGroup" (
"id" TEXT NOT NULL DEFAULT xid(),
"name" TEXT NOT NULL,
"description" TEXT,
- "salesAccountId" TEXT,
- "discountAccountId" TEXT,
- "inventoryAccountId" TEXT,
- "costOfGoodsSoldLaborAccountId" TEXT,
- "costOfGoodsSoldMaterialAccountId" TEXT,
- "costOfGoodsSoldOverheadAccountId" TEXT,
- "costOfGoodsSoldSubcontractorAccountId" TEXT,
"active" BOOLEAN NOT NULL DEFAULT true,
"createdBy" TEXT NOT NULL,
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
@@ -3282,13 +3246,6 @@ CREATE TABLE "partGroup" (
CONSTRAINT "partGroup_pkey" PRIMARY KEY ("id"),
CONSTRAINT "partGroup_name_key" UNIQUE ("name"),
- CONSTRAINT "partGroup_salesAccountId_fkey" FOREIGN KEY ("salesAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_discountAccountId_fkey" FOREIGN KEY ("discountAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_inventoryAccountId_fkey" FOREIGN KEY ("inventoryAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_costOfGoodsSoldLaborAccountId_fkey" FOREIGN KEY ("costOfGoodsSoldLaborAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_costOfGoodsSoldMaterialAccountId_fkey" FOREIGN KEY ("costOfGoodsSoldMaterialAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_costOfGoodsSoldOverheadAccountId_fkey" FOREIGN KEY ("costOfGoodsSoldOverheadAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_costOfGoodsSoldSubcontractorAccountId_fkey" FOREIGN KEY ("costOfGoodsSoldSubcontractorAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "partGroup_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
CONSTRAINT "partGroup_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
@@ -3375,11 +3332,6 @@ CREATE TABLE "unitOfMeasure" (
CREATE INDEX "unitOfMeasure_code_index" ON "unitOfMeasure"("code");
-INSERT INTO "unitOfMeasure" ("code", "name", "createdBy")
-VALUES
-( 'EA', 'Each', 'system'),
-( 'PCS', 'Pieces', 'system');
-
ALTER TABLE "unitOfMeasure" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Authenticated users can view units of measure" ON "unitOfMeasure"
@@ -3529,9 +3481,6 @@ CREATE TABLE "partCost" (
"costingMethod" "partCostingMethod" NOT NULL,
"standardCost" NUMERIC(15,5) NOT NULL DEFAULT 0,
"unitCost" NUMERIC(15,5) NOT NULL DEFAULT 0,
- "salesAccountId" TEXT,
- "discountAccountId" TEXT,
- "inventoryAccountId" TEXT,
"costIsAdjusted" BOOLEAN NOT NULL DEFAULT false,
"createdBy" TEXT NOT NULL,
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
@@ -3539,9 +3488,6 @@ CREATE TABLE "partCost" (
"updatedAt" TIMESTAMP WITH TIME ZONE,
CONSTRAINT "partCost_partId_fkey" FOREIGN KEY ("partId") REFERENCES "part"("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_salesAccountId_fkey" FOREIGN KEY ("salesAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_discountAccountId_fkey" FOREIGN KEY ("discountAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_inventoryAccountId_fkey" FOREIGN KEY ("inventoryAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "partGroup_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
CONSTRAINT "partGroup_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
@@ -3950,7 +3896,7 @@ CREATE TABLE "partPlanning" (
CREATE INDEX "partPlanning_partId_locationId_index" ON "partPlanning" ("partId", "locationId");
ALTER TABLE "partPlanning" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Employees with part_view can view part planning" ON "partPlanning"
+CREATE POLICY "Employees with parts_view can view part planning" ON "partPlanning"
FOR SELECT
USING (
coalesce(get_my_claim('parts_view')::boolean,false)
@@ -3958,7 +3904,7 @@ CREATE POLICY "Employees with part_view can view part planning" ON "partPlanning
);
-- these are records are created lazily when a user attempts to view them
-CREATE POLICY "Employees with part_view can insert part planning" ON "partPlanning"
+CREATE POLICY "Employees with parts_view can insert part planning" ON "partPlanning"
FOR INSERT
WITH CHECK (
coalesce(get_my_claim('parts_view')::boolean,false)
@@ -4328,18 +4274,6 @@ CREATE TABLE "paymentTerm" (
CONSTRAINT "paymentTerm_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE CASCADE
);
-INSERT INTO "paymentTerm" ("name", "daysDue", "calculationMethod", "daysDiscount", "discountPercentage", "createdBy")
-VALUES
- ('Net 15', 15, 'Net', 0, 0, 'system'),
- ('Net 30', 30, 'Net', 0, 0, 'system'),
- ('Net 50', 50, 'Net', 0, 0, 'system'),
- ('Net 60', 60, 'Net', 0, 0, 'system'),
- ('Net 90', 90, 'Net', 0, 0, 'system'),
- ('1% 10 Net 30', 30, 'Net', 10, 1, 'system'),
- ('2% 10 Net 30', 30, 'Net', 10, 2, 'system'),
- ('Due on Receipt', 0, 'Net', 0, 0, 'system'),
- ('Net EOM 10', 10, 'End of Month', 0, 0, 'system');
-
ALTER TABLE "paymentTerm" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Certain employees can view payment terms" ON "paymentTerm"
@@ -4769,9 +4703,6 @@ CREATE TABLE "sequence" (
CONSTRAINT "sequence_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-INSERT INTO "sequence" ("table", "name", "prefix", "suffix", "next", "size", "step")
-VALUES ('purchaseOrder', 'Purchase Order', 'PO', NULL, 0, 6, 1);
-
```
@@ -5516,8 +5447,36 @@ CREATE INDEX "receipt_locationId_idx" ON "receipt" ("locationId");
CREATE INDEX "receipt_sourceDocumentId_idx" ON "receipt" ("sourceDocumentId");
CREATE INDEX "receipt_supplierId_idx" ON "receipt" ("supplierId");
-INSERT INTO "sequence" ("table", "name", "prefix", "suffix", "next", "size", "step")
-VALUES ('receipt', 'Receipt', 'RE', NULL, 0, 6, 1);
+ALTER TABLE "receipt" ENABLE ROW LEVEL SECURITY;
+
+CREATE POLICY "Employees with inventory_view can view receipts" ON "receipt"
+ FOR SELECT
+ USING (
+ coalesce(get_my_claim('inventory_view')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+
+CREATE POLICY "Employees with inventory_create can insert receipts" ON "receipt"
+ FOR INSERT
+ WITH CHECK (
+ coalesce(get_my_claim('inventory_create')::boolean,false)
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+);
+
+CREATE POLICY "Employees with inventory_update can update receipts" ON "receipt"
+ FOR UPDATE
+ USING (
+ coalesce(get_my_claim('inventory_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+CREATE POLICY "Employees with inventory_delete can delete receipts" ON "receipt"
+ FOR DELETE
+ USING (
+ coalesce(get_my_claim('inventory_delete')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
CREATE TABLE "receiptLine" (
"id" TEXT NOT NULL DEFAULT xid(),
@@ -5549,6 +5508,37 @@ CREATE INDEX "receiptLine_receiptId_idx" ON "receiptLine" ("receiptId");
CREATE INDEX "receiptLine_lineId_idx" ON "receiptLine" ("lineId");
CREATE INDEX "receiptLine_receiptId_lineId_idx" ON "receiptLine" ("receiptId", "lineId");
+ALTER TABLE "receiptLine" ENABLE ROW LEVEL SECURITY;
+
+CREATE POLICY "Employees with inventory_view can view receipt lines" ON "receiptLine"
+ FOR SELECT
+ USING (
+ coalesce(get_my_claim('inventory_view')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+
+CREATE POLICY "Employees with inventory_create can insert receipt lines" ON "receiptLine"
+ FOR INSERT
+ WITH CHECK (
+ coalesce(get_my_claim('inventory_create')::boolean,false)
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+);
+
+CREATE POLICY "Employees with inventory_update can update receipt lines" ON "receiptLine"
+ FOR UPDATE
+ USING (
+ coalesce(get_my_claim('inventory_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+CREATE POLICY "Employees with inventory_delete can delete receipt lines" ON "receiptLine"
+ FOR DELETE
+ USING (
+ coalesce(get_my_claim('inventory_delete')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
CREATE VIEW "receipt_quantity_received_by_line" AS
SELECT
r."sourceDocumentId",
@@ -5574,3 +5564,671 @@ CREATE VIEW "user_default_view" AS
LEFT JOIN "employeeJob" ej ON ej.id = u.id;
```
+
+
+## `posting-groups`
+
+```sql
+CREATE TABLE "accountDefault" (
+ "id" BOOLEAN NOT NULL DEFAULT TRUE,
+ -- income statement
+ -- revenue
+ "salesAccount" TEXT NOT NULL,
+ "salesDiscountAccount" TEXT NOT NULL,
+
+ -- part cost
+ "costOfGoodsSoldAccount" TEXT NOT NULL,
+ "purchaseAccount" TEXT NOT NULL,
+ "directCostAppliedAccount" TEXT NOT NULL,
+ "overheadCostAppliedAccount" TEXT NOT NULL,
+ "purchaseVarianceAccount" TEXT NOT NULL,
+ "inventoryAdjustmentVarianceAccount" TEXT NOT NULL,
+
+ -- direct costs
+ "materialVarianceAccount" TEXT NOT NULL,
+ "capacityVarianceAccount" TEXT NOT NULL,
+ "overheadAccount" TEXT NOT NULL,
+ "maintenanceAccount" TEXT NOT NULL,
+
+ -- depreciaition of fixed assets
+ "assetDepreciationExpenseAccount" TEXT NOT NULL,
+ "assetGainsAndLossesAccount" TEXT NOT NULL,
+ "serviceChargeAccount" TEXT NOT NULL,
+
+ -- interest
+ "interestAccount" TEXT NOT NULL,
+ "supplierPaymentDiscountAccount" TEXT NOT NULL,
+ "customerPaymentDiscountAccount" TEXT NOT NULL,
+ "roundingAccount" TEXT NOT NULL,
+
+ -- balance sheet
+ -- assets
+ "assetAquisitionCostAccount" TEXT NOT NULL,
+ "assetAquisitionCostOnDisposalAccount" TEXT NOT NULL,
+ "accumulatedDepreciationAccount" TEXT NOT NULL,
+ "accumulatedDepreciationOnDisposalAccount" TEXT NOT NULL,
+
+ -- current assets
+ "inventoryAccount" TEXT NOT NULL,
+ "inventoryInterimAccrualAccount" TEXT NOT NULL,
+ "workInProgressAccount" TEXT NOT NULL,
+ "receivablesAccount" TEXT NOT NULL,
+ "inventoryShippedNotInvoicedAccount" TEXT NOT NULL,
+ "bankCashAccount" TEXT NOT NULL,
+ "bankLocalCurrencyAccount" TEXT NOT NULL,
+ "bankForeignCurrencyAccount" TEXT NOT NULL,
+
+ -- liabilities
+ "prepaymentAccount" TEXT NOT NULL,
+ "payablesAccount" TEXT NOT NULL,
+ "inventoryReceivedNotInvoicedAccount" TEXT NOT NULL,
+ "salesTaxPayableAccount" TEXT NOT NULL,
+ "purchaseTaxPayableAccount" TEXT NOT NULL,
+ "reverseChargeSalesTaxPayableAccount" TEXT NOT NULL,
+
+ -- retained earnings
+ "retainedEarningsAccount" TEXT NOT NULL,
+
+ "updatedBy" TEXT,
+
+
+
+ CONSTRAINT "accountDefault_pkey" PRIMARY KEY ("id"),
+ -- this is a hack to make sure that this table only ever has one row
+ CONSTRAINT "accountDefault_id_check" CHECK ("id" = TRUE),
+ CONSTRAINT "accountDefault_id_unique" UNIQUE ("id"),
+ CONSTRAINT "accountDefault_salesAccount_fkey" FOREIGN KEY ("salesAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_salesDiscountAccount_fkey" FOREIGN KEY ("salesDiscountAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_costOfGoodsSoldAccount_fkey" FOREIGN KEY ("costOfGoodsSoldAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_purchaseAccount_fkey" FOREIGN KEY ("purchaseAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_directCostAppliedAccount_fkey" FOREIGN KEY ("directCostAppliedAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_overheadCostAppliedAccount_fkey" FOREIGN KEY ("overheadCostAppliedAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_purchaseVarianceAccount_fkey" FOREIGN KEY ("purchaseVarianceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_inventoryAdjustmentVarianceAccount_fkey" FOREIGN KEY ("inventoryAdjustmentVarianceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_materialVarianceAccount_fkey" FOREIGN KEY ("materialVarianceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_capacityVarianceAccount_fkey" FOREIGN KEY ("capacityVarianceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_overheadAccount_fkey" FOREIGN KEY ("overheadAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_maintenanceAccount_fkey" FOREIGN KEY ("maintenanceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_assetDepreciationExpenseAccount_fkey" FOREIGN KEY ("assetDepreciationExpenseAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_assetGainsAndLossesAccount_fkey" FOREIGN KEY ("assetGainsAndLossesAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_serviceChargeAccount_fkey" FOREIGN KEY ("serviceChargeAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_interestAccount_fkey" FOREIGN KEY ("interestAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_supplierPaymentDiscountAccount_fkey" FOREIGN KEY ("supplierPaymentDiscountAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_customerPaymentDiscountAccount_fkey" FOREIGN KEY ("customerPaymentDiscountAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_roundingAccount_fkey" FOREIGN KEY ("roundingAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_aquisitionCostAccount_fkey" FOREIGN KEY ("assetAquisitionCostAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_aquisitionCostOnDisposalAccount_fkey" FOREIGN KEY ("assetAquisitionCostOnDisposalAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_accumulatedDepreciationAccount_fkey" FOREIGN KEY ("accumulatedDepreciationAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_accumulatedDepreciationOnDisposalAccount_fkey" FOREIGN KEY ("accumulatedDepreciationOnDisposalAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_inventoryAccount_fkey" FOREIGN KEY ("inventoryAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_inventoryInterimAccrualAccount_fkey" FOREIGN KEY ("inventoryInterimAccrualAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_workInProgressAccount_fkey" FOREIGN KEY ("workInProgressAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_receivablesAccount_fkey" FOREIGN KEY ("receivablesAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_inventoryShippedNotInvoicedAccount_fkey" FOREIGN KEY ("inventoryShippedNotInvoicedAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_bankCashAccount_fkey" FOREIGN KEY ("bankCashAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_bankLocalCurrencyAccount_fkey" FOREIGN KEY ("bankLocalCurrencyAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_bankForeignCurrencyAccount_fkey" FOREIGN KEY ("bankForeignCurrencyAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_prepaymentAccount_fkey" FOREIGN KEY ("prepaymentAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_payablesAccount_fkey" FOREIGN KEY ("payablesAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_inventoryReceivedNotInvoicedAccount_fkey" FOREIGN KEY ("inventoryReceivedNotInvoicedAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_salesTaxPayableAccount_fkey" FOREIGN KEY ("salesTaxPayableAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_reverseChargeSalesTaxPayableAccount_fkey" FOREIGN KEY ("reverseChargeSalesTaxPayableAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_purchaseTaxPayableAccount_fkey" FOREIGN KEY ("purchaseTaxPayableAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_retainedEarningsAccount_fkey" FOREIGN KEY ("retainedEarningsAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
+);
+
+ALTER TABLE "accountDefault" ENABLE ROW LEVEL SECURITY;
+
+
+CREATE POLICY "Employees with accounting_view can view account defaults" ON "accountDefault"
+ FOR SELECT
+ USING (
+ coalesce(get_my_claim('accounting_view')::boolean,false)
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+CREATE POLICY "Employees with accounting_update can update account defaults" ON "accountDefault"
+ FOR UPDATE
+ USING (
+ coalesce(get_my_claim('accounting_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+
+
+CREATE TABLE "postingGroupInventory" (
+ "id" TEXT NOT NULL DEFAULT xid(),
+ "partGroupId" TEXT,
+ "locationId" TEXT,
+ "costOfGoodsSoldAccount" TEXT NOT NULL,
+ "inventoryAccount" TEXT NOT NULL,
+ "inventoryInterimAccrualAccount" TEXT NOT NULL,
+ "inventoryReceivedNotInvoicedAccount" TEXT NOT NULL,
+ "inventoryShippedNotInvoicedAccount" TEXT NOT NULL,
+ "workInProgressAccount" TEXT NOT NULL,
+ "directCostAppliedAccount" TEXT NOT NULL,
+ "overheadCostAppliedAccount" TEXT NOT NULL,
+ "purchaseVarianceAccount" TEXT NOT NULL,
+ "inventoryAdjustmentVarianceAccount" TEXT NOT NULL,
+ "materialVarianceAccount" TEXT NOT NULL,
+ "capacityVarianceAccount" TEXT NOT NULL,
+ "overheadAccount" TEXT NOT NULL,
+ "updatedBy" TEXT,
+
+ CONSTRAINT "postingGroupInventory_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "postingGroupInventory_id_partGroupId_locationId_key" UNIQUE ("partGroupId", "locationId"),
+ CONSTRAINT "postingGroupInventory_partGroupId_fkey" FOREIGN KEY ("partGroupId") REFERENCES "partGroup" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_costOfGoodsSoldAccount_fkey" FOREIGN KEY ("costOfGoodsSoldAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_inventoryAccount_fkey" FOREIGN KEY ("inventoryAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_inventoryInterimAccrualAccount_fkey" FOREIGN KEY ("inventoryInterimAccrualAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_inventoryReceivedNotInvoicedAccount_fkey" FOREIGN KEY ("inventoryReceivedNotInvoicedAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_inventoryShippedNotInvoicedAccount_fkey" FOREIGN KEY ("inventoryShippedNotInvoicedAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_workInProgressAccount_fkey" FOREIGN KEY ("workInProgressAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_directCostAppliedAccount_fkey" FOREIGN KEY ("directCostAppliedAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_overheadCostAppliedAccount_fkey" FOREIGN KEY ("overheadCostAppliedAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_purchaseVarianceAccount_fkey" FOREIGN KEY ("purchaseVarianceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_inventoryAdjustmentVarianceAccount_fkey" FOREIGN KEY ("inventoryAdjustmentVarianceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_materialVarianceAccount_fkey" FOREIGN KEY ("materialVarianceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_capacityVarianceAccount_fkey" FOREIGN KEY ("capacityVarianceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_overheadAccount_fkey" FOREIGN KEY ("overheadAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE
+);
+
+CREATE INDEX "postingGroupInventory_partGroupId_locationId_idx" ON "postingGroupInventory" ("partGroupId", "locationId");
+
+ALTER TABLE "postingGroupInventory" ENABLE ROW LEVEL SECURITY;
+
+CREATE POLICY "Employees with accounting_view can view inventory posting groups" ON "postingGroupInventory"
+ FOR SELECT
+ USING (
+ coalesce(get_my_claim('accounting_view')::boolean,false)
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+CREATE POLICY "Employees with accounting_update can update inventory posting groups" ON "postingGroupInventory"
+ FOR UPDATE
+ USING (
+ coalesce(get_my_claim('accounting_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+
+CREATE TABLE "postingGroupPurchasing" (
+ "id" TEXT NOT NULL DEFAULT xid(),
+ "supplierTypeId" TEXT,
+ "partGroupId" TEXT,
+ "purchaseAccount" TEXT NOT NULL,
+ "purchaseDiscountAccount" TEXT NOT NULL,
+ "purchaseCreditAccount" TEXT NOT NULL,
+ "purchasePrepaymentAccount" TEXT NOT NULL,
+ "purchaseTaxPayableAccount" TEXT NOT NULL,
+ "updatedBy" TEXT,
+
+ CONSTRAINT "postingGroupPurchasing_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "postingGroupPurchasing_id_supplierTypeId_partGroupId_key" UNIQUE ("supplierTypeId", "partGroupId"),
+ CONSTRAINT "postingGroupPurchasing_partGroupId_fkey" FOREIGN KEY ("partGroupId") REFERENCES "partGroup" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupPurchasing_supplierTypeId_fkey" FOREIGN KEY ("supplierTypeId") REFERENCES "supplierType" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupPurchasing_purchaseAccount_fkey" FOREIGN KEY ("purchaseAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupPurchasing_purchaseDiscountAccount_fkey" FOREIGN KEY ("purchaseDiscountAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupPurchasing_purchaseCreditAccount_fkey" FOREIGN KEY ("purchaseCreditAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupPurchasing_purchasePrepaymentAccount_fkey" FOREIGN KEY ("purchasePrepaymentAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupPurchasing_purchaseTaxPayableAccount_fkey" FOREIGN KEY ("purchaseTaxPayableAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupPurchasing_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE
+);
+
+CREATE INDEX "postingGroupPurchasing_partGroupId_supplierTypeId_idx" ON "postingGroupPurchasing" ("partGroupId", "supplierTypeId");
+
+ALTER TABLE "postingGroupPurchasing" ENABLE ROW LEVEL SECURITY;
+
+CREATE POLICY "Employees with accounting_view can view purchasing posting groups" ON "postingGroupPurchasing"
+ FOR SELECT
+ USING (
+ coalesce(get_my_claim('accounting_view')::boolean,false)
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+CREATE POLICY "Employees with accounting_update can update purchasing posting groups" ON "postingGroupPurchasing"
+ FOR UPDATE
+ USING (
+ coalesce(get_my_claim('accounting_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+CREATE TABLE "postingGroupSales" (
+ "id" TEXT NOT NULL DEFAULT xid(),
+ "customerTypeId" TEXT,
+ "partGroupId" TEXT,
+ "salesAccount" TEXT NOT NULL,
+ "salesDiscountAccount" TEXT NOT NULL,
+ "salesCreditAccount" TEXT NOT NULL,
+ "salesPrepaymentAccount" TEXT NOT NULL,
+ "salesTaxPayableAccount" TEXT NOT NULL,
+ "updatedBy" TEXT,
+
+ CONSTRAINT "postingGroupSales_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "postingGroupSales_id_customerTypeId_partGroupId_key" UNIQUE ("customerTypeId", "partGroupId"),
+ CONSTRAINT "postingGroupSales_partGroupId_fkey" FOREIGN KEY ("partGroupId") REFERENCES "partGroup" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupSales_customerTypeId_fkey" FOREIGN KEY ("customerTypeId") REFERENCES "customerType" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupSales_salesAccount_fkey" FOREIGN KEY ("salesAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupSales_salesDiscountAccount_fkey" FOREIGN KEY ("salesDiscountAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupSales_salesCreditAccount_fkey" FOREIGN KEY ("salesCreditAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupSales_salesPrepaymentAccount_fkey" FOREIGN KEY ("salesPrepaymentAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupSales_salesTaxPayableAccount_fkey" FOREIGN KEY ("salesTaxPayableAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupSales_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE
+);
+
+CREATE INDEX "postingGroupSales_partGroupId_customerTypeId_idx" ON "postingGroupSales" ("partGroupId", "customerTypeId");
+
+CREATE POLICY "Employees with accounting_view can view sales posting groups" ON "postingGroupSales"
+ FOR SELECT
+ USING (
+ coalesce(get_my_claim('accounting_view')::boolean,false)
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+CREATE POLICY "Employees with accounting_update can update sales posting groups" ON "postingGroupSales"
+ FOR UPDATE
+ USING (
+ coalesce(get_my_claim('accounting_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+CREATE FUNCTION public.create_posting_groups_for_location()
+RETURNS TRIGGER AS $$
+DECLARE
+ part_group RECORD;
+ account_defaults RECORD;
+BEGIN
+ SELECT * INTO account_defaults FROM "accountDefault" WHERE "id" = TRUE;
+
+ FOR part_group IN SELECT "id" FROM "partGroup"
+ LOOP
+ INSERT INTO "postingGroupInventory" (
+ "partGroupId",
+ "locationId",
+ "costOfGoodsSoldAccount",
+ "inventoryAccount",
+ "inventoryInterimAccrualAccount",
+ "inventoryReceivedNotInvoicedAccount",
+ "inventoryShippedNotInvoicedAccount",
+ "workInProgressAccount",
+ "directCostAppliedAccount",
+ "overheadCostAppliedAccount",
+ "purchaseVarianceAccount",
+ "inventoryAdjustmentVarianceAccount",
+ "materialVarianceAccount",
+ "capacityVarianceAccount",
+ "overheadAccount",
+ "updatedBy"
+ ) VALUES (
+ part_group."id",
+ new."id",
+ account_defaults."costOfGoodsSoldAccount",
+ account_defaults."inventoryAccount",
+ account_defaults."inventoryInterimAccrualAccount",
+ account_defaults."inventoryReceivedNotInvoicedAccount",
+ account_defaults."inventoryShippedNotInvoicedAccount",
+ account_defaults."workInProgressAccount",
+ account_defaults."directCostAppliedAccount",
+ account_defaults."overheadCostAppliedAccount",
+ account_defaults."purchaseVarianceAccount",
+ account_defaults."inventoryAdjustmentVarianceAccount",
+ account_defaults."materialVarianceAccount",
+ account_defaults."capacityVarianceAccount",
+ account_defaults."overheadAccount",
+ new."createdBy"
+ );
+ END LOOP;
+
+ -- insert the null part group
+ INSERT INTO "postingGroupInventory" (
+ "partGroupId",
+ "locationId",
+ "costOfGoodsSoldAccount",
+ "inventoryAccount",
+ "inventoryInterimAccrualAccount",
+ "inventoryReceivedNotInvoicedAccount",
+ "inventoryShippedNotInvoicedAccount",
+ "workInProgressAccount",
+ "directCostAppliedAccount",
+ "overheadCostAppliedAccount",
+ "purchaseVarianceAccount",
+ "inventoryAdjustmentVarianceAccount",
+ "materialVarianceAccount",
+ "capacityVarianceAccount",
+ "overheadAccount",
+ "updatedBy"
+ ) VALUES (
+ NULL,
+ new."id",
+ account_defaults."costOfGoodsSoldAccount",
+ account_defaults."inventoryAccount",
+ account_defaults."inventoryInterimAccrualAccount",
+ account_defaults."inventoryReceivedNotInvoicedAccount",
+ account_defaults."inventoryShippedNotInvoicedAccount",
+ account_defaults."workInProgressAccount",
+ account_defaults."directCostAppliedAccount",
+ account_defaults."overheadCostAppliedAccount",
+ account_defaults."purchaseVarianceAccount",
+ account_defaults."inventoryAdjustmentVarianceAccount",
+ account_defaults."materialVarianceAccount",
+ account_defaults."capacityVarianceAccount",
+ account_defaults."overheadAccount",
+ new."createdBy"
+ );
+
+ RETURN new;
+END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+CREATE TRIGGER create_location
+ AFTER INSERT on public."location"
+ FOR EACH ROW EXECUTE PROCEDURE public.create_posting_groups_for_location();
+
+
+CREATE FUNCTION public.create_posting_groups_for_part_group()
+RETURNS TRIGGER AS $$
+DECLARE
+ rec RECORD;
+ account_defaults RECORD;
+BEGIN
+ SELECT * INTO account_defaults FROM "accountDefault" WHERE "id" = TRUE;
+
+ FOR rec IN SELECT "id" FROM "customerType"
+ LOOP
+ INSERT INTO "postingGroupSales" (
+ "partGroupId",
+ "customerTypeId",
+ "salesAccount",
+ "salesDiscountAccount",
+ "salesCreditAccount",
+ "salesPrepaymentAccount",
+ "salesTaxPayableAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ rec."id",
+ account_defaults."salesAccount",
+ account_defaults."salesDiscountAccount",
+ account_defaults."receivablesAccount",
+ account_defaults."prepaymentAccount",
+ account_defaults."salesTaxPayableAccount",
+ new."createdBy"
+ );
+ END LOOP;
+
+ -- insert the null customer type
+ INSERT INTO "postingGroupSales" (
+ "partGroupId",
+ "customerTypeId",
+ "salesAccount",
+ "salesDiscountAccount",
+ "salesCreditAccount",
+ "salesPrepaymentAccount",
+ "salesTaxPayableAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ NULL,
+ account_defaults."salesAccount",
+ account_defaults."salesDiscountAccount",
+ account_defaults."receivablesAccount",
+ account_defaults."prepaymentAccount",
+ account_defaults."salesTaxPayableAccount",
+ new."createdBy"
+ );
+
+ FOR rec IN SELECT "id" FROM "supplierType"
+ LOOP
+ INSERT INTO "postingGroupPurchasing" (
+ "partGroupId",
+ "supplierTypeId",
+ "purchaseAccount",
+ "purchaseDiscountAccount",
+ "purchaseCreditAccount",
+ "purchasePrepaymentAccount",
+ "purchaseTaxPayableAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ rec."id",
+ account_defaults."purchaseAccount",
+ account_defaults."purchaseAccount",
+ account_defaults."payablesAccount",
+ account_defaults."prepaymentAccount",
+ account_defaults."purchaseTaxPayableAccount",
+ new."createdBy"
+ );
+ END LOOP;
+
+ -- insert the null supplier type
+ INSERT INTO "postingGroupPurchasing" (
+ "partGroupId",
+ "supplierTypeId",
+ "purchaseAccount",
+ "purchaseDiscountAccount",
+ "purchaseCreditAccount",
+ "purchasePrepaymentAccount",
+ "purchaseTaxPayableAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ NULL,
+ account_defaults."purchaseAccount",
+ account_defaults."purchaseAccount",
+ account_defaults."payablesAccount",
+ account_defaults."prepaymentAccount",
+ account_defaults."purchaseTaxPayableAccount",
+ new."createdBy"
+ );
+
+ FOR rec IN SELECT "id" FROM "location"
+ LOOP
+ INSERT INTO "postingGroupInventory" (
+ "partGroupId",
+ "locationId",
+ "costOfGoodsSoldAccount",
+ "inventoryAccount",
+ "inventoryInterimAccrualAccount",
+ "inventoryReceivedNotInvoicedAccount",
+ "inventoryShippedNotInvoicedAccount",
+ "workInProgressAccount",
+ "directCostAppliedAccount",
+ "overheadCostAppliedAccount",
+ "purchaseVarianceAccount",
+ "inventoryAdjustmentVarianceAccount",
+ "materialVarianceAccount",
+ "capacityVarianceAccount",
+ "overheadAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ rec."id",
+ account_defaults."costOfGoodsSoldAccount",
+ account_defaults."inventoryAccount",
+ account_defaults."inventoryInterimAccrualAccount",
+ account_defaults."inventoryReceivedNotInvoicedAccount",
+ account_defaults."inventoryShippedNotInvoicedAccount",
+ account_defaults."workInProgressAccount",
+ account_defaults."directCostAppliedAccount",
+ account_defaults."overheadCostAppliedAccount",
+ account_defaults."purchaseVarianceAccount",
+ account_defaults."inventoryAdjustmentVarianceAccount",
+ account_defaults."materialVarianceAccount",
+ account_defaults."capacityVarianceAccount",
+ account_defaults."overheadAccount",
+ new."createdBy"
+ );
+ END LOOP;
+
+ -- insert the null location
+ INSERT INTO "postingGroupInventory" (
+ "partGroupId",
+ "locationId",
+ "costOfGoodsSoldAccount",
+ "inventoryAccount",
+ "inventoryInterimAccrualAccount",
+ "inventoryReceivedNotInvoicedAccount",
+ "inventoryShippedNotInvoicedAccount",
+ "workInProgressAccount",
+ "directCostAppliedAccount",
+ "overheadCostAppliedAccount",
+ "purchaseVarianceAccount",
+ "inventoryAdjustmentVarianceAccount",
+ "materialVarianceAccount",
+ "capacityVarianceAccount",
+ "overheadAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ NULL,
+ account_defaults."costOfGoodsSoldAccount",
+ account_defaults."inventoryAccount",
+ account_defaults."inventoryInterimAccrualAccount",
+ account_defaults."inventoryReceivedNotInvoicedAccount",
+ account_defaults."inventoryShippedNotInvoicedAccount",
+ account_defaults."workInProgressAccount",
+ account_defaults."directCostAppliedAccount",
+ account_defaults."overheadCostAppliedAccount",
+ account_defaults."purchaseVarianceAccount",
+ account_defaults."inventoryAdjustmentVarianceAccount",
+ account_defaults."materialVarianceAccount",
+ account_defaults."capacityVarianceAccount",
+ account_defaults."overheadAccount",
+ new."createdBy"
+ );
+
+ RETURN new;
+END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+
+CREATE TRIGGER create_part_group
+ AFTER INSERT on public."partGroup"
+ FOR EACH ROW EXECUTE PROCEDURE public.create_posting_groups_for_part_group();
+
+CREATE FUNCTION public.create_posting_groups_for_customer_type()
+RETURNS TRIGGER AS $$
+DECLARE
+ rec RECORD;
+ account_defaults RECORD;
+BEGIN
+ SELECT * INTO account_defaults FROM "accountDefault" WHERE "id" = TRUE;
+
+ FOR rec IN SELECT "id" FROM "partGroup"
+ LOOP
+ INSERT INTO "postingGroupSales" (
+ "customerTypeId",
+ "partGroupId",
+ "salesAccount",
+ "salesDiscountAccount",
+ "salesCreditAccount",
+ "salesPrepaymentAccount",
+ "salesTaxPayableAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ rec."id",
+ account_defaults."salesAccount",
+ account_defaults."salesDiscountAccount",
+ account_defaults."salesAccount",
+ account_defaults."prepaymentAccount",
+ account_defaults."salesTaxPayableAccount",
+ new."createdBy"
+ );
+ END LOOP;
+
+ -- insert the null part group
+ INSERT INTO "postingGroupSales" (
+ "customerTypeId",
+ "partGroupId",
+ "salesAccount",
+ "salesDiscountAccount",
+ "salesCreditAccount",
+ "salesPrepaymentAccount",
+ "salesTaxPayableAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ NULL,
+ account_defaults."salesAccount",
+ account_defaults."salesDiscountAccount",
+ account_defaults."salesAccount",
+ account_defaults."prepaymentAccount",
+ account_defaults."salesTaxPayableAccount",
+ new."createdBy"
+ );
+
+ RETURN new;
+END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+CREATE TRIGGER create_posting_groups_for_customer_type
+ AFTER INSERT on public."customerType"
+ FOR EACH ROW EXECUTE PROCEDURE public.create_posting_groups_for_customer_type();
+
+
+CREATE FUNCTION public.create_posting_groups_for_supplier_type()
+RETURNS TRIGGER AS $$
+DECLARE
+ rec RECORD;
+ account_defaults RECORD;
+BEGIN
+ SELECT * INTO account_defaults FROM "accountDefault" WHERE "id" = TRUE;
+
+ FOR rec IN SELECT "id" FROM "partGroup"
+ LOOP
+ INSERT INTO "postingGroupPurchasing" (
+ "supplierTypeId",
+ "partGroupId",
+ "purchaseAccount",
+ "purchaseDiscountAccount",
+ "purchaseCreditAccount",
+ "purchasePrepaymentAccount",
+ "purchaseTaxPayableAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ rec."id",
+ account_defaults."purchaseAccount",
+ account_defaults."purchaseAccount",
+ account_defaults."purchaseAccount",
+ account_defaults."prepaymentAccount",
+ account_defaults."purchaseTaxPayableAccount",
+ new."createdBy"
+ );
+ END LOOP;
+
+ -- insert the null part group
+ INSERT INTO "postingGroupPurchasing" (
+ "supplierTypeId",
+ "partGroupId",
+ "purchaseAccount",
+ "purchaseDiscountAccount",
+ "purchaseCreditAccount",
+ "purchasePrepaymentAccount",
+ "purchaseTaxPayableAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ NULL,
+ account_defaults."purchaseAccount",
+ account_defaults."purchaseAccount",
+ account_defaults."purchaseAccount",
+ account_defaults."prepaymentAccount",
+ account_defaults."purchaseTaxPayableAccount",
+ new."createdBy"
+ );
+
+ RETURN new;
+END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+CREATE TRIGGER create_posting_groups_for_supplier_type
+ AFTER INSERT on public."supplierType"
+ FOR EACH ROW EXECUTE PROCEDURE public.create_posting_groups_for_supplier_type();
+
+```
+
diff --git a/apps/carbon/app/components/Editable/EditableList.tsx b/apps/carbon/app/components/Editable/EditableList.tsx
index d4b301c983..4094275755 100644
--- a/apps/carbon/app/components/Editable/EditableList.tsx
+++ b/apps/carbon/app/components/Editable/EditableList.tsx
@@ -41,6 +41,7 @@ const EditableList =
<Select
autoFocus
borderRadius="none"
+ defaultValue={options.find((option) => option.value === value)}
options={options}
// @ts-ignore
onChange={onChange}
diff --git a/apps/carbon/app/components/Form/AccountCategory.tsx b/apps/carbon/app/components/Form/AccountCategory.tsx
index d2158e4e33..e91a352cfc 100644
--- a/apps/carbon/app/components/Form/AccountCategory.tsx
+++ b/apps/carbon/app/components/Form/AccountCategory.tsx
@@ -8,8 +8,10 @@ import {
import { useFetcher } from "@remix-run/react";
import { useEffect, useMemo } from "react";
import { useControlField, useField } from "remix-validated-form";
-import type { AccountCategory as AccountCategoryType } from "~/modules/accounting";
-import type { getAccountCategoriesList } from "~/modules/accounting";
+import type {
+ AccountCategory as AccountCategoryType,
+ getAccountCategoriesList,
+} from "~/modules/accounting";
import { mapRowsToOptions } from "~/utils/form";
import type { SelectProps } from "./Select";
@@ -100,6 +102,7 @@ const AccountCategory = ({
placeholder={placeholder}
// @ts-ignore
w="full"
+ isClearable
isReadOnly={isReadOnly}
onChange={handleChange}
/>
diff --git a/apps/carbon/app/components/Layout/Sidebar/CollapsibleSidebar.tsx b/apps/carbon/app/components/Layout/Sidebar/CollapsibleSidebar.tsx
index db44390e00..557f86d409 100644
--- a/apps/carbon/app/components/Layout/Sidebar/CollapsibleSidebar.tsx
+++ b/apps/carbon/app/components/Layout/Sidebar/CollapsibleSidebar.tsx
@@ -29,8 +29,9 @@ export const CollapsibleSidebar = ({ children }: PropsWithChildren<{}>) => {
borderRight={1}
borderRightColor={useColor("gray.300")}
borderRightStyle="solid"
- position="relative"
h="calc(100vh - 50px)"
+ position="sticky"
+ top={50}
>
<Tooltip label={sidebar.isOpen ? "Collapse" : "Expand"} placement="right">
<IconButton
diff --git a/apps/carbon/app/components/Layout/Sidebar/useSidebar.tsx b/apps/carbon/app/components/Layout/Sidebar/useSidebar.tsx
index 858ed844ac..52ea55f4d3 100644
--- a/apps/carbon/app/components/Layout/Sidebar/useSidebar.tsx
+++ b/apps/carbon/app/components/Layout/Sidebar/useSidebar.tsx
@@ -1,18 +1,18 @@
-import type { Authenticated, NavItem } from "~/types";
-import { AiOutlinePartition, AiOutlineFieldTime } from "react-icons/ai";
+import { AiOutlineFieldTime, AiOutlinePartition } from "react-icons/ai";
import { BiListCheck, BiMessage } from "react-icons/bi";
import {
BsCalendar2Week,
BsCartDash,
BsCartPlus,
+ BsCreditCard,
BsPeopleFill,
BsShieldLock,
} from "react-icons/bs";
import { CgProfile } from "react-icons/cg";
import { HiOutlineCube, HiOutlineDocumentDuplicate } from "react-icons/hi";
import { LuSettings2 } from "react-icons/lu";
-import { TbPigMoney } from "react-icons/tb";
import { usePermissions } from "~/hooks";
+import type { Authenticated, NavItem } from "~/types";
export function useSidebar() {
const permissions = usePermissions();
@@ -76,7 +76,7 @@ export function useSidebar() {
permission: "accounting",
name: "Accounting",
to: "/x/accounting",
- icon: <TbPigMoney />,
+ icon: <BsCreditCard />,
},
{
permission: "resources",
diff --git a/apps/carbon/app/components/Layout/Topbar/useBreadcrumbs.tsx b/apps/carbon/app/components/Layout/Topbar/useBreadcrumbs.tsx
index 401ce9cdcd..3eeb7ec111 100644
--- a/apps/carbon/app/components/Layout/Topbar/useBreadcrumbs.tsx
+++ b/apps/carbon/app/components/Layout/Topbar/useBreadcrumbs.tsx
@@ -62,6 +62,21 @@ export default function useBreadcrumbs(): Route[] {
name: "Currencies",
to: match.pathname,
});
+ case "routes/x+/accounting+/groups.inventory":
+ return acc.concat({
+ name: "Inventory Groups",
+ to: match.pathname,
+ });
+ case "routes/x+/accounting+/groups.purchasing":
+ return acc.concat({
+ name: "Purchasing Groups",
+ to: match.pathname,
+ });
+ case "routes/x+/accounting+/groups.sales":
+ return acc.concat({
+ name: "Sales Groups",
+ to: match.pathname,
+ });
case "routes/x+/accounting+/payment-terms":
return acc.concat({
name: "Payment Terms",
diff --git a/apps/carbon/app/components/Table/components/TableHeader/TableHeader.tsx b/apps/carbon/app/components/Table/components/TableHeader/TableHeader.tsx
index 16d896fba0..d66a2992dd 100644
--- a/apps/carbon/app/components/Table/components/TableHeader/TableHeader.tsx
+++ b/apps/carbon/app/components/Table/components/TableHeader/TableHeader.tsx
@@ -77,7 +77,7 @@ const TableHeader = <T extends object>({
variant="ghost"
onClick={() => setEditMode(true)}
>
- Edit Mode
+ Edit
</Button>
))}
</HStack>
diff --git a/apps/carbon/app/modules/account/index.ts b/apps/carbon/app/modules/account/index.ts
index 684aed031a..83b8af135e 100644
--- a/apps/carbon/app/modules/account/index.ts
+++ b/apps/carbon/app/modules/account/index.ts
@@ -1,3 +1,3 @@
export * from "./services";
-export * from "./interfaces";
export * from "./types";
+export * from "./ui";
diff --git a/apps/carbon/app/modules/account/interfaces/Password/PasswordForm/PasswordForm.tsx b/apps/carbon/app/modules/account/ui/Password/PasswordForm/PasswordForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/account/interfaces/Password/PasswordForm/PasswordForm.tsx
rename to apps/carbon/app/modules/account/ui/Password/PasswordForm/PasswordForm.tsx
diff --git a/apps/carbon/app/modules/account/interfaces/Password/PasswordForm/index.ts b/apps/carbon/app/modules/account/ui/Password/PasswordForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/account/interfaces/Password/PasswordForm/index.ts
rename to apps/carbon/app/modules/account/ui/Password/PasswordForm/index.ts
diff --git a/apps/carbon/app/modules/account/interfaces/Password/index.ts b/apps/carbon/app/modules/account/ui/Password/index.ts
similarity index 100%
rename from apps/carbon/app/modules/account/interfaces/Password/index.ts
rename to apps/carbon/app/modules/account/ui/Password/index.ts
diff --git a/apps/carbon/app/modules/account/interfaces/Personal/PersonalDataForm/PersonalDataForm.tsx b/apps/carbon/app/modules/account/ui/Personal/PersonalDataForm/PersonalDataForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/account/interfaces/Personal/PersonalDataForm/PersonalDataForm.tsx
rename to apps/carbon/app/modules/account/ui/Personal/PersonalDataForm/PersonalDataForm.tsx
diff --git a/apps/carbon/app/modules/account/interfaces/Personal/PersonalDataForm/index.ts b/apps/carbon/app/modules/account/ui/Personal/PersonalDataForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/account/interfaces/Personal/PersonalDataForm/index.ts
rename to apps/carbon/app/modules/account/ui/Personal/PersonalDataForm/index.ts
diff --git a/apps/carbon/app/modules/account/interfaces/Personal/index.ts b/apps/carbon/app/modules/account/ui/Personal/index.ts
similarity index 100%
rename from apps/carbon/app/modules/account/interfaces/Personal/index.ts
rename to apps/carbon/app/modules/account/ui/Personal/index.ts
diff --git a/apps/carbon/app/modules/account/interfaces/Profile/ProfileForm/ProfileForm.tsx b/apps/carbon/app/modules/account/ui/Profile/ProfileForm/ProfileForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/account/interfaces/Profile/ProfileForm/ProfileForm.tsx
rename to apps/carbon/app/modules/account/ui/Profile/ProfileForm/ProfileForm.tsx
diff --git a/apps/carbon/app/modules/account/interfaces/Profile/ProfileForm/index.ts b/apps/carbon/app/modules/account/ui/Profile/ProfileForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/account/interfaces/Profile/ProfileForm/index.ts
rename to apps/carbon/app/modules/account/ui/Profile/ProfileForm/index.ts
diff --git a/apps/carbon/app/modules/account/interfaces/Profile/ProfilePhotoForm/ProfilePhotoForm.tsx b/apps/carbon/app/modules/account/ui/Profile/ProfilePhotoForm/ProfilePhotoForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/account/interfaces/Profile/ProfilePhotoForm/ProfilePhotoForm.tsx
rename to apps/carbon/app/modules/account/ui/Profile/ProfilePhotoForm/ProfilePhotoForm.tsx
diff --git a/apps/carbon/app/modules/account/interfaces/Profile/ProfilePhotoForm/index.ts b/apps/carbon/app/modules/account/ui/Profile/ProfilePhotoForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/account/interfaces/Profile/ProfilePhotoForm/index.ts
rename to apps/carbon/app/modules/account/ui/Profile/ProfilePhotoForm/index.ts
diff --git a/apps/carbon/app/modules/account/interfaces/Profile/index.ts b/apps/carbon/app/modules/account/ui/Profile/index.ts
similarity index 100%
rename from apps/carbon/app/modules/account/interfaces/Profile/index.ts
rename to apps/carbon/app/modules/account/ui/Profile/index.ts
diff --git a/apps/carbon/app/modules/account/interfaces/UserAttributes/UserAttributesForm.tsx b/apps/carbon/app/modules/account/ui/UserAttributes/UserAttributesForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/account/interfaces/UserAttributes/UserAttributesForm.tsx
rename to apps/carbon/app/modules/account/ui/UserAttributes/UserAttributesForm.tsx
diff --git a/apps/carbon/app/modules/account/interfaces/UserAttributes/index.ts b/apps/carbon/app/modules/account/ui/UserAttributes/index.ts
similarity index 100%
rename from apps/carbon/app/modules/account/interfaces/UserAttributes/index.ts
rename to apps/carbon/app/modules/account/ui/UserAttributes/index.ts
diff --git a/apps/carbon/app/modules/account/interfaces/index.ts b/apps/carbon/app/modules/account/ui/index.ts
similarity index 100%
rename from apps/carbon/app/modules/account/interfaces/index.ts
rename to apps/carbon/app/modules/account/ui/index.ts
diff --git a/apps/carbon/app/modules/account/interfaces/useAccountSidebar.tsx b/apps/carbon/app/modules/account/ui/useAccountSidebar.tsx
similarity index 100%
rename from apps/carbon/app/modules/account/interfaces/useAccountSidebar.tsx
rename to apps/carbon/app/modules/account/ui/useAccountSidebar.tsx
diff --git a/apps/carbon/app/modules/accounting/index.ts b/apps/carbon/app/modules/accounting/index.ts
index 490fd762ea..83b8af135e 100644
--- a/apps/carbon/app/modules/accounting/index.ts
+++ b/apps/carbon/app/modules/accounting/index.ts
@@ -1,3 +1,3 @@
-export * from "./interfaces";
export * from "./services";
export * from "./types";
+export * from "./ui";
diff --git a/apps/carbon/app/modules/accounting/services/accounting.form.ts b/apps/carbon/app/modules/accounting/services/accounting.form.ts
index 645b1e6bc6..e5881aa24e 100644
--- a/apps/carbon/app/modules/accounting/services/accounting.form.ts
+++ b/apps/carbon/app/modules/accounting/services/accounting.form.ts
@@ -100,7 +100,7 @@ export const accountValidator = withZod(
})
.refine(
(data) => {
- if (data.type !== "Heading") {
+ if (!["Heading", "Begin Total", "End Total"].includes(data.type)) {
return !!data.accountCategoryId;
}
return true;
@@ -162,6 +162,123 @@ export const currencyValidator = withZod(
})
);
+export const defaultAcountValidator = withZod(
+ z.object({
+ salesAccount: z.string().min(1, { message: "Sales account is required" }),
+ salesDiscountAccount: z.string().min(1, {
+ message: "Sales discount account is required",
+ }),
+ costOfGoodsSoldAccount: z.string().min(1, {
+ message: "Cost of goods sold account is required",
+ }),
+ purchaseAccount: z.string().min(1, {
+ message: "Purchase account is required",
+ }),
+ directCostAppliedAccount: z.string().min(1, {
+ message: "Direct cost applied account is required",
+ }),
+ overheadCostAppliedAccount: z.string().min(1, {
+ message: "Overhead cost applied account is required",
+ }),
+ purchaseVarianceAccount: z.string().min(1, {
+ message: "Purchase variance account is required",
+ }),
+ inventoryAdjustmentVarianceAccount: z.string().min(1, {
+ message: "Inventory adjustment variance account is required",
+ }),
+ materialVarianceAccount: z.string().min(1, {
+ message: "Material variance account is required",
+ }),
+ capacityVarianceAccount: z.string().min(1, {
+ message: "Capacity variance account is required",
+ }),
+ overheadAccount: z.string().min(1, {
+ message: "Overhead account is required",
+ }),
+ maintenanceAccount: z.string().min(1, {
+ message: "Maintenance account is required",
+ }),
+ assetDepreciationExpenseAccount: z.string().min(1, {
+ message: "Depreciation expense account is required",
+ }),
+ assetGainsAndLossesAccount: z.string().min(1, {
+ message: "Gains and losses account is required",
+ }),
+ serviceChargeAccount: z.string().min(1, {
+ message: "Service charge account is required",
+ }),
+ interestAccount: z.string().min(1, {
+ message: "Interest account is required",
+ }),
+ supplierPaymentDiscountAccount: z.string().min(1, {
+ message: "Supplier payment discount account is required",
+ }),
+ customerPaymentDiscountAccount: z.string().min(1, {
+ message: "Customer payment discount account is required",
+ }),
+ roundingAccount: z.string().min(1, {
+ message: "Rounding account is required",
+ }),
+ assetAquisitionCostAccount: z.string().min(1, {
+ message: "Aquisition cost account is required",
+ }),
+ assetAquisitionCostOnDisposalAccount: z.string().min(1, {
+ message: "Aquisition cost on disposal account is required",
+ }),
+ accumulatedDepreciationAccount: z.string().min(1, {
+ message: "Accumulated depreciation account is required",
+ }),
+ accumulatedDepreciationOnDisposalAccount: z.string().min(1, {
+ message: "Accumulated depreciation on disposal account is required",
+ }),
+ inventoryAccount: z.string().min(1, {
+ message: "Inventory account is required",
+ }),
+ inventoryInterimAccrualAccount: z.string().min(1, {
+ message: "Inventory interim accrual account is required",
+ }),
+ inventoryReceivedNotInvoicedAccount: z.string().min(1, {
+ message: "Inventory received not invoiced account is required",
+ }),
+ inventoryShippedNotInvoicedAccount: z.string().min(1, {
+ message: "Inventory shipped not invoiced account is required",
+ }),
+ workInProgressAccount: z.string().min(1, {
+ message: "Work in progress account is required",
+ }),
+ receivablesAccount: z.string().min(1, {
+ message: "Receivables account is required",
+ }),
+ bankCashAccount: z.string().min(1, {
+ message: "Bank cash account is required",
+ }),
+ bankLocalCurrencyAccount: z.string().min(1, {
+ message: "Bank local currency account is required",
+ }),
+ bankForeignCurrencyAccount: z.string().min(1, {
+ message: "Bank foreign currency account is required",
+ }),
+ prepaymentAccount: z.string().min(1, {
+ message: "Prepayment account is required",
+ }),
+ payablesAccount: z.string().min(1, {
+ message: "Payables account is required",
+ }),
+ salesTaxPayableAccount: z.string().min(1, {
+ message: "Sales tax payable account is required",
+ }),
+ purchaseTaxPayableAccount: z.string().min(1, {
+ message: "Purchase tax payable account is required",
+ }),
+ reverseChargeSalesTaxPayableAccount: z.string().min(1, {
+ message: "Reverse charge sales tax payable account is required",
+ }),
+ retainedEarningsAccount: z.string().min(1, {
+ message: "Retained earnings account is required",
+ }),
+ })
+);
+
export const partLedgerValidator = withZod(
z.object({
postingDate: z.string().min(1, { message: "Posting date is required" }),
diff --git a/apps/carbon/app/modules/accounting/services/accounting.server.ts b/apps/carbon/app/modules/accounting/services/accounting.server.ts
index 53f9cc8ade..c39e06b2fb 100644
--- a/apps/carbon/app/modules/accounting/services/accounting.server.ts
+++ b/apps/carbon/app/modules/accounting/services/accounting.server.ts
@@ -1,6 +1,8 @@
import type { Database } from "@carbon/database";
import { getDateNYearsAgo } from "@carbon/utils";
import type { SupabaseClient } from "@supabase/supabase-js";
+import { getSupabaseServiceRole } from "~/lib/supabase";
+import type { ReceiptLine } from "~/modules/inventory";
import type { TypeOfValidator } from "~/types/validators";
import type { GenericQueryFilters } from "~/utils/query";
import { setGenericQueryFilters } from "~/utils/query";
@@ -12,6 +14,7 @@ import type {
accountSubcategoryValidator,
accountValidator,
currencyValidator,
+ defaultAcountValidator,
partLedgerValidator,
paymentTermValidator,
valueLedgerValidator,
@@ -136,14 +139,23 @@ export async function getAccounts(
export async function getAccountsList(
client: SupabaseClient<Database>,
- type = "Posting"
+ args?: {
+ type?: string | null;
+ incomeBalance?: string | null;
+ }
) {
- return client
- .from("account")
- .select("number, name")
- .eq("active", true)
- .eq("type", type)
- .order("name", { ascending: true });
+ let query = client.from("account").select("number, name").eq("active", true);
+
+ if (args?.type) {
+ query = query.eq("type", args.type);
+ }
+
+ if (args?.incomeBalance) {
+ query = query.eq("incomeBalance", args.incomeBalance);
+ }
+
+ query = query.order("number", { ascending: true });
+ return query;
}
export async function getAccountCategories(
@@ -373,6 +385,33 @@ export async function getCurrenciesList(client: SupabaseClient<Database>) {
.order("name", { ascending: true });
}
+export async function getDefaultAccounts(client: SupabaseClient<Database>) {
+ return client.from("accountDefault").select("*").eq("id", true).single();
+}
+
+export async function getInventoryPostingGroups(
+ client: SupabaseClient<Database>,
+ args: GenericQueryFilters & {
+ partGroup: string | null;
+ location: string | null;
+ }
+) {
+ let query = client.from("postingGroupInventory").select("*", {
+ count: "exact",
+ });
+
+ if (args.partGroup) {
+ query = query.eq("partGroupId", args.partGroup);
+ }
+
+ if (args.location) {
+ query = query.eq("locationId", args.location);
+ }
+
+ query = setGenericQueryFilters(query, args, "partGroupId", false);
+ return query;
+}
+
export async function getPaymentTerm(
client: SupabaseClient<Database>,
paymentTermId: string
@@ -413,6 +452,52 @@ export async function getPaymentTermsList(client: SupabaseClient<Database>) {
.order("name", { ascending: true });
}
+export async function getPurchasingPostingGroups(
+ client: SupabaseClient<Database>,
+ args: GenericQueryFilters & {
+ partGroup: string | null;
+ supplierType: string | null;
+ }
+) {
+ let query = client.from("postingGroupPurchasing").select("*", {
+ count: "exact",
+ });
+
+ if (args.partGroup) {
+ query = query.eq("partGroupId", args.partGroup);
+ }
+
+ if (args.supplierType) {
+ query = query.eq("supplierTypeId", args.supplierType);
+ }
+
+ query = setGenericQueryFilters(query, args, "partGroupId", false);
+ return query;
+}
+
+export async function getSalesPostingGroups(
+ client: SupabaseClient<Database>,
+ args: GenericQueryFilters & {
+ partGroup: string | null;
+ customerType: string | null;
+ }
+) {
+ let query = client.from("postingGroupSales").select("*", {
+ count: "exact",
+ });
+
+ if (args.partGroup) {
+ query = query.eq("partGroupId", args.partGroup);
+ }
+
+ if (args.customerType) {
+ query = query.eq("customerTypeId", args.customerType);
+ }
+
+ query = setGenericQueryFilters(query, args, "partGroupId", false);
+ return query;
+}
+
export async function insertAccountEntries(
client: SupabaseClient<Database>,
accountEntries: TypeOfValidator<typeof accountLedgerValidator>[]
@@ -463,6 +548,90 @@ export async function insertValueLedger(
return client.from("valueLedger").insert([valueEntry]).select("id").single();
}
+export async function updateDefaultAccounts(
+ client: SupabaseClient<Database>,
+ defaultAccounts: TypeOfValidator<typeof defaultAcountValidator> & {
+ updatedBy: string;
+ }
+) {
+ return client.from("accountDefault").update(defaultAccounts).eq("id", true);
+}
+
+export async function postReceiptWithExpectedCost(receiptId: string) {
+ const client = getSupabaseServiceRole();
+ const [receipt, receiptLines] = await Promise.all([
+ client.from("receipt").select("*").eq("id", receiptId).single(),
+ client.from("receiptLine").select("*").eq("receiptId", receiptId),
+ ]);
+
+ if (receipt.error) return receipt;
+ if (receiptLines.error) return receiptLines;
+
+ switch (receipt.data?.sourceDocument) {
+ case "Purchase Order":
+ // TODO: this should all be done as a transaction
+ const purchaseOrderLines = await client
+ .from("purchaseOrderLine")
+ .select("*")
+ .eq("purchaseOrderId", receipt.data.sourceDocumentId);
+ if (purchaseOrderLines.error) return purchaseOrderLines;
+
+ const receiptLinesByLineId = receiptLines.data.reduce<
+ Record<string, ReceiptLine>
+ >((acc, receiptLine) => {
+ if (receiptLine.lineId) {
+ acc[receiptLine.lineId] = receiptLine;
+ }
+ return acc;
+ }, {});
+
+ // First, update the quantity received on the purchase order lines
+ purchaseOrderLines.data.forEach(async (purchaseOrderLine) => {
+ const receiptLine = receiptLinesByLineId[purchaseOrderLine.id];
+ if (!receiptLine) return;
+
+ if (!purchaseOrderLine.purchaseQuantity) return;
+
+ const newQuantityReceived =
+ (purchaseOrderLine.quantityReceived ?? 0) +
+ receiptLine.receivedQuantity;
+
+ const newQuantityToReceive =
+ (purchaseOrderLine.quantityToReceive ??
+ purchaseOrderLine.purchaseQuantity) - receiptLine.receivedQuantity;
+
+ const receivedComplete =
+ receiptLine.receivedQuantity >=
+ (purchaseOrderLine.quantityToReceive ??
+ purchaseOrderLine.purchaseQuantity);
+
+ let purchaseOrderLineUpdate = await client
+ .from("purchaseOrderLine")
+ .update({
+ quantityReceived: newQuantityReceived,
+ quantityToReceive: newQuantityToReceive,
+ receivedComplete,
+ })
+ .eq("id", purchaseOrderLine.id);
+
+ if (purchaseOrderLineUpdate.error) return purchaseOrderLineUpdate;
+ });
+
+ // Next, make the following entries for each line on the receipt:
+ // - a value ledger entry for the value of the receipt
+ // - a part ledger entry for the quantity received
+ // - a G/L entry to debit interim inventory accrual
+ // - a G/L entry to credit inventory received not invoiced
+ receiptLines.data.forEach(async (receiptLine) => {
+ // TODO:
+ });
+
+ break;
+ default:
+ break;
+ }
+}
+
export async function upsertAccount(
client: SupabaseClient<Database>,
account:
diff --git a/apps/carbon/app/modules/accounting/types.ts b/apps/carbon/app/modules/accounting/types.ts
index 0777c33b17..e487677bf0 100644
--- a/apps/carbon/app/modules/accounting/types.ts
+++ b/apps/carbon/app/modules/accounting/types.ts
@@ -2,9 +2,13 @@ import type { Database } from "@carbon/database";
import type {
getAccount,
getAccountCategories,
+ getAccountsList,
getAccountSubcategories,
getCurrencies,
+ getInventoryPostingGroups,
getPaymentTerms,
+ getPurchasingPostingGroups,
+ getSalesPostingGroups,
} from "./services";
export type Account = NonNullable<
@@ -18,6 +22,10 @@ export type AccountCategory = NonNullable<
export type AccountConsolidatedRate =
Database["public"]["Enums"]["glConsolidatedRate"];
+export type AccountListItem = NonNullable<
+ NonNullable<Awaited<ReturnType<typeof getAccountsList>>>["data"]
+>[number];
+
export type AccountSubcategory = NonNullable<
Awaited<ReturnType<typeof getAccountSubcategories>>["data"]
>[number];
@@ -40,6 +48,10 @@ export type Currency = NonNullable<
Awaited<ReturnType<typeof getCurrencies>>["data"]
>[number];
+export type InventoryPostingGroup = NonNullable<
+ Awaited<ReturnType<typeof getInventoryPostingGroups>>["data"]
+>[number];
+
export type PaymentTermCalculationMethod =
Database["public"]["Enums"]["paymentTermCalculationMethod"];
@@ -47,9 +59,17 @@ export type PaymentTerm = NonNullable<
Awaited<ReturnType<typeof getPaymentTerms>>["data"]
>[number];
+export type PurchasingPostingGroup = NonNullable<
+ Awaited<ReturnType<typeof getPurchasingPostingGroups>>["data"]
+>[number];
+
export type Transaction = {
number: string;
netChange: number;
balanceAtDate: number;
balance: number;
};
+
+export type SalesPostingGroup = NonNullable<
+ Awaited<ReturnType<typeof getSalesPostingGroups>>["data"]
+>[number];
diff --git a/apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountCategoriesTable/AccountCategoriesTable.tsx b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoriesTable/AccountCategoriesTable.tsx
similarity index 98%
rename from apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountCategoriesTable/AccountCategoriesTable.tsx
rename to apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoriesTable/AccountCategoriesTable.tsx
index ea6c0195fe..bfd01744c6 100644
--- a/apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountCategoriesTable/AccountCategoriesTable.tsx
+++ b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoriesTable/AccountCategoriesTable.tsx
@@ -11,7 +11,7 @@ import { useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useCallback, useMemo, useState } from "react";
import { BiAddToQueue } from "react-icons/bi";
-import { BsPencilSquare, BsListUl, BsPlus } from "react-icons/bs";
+import { BsListUl, BsPencilSquare, BsPlus } from "react-icons/bs";
import { IoMdTrash } from "react-icons/io";
import { Table } from "~/components";
import { ConfirmDelete } from "~/components/Modals";
@@ -68,7 +68,6 @@ const AccountCategoriesTable = memo(
return (
<Badge
size="sm"
- variant="outline"
colorScheme={isDebit ? "green" : isCredit ? "red" : "gray"}
>
{item.getValue<string>()}
diff --git a/apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountCategoriesTable/index.ts b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoriesTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountCategoriesTable/index.ts
rename to apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoriesTable/index.ts
diff --git a/apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountCategoriesTableFilters/AccountCategoriesTableFilters.tsx b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoriesTableFilters/AccountCategoriesTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountCategoriesTableFilters/AccountCategoriesTableFilters.tsx
rename to apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoriesTableFilters/AccountCategoriesTableFilters.tsx
diff --git a/apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountCategoriesTableFilters/index.ts b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoriesTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountCategoriesTableFilters/index.ts
rename to apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoriesTableFilters/index.ts
diff --git a/apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountCategoryDetail/AccountCategoryDetail.tsx b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryDetail/AccountCategoryDetail.tsx
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountCategoryDetail/AccountCategoryDetail.tsx
rename to apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryDetail/AccountCategoryDetail.tsx
diff --git a/apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountCategoryDetail/index.ts b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryDetail/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountCategoryDetail/index.ts
rename to apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryDetail/index.ts
diff --git a/apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountCategoryForm/AccountCategoryForm.tsx b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryForm/AccountCategoryForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountCategoryForm/AccountCategoryForm.tsx
rename to apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryForm/AccountCategoryForm.tsx
diff --git a/apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountCategoryForm/index.ts b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountCategoryForm/index.ts
rename to apps/carbon/app/modules/accounting/ui/AccountCategories/AccountCategoryForm/index.ts
diff --git a/apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountSubcategoryForm/AccountSubcategoryForm.tsx b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountSubcategoryForm/AccountSubcategoryForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountSubcategoryForm/AccountSubcategoryForm.tsx
rename to apps/carbon/app/modules/accounting/ui/AccountCategories/AccountSubcategoryForm/AccountSubcategoryForm.tsx
diff --git a/apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountSubcategoryForm/index.ts b/apps/carbon/app/modules/accounting/ui/AccountCategories/AccountSubcategoryForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/AccountCategories/AccountSubcategoryForm/index.ts
rename to apps/carbon/app/modules/accounting/ui/AccountCategories/AccountSubcategoryForm/index.ts
diff --git a/apps/carbon/app/modules/accounting/interfaces/AccountCategories/index.ts b/apps/carbon/app/modules/accounting/ui/AccountCategories/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/AccountCategories/index.ts
rename to apps/carbon/app/modules/accounting/ui/AccountCategories/index.ts
diff --git a/apps/carbon/app/modules/accounting/ui/AccountDefaults/AccountDefaultsForm.tsx b/apps/carbon/app/modules/accounting/ui/AccountDefaults/AccountDefaultsForm.tsx
new file mode 100644
index 0000000000..0bac9a3a29
--- /dev/null
+++ b/apps/carbon/app/modules/accounting/ui/AccountDefaults/AccountDefaultsForm.tsx
@@ -0,0 +1,399 @@
+import {
+ Button,
+ Grid,
+ Heading,
+ HStack,
+ Tab,
+ TabList,
+ TabPanel,
+ TabPanels,
+ Tabs,
+ VStack,
+} from "@chakra-ui/react";
+import { useNavigate } from "@remix-run/react";
+import { ValidatedForm } from "remix-validated-form";
+import { Select, Submit } from "~/components/Form";
+import { usePermissions } from "~/hooks";
+import type { AccountListItem } from "~/modules/accounting";
+import { defaultAcountValidator } from "~/modules/accounting";
+import type { TypeOfValidator } from "~/types/validators";
+
+type AccountDefaultsFormProps = {
+ balanceSheetAccounts: AccountListItem[];
+ incomeStatementAccounts: AccountListItem[];
+ initialValues: TypeOfValidator<typeof defaultAcountValidator>;
+};
+
+const AccountDefaultsForm = ({
+ balanceSheetAccounts,
+ incomeStatementAccounts,
+ initialValues,
+}: AccountDefaultsFormProps) => {
+ const permissions = usePermissions();
+ const navigate = useNavigate();
+ const onClose = () => navigate(-1);
+
+ const isDisabled = !permissions.can("update", "accounting");
+
+ const incomeStatementAccountOptions = incomeStatementAccounts.map((c) => ({
+ value: c.number,
+ label: `${c.number} - ${c.name}`,
+ }));
+
+ const balanceSheetAccountOptions = balanceSheetAccounts.map((c) => ({
+ value: c.number,
+ label: `${c.number} - ${c.name}`,
+ }));
+
+ return (
+ <VStack w="full" h="full" spacing={0}>
+ <ValidatedForm
+ validator={defaultAcountValidator}
+ method="post"
+ action="/x/accounting/defaults"
+ defaultValues={initialValues}
+ style={{
+ width: "100%",
+ }}
+ >
+ <Tabs colorScheme="gray">
+ <TabList>
+ <Tab>Income Statement</Tab>
+ <Tab>Balance Sheet</Tab>
+ </TabList>
+
+ <TabPanels>
+ <TabPanel>
+ <VStack w="full" alignItems="start" spacing={8}>
+ <VStack w="full" alignItems="start" spacing={4}>
+ <Heading size="xs" color="gray.400" textTransform="uppercase">
+ Revenue
+ </Heading>
+ <Grid
+ gridTemplateColumns={["1fr", "1fr 1fr", "1fr 1fr"]}
+ gridColumnGap={8}
+ gridRowGap={4}
+ mb={4}
+ w="full"
+ >
+ <Select
+ name="salesAccount"
+ label="Sales"
+ options={incomeStatementAccountOptions}
+ />
+ <Select
+ name="salesDiscountAccount"
+ label="Sales Discounts"
+ options={incomeStatementAccountOptions}
+ />
+ </Grid>
+ </VStack>
+ <VStack w="full" alignItems="start" spacing={4}>
+ <Heading size="xs" color="gray.400" textTransform="uppercase">
+ Cost of Goods Sold
+ </Heading>
+ <Grid
+ gridTemplateColumns={["1fr", "1fr 1fr", "1fr 1fr"]}
+ gridColumnGap={8}
+ gridRowGap={4}
+ mb={4}
+ w="full"
+ >
+ <Select
+ name="costOfGoodsSoldAccount"
+ label="Cost of Goods Sold"
+ options={incomeStatementAccountOptions}
+ />
+ <Select
+ name="purchaseAccount"
+ label="Purchases"
+ options={incomeStatementAccountOptions}
+ />
+ <Select
+ name="directCostAppliedAccount"
+ label="Direct Cost Applied"
+ options={incomeStatementAccountOptions}
+ />
+ <Select
+ name="overheadCostAppliedAccount"
+ label="Overhead Cost Applied"
+ options={incomeStatementAccountOptions}
+ />
+ <Select
+ name="purchaseVarianceAccount"
+ label="Purchase Variance"
+ options={incomeStatementAccountOptions}
+ />
+ <Select
+ name="inventoryAdjustmentVarianceAccount"
+ label="Inventory Adjustment"
+ options={incomeStatementAccountOptions}
+ />
+ </Grid>
+ </VStack>
+ <VStack w="full" alignItems="start" spacing={4}>
+ <Heading size="xs" color="gray.400" textTransform="uppercase">
+ Direct Costs
+ </Heading>
+ <Grid
+ gridTemplateColumns={["1fr", "1fr 1fr", "1fr 1fr"]}
+ gridColumnGap={8}
+ gridRowGap={4}
+ mb={4}
+ w="full"
+ >
+ <Select
+ name="materialVarianceAccount"
+ label="Material Variance"
+ options={incomeStatementAccountOptions}
+ />
+ <Select
+ name="capacityVarianceAccount"
+ label="Capacity Variance"
+ options={incomeStatementAccountOptions}
+ />
+ <Select
+ name="overheadAccount"
+ label="Overhead"
+ options={incomeStatementAccountOptions}
+ />
+ <Select
+ name="maintenanceAccount"
+ label="Maintenance Expense"
+ options={incomeStatementAccountOptions}
+ />
+ </Grid>
+ </VStack>
+ <VStack w="full" alignItems="start" spacing={4}>
+ <Heading size="xs" color="gray.400" textTransform="uppercase">
+ Depreciation of Fixed Assets
+ </Heading>
+ <Grid
+ gridTemplateColumns={["1fr", "1fr 1fr", "1fr 1fr"]}
+ gridColumnGap={8}
+ gridRowGap={4}
+ mb={4}
+ w="full"
+ >
+ <Select
+ name="assetDepreciationExpenseAccount"
+ label="Depreciation Expense"
+ options={incomeStatementAccountOptions}
+ />
+ <Select
+ name="assetGainsAndLossesAccount"
+ label="Gains and Losses"
+ options={incomeStatementAccountOptions}
+ />
+ <Select
+ name="serviceChargeAccount"
+ label="Service Charges"
+ options={incomeStatementAccountOptions}
+ />
+ </Grid>
+ </VStack>
+ <VStack w="full" alignItems="start" spacing={4}>
+ <Heading size="xs" color="gray.400" textTransform="uppercase">
+ Interest
+ </Heading>
+ <Grid
+ gridTemplateColumns={["1fr", "1fr 1fr", "1fr 1fr"]}
+ gridColumnGap={8}
+ gridRowGap={4}
+ mb={4}
+ w="full"
+ >
+ <Select
+ name="interestAccount"
+ label="Interest"
+ options={incomeStatementAccountOptions}
+ />
+ <Select
+ name="supplierPaymentDiscountAccount"
+ label="Supplier Payment Discounts"
+ options={incomeStatementAccountOptions}
+ />
+ <Select
+ name="customerPaymentDiscountAccount"
+ label="Customer Payment Discounts"
+ options={incomeStatementAccountOptions}
+ />
+ <Select
+ name="roundingAccount"
+ label="Rounding Account"
+ options={incomeStatementAccountOptions}
+ />
+ </Grid>
+ </VStack>
+ </VStack>
+ </TabPanel>
+ <TabPanel>
+ <VStack w="full" alignItems="start" spacing={8}>
+ <VStack w="full" alignItems="start" spacing={4}>
+ <Heading size="xs" color="gray.400" textTransform="uppercase">
+ Current Assets
+ </Heading>
+ <Grid
+ gridTemplateColumns={["1fr", "1fr 1fr", "1fr 1fr"]}
+ gridColumnGap={8}
+ gridRowGap={4}
+ mb={4}
+ w="full"
+ >
+ <Select
+ name="inventoryAccount"
+ label="Inventory"
+ options={balanceSheetAccountOptions}
+ />
+ <Select
+ name="inventoryInterimAccrualAccount"
+ label="Inventory Interim Accrual"
+ options={balanceSheetAccountOptions}
+ />
+ <Select
+ name="workInProgressAccount"
+ label="Work in Progress (WIP)"
+ options={balanceSheetAccountOptions}
+ />
+ <Select
+ name="receivablesAccount"
+ label="Receivables"
+ options={balanceSheetAccountOptions}
+ />
+ <Select
+ name="inventoryShippedNotInvoicedAccount"
+ label="Inventory Shipped Not Invoiced"
+ options={balanceSheetAccountOptions}
+ />
+ <Select
+ name="bankCashAccount"
+ label="Bank - Cash"
+ options={balanceSheetAccountOptions}
+ />
+ <Select
+ name="bankLocalCurrencyAccount"
+ label="Bank - Local Currency"
+ options={balanceSheetAccountOptions}
+ />
+ <Select
+ name="bankForeignCurrencyAccount"
+ label="Bank - Foreign Currency"
+ options={balanceSheetAccountOptions}
+ />
+ </Grid>
+ </VStack>
+ <VStack w="full" alignItems="start" spacing={4}>
+ <Heading size="xs" color="gray.400" textTransform="uppercase">
+ Fixed Assets
+ </Heading>
+ <Grid
+ gridTemplateColumns={["1fr", "1fr 1fr", "1fr 1fr"]}
+ gridColumnGap={8}
+ gridRowGap={4}
+ mb={4}
+ w="full"
+ >
+ <Select
+ name="assetAquisitionCostAccount"
+ label="Asset Aquisition Cost"
+ options={balanceSheetAccountOptions}
+ />
+ <Select
+ name="assetAquisitionCostOnDisposalAccount"
+ label="Asset Cost on Disposal"
+ options={balanceSheetAccountOptions}
+ />
+ <Select
+ name="accumulatedDepreciationAccount"
+ label="Accumulated Depreciation"
+ options={balanceSheetAccountOptions}
+ />
+ <Select
+ name="accumulatedDepreciationOnDisposalAccount"
+ label="Accumulated Depreciation on Disposal"
+ options={balanceSheetAccountOptions}
+ />
+ </Grid>
+ </VStack>
+ <VStack w="full" alignItems="start" spacing={4}>
+ <Heading size="xs" color="gray.400" textTransform="uppercase">
+ Liabilities
+ </Heading>
+ <Grid
+ gridTemplateColumns={["1fr", "1fr 1fr", "1fr 1fr"]}
+ gridColumnGap={8}
+ gridRowGap={4}
+ mb={4}
+ w="full"
+ >
+ <Select
+ name="prepaymentAccount"
+ label="Prepayments"
+ options={balanceSheetAccountOptions}
+ />
+ <Select
+ name="payablesAccount"
+ label="Payables"
+ options={balanceSheetAccountOptions}
+ />
+ <Select
+ name="inventoryReceivedNotInvoicedAccount"
+ label="Inventory Received Not Invoiced"
+ options={balanceSheetAccountOptions}
+ />
+ <Select
+ name="salesTaxPayableAccount"
+ label="Sales Tax Payable"
+ options={balanceSheetAccountOptions}
+ />
+ <Select
+ name="purchaseTaxPayableAccount"
+ label="Purchase Tax Payable"
+ options={balanceSheetAccountOptions}
+ />
+ <Select
+ name="reverseChargeSalesTaxPayableAccount"
+ label="Reverse Charge Sales Tax"
+ options={balanceSheetAccountOptions}
+ />
+ </Grid>
+ </VStack>
+ <VStack w="full" alignItems="start" spacing={4}>
+ <Heading size="xs" color="gray.400" textTransform="uppercase">
+ Equity
+ </Heading>
+ <Grid
+ gridTemplateColumns={["1fr", "1fr 1fr", "1fr 1fr"]}
+ gridColumnGap={8}
+ gridRowGap={4}
+ w="full"
+ >
+ <Select
+ name="retainedEarningsAccount"
+ label="Retained Earnings"
+ options={balanceSheetAccountOptions}
+ />
+ </Grid>
+ </VStack>
+ </VStack>
+ </TabPanel>
+ </TabPanels>
+ </Tabs>
+
+ <HStack spacing={2}>
+ <Submit isDisabled={isDisabled}>Save</Submit>
+ <Button
+ size="md"
+ colorScheme="gray"
+ variant="solid"
+ onClick={onClose}
+ >
+ Cancel
+ </Button>
+ </HStack>
+ </ValidatedForm>
+ </VStack>
+ );
+};
+
+export default AccountDefaultsForm;
diff --git a/apps/carbon/app/modules/accounting/ui/AccountDefaults/index.ts b/apps/carbon/app/modules/accounting/ui/AccountDefaults/index.ts
new file mode 100644
index 0000000000..056bc1e5c4
--- /dev/null
+++ b/apps/carbon/app/modules/accounting/ui/AccountDefaults/index.ts
@@ -0,0 +1,3 @@
+import AccountDefaultsForm from "./AccountDefaultsForm";
+
+export { AccountDefaultsForm };
diff --git a/apps/carbon/app/modules/accounting/interfaces/ChartOfAccounts/ChartOfAccountForm/ChartOfAccountForm.tsx b/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm/ChartOfAccountForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/ChartOfAccounts/ChartOfAccountForm/ChartOfAccountForm.tsx
rename to apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm/ChartOfAccountForm.tsx
diff --git a/apps/carbon/app/modules/accounting/interfaces/ChartOfAccounts/ChartOfAccountForm/index.ts b/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/ChartOfAccounts/ChartOfAccountForm/index.ts
rename to apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountForm/index.ts
diff --git a/apps/carbon/app/modules/accounting/interfaces/ChartOfAccounts/ChartOfAccountsTable/ChartOfAccountsTable.tsx b/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountsTable/ChartOfAccountsTable.tsx
similarity index 80%
rename from apps/carbon/app/modules/accounting/interfaces/ChartOfAccounts/ChartOfAccountsTable/ChartOfAccountsTable.tsx
rename to apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountsTable/ChartOfAccountsTable.tsx
index 4ee6c7ffcb..7af65ebe72 100644
--- a/apps/carbon/app/modules/accounting/interfaces/ChartOfAccounts/ChartOfAccountsTable/ChartOfAccountsTable.tsx
+++ b/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountsTable/ChartOfAccountsTable.tsx
@@ -1,4 +1,3 @@
-import { DataTable, DataTableColumnHeader } from "@carbon/react";
import {
Box,
Checkbox,
@@ -11,6 +10,7 @@ import { Link as RemixLink, useNavigate } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
import { memo, useMemo } from "react";
import { MdMoreHoriz } from "react-icons/md";
+import Grid from "~/components/Grid";
import type { Chart } from "~/modules/accounting";
type ChartOfAccountsTableProps = {
@@ -23,9 +23,7 @@ const ChartOfAccountsTable = memo(({ data }: ChartOfAccountsTableProps) => {
return [
{
accessorKey: "number",
- header: ({ column }) => (
- <DataTableColumnHeader column={column} title="No." />
- ),
+ header: "Number",
cell: ({ row }) => {
const isPosting = row.original.type === "Posting";
@@ -74,17 +72,26 @@ const ChartOfAccountsTable = memo(({ data }: ChartOfAccountsTableProps) => {
{
accessorKey: "netChange",
header: "Net Change",
- cell: ({ row }) => (row.original.netChange ?? 0).toFixed(2),
+ cell: ({ row }) => {
+ const hasValue = ["Posting", "End Total"].includes(row.original.type);
+ return hasValue ? (row.original.netChange ?? 0).toFixed(2) : null;
+ },
},
{
accessorKey: "balanceAtDate",
header: "Balance at Date",
- cell: ({ row }) => (row.original.balanceAtDate ?? 0).toFixed(2),
+ cell: ({ row }) => {
+ const hasValue = ["Posting", "End Total"].includes(row.original.type);
+ return hasValue ? (row.original.balanceAtDate ?? 0).toFixed(2) : null;
+ },
},
{
accessorKey: "balance",
header: "Balance",
- cell: ({ row }) => (row.original.balance ?? 0).toFixed(2),
+ cell: ({ row }) => {
+ const hasValue = ["Posting", "End Total"].includes(row.original.type);
+ return hasValue ? (row.original.balance ?? 0).toFixed(2) : null;
+ },
},
{
accessorKey: "incomeBalance",
@@ -119,7 +126,7 @@ const ChartOfAccountsTable = memo(({ data }: ChartOfAccountsTableProps) => {
];
}, [navigate]);
- return <DataTable data={data} columns={columns} />;
+ return <Grid<Chart> data={data} columns={columns} withSimpleSorting />;
});
ChartOfAccountsTable.displayName = "ChartOfAccountsTable";
diff --git a/apps/carbon/app/modules/accounting/interfaces/ChartOfAccounts/ChartOfAccountsTable/index.ts b/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountsTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/ChartOfAccounts/ChartOfAccountsTable/index.ts
rename to apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountsTable/index.ts
diff --git a/apps/carbon/app/modules/accounting/interfaces/ChartOfAccounts/ChartOfAccountsTableFilters/ChartOfAccountsTableFilters.tsx b/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountsTableFilters/ChartOfAccountsTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/ChartOfAccounts/ChartOfAccountsTableFilters/ChartOfAccountsTableFilters.tsx
rename to apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountsTableFilters/ChartOfAccountsTableFilters.tsx
diff --git a/apps/carbon/app/modules/accounting/interfaces/ChartOfAccounts/ChartOfAccountsTableFilters/index.ts b/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountsTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/ChartOfAccounts/ChartOfAccountsTableFilters/index.ts
rename to apps/carbon/app/modules/accounting/ui/ChartOfAccounts/ChartOfAccountsTableFilters/index.ts
diff --git a/apps/carbon/app/modules/accounting/interfaces/ChartOfAccounts/index.ts b/apps/carbon/app/modules/accounting/ui/ChartOfAccounts/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/ChartOfAccounts/index.ts
rename to apps/carbon/app/modules/accounting/ui/ChartOfAccounts/index.ts
diff --git a/apps/carbon/app/modules/accounting/interfaces/Currencies/CurrenciesTable/CurrenciesTable.tsx b/apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTable/CurrenciesTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/Currencies/CurrenciesTable/CurrenciesTable.tsx
rename to apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTable/CurrenciesTable.tsx
diff --git a/apps/carbon/app/modules/accounting/interfaces/Currencies/CurrenciesTable/index.ts b/apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/Currencies/CurrenciesTable/index.ts
rename to apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTable/index.ts
diff --git a/apps/carbon/app/modules/accounting/interfaces/Currencies/CurrenciesTableFilters/CurrenciesTableFilters.tsx b/apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTableFilters/CurrenciesTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/Currencies/CurrenciesTableFilters/CurrenciesTableFilters.tsx
rename to apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTableFilters/CurrenciesTableFilters.tsx
diff --git a/apps/carbon/app/modules/accounting/interfaces/Currencies/CurrenciesTableFilters/index.ts b/apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/Currencies/CurrenciesTableFilters/index.ts
rename to apps/carbon/app/modules/accounting/ui/Currencies/CurrenciesTableFilters/index.ts
diff --git a/apps/carbon/app/modules/accounting/interfaces/Currencies/CurrencyForm/CurrencyForm.tsx b/apps/carbon/app/modules/accounting/ui/Currencies/CurrencyForm/CurrencyForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/Currencies/CurrencyForm/CurrencyForm.tsx
rename to apps/carbon/app/modules/accounting/ui/Currencies/CurrencyForm/CurrencyForm.tsx
diff --git a/apps/carbon/app/modules/accounting/interfaces/Currencies/CurrencyForm/index.ts b/apps/carbon/app/modules/accounting/ui/Currencies/CurrencyForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/Currencies/CurrencyForm/index.ts
rename to apps/carbon/app/modules/accounting/ui/Currencies/CurrencyForm/index.ts
diff --git a/apps/carbon/app/modules/accounting/interfaces/Currencies/index.ts b/apps/carbon/app/modules/accounting/ui/Currencies/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/Currencies/index.ts
rename to apps/carbon/app/modules/accounting/ui/Currencies/index.ts
diff --git a/apps/carbon/app/modules/accounting/interfaces/PaymentTerms/PaymentTermForm/PaymentTermForm.tsx b/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermForm/PaymentTermForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/PaymentTerms/PaymentTermForm/PaymentTermForm.tsx
rename to apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermForm/PaymentTermForm.tsx
diff --git a/apps/carbon/app/modules/accounting/interfaces/PaymentTerms/PaymentTermForm/index.ts b/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/PaymentTerms/PaymentTermForm/index.ts
rename to apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermForm/index.ts
diff --git a/apps/carbon/app/modules/accounting/interfaces/PaymentTerms/PaymentTermsTable/PaymentTermsTable.tsx b/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermsTable/PaymentTermsTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/PaymentTerms/PaymentTermsTable/PaymentTermsTable.tsx
rename to apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermsTable/PaymentTermsTable.tsx
diff --git a/apps/carbon/app/modules/accounting/interfaces/PaymentTerms/PaymentTermsTable/index.ts b/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermsTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/PaymentTerms/PaymentTermsTable/index.ts
rename to apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermsTable/index.ts
diff --git a/apps/carbon/app/modules/accounting/interfaces/PaymentTerms/PaymentTermsTableFilters/PaymentTermsTableFilters.tsx b/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermsTableFilters/PaymentTermsTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/PaymentTerms/PaymentTermsTableFilters/PaymentTermsTableFilters.tsx
rename to apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermsTableFilters/PaymentTermsTableFilters.tsx
diff --git a/apps/carbon/app/modules/accounting/interfaces/PaymentTerms/PaymentTermsTableFilters/index.ts b/apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermsTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/PaymentTerms/PaymentTermsTableFilters/index.ts
rename to apps/carbon/app/modules/accounting/ui/PaymentTerms/PaymentTermsTableFilters/index.ts
diff --git a/apps/carbon/app/modules/accounting/interfaces/PaymentTerms/index.ts b/apps/carbon/app/modules/accounting/ui/PaymentTerms/index.ts
similarity index 100%
rename from apps/carbon/app/modules/accounting/interfaces/PaymentTerms/index.ts
rename to apps/carbon/app/modules/accounting/ui/PaymentTerms/index.ts
diff --git a/apps/carbon/app/modules/accounting/ui/PostingGroups/InventoryPostingGroupsFilters.tsx b/apps/carbon/app/modules/accounting/ui/PostingGroups/InventoryPostingGroupsFilters.tsx
new file mode 100644
index 0000000000..86607e821b
--- /dev/null
+++ b/apps/carbon/app/modules/accounting/ui/PostingGroups/InventoryPostingGroupsFilters.tsx
@@ -0,0 +1,73 @@
+import { Select, useColor } from "@carbon/react";
+import { HStack } from "@chakra-ui/react";
+import { useUrlParams } from "~/hooks";
+import type { ListItem } from "~/types";
+
+type InventoryPostingGroupsFiltersProps = {
+ partGroups: ListItem[];
+ locations: ListItem[];
+};
+
+const InventoryPostingGroupsFilters = ({
+ partGroups,
+ locations,
+}: InventoryPostingGroupsFiltersProps) => {
+ const [params, setParams] = useUrlParams();
+ const borderColor = useColor("gray.200");
+
+ const partGroupOptions = partGroups.map((partGroup) => ({
+ label: partGroup.name,
+ value: partGroup.id,
+ }));
+
+ const locationOptions = locations.map((location) => ({
+ label: location.name,
+ value: location.id,
+ }));
+
+ return (
+ <HStack
+ borderBottomColor={borderColor}
+ borderBottomStyle="solid"
+ borderBottomWidth={1}
+ justifyContent="flex-start"
+ px={4}
+ py={3}
+ spacing={4}
+ w="full"
+ >
+ <Select
+ // @ts-ignore
+ size="sm"
+ isClearable
+ value={partGroupOptions.find(
+ (partGroup) => partGroup.value === params.get("partGroup")
+ )}
+ options={partGroupOptions}
+ onChange={(selected) => {
+ setParams({ partGroup: selected?.value });
+ }}
+ aria-label="Part Group"
+ minW={180}
+ placeholder="Part Group"
+ />
+ <Select
+ // @ts-ignore
+ size="sm"
+ isClearable
+ value={locationOptions.find(
+ (location) => location.value === params.get("location")
+ )}
+ options={locationOptions}
+ onChange={(selected) => {
+ setParams({ location: selected?.value });
+ }}
+ aria-label="Location"
+ minW={180}
+ placeholder="Location"
+ />
+ </HStack>
+ );
+};
+
+export default InventoryPostingGroupsFilters;
diff --git a/apps/carbon/app/modules/accounting/ui/PostingGroups/InventoryPostingGroupsTable.tsx b/apps/carbon/app/modules/accounting/ui/PostingGroups/InventoryPostingGroupsTable.tsx
new file mode 100644
index 0000000000..604006d057
--- /dev/null
+++ b/apps/carbon/app/modules/accounting/ui/PostingGroups/InventoryPostingGroupsTable.tsx
@@ -0,0 +1,197 @@
+import type { ColumnDef } from "@tanstack/react-table";
+import { useMemo } from "react";
+import { Table } from "~/components";
+import { EditableList } from "~/components/Editable";
+import type {
+ AccountListItem,
+ InventoryPostingGroup,
+} from "~/modules/accounting";
+import type { ListItem } from "~/types";
+import usePostingGroups from "./usePostingGroups";
+
+type InventoryPostingGroupsTableProps = {
+ data: InventoryPostingGroup[];
+ count: number;
+ partGroups: ListItem[];
+ locations: ListItem[];
+ balanceSheetAccounts: AccountListItem[];
+ incomeStatementAccounts: AccountListItem[];
+};
+
+const InventoryPostingGroupsTable = ({
+ data,
+ count,
+ partGroups,
+ locations,
+ balanceSheetAccounts,
+ incomeStatementAccounts,
+}: InventoryPostingGroupsTableProps) => {
+ const { canEdit, handleCellEdit } = usePostingGroups("postingGroupInventory");
+
+ const balanceSheetAccountOptions = useMemo(() => {
+ return balanceSheetAccounts.map((account) => ({
+ label: account.number,
+ value: account.number,
+ }));
+ }, [balanceSheetAccounts]);
+
+ const incomeStatementAccountOptions = useMemo(() => {
+ return incomeStatementAccounts.map((account) => ({
+ label: account.number,
+ value: account.number,
+ }));
+ }, [incomeStatementAccounts]);
+
+ const columns = useMemo<ColumnDef<InventoryPostingGroup>[]>(() => {
+ return [
+ {
+ id: "partGroup",
+ header: "Part Group",
+ cell: ({ row }) =>
+ partGroups.find((group) => group.id === row.original.partGroupId)
+ ?.name,
+ },
+ {
+ id: "location",
+ header: "Location",
+ cell: ({ row }) =>
+ locations.find((type) => type.id === row.original.locationId)?.name,
+ },
+ {
+ accessorKey: "costOfGoodsSoldAccount",
+ header: "COGS",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "inventoryAccount",
+ header: "Inventory",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "inventoryInterimAccrualAccount",
+ header: "Inv. Interim Accrual",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "inventoryReceivedNotInvoicedAccount",
+ header: "Received Not Invoiced",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "inventoryShippedNotInvoicedAccount",
+ header: "Shipped Not Invoiced",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "workInProgressAccount",
+ header: "WIP",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "directCostAppliedAccount",
+ header: "Direct Cost Applied",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "overheadCostAppliedAccount",
+ header: "Overhead Cost Applied",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "purchaseVarianceAccount",
+ header: "Purchase Variance",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "inventoryAdjustmentVarianceAccount",
+ header: "Inv. Adjustment Variance",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "materialVarianceAccount",
+ header: "Material Variance",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "capacityVarianceAccount",
+ header: "Capacity Variance",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "overheadAccount",
+ header: "Overhead",
+ cell: (item) => item.getValue(),
+ },
+ ];
+ }, [locations, partGroups]);
+
+ const editableComponents = useMemo(
+ () => ({
+ costOfGoodsSoldAccount: EditableList(
+ handleCellEdit,
+ incomeStatementAccountOptions
+ ),
+ inventoryAccount: EditableList(
+ handleCellEdit,
+ balanceSheetAccountOptions
+ ),
+ inventoryInterimAccrualAccount: EditableList(
+ handleCellEdit,
+ balanceSheetAccountOptions
+ ),
+ inventoryReceivedNotInvoicedAccount: EditableList(
+ handleCellEdit,
+ balanceSheetAccountOptions
+ ),
+ inventoryShippedNotInvoicedAccount: EditableList(
+ handleCellEdit,
+ balanceSheetAccountOptions
+ ),
+ workInProgressAccount: EditableList(
+ handleCellEdit,
+ balanceSheetAccountOptions
+ ),
+ directCostAppliedAccount: EditableList(
+ handleCellEdit,
+ incomeStatementAccountOptions
+ ),
+ overheadCostAppliedAccount: EditableList(
+ handleCellEdit,
+ incomeStatementAccountOptions
+ ),
+ purchaseVarianceAccount: EditableList(
+ handleCellEdit,
+ incomeStatementAccountOptions
+ ),
+ inventoryAdjustmentVarianceAccount: EditableList(
+ handleCellEdit,
+ incomeStatementAccountOptions
+ ),
+ materialVarianceAccount: EditableList(
+ handleCellEdit,
+ incomeStatementAccountOptions
+ ),
+ capacityVarianceAccount: EditableList(
+ handleCellEdit,
+ incomeStatementAccountOptions
+ ),
+ overheadAccount: EditableList(
+ handleCellEdit,
+ incomeStatementAccountOptions
+ ),
+ }),
+ [handleCellEdit, balanceSheetAccountOptions, incomeStatementAccountOptions]
+ );
+
+ return (
+ <Table<InventoryPostingGroup>
+ data={data}
+ columns={columns}
+ count={count}
+ editableComponents={editableComponents}
+ withInlineEditing={canEdit}
+ />
+ );
+};
+
+export default InventoryPostingGroupsTable;
diff --git a/apps/carbon/app/modules/accounting/ui/PostingGroups/PurchasingPostingGroupsFilters.tsx b/apps/carbon/app/modules/accounting/ui/PostingGroups/PurchasingPostingGroupsFilters.tsx
new file mode 100644
index 0000000000..76b93ffa7d
--- /dev/null
+++ b/apps/carbon/app/modules/accounting/ui/PostingGroups/PurchasingPostingGroupsFilters.tsx
@@ -0,0 +1,73 @@
+import { Select, useColor } from "@carbon/react";
+import { HStack } from "@chakra-ui/react";
+import { useUrlParams } from "~/hooks";
+import type { ListItem } from "~/types";
+
+type PurchasingPostingGroupsFiltersProps = {
+ partGroups: ListItem[];
+ supplierTypes: ListItem[];
+};
+
+const PurchasingPostingGroupsFilters = ({
+ partGroups,
+ supplierTypes,
+}: PurchasingPostingGroupsFiltersProps) => {
+ const [params, setParams] = useUrlParams();
+ const borderColor = useColor("gray.200");
+
+ const partGroupOptions = partGroups.map((partGroup) => ({
+ label: partGroup.name,
+ value: partGroup.id,
+ }));
+
+ const supplierTypeOptions = supplierTypes.map((supplierType) => ({
+ label: supplierType.name,
+ value: supplierType.id,
+ }));
+
+ return (
+ <HStack
+ borderBottomColor={borderColor}
+ borderBottomStyle="solid"
+ borderBottomWidth={1}
+ justifyContent="flex-start"
+ px={4}
+ py={3}
+ spacing={4}
+ w="full"
+ >
+ <Select
+ // @ts-ignore
+ size="sm"
+ isClearable
+ value={partGroupOptions.find(
+ (partGroup) => partGroup.value === params.get("partGroup")
+ )}
+ options={partGroupOptions}
+ onChange={(selected) => {
+ setParams({ partGroup: selected?.value });
+ }}
+ aria-label="Part Group"
+ minW={180}
+ placeholder="Part Group"
+ />
+ <Select
+ // @ts-ignore
+ size="sm"
+ isClearable
+ value={supplierTypeOptions.find(
+ (supplierType) => supplierType.value === params.get("supplierType")
+ )}
+ options={supplierTypeOptions}
+ onChange={(selected) => {
+ setParams({ supplierType: selected?.value });
+ }}
+ aria-label="Supplier Type"
+ minW={180}
+ placeholder="Supplier Type"
+ />
+ </HStack>
+ );
+};
+
+export default PurchasingPostingGroupsFilters;
diff --git a/apps/carbon/app/modules/accounting/ui/PostingGroups/PurchasingPostingGroupsTable.tsx b/apps/carbon/app/modules/accounting/ui/PostingGroups/PurchasingPostingGroupsTable.tsx
new file mode 100644
index 0000000000..d18aea76e5
--- /dev/null
+++ b/apps/carbon/app/modules/accounting/ui/PostingGroups/PurchasingPostingGroupsTable.tsx
@@ -0,0 +1,128 @@
+import type { ColumnDef } from "@tanstack/react-table";
+import { useMemo } from "react";
+import { Table } from "~/components";
+import { EditableList } from "~/components/Editable";
+import type {
+ AccountListItem,
+ PurchasingPostingGroup,
+} from "~/modules/accounting";
+import type { ListItem } from "~/types";
+import usePostingGroups from "./usePostingGroups";
+
+type PurchasingPostingGroupsTableProps = {
+ data: PurchasingPostingGroup[];
+ count: number;
+ partGroups: ListItem[];
+ supplierTypes: ListItem[];
+ balanceSheetAccounts: AccountListItem[];
+ incomeStatementAccounts: AccountListItem[];
+};
+
+const PurchasingPostingGroupsTable = ({
+ data,
+ count,
+ partGroups,
+ supplierTypes,
+ balanceSheetAccounts,
+ incomeStatementAccounts,
+}: PurchasingPostingGroupsTableProps) => {
+ const { canEdit, handleCellEdit } = usePostingGroups(
+ "postingGroupPurchasing"
+ );
+
+ const balanceSheetAccountOptions = useMemo(() => {
+ return balanceSheetAccounts.map((account) => ({
+ label: account.number,
+ value: account.number,
+ }));
+ }, [balanceSheetAccounts]);
+
+ const incomeStatementAccountOptions = useMemo(() => {
+ return incomeStatementAccounts.map((account) => ({
+ label: account.number,
+ value: account.number,
+ }));
+ }, [incomeStatementAccounts]);
+
+ const columns = useMemo<ColumnDef<PurchasingPostingGroup>[]>(() => {
+ return [
+ {
+ id: "partGroup",
+ header: "Part Group",
+ cell: ({ row }) =>
+ partGroups.find((group) => group.id === row.original.partGroupId)
+ ?.name,
+ },
+ {
+ id: "supplierType",
+ header: "Supplier Type",
+ cell: ({ row }) =>
+ supplierTypes.find((type) => type.id === row.original.supplierTypeId)
+ ?.name,
+ },
+ {
+ accessorKey: "purchaseAccount",
+ header: "Purchase",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "purchaseDiscountAccount",
+ header: "Purchase Discount",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "purchaseCreditAccount",
+ header: "Purchase Credit",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "purchasePrepaymentAccount",
+ header: "Purchase Prepayment",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "purchaseTaxPayableAccount",
+ header: "Purchase Tax Payable",
+ cell: (item) => item.getValue(),
+ },
+ ];
+ }, [supplierTypes, partGroups]);
+
+ const editableComponents = useMemo(
+ () => ({
+ purchaseAccount: EditableList(
+ handleCellEdit,
+ incomeStatementAccountOptions
+ ),
+ purchaseDiscountAccount: EditableList(
+ handleCellEdit,
+ incomeStatementAccountOptions
+ ),
+ purchaseCreditAccount: EditableList(
+ handleCellEdit,
+ balanceSheetAccountOptions
+ ),
+ purchasePrepaymentAccount: EditableList(
+ handleCellEdit,
+ balanceSheetAccountOptions
+ ),
+ purchaseTaxPayableAccount: EditableList(
+ handleCellEdit,
+ balanceSheetAccountOptions
+ ),
+ }),
+ [handleCellEdit, balanceSheetAccountOptions, incomeStatementAccountOptions]
+ );
+
+ return (
+ <Table<PurchasingPostingGroup>
+ data={data}
+ columns={columns}
+ count={count}
+ editableComponents={editableComponents}
+ withInlineEditing={canEdit}
+ />
+ );
+};
+
+export default PurchasingPostingGroupsTable;
diff --git a/apps/carbon/app/modules/accounting/ui/PostingGroups/SalesPostingGroupsFilters.tsx b/apps/carbon/app/modules/accounting/ui/PostingGroups/SalesPostingGroupsFilters.tsx
new file mode 100644
index 0000000000..da196903d6
--- /dev/null
+++ b/apps/carbon/app/modules/accounting/ui/PostingGroups/SalesPostingGroupsFilters.tsx
@@ -0,0 +1,73 @@
+import { Select, useColor } from "@carbon/react";
+import { HStack } from "@chakra-ui/react";
+import { useUrlParams } from "~/hooks";
+import type { ListItem } from "~/types";
+
+type SalesPostingGroupsFiltersProps = {
+ partGroups: ListItem[];
+ customerTypes: ListItem[];
+};
+
+const SalesPostingGroupsFilters = ({
+ partGroups,
+ customerTypes,
+}: SalesPostingGroupsFiltersProps) => {
+ const [params, setParams] = useUrlParams();
+ const borderColor = useColor("gray.200");
+
+ const partGroupOptions = partGroups.map((partGroup) => ({
+ label: partGroup.name,
+ value: partGroup.id,
+ }));
+
+ const customerTypeOptions = customerTypes.map((customerType) => ({
+ label: customerType.name,
+ value: customerType.id,
+ }));
+
+ return (
+ <HStack
+ borderBottomColor={borderColor}
+ borderBottomStyle="solid"
+ borderBottomWidth={1}
+ justifyContent="flex-start"
+ px={4}
+ py={3}
+ spacing={4}
+ w="full"
+ >
+ <Select
+ // @ts-ignore
+ size="sm"
+ isClearable
+ value={partGroupOptions.find(
+ (partGroup) => partGroup.value === params.get("partGroup")
+ )}
+ options={partGroupOptions}
+ onChange={(selected) => {
+ setParams({ partGroup: selected?.value });
+ }}
+ aria-label="Part Group"
+ minW={180}
+ placeholder="Part Group"
+ />
+ <Select
+ // @ts-ignore
+ size="sm"
+ isClearable
+ value={customerTypeOptions.find(
+ (customerType) => customerType.value === params.get("customerType")
+ )}
+ options={customerTypeOptions}
+ onChange={(selected) => {
+ setParams({ customerType: selected?.value });
+ }}
+ aria-label="Customer Type"
+ minW={180}
+ placeholder="Customer Type"
+ />
+ </HStack>
+ );
+};
+
+export default SalesPostingGroupsFilters;
diff --git a/apps/carbon/app/modules/accounting/ui/PostingGroups/SalesPostingGroupsTable.tsx b/apps/carbon/app/modules/accounting/ui/PostingGroups/SalesPostingGroupsTable.tsx
new file mode 100644
index 0000000000..3fcef171ff
--- /dev/null
+++ b/apps/carbon/app/modules/accounting/ui/PostingGroups/SalesPostingGroupsTable.tsx
@@ -0,0 +1,120 @@
+import type { ColumnDef } from "@tanstack/react-table";
+import { useMemo } from "react";
+import { Table } from "~/components";
+import { EditableList } from "~/components/Editable";
+import type { AccountListItem, SalesPostingGroup } from "~/modules/accounting";
+import type { ListItem } from "~/types";
+import usePostingGroups from "./usePostingGroups";
+
+type SalesPostingGroupsTableProps = {
+ data: SalesPostingGroup[];
+ count: number;
+ partGroups: ListItem[];
+ customerTypes: ListItem[];
+ balanceSheetAccounts: AccountListItem[];
+ incomeStatementAccounts: AccountListItem[];
+};
+
+const SalesPostingGroupsTable = ({
+ data,
+ count,
+ partGroups,
+ customerTypes,
+ balanceSheetAccounts,
+ incomeStatementAccounts,
+}: SalesPostingGroupsTableProps) => {
+ const { canEdit, handleCellEdit } = usePostingGroups("postingGroupSales");
+
+ const balanceSheetAccountOptions = useMemo(() => {
+ return balanceSheetAccounts.map((account) => ({
+ label: account.number,
+ value: account.number,
+ }));
+ }, [balanceSheetAccounts]);
+
+ const incomeStatementAccountOptions = useMemo(() => {
+ return incomeStatementAccounts.map((account) => ({
+ label: account.number,
+ value: account.number,
+ }));
+ }, [incomeStatementAccounts]);
+
+ const columns = useMemo<ColumnDef<SalesPostingGroup>[]>(() => {
+ return [
+ {
+ id: "partGroup",
+ header: "Part Group",
+ cell: ({ row }) =>
+ partGroups.find((group) => group.id === row.original.partGroupId)
+ ?.name,
+ },
+ {
+ id: "customerType",
+ header: "Customer Type",
+ cell: ({ row }) =>
+ customerTypes.find((type) => type.id === row.original.customerTypeId)
+ ?.name,
+ },
+ {
+ accessorKey: "salesAccount",
+ header: "Sales",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "salesDiscountAccount",
+ header: "Sales Discount",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "salesCreditAccount",
+ header: "Sales Credit",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "salesPrepaymentAccount",
+ header: "Sales Prepayment",
+ cell: (item) => item.getValue(),
+ },
+ {
+ accessorKey: "salesTaxPayableAccount",
+ header: "Sales Tax Payable",
+ cell: (item) => item.getValue(),
+ },
+ ];
+ }, [customerTypes, partGroups]);
+
+ const editableComponents = useMemo(
+ () => ({
+ salesAccount: EditableList(handleCellEdit, incomeStatementAccountOptions),
+ salesDiscountAccount: EditableList(
+ handleCellEdit,
+ incomeStatementAccountOptions
+ ),
+ salesCreditAccount: EditableList(
+ handleCellEdit,
+ balanceSheetAccountOptions
+ ),
+ salesPrepaymentAccount: EditableList(
+ handleCellEdit,
+ balanceSheetAccountOptions
+ ),
+ salesTaxPayableAccount: EditableList(
+ handleCellEdit,
+ balanceSheetAccountOptions
+ ),
+ }),
+ [handleCellEdit, balanceSheetAccountOptions, incomeStatementAccountOptions]
+ );
+
+ return (
+ <Table<SalesPostingGroup>
+ data={data}
+ columns={columns}
+ count={count}
+ editableComponents={editableComponents}
+ withInlineEditing={canEdit}
+ />
+ );
+};
+
+export default SalesPostingGroupsTable;
diff --git a/apps/carbon/app/modules/accounting/ui/PostingGroups/index.ts b/apps/carbon/app/modules/accounting/ui/PostingGroups/index.ts
new file mode 100644
index 0000000000..4cd473cd05
--- /dev/null
+++ b/apps/carbon/app/modules/accounting/ui/PostingGroups/index.ts
@@ -0,0 +1,15 @@
+import InventoryPostingGroupsFilters from "./InventoryPostingGroupsFilters";
+import InventoryPostingGroupsTable from "./InventoryPostingGroupsTable";
+import PurchasingPostingGroupsFilters from "./PurchasingPostingGroupsFilters";
+import PurchasingPostingGroupsTable from "./PurchasingPostingGroupsTable";
+import SalesPostingGroupsFilters from "./SalesPostingGroupsFilters";
+import SalesPostingGroupsTable from "./SalesPostingGroupsTable";
+
+export {
+ InventoryPostingGroupsFilters,
+ InventoryPostingGroupsTable,
+ PurchasingPostingGroupsFilters,
+ PurchasingPostingGroupsTable,
+ SalesPostingGroupsFilters,
+ SalesPostingGroupsTable,
+};
diff --git a/apps/carbon/app/modules/accounting/ui/PostingGroups/usePostingGroups.tsx b/apps/carbon/app/modules/accounting/ui/PostingGroups/usePostingGroups.tsx
new file mode 100644
index 0000000000..b48d7fc0fe
--- /dev/null
+++ b/apps/carbon/app/modules/accounting/ui/PostingGroups/usePostingGroups.tsx
@@ -0,0 +1,40 @@
+import { useCallback } from "react";
+import { usePermissions } from "~/hooks";
+import { useSupabase } from "~/lib/supabase";
+import type {
+ InventoryPostingGroup,
+ PurchasingPostingGroup,
+ SalesPostingGroup,
+} from "~/modules/accounting";
+
+export default function usePostingGroups(table: string) {
+ const { supabase } = useSupabase();
+ const permissions = usePermissions();
+
+ const canEdit = permissions.can("update", "accounting");
+ const canDelete = permissions.can("delete", "accounting");
+
+ const handleCellEdit = useCallback(
+ async (
+ id: string,
+ value: unknown,
+ row: PurchasingPostingGroup | SalesPostingGroup | InventoryPostingGroup
+ ) => {
+ if (!supabase) throw new Error("Supabase client not found");
+ return await supabase
+ .from(table)
+ .update({
+ [id]: value,
+ })
+ .eq("id", row.id);
+ },
+ [supabase, table]
+ );
+
+ return {
+ canDelete,
+ canEdit,
+ supabase,
+ handleCellEdit,
+ };
+}
diff --git a/apps/carbon/app/modules/accounting/interfaces/index.ts b/apps/carbon/app/modules/accounting/ui/index.ts
similarity index 76%
rename from apps/carbon/app/modules/accounting/interfaces/index.ts
rename to apps/carbon/app/modules/accounting/ui/index.ts
index 389a6af6ca..5403376c36 100644
--- a/apps/carbon/app/modules/accounting/interfaces/index.ts
+++ b/apps/carbon/app/modules/accounting/ui/index.ts
@@ -1,7 +1,9 @@
import useAccountingSidebar from "./useAccountingSidebar";
-export { useAccountingSidebar };
export * from "./AccountCategories";
+export * from "./AccountDefaults";
export * from "./ChartOfAccounts";
export * from "./Currencies";
export * from "./PaymentTerms";
+export * from "./PostingGroups";
+export { useAccountingSidebar };
diff --git a/apps/carbon/app/modules/accounting/interfaces/useAccountingSidebar.tsx b/apps/carbon/app/modules/accounting/ui/useAccountingSidebar.tsx
similarity index 65%
rename from apps/carbon/app/modules/accounting/interfaces/useAccountingSidebar.tsx
rename to apps/carbon/app/modules/accounting/ui/useAccountingSidebar.tsx
index ad1539063c..53fdfc981b 100644
--- a/apps/carbon/app/modules/accounting/interfaces/useAccountingSidebar.tsx
+++ b/apps/carbon/app/modules/accounting/ui/useAccountingSidebar.tsx
@@ -10,21 +10,51 @@ const accountingRoutes: AuthenticatedRouteGroup[] = [
to: "/x/accounting/charts",
role: "employee",
},
+ // {
+ // name: "Journal Entries",
+ // to: "/x/accounting/journals",
+ // role: "employee",
+ // },
],
},
{
- name: "Configure",
+ name: "Posting Groups",
routes: [
{
- name: "Currencies",
- to: "/x/accounting/currencies",
+ name: "Inventory Groups",
+ to: "/x/accounting/groups/inventory",
+ role: "employee",
+ },
+ {
+ name: "Purchasing Groups",
+ to: "/x/accounting/groups/purchasing",
role: "employee",
},
{
- name: "G/L Categories",
+ name: "Sales Groups",
+ to: "/x/accounting/groups/sales",
+ role: "employee",
+ },
+ ],
+ },
+ {
+ name: "Configure",
+ routes: [
+ {
+ name: "Account Categories",
to: "/x/accounting/categories",
role: "employee",
},
+ {
+ name: "Account Defaults",
+ to: "/x/accounting/defaults",
+ role: "employee",
+ },
+ {
+ name: "Currencies",
+ to: "/x/accounting/currencies",
+ role: "employee",
+ },
{
name: "Payment Terms",
to: "/x/accounting/payment-terms",
diff --git a/apps/carbon/app/modules/documents/index.ts b/apps/carbon/app/modules/documents/index.ts
index 684aed031a..83b8af135e 100644
--- a/apps/carbon/app/modules/documents/index.ts
+++ b/apps/carbon/app/modules/documents/index.ts
@@ -1,3 +1,3 @@
export * from "./services";
-export * from "./interfaces";
export * from "./types";
+export * from "./ui";
diff --git a/apps/carbon/app/modules/documents/interfaces/Documents/DocumentCreateForm/DocumentCreateForm.tsx b/apps/carbon/app/modules/documents/ui/Documents/DocumentCreateForm/DocumentCreateForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/documents/interfaces/Documents/DocumentCreateForm/DocumentCreateForm.tsx
rename to apps/carbon/app/modules/documents/ui/Documents/DocumentCreateForm/DocumentCreateForm.tsx
diff --git a/apps/carbon/app/modules/documents/interfaces/Documents/DocumentCreateForm/index.ts b/apps/carbon/app/modules/documents/ui/Documents/DocumentCreateForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/documents/interfaces/Documents/DocumentCreateForm/index.ts
rename to apps/carbon/app/modules/documents/ui/Documents/DocumentCreateForm/index.ts
diff --git a/apps/carbon/app/modules/documents/interfaces/Documents/DocumentForm/DocumentForm.tsx b/apps/carbon/app/modules/documents/ui/Documents/DocumentForm/DocumentForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/documents/interfaces/Documents/DocumentForm/DocumentForm.tsx
rename to apps/carbon/app/modules/documents/ui/Documents/DocumentForm/DocumentForm.tsx
diff --git a/apps/carbon/app/modules/documents/interfaces/Documents/DocumentForm/index.ts b/apps/carbon/app/modules/documents/ui/Documents/DocumentForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/documents/interfaces/Documents/DocumentForm/index.ts
rename to apps/carbon/app/modules/documents/ui/Documents/DocumentForm/index.ts
diff --git a/apps/carbon/app/modules/documents/interfaces/Documents/DocumentIcon/DocumentIcon.tsx b/apps/carbon/app/modules/documents/ui/Documents/DocumentIcon/DocumentIcon.tsx
similarity index 100%
rename from apps/carbon/app/modules/documents/interfaces/Documents/DocumentIcon/DocumentIcon.tsx
rename to apps/carbon/app/modules/documents/ui/Documents/DocumentIcon/DocumentIcon.tsx
diff --git a/apps/carbon/app/modules/documents/interfaces/Documents/DocumentIcon/index.ts b/apps/carbon/app/modules/documents/ui/Documents/DocumentIcon/index.ts
similarity index 100%
rename from apps/carbon/app/modules/documents/interfaces/Documents/DocumentIcon/index.ts
rename to apps/carbon/app/modules/documents/ui/Documents/DocumentIcon/index.ts
diff --git a/apps/carbon/app/modules/documents/interfaces/Documents/DocumentsTable/DocumentsTable.tsx b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable/DocumentsTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/documents/interfaces/Documents/DocumentsTable/DocumentsTable.tsx
rename to apps/carbon/app/modules/documents/ui/Documents/DocumentsTable/DocumentsTable.tsx
diff --git a/apps/carbon/app/modules/documents/interfaces/Documents/DocumentsTable/index.ts b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/documents/interfaces/Documents/DocumentsTable/index.ts
rename to apps/carbon/app/modules/documents/ui/Documents/DocumentsTable/index.ts
diff --git a/apps/carbon/app/modules/documents/interfaces/Documents/DocumentsTableFilters/DocumentsTableFilters.tsx b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTableFilters/DocumentsTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/documents/interfaces/Documents/DocumentsTableFilters/DocumentsTableFilters.tsx
rename to apps/carbon/app/modules/documents/ui/Documents/DocumentsTableFilters/DocumentsTableFilters.tsx
diff --git a/apps/carbon/app/modules/documents/interfaces/Documents/DocumentsTableFilters/index.ts b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/documents/interfaces/Documents/DocumentsTableFilters/index.ts
rename to apps/carbon/app/modules/documents/ui/Documents/DocumentsTableFilters/index.ts
diff --git a/apps/carbon/app/modules/documents/interfaces/Documents/index.ts b/apps/carbon/app/modules/documents/ui/Documents/index.ts
similarity index 100%
rename from apps/carbon/app/modules/documents/interfaces/Documents/index.ts
rename to apps/carbon/app/modules/documents/ui/Documents/index.ts
diff --git a/apps/carbon/app/modules/documents/interfaces/Documents/useDocument.ts b/apps/carbon/app/modules/documents/ui/Documents/useDocument.ts
similarity index 100%
rename from apps/carbon/app/modules/documents/interfaces/Documents/useDocument.ts
rename to apps/carbon/app/modules/documents/ui/Documents/useDocument.ts
diff --git a/apps/carbon/app/modules/documents/interfaces/index.ts b/apps/carbon/app/modules/documents/ui/index.ts
similarity index 100%
rename from apps/carbon/app/modules/documents/interfaces/index.ts
rename to apps/carbon/app/modules/documents/ui/index.ts
diff --git a/apps/carbon/app/modules/documents/interfaces/useDocumentsSidebar.tsx b/apps/carbon/app/modules/documents/ui/useDocumentsSidebar.tsx
similarity index 100%
rename from apps/carbon/app/modules/documents/interfaces/useDocumentsSidebar.tsx
rename to apps/carbon/app/modules/documents/ui/useDocumentsSidebar.tsx
diff --git a/apps/carbon/app/modules/inventory/index.ts b/apps/carbon/app/modules/inventory/index.ts
index 490fd762ea..83b8af135e 100644
--- a/apps/carbon/app/modules/inventory/index.ts
+++ b/apps/carbon/app/modules/inventory/index.ts
@@ -1,3 +1,3 @@
-export * from "./interfaces";
export * from "./services";
export * from "./types";
+export * from "./ui";
diff --git a/apps/carbon/app/modules/inventory/interfaces/Receipts/ReceiptForm/ReceiptForm.tsx b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/inventory/interfaces/Receipts/ReceiptForm/ReceiptForm.tsx
rename to apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/ReceiptForm.tsx
diff --git a/apps/carbon/app/modules/inventory/interfaces/Receipts/ReceiptForm/index.ts b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/inventory/interfaces/Receipts/ReceiptForm/index.ts
rename to apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/index.ts
diff --git a/apps/carbon/app/modules/inventory/interfaces/Receipts/ReceiptForm/useReceiptForm.tsx b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/useReceiptForm.tsx
similarity index 99%
rename from apps/carbon/app/modules/inventory/interfaces/Receipts/ReceiptForm/useReceiptForm.tsx
rename to apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/useReceiptForm.tsx
index 77927b8f61..5074939a0f 100644
--- a/apps/carbon/app/modules/inventory/interfaces/Receipts/ReceiptForm/useReceiptForm.tsx
+++ b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptForm/useReceiptForm.tsx
@@ -350,7 +350,6 @@ export default function useReceiptForm({
const receiptLineEditableComponents = useMemo(
() => ({
receivedQuantity: EditableNumber(handleCellEdit),
- unitPrice: EditableNumber(handleCellEdit),
}),
[handleCellEdit]
);
diff --git a/apps/carbon/app/modules/inventory/interfaces/Receipts/ReceiptsTable/ReceiptsTable.tsx b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptsTable/ReceiptsTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/inventory/interfaces/Receipts/ReceiptsTable/ReceiptsTable.tsx
rename to apps/carbon/app/modules/inventory/ui/Receipts/ReceiptsTable/ReceiptsTable.tsx
diff --git a/apps/carbon/app/modules/inventory/interfaces/Receipts/ReceiptsTable/index.ts b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptsTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/inventory/interfaces/Receipts/ReceiptsTable/index.ts
rename to apps/carbon/app/modules/inventory/ui/Receipts/ReceiptsTable/index.ts
diff --git a/apps/carbon/app/modules/inventory/interfaces/Receipts/ReceiptsTableFilters/ReceiptsTableFilters.tsx b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptsTableFilters/ReceiptsTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/inventory/interfaces/Receipts/ReceiptsTableFilters/ReceiptsTableFilters.tsx
rename to apps/carbon/app/modules/inventory/ui/Receipts/ReceiptsTableFilters/ReceiptsTableFilters.tsx
diff --git a/apps/carbon/app/modules/inventory/interfaces/Receipts/ReceiptsTableFilters/index.ts b/apps/carbon/app/modules/inventory/ui/Receipts/ReceiptsTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/inventory/interfaces/Receipts/ReceiptsTableFilters/index.ts
rename to apps/carbon/app/modules/inventory/ui/Receipts/ReceiptsTableFilters/index.ts
diff --git a/apps/carbon/app/modules/inventory/interfaces/Receipts/index.ts b/apps/carbon/app/modules/inventory/ui/Receipts/index.ts
similarity index 100%
rename from apps/carbon/app/modules/inventory/interfaces/Receipts/index.ts
rename to apps/carbon/app/modules/inventory/ui/Receipts/index.ts
diff --git a/apps/carbon/app/modules/inventory/interfaces/ShippingMethods/ShippingMethodForm/ShippingMethodForm.tsx b/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodForm/ShippingMethodForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/inventory/interfaces/ShippingMethods/ShippingMethodForm/ShippingMethodForm.tsx
rename to apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodForm/ShippingMethodForm.tsx
diff --git a/apps/carbon/app/modules/inventory/interfaces/ShippingMethods/ShippingMethodForm/index.ts b/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/inventory/interfaces/ShippingMethods/ShippingMethodForm/index.ts
rename to apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodForm/index.ts
diff --git a/apps/carbon/app/modules/inventory/interfaces/ShippingMethods/ShippingMethodsTable/ShippingMethodsTable.tsx b/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodsTable/ShippingMethodsTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/inventory/interfaces/ShippingMethods/ShippingMethodsTable/ShippingMethodsTable.tsx
rename to apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodsTable/ShippingMethodsTable.tsx
diff --git a/apps/carbon/app/modules/inventory/interfaces/ShippingMethods/ShippingMethodsTable/index.ts b/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodsTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/inventory/interfaces/ShippingMethods/ShippingMethodsTable/index.ts
rename to apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodsTable/index.ts
diff --git a/apps/carbon/app/modules/inventory/interfaces/ShippingMethods/ShippingMethodsTableFilters/ShippingMethodsTableFilters.tsx b/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodsTableFilters/ShippingMethodsTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/inventory/interfaces/ShippingMethods/ShippingMethodsTableFilters/ShippingMethodsTableFilters.tsx
rename to apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodsTableFilters/ShippingMethodsTableFilters.tsx
diff --git a/apps/carbon/app/modules/inventory/interfaces/ShippingMethods/ShippingMethodsTableFilters/index.ts b/apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodsTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/inventory/interfaces/ShippingMethods/ShippingMethodsTableFilters/index.ts
rename to apps/carbon/app/modules/inventory/ui/ShippingMethods/ShippingMethodsTableFilters/index.ts
diff --git a/apps/carbon/app/modules/inventory/interfaces/ShippingMethods/index.ts b/apps/carbon/app/modules/inventory/ui/ShippingMethods/index.ts
similarity index 100%
rename from apps/carbon/app/modules/inventory/interfaces/ShippingMethods/index.ts
rename to apps/carbon/app/modules/inventory/ui/ShippingMethods/index.ts
diff --git a/apps/carbon/app/modules/inventory/interfaces/index.ts b/apps/carbon/app/modules/inventory/ui/index.ts
similarity index 100%
rename from apps/carbon/app/modules/inventory/interfaces/index.ts
rename to apps/carbon/app/modules/inventory/ui/index.ts
diff --git a/apps/carbon/app/modules/inventory/interfaces/useInventorySidebar.tsx b/apps/carbon/app/modules/inventory/ui/useInventorySidebar.tsx
similarity index 100%
rename from apps/carbon/app/modules/inventory/interfaces/useInventorySidebar.tsx
rename to apps/carbon/app/modules/inventory/ui/useInventorySidebar.tsx
diff --git a/apps/carbon/app/modules/parts/index.ts b/apps/carbon/app/modules/parts/index.ts
index 684aed031a..83b8af135e 100644
--- a/apps/carbon/app/modules/parts/index.ts
+++ b/apps/carbon/app/modules/parts/index.ts
@@ -1,3 +1,3 @@
export * from "./services";
-export * from "./interfaces";
export * from "./types";
+export * from "./ui";
diff --git a/apps/carbon/app/modules/parts/services/parts.form.ts b/apps/carbon/app/modules/parts/services/parts.form.ts
index 0fd26148d6..ea1b2bb245 100644
--- a/apps/carbon/app/modules/parts/services/parts.form.ts
+++ b/apps/carbon/app/modules/parts/services/parts.form.ts
@@ -45,13 +45,6 @@ export const partGroupValidator = withZod(
id: zfd.text(z.string().optional()),
name: z.string().min(1, { message: "Name is required" }).max(255),
description: z.string().optional(),
- salesAccountId: zfd.text(z.string().optional()),
- discountAccountId: zfd.text(z.string().optional()),
- inventoryAccountId: zfd.text(z.string().optional()),
- // costOfGoodsSoldLaborAccountId: zfd.text(z.string().optional()),
- // costOfGoodsSoldMaterialAccountId: zfd.text(z.string().optional()),
- // costOfGoodsSoldOverheadAccountId: zfd.text(z.string().optional()),
- // costOfGoodsSoldSubcontractAccountId: zfd.text(z.string().optional()),
})
);
diff --git a/apps/carbon/app/modules/parts/services/parts.server.ts b/apps/carbon/app/modules/parts/services/parts.server.ts
index 283b002dd3..1a5c26ca75 100644
--- a/apps/carbon/app/modules/parts/services/parts.server.ts
+++ b/apps/carbon/app/modules/parts/services/parts.server.ts
@@ -7,6 +7,7 @@ import { sanitize } from "~/utils/supabase";
import type { PartReplenishmentSystem } from "../types";
import type {
partCostValidator,
+ partGroupValidator,
partInventoryValidator,
partManufacturingValidator,
partPlanningValidator,
@@ -20,7 +21,7 @@ export async function deletePartGroup(
client: SupabaseClient<Database>,
id: string
) {
- return client.from("partGroup").update({ active: false }).eq("id", id);
+ return client.from("partGroup").delete().eq("id", id);
}
export async function deleteUnitOfMeasure(
@@ -34,40 +35,23 @@ export async function getPartCost(
client: SupabaseClient<Database>,
id: string
) {
- return client
- .from("partCost")
- .select(
- "partId, costingMethod, standardCost, unitCost, salesAccountId, discountAccountId, inventoryAccountId, costIsAdjusted"
- )
- .eq("partId", id)
- .single();
+ return client.from("partCost").select("*").eq("partId", id).single();
}
export async function getPartGroup(
client: SupabaseClient<Database>,
id: string
) {
- return client
- .from("partGroup")
- .select(
- "id, name, description, salesAccountId, discountAccountId, inventoryAccountId"
- )
- .eq("id", id)
- .single();
+ return client.from("partGroup").select("*").eq("id", id).single();
}
export async function getPartGroups(
client: SupabaseClient<Database>,
args?: GenericQueryFilters & { name: string | null }
) {
- let query = client
- .from("partGroup")
- .select(
- "id, name, description, salesAccountId, discountAccountId, inventoryAccountId",
- {
- count: "exact",
- }
- );
+ let query = client.from("partGroup").select("*", {
+ count: "exact",
+ });
if (args?.name) {
query = query.ilike("name", `%${args.name}%`);
@@ -416,23 +400,13 @@ export async function upsertPartPurchasing(
export async function upsertPartGroup(
client: SupabaseClient<Database>,
partGroup:
- | {
- name: string;
- description?: string;
- salesAccountId?: string | null;
- inventoryAccountId?: string | null;
- discountAccountId?: string | null;
+ | (Omit<TypeOfValidator<typeof partGroupValidator>, "id"> & {
createdBy: string;
- }
- | {
+ })
+ | (Omit<TypeOfValidator<typeof partGroupValidator>, "id"> & {
id: string;
- name: string;
- description?: string;
- salesAccountId?: string | null;
- inventoryAccountId?: string | null;
- discountAccountId?: string | null;
updatedBy: string;
- }
+ })
) {
if ("createdBy" in partGroup) {
return client.from("partGroup").insert([partGroup]).select("id").single();
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartCostingForm/PartCostingForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartCostingForm/PartCostingForm.tsx
similarity index 74%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartCostingForm/PartCostingForm.tsx
rename to apps/carbon/app/modules/parts/ui/Part/PartCostingForm/PartCostingForm.tsx
index f9fd6dd4e6..7f2b34ddfb 100644
--- a/apps/carbon/app/modules/parts/interfaces/Part/PartCostingForm/PartCostingForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/Part/PartCostingForm/PartCostingForm.tsx
@@ -13,27 +13,18 @@ import { usePermissions } from "~/hooks";
import type { PartCostingMethod } from "~/modules/parts";
import { partCostValidator } from "~/modules/parts";
import type { TypeOfValidator } from "~/types/validators";
-import { mapRowsToOptions } from "~/utils/form";
type PartCostingFormProps = {
initialValues: TypeOfValidator<typeof partCostValidator>;
- accounts: { number: string; name: string }[];
partCostingMethods: PartCostingMethod[];
};
const PartCostingForm = ({
initialValues,
- accounts,
partCostingMethods,
}: PartCostingFormProps) => {
const permissions = usePermissions();
- const accountOptions = mapRowsToOptions({
- data: accounts,
- value: "number",
- label: "name",
- });
-
const partCostingMethodOptions = partCostingMethods.map(
(partCostingMethod) => ({
label: partCostingMethod,
@@ -68,25 +59,6 @@ const PartCostingForm = ({
<Number name="standardCost" label="Standard Cost" precision={2} />
<Number name="unitCost" label="Unit Cost" precision={2} />
</VStack>
- {permissions.has("accounting") && (
- <VStack alignItems="start" spacing={2} w="full">
- <Select
- name="salesAccountId"
- label="Sales Account"
- options={accountOptions}
- />
- <Select
- name="inventoryAccountId"
- label="Inventory Account"
- options={accountOptions}
- />
- <Select
- name="discountAccountId"
- label="Discount Account"
- options={accountOptions}
- />
- </VStack>
- )}
<VStack alignItems="start" spacing={2} w="full">
<Number
name="salesHistory"
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartCostingForm/index.ts b/apps/carbon/app/modules/parts/ui/Part/PartCostingForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartCostingForm/index.ts
rename to apps/carbon/app/modules/parts/ui/Part/PartCostingForm/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartForm/PartForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartForm/PartForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartForm/PartForm.tsx
rename to apps/carbon/app/modules/parts/ui/Part/PartForm/PartForm.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartForm/index.ts b/apps/carbon/app/modules/parts/ui/Part/PartForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartForm/index.ts
rename to apps/carbon/app/modules/parts/ui/Part/PartForm/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartInventoryForm/PartInventoryForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartInventoryForm/PartInventoryForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartInventoryForm/PartInventoryForm.tsx
rename to apps/carbon/app/modules/parts/ui/Part/PartInventoryForm/PartInventoryForm.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartInventoryForm/index.ts b/apps/carbon/app/modules/parts/ui/Part/PartInventoryForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartInventoryForm/index.ts
rename to apps/carbon/app/modules/parts/ui/Part/PartInventoryForm/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartManufacturingForm/PartManufacturingForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartManufacturingForm/PartManufacturingForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartManufacturingForm/PartManufacturingForm.tsx
rename to apps/carbon/app/modules/parts/ui/Part/PartManufacturingForm/PartManufacturingForm.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartManufacturingForm/index.ts b/apps/carbon/app/modules/parts/ui/Part/PartManufacturingForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartManufacturingForm/index.ts
rename to apps/carbon/app/modules/parts/ui/Part/PartManufacturingForm/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartPlanningForm/PartPlanningForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartPlanningForm/PartPlanningForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartPlanningForm/PartPlanningForm.tsx
rename to apps/carbon/app/modules/parts/ui/Part/PartPlanningForm/PartPlanningForm.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartPlanningForm/index.ts b/apps/carbon/app/modules/parts/ui/Part/PartPlanningForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartPlanningForm/index.ts
rename to apps/carbon/app/modules/parts/ui/Part/PartPlanningForm/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartPreview/PartPreview.tsx b/apps/carbon/app/modules/parts/ui/Part/PartPreview/PartPreview.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartPreview/PartPreview.tsx
rename to apps/carbon/app/modules/parts/ui/Part/PartPreview/PartPreview.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartPreview/index.ts b/apps/carbon/app/modules/parts/ui/Part/PartPreview/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartPreview/index.ts
rename to apps/carbon/app/modules/parts/ui/Part/PartPreview/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartPurchasingForm/PartPurchasingForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartPurchasingForm/PartPurchasingForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartPurchasingForm/PartPurchasingForm.tsx
rename to apps/carbon/app/modules/parts/ui/Part/PartPurchasingForm/PartPurchasingForm.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartPurchasingForm/index.ts b/apps/carbon/app/modules/parts/ui/Part/PartPurchasingForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartPurchasingForm/index.ts
rename to apps/carbon/app/modules/parts/ui/Part/PartPurchasingForm/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartSalePriceForm/PartSalePriceForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartSalePriceForm/PartSalePriceForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartSalePriceForm/PartSalePriceForm.tsx
rename to apps/carbon/app/modules/parts/ui/Part/PartSalePriceForm/PartSalePriceForm.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartSalePriceForm/index.ts b/apps/carbon/app/modules/parts/ui/Part/PartSalePriceForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartSalePriceForm/index.ts
rename to apps/carbon/app/modules/parts/ui/Part/PartSalePriceForm/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartSidebar/PartSidebar.tsx b/apps/carbon/app/modules/parts/ui/Part/PartSidebar/PartSidebar.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartSidebar/PartSidebar.tsx
rename to apps/carbon/app/modules/parts/ui/Part/PartSidebar/PartSidebar.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartSidebar/index.ts b/apps/carbon/app/modules/parts/ui/Part/PartSidebar/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartSidebar/index.ts
rename to apps/carbon/app/modules/parts/ui/Part/PartSidebar/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartSidebar/usePartSidebar.tsx b/apps/carbon/app/modules/parts/ui/Part/PartSidebar/usePartSidebar.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartSidebar/usePartSidebar.tsx
rename to apps/carbon/app/modules/parts/ui/Part/PartSidebar/usePartSidebar.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartSupplierForm/PartSupplierForm.tsx b/apps/carbon/app/modules/parts/ui/Part/PartSupplierForm/PartSupplierForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartSupplierForm/PartSupplierForm.tsx
rename to apps/carbon/app/modules/parts/ui/Part/PartSupplierForm/PartSupplierForm.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartSupplierForm/index.ts b/apps/carbon/app/modules/parts/ui/Part/PartSupplierForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartSupplierForm/index.ts
rename to apps/carbon/app/modules/parts/ui/Part/PartSupplierForm/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartSuppliers/PartSuppliers.tsx b/apps/carbon/app/modules/parts/ui/Part/PartSuppliers/PartSuppliers.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartSuppliers/PartSuppliers.tsx
rename to apps/carbon/app/modules/parts/ui/Part/PartSuppliers/PartSuppliers.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartSuppliers/index.ts b/apps/carbon/app/modules/parts/ui/Part/PartSuppliers/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartSuppliers/index.ts
rename to apps/carbon/app/modules/parts/ui/Part/PartSuppliers/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/PartSuppliers/usePartSuppliers.tsx b/apps/carbon/app/modules/parts/ui/Part/PartSuppliers/usePartSuppliers.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/PartSuppliers/usePartSuppliers.tsx
rename to apps/carbon/app/modules/parts/ui/Part/PartSuppliers/usePartSuppliers.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/Part/index.ts b/apps/carbon/app/modules/parts/ui/Part/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Part/index.ts
rename to apps/carbon/app/modules/parts/ui/Part/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/PartGroups/PartGroupForm/PartGroupForm.tsx b/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm/PartGroupForm.tsx
similarity index 71%
rename from apps/carbon/app/modules/parts/interfaces/PartGroups/PartGroupForm/PartGroupForm.tsx
rename to apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm/PartGroupForm.tsx
index ab5d743566..bc56b2f0d5 100644
--- a/apps/carbon/app/modules/parts/interfaces/PartGroups/PartGroupForm/PartGroupForm.tsx
+++ b/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm/PartGroupForm.tsx
@@ -12,11 +12,10 @@ import {
} from "@chakra-ui/react";
import { useNavigate } from "@remix-run/react";
import { ValidatedForm } from "remix-validated-form";
-import { Hidden, Input, Select, Submit, TextArea } from "~/components/Form";
+import { Hidden, Input, Submit, TextArea } from "~/components/Form";
import { usePermissions } from "~/hooks";
import { partGroupValidator } from "~/modules/parts";
import type { TypeOfValidator } from "~/types/validators";
-import { mapRowsToOptions } from "~/utils/form";
type PartGroupFormProps = {
initialValues: TypeOfValidator<typeof partGroupValidator>;
@@ -36,12 +35,6 @@ const PartGroupForm = ({ accounts, initialValues }: PartGroupFormProps) => {
? !permissions.can("update", "parts")
: !permissions.can("create", "parts");
- const accountOptions = mapRowsToOptions({
- data: accounts,
- value: "number",
- label: "name",
- });
-
return (
<Drawer onClose={onClose} isOpen={true} size="sm">
<ValidatedForm
@@ -63,25 +56,6 @@ const PartGroupForm = ({ accounts, initialValues }: PartGroupFormProps) => {
<VStack spacing={4} alignItems="start">
<Input name="name" label="Part Group" />
<TextArea name="description" label="Description" />
- {permissions.has("accounting") && (
- <>
- <Select
- name="salesAccountId"
- label="Sales Account"
- options={accountOptions}
- />
- <Select
- name="discountAccountId"
- label="Discount Account"
- options={accountOptions}
- />
- <Select
- name="inventoryAccountId"
- label="Inventory Account"
- options={accountOptions}
- />
- </>
- )}
</VStack>
</DrawerBody>
<DrawerFooter>
diff --git a/apps/carbon/app/modules/parts/interfaces/PartGroups/PartGroupForm/index.ts b/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/PartGroups/PartGroupForm/index.ts
rename to apps/carbon/app/modules/parts/ui/PartGroups/PartGroupForm/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/PartGroups/PartGroupsTable/PartGroupsTable.tsx b/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupsTable/PartGroupsTable.tsx
similarity index 72%
rename from apps/carbon/app/modules/parts/interfaces/PartGroups/PartGroupsTable/PartGroupsTable.tsx
rename to apps/carbon/app/modules/parts/ui/PartGroups/PartGroupsTable/PartGroupsTable.tsx
index 13cf1508cd..fe686dbe83 100644
--- a/apps/carbon/app/modules/parts/interfaces/PartGroups/PartGroupsTable/PartGroupsTable.tsx
+++ b/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupsTable/PartGroupsTable.tsx
@@ -17,13 +17,13 @@ const PartGroupsTable = memo(({ data, count }: PartGroupsTableProps) => {
const [params] = useUrlParams();
const navigate = useNavigate();
const permissions = usePermissions();
- const hasAccounting =
- permissions.has("accounting") && permissions.can("view", "accounting");
+ // const hasAccounting =
+ // permissions.has("accounting") && permissions.can("view", "accounting");
const rows = useMemo(() => data, [data]);
- const columns = useMemo<ColumnDef<(typeof rows)[number]>[]>(() => {
- const result: ColumnDef<(typeof rows)[number]>[] = [
+ const columns = useMemo<ColumnDef<(typeof rows)[number]>[]>(
+ () => [
{
accessorKey: "name",
header: "Name",
@@ -38,28 +38,9 @@ const PartGroupsTable = memo(({ data, count }: PartGroupsTableProps) => {
header: "Description",
cell: (item) => item.getValue(),
},
- ];
-
- return hasAccounting
- ? result.concat([
- {
- accessorKey: "salesAccountId",
- header: "Sales Account",
- cell: (item) => item.getValue(),
- },
- {
- accessorKey: "inventoryAccountId",
- header: "Inventory Account",
- cell: (item) => item.getValue(),
- },
- {
- accessorKey: "discountAccountId",
- header: "Discount Account",
- cell: (item) => item.getValue(),
- },
- ])
- : result;
- }, [hasAccounting, navigate]);
+ ],
+ [navigate]
+ );
const renderContextMenu = useCallback(
(row: (typeof rows)[number]) => {
diff --git a/apps/carbon/app/modules/parts/interfaces/PartGroups/PartGroupsTable/index.ts b/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupsTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/PartGroups/PartGroupsTable/index.ts
rename to apps/carbon/app/modules/parts/ui/PartGroups/PartGroupsTable/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/PartGroups/PartGroupsTableFilters/PartGroupsTableFilters.tsx b/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupsTableFilters/PartGroupsTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/PartGroups/PartGroupsTableFilters/PartGroupsTableFilters.tsx
rename to apps/carbon/app/modules/parts/ui/PartGroups/PartGroupsTableFilters/PartGroupsTableFilters.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/PartGroups/PartGroupsTableFilters/index.ts b/apps/carbon/app/modules/parts/ui/PartGroups/PartGroupsTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/PartGroups/PartGroupsTableFilters/index.ts
rename to apps/carbon/app/modules/parts/ui/PartGroups/PartGroupsTableFilters/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/PartGroups/index.ts b/apps/carbon/app/modules/parts/ui/PartGroups/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/PartGroups/index.ts
rename to apps/carbon/app/modules/parts/ui/PartGroups/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/Parts/PartsTable/PartsTable.tsx b/apps/carbon/app/modules/parts/ui/Parts/PartsTable/PartsTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Parts/PartsTable/PartsTable.tsx
rename to apps/carbon/app/modules/parts/ui/Parts/PartsTable/PartsTable.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/Parts/PartsTable/index.ts b/apps/carbon/app/modules/parts/ui/Parts/PartsTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Parts/PartsTable/index.ts
rename to apps/carbon/app/modules/parts/ui/Parts/PartsTable/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/Parts/PartsTableFilters/PartsTableFilters.tsx b/apps/carbon/app/modules/parts/ui/Parts/PartsTableFilters/PartsTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Parts/PartsTableFilters/PartsTableFilters.tsx
rename to apps/carbon/app/modules/parts/ui/Parts/PartsTableFilters/PartsTableFilters.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/Parts/PartsTableFilters/index.ts b/apps/carbon/app/modules/parts/ui/Parts/PartsTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Parts/PartsTableFilters/index.ts
rename to apps/carbon/app/modules/parts/ui/Parts/PartsTableFilters/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/Parts/index.ts b/apps/carbon/app/modules/parts/ui/Parts/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Parts/index.ts
rename to apps/carbon/app/modules/parts/ui/Parts/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/Routing/PartsTree/PartsTree.tsx b/apps/carbon/app/modules/parts/ui/Routing/PartsTree/PartsTree.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Routing/PartsTree/PartsTree.tsx
rename to apps/carbon/app/modules/parts/ui/Routing/PartsTree/PartsTree.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/Routing/PartsTree/index.ts b/apps/carbon/app/modules/parts/ui/Routing/PartsTree/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Routing/PartsTree/index.ts
rename to apps/carbon/app/modules/parts/ui/Routing/PartsTree/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/Routing/index.ts b/apps/carbon/app/modules/parts/ui/Routing/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/Routing/index.ts
rename to apps/carbon/app/modules/parts/ui/Routing/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/UnitOfMeasure/UnitOfMeasureForm/UnitOfMeasureForm.tsx b/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasureForm/UnitOfMeasureForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/UnitOfMeasure/UnitOfMeasureForm/UnitOfMeasureForm.tsx
rename to apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasureForm/UnitOfMeasureForm.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/UnitOfMeasure/UnitOfMeasureForm/index.ts b/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasureForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/UnitOfMeasure/UnitOfMeasureForm/index.ts
rename to apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasureForm/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/UnitOfMeasure/UnitOfMeasuresTable/UnitOfMeasuresTable.tsx b/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasuresTable/UnitOfMeasuresTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/UnitOfMeasure/UnitOfMeasuresTable/UnitOfMeasuresTable.tsx
rename to apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasuresTable/UnitOfMeasuresTable.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/UnitOfMeasure/UnitOfMeasuresTable/index.ts b/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasuresTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/UnitOfMeasure/UnitOfMeasuresTable/index.ts
rename to apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasuresTable/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/UnitOfMeasure/UnitOfMeasuresTableFilters/UnitOfMeasuresTableFilters.tsx b/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasuresTableFilters/UnitOfMeasuresTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/UnitOfMeasure/UnitOfMeasuresTableFilters/UnitOfMeasuresTableFilters.tsx
rename to apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasuresTableFilters/UnitOfMeasuresTableFilters.tsx
diff --git a/apps/carbon/app/modules/parts/interfaces/UnitOfMeasure/UnitOfMeasuresTableFilters/index.ts b/apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasuresTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/UnitOfMeasure/UnitOfMeasuresTableFilters/index.ts
rename to apps/carbon/app/modules/parts/ui/UnitOfMeasure/UnitOfMeasuresTableFilters/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/UnitOfMeasure/index.ts b/apps/carbon/app/modules/parts/ui/UnitOfMeasure/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/UnitOfMeasure/index.ts
rename to apps/carbon/app/modules/parts/ui/UnitOfMeasure/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/index.ts b/apps/carbon/app/modules/parts/ui/index.ts
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/index.ts
rename to apps/carbon/app/modules/parts/ui/index.ts
diff --git a/apps/carbon/app/modules/parts/interfaces/usePartsSidebar.tsx b/apps/carbon/app/modules/parts/ui/usePartsSidebar.tsx
similarity index 100%
rename from apps/carbon/app/modules/parts/interfaces/usePartsSidebar.tsx
rename to apps/carbon/app/modules/parts/ui/usePartsSidebar.tsx
diff --git a/apps/carbon/app/modules/purchasing/index.ts b/apps/carbon/app/modules/purchasing/index.ts
index 684aed031a..83b8af135e 100644
--- a/apps/carbon/app/modules/purchasing/index.ts
+++ b/apps/carbon/app/modules/purchasing/index.ts
@@ -1,3 +1,3 @@
export * from "./services";
-export * from "./interfaces";
export * from "./types";
+export * from "./ui";
diff --git a/apps/carbon/app/modules/purchasing/services/purchasing.server.ts b/apps/carbon/app/modules/purchasing/services/purchasing.server.ts
index d95e648f67..8046695da2 100644
--- a/apps/carbon/app/modules/purchasing/services/purchasing.server.ts
+++ b/apps/carbon/app/modules/purchasing/services/purchasing.server.ts
@@ -11,6 +11,7 @@ import type {
purchaseOrderLineValidator,
purchaseOrderPaymentValidator,
purchaseOrderValidator,
+ supplierTypeValidator,
supplierValidator,
} from "./purchasing.form";
@@ -314,6 +315,10 @@ export async function getSupplierTypes(
return query;
}
+export async function getSupplierTypesList(client: SupabaseClient<Database>) {
+ return client.from("supplierType").select("id, name");
+}
+
export async function insertSupplier(
client: SupabaseClient<Database>,
supplier:
@@ -611,14 +616,26 @@ export async function upsertPurchaseOrderLine(
if ("id" in purchaseOrderLine) {
return client
.from("purchaseOrderLine")
- .update(sanitize(purchaseOrderLine))
+ .update(
+ sanitize({
+ ...purchaseOrderLine,
+ quantityToReceive: purchaseOrderLine.purchaseQuantity,
+ quantityToInvoice: purchaseOrderLine.purchaseQuantity,
+ })
+ )
.eq("id", purchaseOrderLine.id)
.select("id")
.single();
}
return client
.from("purchaseOrderLine")
- .insert([purchaseOrderLine])
+ .insert([
+ {
+ ...purchaseOrderLine,
+ quantityToReceive: purchaseOrderLine.purchaseQuantity,
+ quantityToInvoice: purchaseOrderLine.purchaseQuantity,
+ },
+ ])
.select("id")
.single();
}
@@ -651,11 +668,21 @@ export async function upsertPurchaseOrderPayment(
export async function upsertSupplierType(
client: SupabaseClient<Database>,
- supplierType: { id?: string; name: string; color: string | null }
+ supplierType:
+ | (Omit<TypeOfValidator<typeof supplierTypeValidator>, "id"> & {
+ createdBy: string;
+ })
+ | (Omit<TypeOfValidator<typeof supplierTypeValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
) {
- return client
- .from("supplierType")
- .upsert([supplierType])
- .select("id")
- .single();
+ if ("createdBy" in supplierType) {
+ return client.from("supplierType").insert([supplierType]);
+ } else {
+ return client
+ .from("supplierType")
+ .update(sanitize(supplierType))
+ .eq("id", supplierType.id);
+ }
}
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderDeliveryForm/PurchaseOrderDeliveryForm.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm/PurchaseOrderDeliveryForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderDeliveryForm/PurchaseOrderDeliveryForm.tsx
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm/PurchaseOrderDeliveryForm.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderDeliveryForm/index.ts b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderDeliveryForm/index.ts
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDeliveryForm/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderDocumentForm/PurchaseOrderDocumentForm.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDocumentForm/PurchaseOrderDocumentForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderDocumentForm/PurchaseOrderDocumentForm.tsx
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDocumentForm/PurchaseOrderDocumentForm.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderDocumentForm/index.ts b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDocumentForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderDocumentForm/index.ts
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderDocumentForm/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderForm/PurchaseOrderForm.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderForm/PurchaseOrderForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderForm/PurchaseOrderForm.tsx
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderForm/PurchaseOrderForm.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderForm/index.ts b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderForm/index.ts
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderForm/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderHeader/PurchaseOrderHeader.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader/PurchaseOrderHeader.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderHeader/PurchaseOrderHeader.tsx
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader/PurchaseOrderHeader.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderHeader/index.ts b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderHeader/index.ts
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderHeader/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderInternalDocuments/PurchaseOrderDocuments.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderInternalDocuments/PurchaseOrderDocuments.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderInternalDocuments/PurchaseOrderDocuments.tsx
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderInternalDocuments/PurchaseOrderDocuments.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderInternalDocuments/index.ts b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderInternalDocuments/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderInternalDocuments/index.ts
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderInternalDocuments/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderInternalDocuments/usePurchaseOrderDocuments.ts b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderInternalDocuments/usePurchaseOrderDocuments.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderInternalDocuments/usePurchaseOrderDocuments.ts
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderInternalDocuments/usePurchaseOrderDocuments.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderLineForm/PurchaseOrderLineForm.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm/PurchaseOrderLineForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderLineForm/PurchaseOrderLineForm.tsx
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm/PurchaseOrderLineForm.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderLineForm/index.ts b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderLineForm/index.ts
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLineForm/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderLines/PurchaseOrderLines.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/PurchaseOrderLines.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderLines/PurchaseOrderLines.tsx
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/PurchaseOrderLines.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderLines/index.ts b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderLines/index.ts
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderLines/usePurchaseOrderLines.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/usePurchaseOrderLines.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderLines/usePurchaseOrderLines.tsx
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderLines/usePurchaseOrderLines.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderPaymentForm/PurchaseOrderPaymentForm.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderPaymentForm/PurchaseOrderPaymentForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderPaymentForm/PurchaseOrderPaymentForm.tsx
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderPaymentForm/PurchaseOrderPaymentForm.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderPaymentForm/index.ts b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderPaymentForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderPaymentForm/index.ts
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderPaymentForm/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderSidebar/PurchaseOrderSidebar.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSidebar/PurchaseOrderSidebar.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderSidebar/PurchaseOrderSidebar.tsx
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSidebar/PurchaseOrderSidebar.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderSidebar/index.ts b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSidebar/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderSidebar/index.ts
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSidebar/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderSidebar/usePurchaseOrderSidebar.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSidebar/usePurchaseOrderSidebar.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/PurchaseOrderSidebar/usePurchaseOrderSidebar.tsx
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/PurchaseOrderSidebar/usePurchaseOrderSidebar.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/index.ts b/apps/carbon/app/modules/purchasing/ui/PurchaseOrder/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrder/index.ts
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrder/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrders/PurchaseOrdersTable/PurchaseOrdersTable.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTable/PurchaseOrdersTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrders/PurchaseOrdersTable/PurchaseOrdersTable.tsx
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTable/PurchaseOrdersTable.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrders/PurchaseOrdersTable/index.ts b/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrders/PurchaseOrdersTable/index.ts
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTable/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrders/PurchaseOrdersTableFilters/PurchaseOrdersTableFilters.tsx b/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTableFilters/PurchaseOrdersTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrders/PurchaseOrdersTableFilters/PurchaseOrdersTableFilters.tsx
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTableFilters/PurchaseOrdersTableFilters.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrders/PurchaseOrdersTableFilters/index.ts b/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrders/PurchaseOrdersTableFilters/index.ts
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrders/PurchaseOrdersTableFilters/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrders/index.ts b/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrders/index.ts
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrders/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/PurchaseOrders/usePurchaseOrder.ts b/apps/carbon/app/modules/purchasing/ui/PurchaseOrders/usePurchaseOrder.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/PurchaseOrders/usePurchaseOrder.ts
rename to apps/carbon/app/modules/purchasing/ui/PurchaseOrders/usePurchaseOrder.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/SupplierTypes/SupplierTypeForm/SupplierTypeForm.tsx b/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypeForm/SupplierTypeForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/SupplierTypes/SupplierTypeForm/SupplierTypeForm.tsx
rename to apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypeForm/SupplierTypeForm.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/SupplierTypes/SupplierTypeForm/index.ts b/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypeForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/SupplierTypes/SupplierTypeForm/index.ts
rename to apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypeForm/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/SupplierTypes/SupplierTypesTable/SupplierTypesTable.tsx b/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypesTable/SupplierTypesTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/SupplierTypes/SupplierTypesTable/SupplierTypesTable.tsx
rename to apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypesTable/SupplierTypesTable.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/SupplierTypes/SupplierTypesTable/index.ts b/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypesTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/SupplierTypes/SupplierTypesTable/index.ts
rename to apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypesTable/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/SupplierTypes/SupplierTypesTableFilters/SupplierTypesTableFilters.tsx b/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypesTableFilters/SupplierTypesTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/SupplierTypes/SupplierTypesTableFilters/SupplierTypesTableFilters.tsx
rename to apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypesTableFilters/SupplierTypesTableFilters.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/SupplierTypes/SupplierTypesTableFilters/index.ts b/apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypesTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/SupplierTypes/SupplierTypesTableFilters/index.ts
rename to apps/carbon/app/modules/purchasing/ui/SupplierTypes/SupplierTypesTableFilters/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/SupplierTypes/index.ts b/apps/carbon/app/modules/purchasing/ui/SupplierTypes/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/SupplierTypes/index.ts
rename to apps/carbon/app/modules/purchasing/ui/SupplierTypes/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/Suppliers/SupplierForm/SupplierForm.tsx b/apps/carbon/app/modules/purchasing/ui/Suppliers/SupplierForm/SupplierForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/Suppliers/SupplierForm/SupplierForm.tsx
rename to apps/carbon/app/modules/purchasing/ui/Suppliers/SupplierForm/SupplierForm.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/Suppliers/SupplierForm/components/SupplierContacts.tsx b/apps/carbon/app/modules/purchasing/ui/Suppliers/SupplierForm/components/SupplierContacts.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/Suppliers/SupplierForm/components/SupplierContacts.tsx
rename to apps/carbon/app/modules/purchasing/ui/Suppliers/SupplierForm/components/SupplierContacts.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/Suppliers/SupplierForm/components/SupplierContactsForm.tsx b/apps/carbon/app/modules/purchasing/ui/Suppliers/SupplierForm/components/SupplierContactsForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/Suppliers/SupplierForm/components/SupplierContactsForm.tsx
rename to apps/carbon/app/modules/purchasing/ui/Suppliers/SupplierForm/components/SupplierContactsForm.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/Suppliers/SupplierForm/components/SupplierLocationForm.tsx b/apps/carbon/app/modules/purchasing/ui/Suppliers/SupplierForm/components/SupplierLocationForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/Suppliers/SupplierForm/components/SupplierLocationForm.tsx
rename to apps/carbon/app/modules/purchasing/ui/Suppliers/SupplierForm/components/SupplierLocationForm.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/Suppliers/SupplierForm/components/SupplierLocations.tsx b/apps/carbon/app/modules/purchasing/ui/Suppliers/SupplierForm/components/SupplierLocations.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/Suppliers/SupplierForm/components/SupplierLocations.tsx
rename to apps/carbon/app/modules/purchasing/ui/Suppliers/SupplierForm/components/SupplierLocations.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/Suppliers/SupplierForm/components/index.ts b/apps/carbon/app/modules/purchasing/ui/Suppliers/SupplierForm/components/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/Suppliers/SupplierForm/components/index.ts
rename to apps/carbon/app/modules/purchasing/ui/Suppliers/SupplierForm/components/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/Suppliers/SupplierForm/index.ts b/apps/carbon/app/modules/purchasing/ui/Suppliers/SupplierForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/Suppliers/SupplierForm/index.ts
rename to apps/carbon/app/modules/purchasing/ui/Suppliers/SupplierForm/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/Suppliers/SuppliersTable/SuppliersTable.tsx b/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTable/SuppliersTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/Suppliers/SuppliersTable/SuppliersTable.tsx
rename to apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTable/SuppliersTable.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/Suppliers/SuppliersTable/index.ts b/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/Suppliers/SuppliersTable/index.ts
rename to apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTable/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/Suppliers/SuppliersTableFilters/SuppliersTableFilters.tsx b/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTableFilters/SuppliersTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/Suppliers/SuppliersTableFilters/SuppliersTableFilters.tsx
rename to apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTableFilters/SuppliersTableFilters.tsx
diff --git a/apps/carbon/app/modules/purchasing/interfaces/Suppliers/SuppliersTableFilters/index.ts b/apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/Suppliers/SuppliersTableFilters/index.ts
rename to apps/carbon/app/modules/purchasing/ui/Suppliers/SuppliersTableFilters/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/Suppliers/index.ts b/apps/carbon/app/modules/purchasing/ui/Suppliers/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/Suppliers/index.ts
rename to apps/carbon/app/modules/purchasing/ui/Suppliers/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/index.ts b/apps/carbon/app/modules/purchasing/ui/index.ts
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/index.ts
rename to apps/carbon/app/modules/purchasing/ui/index.ts
diff --git a/apps/carbon/app/modules/purchasing/interfaces/usePurchasingSidebar.tsx b/apps/carbon/app/modules/purchasing/ui/usePurchasingSidebar.tsx
similarity index 100%
rename from apps/carbon/app/modules/purchasing/interfaces/usePurchasingSidebar.tsx
rename to apps/carbon/app/modules/purchasing/ui/usePurchasingSidebar.tsx
diff --git a/apps/carbon/app/modules/resources/index.ts b/apps/carbon/app/modules/resources/index.ts
index 684aed031a..83b8af135e 100644
--- a/apps/carbon/app/modules/resources/index.ts
+++ b/apps/carbon/app/modules/resources/index.ts
@@ -1,3 +1,3 @@
export * from "./services";
-export * from "./interfaces";
export * from "./types";
+export * from "./ui";
diff --git a/apps/carbon/app/modules/resources/interfaces/Abilities/AbilitiesTable/AbilitiesTable.tsx b/apps/carbon/app/modules/resources/ui/Abilities/AbilitiesTable/AbilitiesTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Abilities/AbilitiesTable/AbilitiesTable.tsx
rename to apps/carbon/app/modules/resources/ui/Abilities/AbilitiesTable/AbilitiesTable.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Abilities/AbilitiesTable/index.ts b/apps/carbon/app/modules/resources/ui/Abilities/AbilitiesTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Abilities/AbilitiesTable/index.ts
rename to apps/carbon/app/modules/resources/ui/Abilities/AbilitiesTable/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Abilities/AbilitiesTableFilters/AbilitiesTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Abilities/AbilitiesTableFilters/AbilitiesTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Abilities/AbilitiesTableFilters/AbilitiesTableFilters.tsx
rename to apps/carbon/app/modules/resources/ui/Abilities/AbilitiesTableFilters/AbilitiesTableFilters.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Abilities/AbilitiesTableFilters/index.ts b/apps/carbon/app/modules/resources/ui/Abilities/AbilitiesTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Abilities/AbilitiesTableFilters/index.ts
rename to apps/carbon/app/modules/resources/ui/Abilities/AbilitiesTableFilters/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Abilities/AbilityChart/AbilityChart.tsx b/apps/carbon/app/modules/resources/ui/Abilities/AbilityChart/AbilityChart.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Abilities/AbilityChart/AbilityChart.tsx
rename to apps/carbon/app/modules/resources/ui/Abilities/AbilityChart/AbilityChart.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Abilities/AbilityChart/index.ts b/apps/carbon/app/modules/resources/ui/Abilities/AbilityChart/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Abilities/AbilityChart/index.ts
rename to apps/carbon/app/modules/resources/ui/Abilities/AbilityChart/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Abilities/AbilityEmployeesTable/AbilityEmployeesTable.tsx b/apps/carbon/app/modules/resources/ui/Abilities/AbilityEmployeesTable/AbilityEmployeesTable.tsx
similarity index 96%
rename from apps/carbon/app/modules/resources/interfaces/Abilities/AbilityEmployeesTable/AbilityEmployeesTable.tsx
rename to apps/carbon/app/modules/resources/ui/Abilities/AbilityEmployeesTable/AbilityEmployeesTable.tsx
index 38629e31cb..5b9429c41e 100644
--- a/apps/carbon/app/modules/resources/interfaces/Abilities/AbilityEmployeesTable/AbilityEmployeesTable.tsx
+++ b/apps/carbon/app/modules/resources/ui/Abilities/AbilityEmployeesTable/AbilityEmployeesTable.tsx
@@ -52,7 +52,7 @@ const AbilityEmployeesTable = ({
[employees, weeks]
);
- const columns = useMemo<ColumnDef<typeof rows[number]>[]>(() => {
+ const columns = useMemo<ColumnDef<(typeof rows)[number]>[]>(() => {
return [
{
// accessorKey: "name",
@@ -120,7 +120,7 @@ const AbilityEmployeesTable = ({
}, []);
const renderContextMenu = useCallback(
- (row: typeof rows[number]) => {
+ (row: (typeof rows)[number]) => {
return (
<>
<MenuItem
@@ -151,7 +151,7 @@ const AbilityEmployeesTable = ({
if (!abilityId) return null;
return (
- <Table<typeof rows[number]>
+ <Table<(typeof rows)[number]>
data={rows}
count={rows.length}
columns={columns}
diff --git a/apps/carbon/app/modules/resources/interfaces/Abilities/AbilityEmployeesTable/index.ts b/apps/carbon/app/modules/resources/ui/Abilities/AbilityEmployeesTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Abilities/AbilityEmployeesTable/index.ts
rename to apps/carbon/app/modules/resources/ui/Abilities/AbilityEmployeesTable/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Abilities/AbilityForm/AbilityForm.tsx b/apps/carbon/app/modules/resources/ui/Abilities/AbilityForm/AbilityForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Abilities/AbilityForm/AbilityForm.tsx
rename to apps/carbon/app/modules/resources/ui/Abilities/AbilityForm/AbilityForm.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Abilities/AbilityForm/index.ts b/apps/carbon/app/modules/resources/ui/Abilities/AbilityForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Abilities/AbilityForm/index.ts
rename to apps/carbon/app/modules/resources/ui/Abilities/AbilityForm/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Abilities/EmployeeAbilityForm/EmployeeAbilityForm.tsx b/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm/EmployeeAbilityForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Abilities/EmployeeAbilityForm/EmployeeAbilityForm.tsx
rename to apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm/EmployeeAbilityForm.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Abilities/EmployeeAbilityForm/index.ts b/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Abilities/EmployeeAbilityForm/index.ts
rename to apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Abilities/index.ts b/apps/carbon/app/modules/resources/ui/Abilities/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Abilities/index.ts
rename to apps/carbon/app/modules/resources/ui/Abilities/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Attributes/AttributeCategoriesTable/AttributesCategoriesTable.tsx b/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoriesTable/AttributesCategoriesTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Attributes/AttributeCategoriesTable/AttributesCategoriesTable.tsx
rename to apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoriesTable/AttributesCategoriesTable.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Attributes/AttributeCategoriesTable/index.ts b/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoriesTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Attributes/AttributeCategoriesTable/index.ts
rename to apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoriesTable/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Attributes/AttributeCategoriesTableFilters/AttributeCategoriesTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoriesTableFilters/AttributeCategoriesTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Attributes/AttributeCategoriesTableFilters/AttributeCategoriesTableFilters.tsx
rename to apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoriesTableFilters/AttributeCategoriesTableFilters.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Attributes/AttributeCategoriesTableFilters/index.ts b/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoriesTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Attributes/AttributeCategoriesTableFilters/index.ts
rename to apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoriesTableFilters/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Attributes/AttributeCategoryDetail/AttributeCategoryDetail.tsx b/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryDetail/AttributeCategoryDetail.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Attributes/AttributeCategoryDetail/AttributeCategoryDetail.tsx
rename to apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryDetail/AttributeCategoryDetail.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Attributes/AttributeCategoryDetail/index.ts b/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryDetail/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Attributes/AttributeCategoryDetail/index.ts
rename to apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryDetail/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Attributes/AttributeCategoryForm/AttributeCategoryForm.tsx b/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryForm/AttributeCategoryForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Attributes/AttributeCategoryForm/AttributeCategoryForm.tsx
rename to apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryForm/AttributeCategoryForm.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Attributes/AttributeCategoryForm/index.ts b/apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Attributes/AttributeCategoryForm/index.ts
rename to apps/carbon/app/modules/resources/ui/Attributes/AttributeCategoryForm/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Attributes/AttributeForm/AttributeForm.tsx b/apps/carbon/app/modules/resources/ui/Attributes/AttributeForm/AttributeForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Attributes/AttributeForm/AttributeForm.tsx
rename to apps/carbon/app/modules/resources/ui/Attributes/AttributeForm/AttributeForm.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Attributes/AttributeForm/index.ts b/apps/carbon/app/modules/resources/ui/Attributes/AttributeForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Attributes/AttributeForm/index.ts
rename to apps/carbon/app/modules/resources/ui/Attributes/AttributeForm/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Attributes/index.ts b/apps/carbon/app/modules/resources/ui/Attributes/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Attributes/index.ts
rename to apps/carbon/app/modules/resources/ui/Attributes/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Contractors/ContractorForm/ContractorForm.tsx b/apps/carbon/app/modules/resources/ui/Contractors/ContractorForm/ContractorForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Contractors/ContractorForm/ContractorForm.tsx
rename to apps/carbon/app/modules/resources/ui/Contractors/ContractorForm/ContractorForm.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Contractors/ContractorForm/index.ts b/apps/carbon/app/modules/resources/ui/Contractors/ContractorForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Contractors/ContractorForm/index.ts
rename to apps/carbon/app/modules/resources/ui/Contractors/ContractorForm/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Contractors/ContractorsTable/ContractorsTable.tsx b/apps/carbon/app/modules/resources/ui/Contractors/ContractorsTable/ContractorsTable.tsx
similarity index 94%
rename from apps/carbon/app/modules/resources/interfaces/Contractors/ContractorsTable/ContractorsTable.tsx
rename to apps/carbon/app/modules/resources/ui/Contractors/ContractorsTable/ContractorsTable.tsx
index 3b5420ead1..2295e72133 100644
--- a/apps/carbon/app/modules/resources/interfaces/Contractors/ContractorsTable/ContractorsTable.tsx
+++ b/apps/carbon/app/modules/resources/ui/Contractors/ContractorsTable/ContractorsTable.tsx
@@ -22,7 +22,7 @@ const ContractorsTable = memo(({ data, count }: ContractorsTableProps) => {
...row,
}));
- const columns = useMemo<ColumnDef<typeof rows[number]>[]>(() => {
+ const columns = useMemo<ColumnDef<(typeof rows)[number]>[]>(() => {
return [
{
accessorKey: "supplier",
@@ -56,7 +56,7 @@ const ContractorsTable = memo(({ data, count }: ContractorsTableProps) => {
}, [navigate]);
const renderContextMenu = useCallback(
- (row: typeof rows[number]) => {
+ (row: (typeof rows)[number]) => {
return (
<>
<MenuItem
@@ -91,7 +91,7 @@ const ContractorsTable = memo(({ data, count }: ContractorsTableProps) => {
);
return (
- <Table<typeof rows[number]>
+ <Table<(typeof rows)[number]>
data={rows}
count={count}
columns={columns}
diff --git a/apps/carbon/app/modules/resources/interfaces/Contractors/ContractorsTable/index.ts b/apps/carbon/app/modules/resources/ui/Contractors/ContractorsTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Contractors/ContractorsTable/index.ts
rename to apps/carbon/app/modules/resources/ui/Contractors/ContractorsTable/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Contractors/ContractorsTableFilters/ContractorsTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Contractors/ContractorsTableFilters/ContractorsTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Contractors/ContractorsTableFilters/ContractorsTableFilters.tsx
rename to apps/carbon/app/modules/resources/ui/Contractors/ContractorsTableFilters/ContractorsTableFilters.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Contractors/ContractorsTableFilters/index.ts b/apps/carbon/app/modules/resources/ui/Contractors/ContractorsTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Contractors/ContractorsTableFilters/index.ts
rename to apps/carbon/app/modules/resources/ui/Contractors/ContractorsTableFilters/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Contractors/index.ts b/apps/carbon/app/modules/resources/ui/Contractors/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Contractors/index.ts
rename to apps/carbon/app/modules/resources/ui/Contractors/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Departments/DepartmentForm/DepartmentForm.tsx b/apps/carbon/app/modules/resources/ui/Departments/DepartmentForm/DepartmentForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Departments/DepartmentForm/DepartmentForm.tsx
rename to apps/carbon/app/modules/resources/ui/Departments/DepartmentForm/DepartmentForm.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Departments/DepartmentForm/index.ts b/apps/carbon/app/modules/resources/ui/Departments/DepartmentForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Departments/DepartmentForm/index.ts
rename to apps/carbon/app/modules/resources/ui/Departments/DepartmentForm/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Departments/DepartmentsTable/DepartmentsTable.tsx b/apps/carbon/app/modules/resources/ui/Departments/DepartmentsTable/DepartmentsTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Departments/DepartmentsTable/DepartmentsTable.tsx
rename to apps/carbon/app/modules/resources/ui/Departments/DepartmentsTable/DepartmentsTable.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Departments/DepartmentsTable/index.ts b/apps/carbon/app/modules/resources/ui/Departments/DepartmentsTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Departments/DepartmentsTable/index.ts
rename to apps/carbon/app/modules/resources/ui/Departments/DepartmentsTable/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Departments/DepartmentsTableFilters/DepartmentsTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Departments/DepartmentsTableFilters/DepartmentsTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Departments/DepartmentsTableFilters/DepartmentsTableFilters.tsx
rename to apps/carbon/app/modules/resources/ui/Departments/DepartmentsTableFilters/DepartmentsTableFilters.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Departments/DepartmentsTableFilters/index.ts b/apps/carbon/app/modules/resources/ui/Departments/DepartmentsTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Departments/DepartmentsTableFilters/index.ts
rename to apps/carbon/app/modules/resources/ui/Departments/DepartmentsTableFilters/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Departments/index.ts b/apps/carbon/app/modules/resources/ui/Departments/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Departments/index.ts
rename to apps/carbon/app/modules/resources/ui/Departments/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentForm/EquipmentForm.tsx b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm/EquipmentForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentForm/EquipmentForm.tsx
rename to apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm/EquipmentForm.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentForm/index.ts b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentForm/index.ts
rename to apps/carbon/app/modules/resources/ui/Equipment/EquipmentForm/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentTypeDetail/EquipmentTypeDetail.tsx b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeDetail/EquipmentTypeDetail.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentTypeDetail/EquipmentTypeDetail.tsx
rename to apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeDetail/EquipmentTypeDetail.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentTypeDetail/index.ts b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeDetail/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentTypeDetail/index.ts
rename to apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeDetail/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentTypeForm/EquipmentTypeForm.tsx b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeForm/EquipmentTypeForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentTypeForm/EquipmentTypeForm.tsx
rename to apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeForm/EquipmentTypeForm.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentTypeForm/index.ts b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentTypeForm/index.ts
rename to apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypeForm/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentTypesTable/EquipmentTypesTable.tsx b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypesTable/EquipmentTypesTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentTypesTable/EquipmentTypesTable.tsx
rename to apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypesTable/EquipmentTypesTable.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentTypesTable/index.ts b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypesTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentTypesTable/index.ts
rename to apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypesTable/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentTypesTableFilters/EquipmentTypesTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypesTableFilters/EquipmentTypesTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentTypesTableFilters/EquipmentTypesTableFilters.tsx
rename to apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypesTableFilters/EquipmentTypesTableFilters.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentTypesTableFilters/index.ts b/apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypesTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Equipment/EquipmentTypesTableFilters/index.ts
rename to apps/carbon/app/modules/resources/ui/Equipment/EquipmentTypesTableFilters/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Equipment/index.ts b/apps/carbon/app/modules/resources/ui/Equipment/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Equipment/index.ts
rename to apps/carbon/app/modules/resources/ui/Equipment/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Holidays/HolidayForm/HolidayForm.tsx b/apps/carbon/app/modules/resources/ui/Holidays/HolidayForm/HolidayForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Holidays/HolidayForm/HolidayForm.tsx
rename to apps/carbon/app/modules/resources/ui/Holidays/HolidayForm/HolidayForm.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Holidays/HolidayForm/index.ts b/apps/carbon/app/modules/resources/ui/Holidays/HolidayForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Holidays/HolidayForm/index.ts
rename to apps/carbon/app/modules/resources/ui/Holidays/HolidayForm/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Holidays/HolidaysTable/HolidaysTable.tsx b/apps/carbon/app/modules/resources/ui/Holidays/HolidaysTable/HolidaysTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Holidays/HolidaysTable/HolidaysTable.tsx
rename to apps/carbon/app/modules/resources/ui/Holidays/HolidaysTable/HolidaysTable.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Holidays/HolidaysTable/index.ts b/apps/carbon/app/modules/resources/ui/Holidays/HolidaysTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Holidays/HolidaysTable/index.ts
rename to apps/carbon/app/modules/resources/ui/Holidays/HolidaysTable/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Holidays/HolidaysTableFilters/HolidaysTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Holidays/HolidaysTableFilters/HolidaysTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Holidays/HolidaysTableFilters/HolidaysTableFilters.tsx
rename to apps/carbon/app/modules/resources/ui/Holidays/HolidaysTableFilters/HolidaysTableFilters.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Holidays/HolidaysTableFilters/index.ts b/apps/carbon/app/modules/resources/ui/Holidays/HolidaysTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Holidays/HolidaysTableFilters/index.ts
rename to apps/carbon/app/modules/resources/ui/Holidays/HolidaysTableFilters/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Holidays/index.ts b/apps/carbon/app/modules/resources/ui/Holidays/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Holidays/index.ts
rename to apps/carbon/app/modules/resources/ui/Holidays/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Locations/LocationForm/LocationForm.tsx b/apps/carbon/app/modules/resources/ui/Locations/LocationForm/LocationForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Locations/LocationForm/LocationForm.tsx
rename to apps/carbon/app/modules/resources/ui/Locations/LocationForm/LocationForm.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Locations/LocationForm/index.ts b/apps/carbon/app/modules/resources/ui/Locations/LocationForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Locations/LocationForm/index.ts
rename to apps/carbon/app/modules/resources/ui/Locations/LocationForm/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Locations/LocationsTable/LocationsTable.tsx b/apps/carbon/app/modules/resources/ui/Locations/LocationsTable/LocationsTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Locations/LocationsTable/LocationsTable.tsx
rename to apps/carbon/app/modules/resources/ui/Locations/LocationsTable/LocationsTable.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Locations/LocationsTable/index.ts b/apps/carbon/app/modules/resources/ui/Locations/LocationsTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Locations/LocationsTable/index.ts
rename to apps/carbon/app/modules/resources/ui/Locations/LocationsTable/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Locations/LocationsTableFilters/LocationsTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Locations/LocationsTableFilters/LocationsTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Locations/LocationsTableFilters/LocationsTableFilters.tsx
rename to apps/carbon/app/modules/resources/ui/Locations/LocationsTableFilters/LocationsTableFilters.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Locations/LocationsTableFilters/index.ts b/apps/carbon/app/modules/resources/ui/Locations/LocationsTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Locations/LocationsTableFilters/index.ts
rename to apps/carbon/app/modules/resources/ui/Locations/LocationsTableFilters/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Locations/index.ts b/apps/carbon/app/modules/resources/ui/Locations/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Locations/index.ts
rename to apps/carbon/app/modules/resources/ui/Locations/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Partners/PartnerForm/PartnerForm.tsx b/apps/carbon/app/modules/resources/ui/Partners/PartnerForm/PartnerForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Partners/PartnerForm/PartnerForm.tsx
rename to apps/carbon/app/modules/resources/ui/Partners/PartnerForm/PartnerForm.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Partners/PartnerForm/index.ts b/apps/carbon/app/modules/resources/ui/Partners/PartnerForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Partners/PartnerForm/index.ts
rename to apps/carbon/app/modules/resources/ui/Partners/PartnerForm/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Partners/PartnersTable/PartnersTable.tsx b/apps/carbon/app/modules/resources/ui/Partners/PartnersTable/PartnersTable.tsx
similarity index 94%
rename from apps/carbon/app/modules/resources/interfaces/Partners/PartnersTable/PartnersTable.tsx
rename to apps/carbon/app/modules/resources/ui/Partners/PartnersTable/PartnersTable.tsx
index f4e57715f8..7fecb2667e 100644
--- a/apps/carbon/app/modules/resources/interfaces/Partners/PartnersTable/PartnersTable.tsx
+++ b/apps/carbon/app/modules/resources/ui/Partners/PartnersTable/PartnersTable.tsx
@@ -22,7 +22,7 @@ const PartnersTable = memo(({ data, count }: PartnersTableProps) => {
...row,
}));
- const columns = useMemo<ColumnDef<typeof rows[number]>[]>(() => {
+ const columns = useMemo<ColumnDef<(typeof rows)[number]>[]>(() => {
return [
{
accessorKey: "supplier",
@@ -58,7 +58,7 @@ const PartnersTable = memo(({ data, count }: PartnersTableProps) => {
}, [navigate]);
const renderContextMenu = useCallback(
- (row: typeof rows[number]) => {
+ (row: (typeof rows)[number]) => {
return (
<>
<MenuItem
@@ -93,7 +93,7 @@ const PartnersTable = memo(({ data, count }: PartnersTableProps) => {
);
return (
- <Table<typeof rows[number]>
+ <Table<(typeof rows)[number]>
data={rows}
count={count}
columns={columns}
diff --git a/apps/carbon/app/modules/resources/interfaces/Partners/PartnersTable/index.ts b/apps/carbon/app/modules/resources/ui/Partners/PartnersTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Partners/PartnersTable/index.ts
rename to apps/carbon/app/modules/resources/ui/Partners/PartnersTable/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Partners/PartnersTableFilters/PartnersTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Partners/PartnersTableFilters/PartnersTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Partners/PartnersTableFilters/PartnersTableFilters.tsx
rename to apps/carbon/app/modules/resources/ui/Partners/PartnersTableFilters/PartnersTableFilters.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Partners/PartnersTableFilters/index.ts b/apps/carbon/app/modules/resources/ui/Partners/PartnersTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Partners/PartnersTableFilters/index.ts
rename to apps/carbon/app/modules/resources/ui/Partners/PartnersTableFilters/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Partners/index.ts b/apps/carbon/app/modules/resources/ui/Partners/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Partners/index.ts
rename to apps/carbon/app/modules/resources/ui/Partners/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/People/PeopleTable/PeopleTable.tsx b/apps/carbon/app/modules/resources/ui/People/PeopleTable/PeopleTable.tsx
similarity index 95%
rename from apps/carbon/app/modules/resources/interfaces/People/PeopleTable/PeopleTable.tsx
rename to apps/carbon/app/modules/resources/ui/People/PeopleTable/PeopleTable.tsx
index 21a6ffbac3..83e7c842e1 100644
--- a/apps/carbon/app/modules/resources/interfaces/People/PeopleTable/PeopleTable.tsx
+++ b/apps/carbon/app/modules/resources/ui/People/PeopleTable/PeopleTable.tsx
@@ -91,8 +91,8 @@ const PeopleTable = memo(
[data]
);
- const columns = useMemo<ColumnDef<typeof rows[number]>[]>(() => {
- const defaultColumns: ColumnDef<typeof rows[number]>[] = [
+ const columns = useMemo<ColumnDef<(typeof rows)[number]>[]>(() => {
+ const defaultColumns: ColumnDef<(typeof rows)[number]>[] = [
{
header: "User",
cell: ({ row }) => (
@@ -144,7 +144,7 @@ const PeopleTable = memo(
},
];
- const additionalColumns: ColumnDef<typeof rows[number]>[] = [];
+ const additionalColumns: ColumnDef<(typeof rows)[number]>[] = [];
attributeCategories.forEach((category) => {
if (category.userAttribute && Array.isArray(category.userAttribute)) {
@@ -182,7 +182,7 @@ const PeopleTable = memo(
const renderContextMenu = useMemo(() => {
return permissions.can("update", "resources")
- ? (row: typeof rows[number]) => {
+ ? (row: (typeof rows)[number]) => {
return (
<MenuItem
icon={<BsPencilSquare />}
@@ -202,7 +202,7 @@ const PeopleTable = memo(
return (
<>
- <Table<typeof rows[number]>
+ <Table<(typeof rows)[number]>
// actions={actions}
count={count}
columns={columns}
diff --git a/apps/carbon/app/modules/resources/interfaces/People/PeopleTable/index.ts b/apps/carbon/app/modules/resources/ui/People/PeopleTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/People/PeopleTable/index.ts
rename to apps/carbon/app/modules/resources/ui/People/PeopleTable/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/People/PeopleTableFilters/PeopleTableFilters.tsx b/apps/carbon/app/modules/resources/ui/People/PeopleTableFilters/PeopleTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/People/PeopleTableFilters/PeopleTableFilters.tsx
rename to apps/carbon/app/modules/resources/ui/People/PeopleTableFilters/PeopleTableFilters.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/People/PeopleTableFilters/index.ts b/apps/carbon/app/modules/resources/ui/People/PeopleTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/People/PeopleTableFilters/index.ts
rename to apps/carbon/app/modules/resources/ui/People/PeopleTableFilters/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/People/index.ts b/apps/carbon/app/modules/resources/ui/People/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/People/index.ts
rename to apps/carbon/app/modules/resources/ui/People/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Person/PersonAbilities/PersonAbilities.tsx b/apps/carbon/app/modules/resources/ui/Person/PersonAbilities/PersonAbilities.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Person/PersonAbilities/PersonAbilities.tsx
rename to apps/carbon/app/modules/resources/ui/Person/PersonAbilities/PersonAbilities.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Person/PersonAbilities/index.ts b/apps/carbon/app/modules/resources/ui/Person/PersonAbilities/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Person/PersonAbilities/index.ts
rename to apps/carbon/app/modules/resources/ui/Person/PersonAbilities/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Person/PersonDaysOff/PersonDaysOff.tsx b/apps/carbon/app/modules/resources/ui/Person/PersonDaysOff/PersonDaysOff.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Person/PersonDaysOff/PersonDaysOff.tsx
rename to apps/carbon/app/modules/resources/ui/Person/PersonDaysOff/PersonDaysOff.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Person/PersonDaysOff/index.ts b/apps/carbon/app/modules/resources/ui/Person/PersonDaysOff/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Person/PersonDaysOff/index.ts
rename to apps/carbon/app/modules/resources/ui/Person/PersonDaysOff/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Person/PersonHeader/PersonHeader.tsx b/apps/carbon/app/modules/resources/ui/Person/PersonHeader/PersonHeader.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Person/PersonHeader/PersonHeader.tsx
rename to apps/carbon/app/modules/resources/ui/Person/PersonHeader/PersonHeader.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Person/PersonHeader/index.ts b/apps/carbon/app/modules/resources/ui/Person/PersonHeader/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Person/PersonHeader/index.ts
rename to apps/carbon/app/modules/resources/ui/Person/PersonHeader/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Person/PersonJob/PersonJob.tsx b/apps/carbon/app/modules/resources/ui/Person/PersonJob/PersonJob.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Person/PersonJob/PersonJob.tsx
rename to apps/carbon/app/modules/resources/ui/Person/PersonJob/PersonJob.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Person/PersonJob/index.ts b/apps/carbon/app/modules/resources/ui/Person/PersonJob/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Person/PersonJob/index.ts
rename to apps/carbon/app/modules/resources/ui/Person/PersonJob/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Person/PersonNotes/PersonNotes.tsx b/apps/carbon/app/modules/resources/ui/Person/PersonNotes/PersonNotes.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Person/PersonNotes/PersonNotes.tsx
rename to apps/carbon/app/modules/resources/ui/Person/PersonNotes/PersonNotes.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Person/PersonNotes/index.ts b/apps/carbon/app/modules/resources/ui/Person/PersonNotes/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Person/PersonNotes/index.ts
rename to apps/carbon/app/modules/resources/ui/Person/PersonNotes/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Person/PersonOvertime/PersonOvertime.tsx b/apps/carbon/app/modules/resources/ui/Person/PersonOvertime/PersonOvertime.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Person/PersonOvertime/PersonOvertime.tsx
rename to apps/carbon/app/modules/resources/ui/Person/PersonOvertime/PersonOvertime.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Person/PersonOvertime/index.ts b/apps/carbon/app/modules/resources/ui/Person/PersonOvertime/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Person/PersonOvertime/index.ts
rename to apps/carbon/app/modules/resources/ui/Person/PersonOvertime/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Person/PersonTabs/PersonTabs.tsx b/apps/carbon/app/modules/resources/ui/Person/PersonTabs/PersonTabs.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Person/PersonTabs/PersonTabs.tsx
rename to apps/carbon/app/modules/resources/ui/Person/PersonTabs/PersonTabs.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Person/PersonTabs/index.ts b/apps/carbon/app/modules/resources/ui/Person/PersonTabs/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Person/PersonTabs/index.ts
rename to apps/carbon/app/modules/resources/ui/Person/PersonTabs/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Person/index.ts b/apps/carbon/app/modules/resources/ui/Person/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Person/index.ts
rename to apps/carbon/app/modules/resources/ui/Person/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Shifts/ShiftForm/ShiftForm.tsx b/apps/carbon/app/modules/resources/ui/Shifts/ShiftForm/ShiftForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Shifts/ShiftForm/ShiftForm.tsx
rename to apps/carbon/app/modules/resources/ui/Shifts/ShiftForm/ShiftForm.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Shifts/ShiftForm/index.ts b/apps/carbon/app/modules/resources/ui/Shifts/ShiftForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Shifts/ShiftForm/index.ts
rename to apps/carbon/app/modules/resources/ui/Shifts/ShiftForm/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Shifts/ShiftsTable/ShiftsTable.tsx b/apps/carbon/app/modules/resources/ui/Shifts/ShiftsTable/ShiftsTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Shifts/ShiftsTable/ShiftsTable.tsx
rename to apps/carbon/app/modules/resources/ui/Shifts/ShiftsTable/ShiftsTable.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Shifts/ShiftsTable/index.ts b/apps/carbon/app/modules/resources/ui/Shifts/ShiftsTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Shifts/ShiftsTable/index.ts
rename to apps/carbon/app/modules/resources/ui/Shifts/ShiftsTable/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Shifts/ShiftsTableFilters/ShiftsTableFilters.tsx b/apps/carbon/app/modules/resources/ui/Shifts/ShiftsTableFilters/ShiftsTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Shifts/ShiftsTableFilters/ShiftsTableFilters.tsx
rename to apps/carbon/app/modules/resources/ui/Shifts/ShiftsTableFilters/ShiftsTableFilters.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/Shifts/ShiftsTableFilters/index.ts b/apps/carbon/app/modules/resources/ui/Shifts/ShiftsTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Shifts/ShiftsTableFilters/index.ts
rename to apps/carbon/app/modules/resources/ui/Shifts/ShiftsTableFilters/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/Shifts/index.ts b/apps/carbon/app/modules/resources/ui/Shifts/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/Shifts/index.ts
rename to apps/carbon/app/modules/resources/ui/Shifts/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellForm/WorkCellForm.tsx b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellForm/WorkCellForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellForm/WorkCellForm.tsx
rename to apps/carbon/app/modules/resources/ui/WorkCells/WorkCellForm/WorkCellForm.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellForm/index.ts b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellForm/index.ts
rename to apps/carbon/app/modules/resources/ui/WorkCells/WorkCellForm/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellTypeDetail/WorkCellTypeDetail.tsx b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeDetail/WorkCellTypeDetail.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellTypeDetail/WorkCellTypeDetail.tsx
rename to apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeDetail/WorkCellTypeDetail.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellTypeDetail/index.ts b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeDetail/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellTypeDetail/index.ts
rename to apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeDetail/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellTypeForm/WorkCellTypeForm.tsx b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeForm/WorkCellTypeForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellTypeForm/WorkCellTypeForm.tsx
rename to apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeForm/WorkCellTypeForm.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellTypeForm/index.ts b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellTypeForm/index.ts
rename to apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypeForm/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellTypesTable/WorkCellTypesTable.tsx b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypesTable/WorkCellTypesTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellTypesTable/WorkCellTypesTable.tsx
rename to apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypesTable/WorkCellTypesTable.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellTypesTable/index.ts b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypesTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellTypesTable/index.ts
rename to apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypesTable/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellTypesTableFilters/WorkCellTypesTableFilters.tsx b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypesTableFilters/WorkCellTypesTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellTypesTableFilters/WorkCellTypesTableFilters.tsx
rename to apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypesTableFilters/WorkCellTypesTableFilters.tsx
diff --git a/apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellTypesTableFilters/index.ts b/apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypesTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/WorkCells/WorkCellTypesTableFilters/index.ts
rename to apps/carbon/app/modules/resources/ui/WorkCells/WorkCellTypesTableFilters/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/WorkCells/index.ts b/apps/carbon/app/modules/resources/ui/WorkCells/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/WorkCells/index.ts
rename to apps/carbon/app/modules/resources/ui/WorkCells/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/index.ts b/apps/carbon/app/modules/resources/ui/index.ts
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/index.ts
rename to apps/carbon/app/modules/resources/ui/index.ts
diff --git a/apps/carbon/app/modules/resources/interfaces/useResourcesSidebar.tsx b/apps/carbon/app/modules/resources/ui/useResourcesSidebar.tsx
similarity index 100%
rename from apps/carbon/app/modules/resources/interfaces/useResourcesSidebar.tsx
rename to apps/carbon/app/modules/resources/ui/useResourcesSidebar.tsx
diff --git a/apps/carbon/app/modules/sales/index.ts b/apps/carbon/app/modules/sales/index.ts
index 684aed031a..83b8af135e 100644
--- a/apps/carbon/app/modules/sales/index.ts
+++ b/apps/carbon/app/modules/sales/index.ts
@@ -1,3 +1,3 @@
export * from "./services";
-export * from "./interfaces";
export * from "./types";
+export * from "./ui";
diff --git a/apps/carbon/app/modules/sales/services/sales.server.ts b/apps/carbon/app/modules/sales/services/sales.server.ts
index f34201930c..8a4a04fb42 100644
--- a/apps/carbon/app/modules/sales/services/sales.server.ts
+++ b/apps/carbon/app/modules/sales/services/sales.server.ts
@@ -5,7 +5,7 @@ import type { TypeOfValidator } from "~/types/validators";
import type { GenericQueryFilters } from "~/utils/query";
import { setGenericQueryFilters } from "~/utils/query";
import { sanitize } from "~/utils/supabase";
-import type { customerValidator } from "./sales.form";
+import type { customerTypeValidator, customerValidator } from "./sales.form";
export async function deleteCustomerContact(
client: SupabaseClient<Database>,
@@ -171,6 +171,10 @@ export async function getCustomerTypes(
return query;
}
+export async function getCustomerTypesList(client: SupabaseClient<Database>) {
+ return client.from("customerType").select("id, name");
+}
+
export async function insertCustomer(
client: SupabaseClient<Database>,
customer: TypeOfValidator<typeof customerValidator> & {
@@ -343,11 +347,21 @@ export async function updateCustomerLocation(
export async function upsertCustomerType(
client: SupabaseClient<Database>,
- customerType: { id?: string; name: string; color: string | null }
+ customerType:
+ | (Omit<TypeOfValidator<typeof customerTypeValidator>, "id"> & {
+ createdBy: string;
+ })
+ | (Omit<TypeOfValidator<typeof customerTypeValidator>, "id"> & {
+ id: string;
+ updatedBy: string;
+ })
) {
- return client
- .from("customerType")
- .upsert([customerType])
- .select("id")
- .single();
+ if ("createdBy" in customerType) {
+ return client.from("customerType").insert([customerType]);
+ } else {
+ return client
+ .from("customerType")
+ .update(sanitize(customerType))
+ .eq("id", customerType.id);
+ }
}
diff --git a/apps/carbon/app/modules/sales/interfaces/CustomerTypes/CustomerTypeForm/CustomerTypeForm.tsx b/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypeForm/CustomerTypeForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/CustomerTypes/CustomerTypeForm/CustomerTypeForm.tsx
rename to apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypeForm/CustomerTypeForm.tsx
diff --git a/apps/carbon/app/modules/sales/interfaces/CustomerTypes/CustomerTypeForm/index.ts b/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypeForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/CustomerTypes/CustomerTypeForm/index.ts
rename to apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypeForm/index.ts
diff --git a/apps/carbon/app/modules/sales/interfaces/CustomerTypes/CustomerTypesTable/CustomerTypesTable.tsx b/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTable/CustomerTypesTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/CustomerTypes/CustomerTypesTable/CustomerTypesTable.tsx
rename to apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTable/CustomerTypesTable.tsx
diff --git a/apps/carbon/app/modules/sales/interfaces/CustomerTypes/CustomerTypesTable/index.ts b/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/CustomerTypes/CustomerTypesTable/index.ts
rename to apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTable/index.ts
diff --git a/apps/carbon/app/modules/sales/interfaces/CustomerTypes/CustomerTypesTableFilters/CustomerTypesTableFilters.tsx b/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTableFilters/CustomerTypesTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/CustomerTypes/CustomerTypesTableFilters/CustomerTypesTableFilters.tsx
rename to apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTableFilters/CustomerTypesTableFilters.tsx
diff --git a/apps/carbon/app/modules/sales/interfaces/CustomerTypes/CustomerTypesTableFilters/index.ts b/apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/CustomerTypes/CustomerTypesTableFilters/index.ts
rename to apps/carbon/app/modules/sales/ui/CustomerTypes/CustomerTypesTableFilters/index.ts
diff --git a/apps/carbon/app/modules/sales/interfaces/CustomerTypes/index.ts b/apps/carbon/app/modules/sales/ui/CustomerTypes/index.ts
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/CustomerTypes/index.ts
rename to apps/carbon/app/modules/sales/ui/CustomerTypes/index.ts
diff --git a/apps/carbon/app/modules/sales/interfaces/Customers/CustomerForm/CustomerForm.tsx b/apps/carbon/app/modules/sales/ui/Customers/CustomerForm/CustomerForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/Customers/CustomerForm/CustomerForm.tsx
rename to apps/carbon/app/modules/sales/ui/Customers/CustomerForm/CustomerForm.tsx
diff --git a/apps/carbon/app/modules/sales/interfaces/Customers/CustomerForm/components/CustomerContacts.tsx b/apps/carbon/app/modules/sales/ui/Customers/CustomerForm/components/CustomerContacts.tsx
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/Customers/CustomerForm/components/CustomerContacts.tsx
rename to apps/carbon/app/modules/sales/ui/Customers/CustomerForm/components/CustomerContacts.tsx
diff --git a/apps/carbon/app/modules/sales/interfaces/Customers/CustomerForm/components/CustomerContactsForm.tsx b/apps/carbon/app/modules/sales/ui/Customers/CustomerForm/components/CustomerContactsForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/Customers/CustomerForm/components/CustomerContactsForm.tsx
rename to apps/carbon/app/modules/sales/ui/Customers/CustomerForm/components/CustomerContactsForm.tsx
diff --git a/apps/carbon/app/modules/sales/interfaces/Customers/CustomerForm/components/CustomerLocationForm.tsx b/apps/carbon/app/modules/sales/ui/Customers/CustomerForm/components/CustomerLocationForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/Customers/CustomerForm/components/CustomerLocationForm.tsx
rename to apps/carbon/app/modules/sales/ui/Customers/CustomerForm/components/CustomerLocationForm.tsx
diff --git a/apps/carbon/app/modules/sales/interfaces/Customers/CustomerForm/components/CustomerLocations.tsx b/apps/carbon/app/modules/sales/ui/Customers/CustomerForm/components/CustomerLocations.tsx
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/Customers/CustomerForm/components/CustomerLocations.tsx
rename to apps/carbon/app/modules/sales/ui/Customers/CustomerForm/components/CustomerLocations.tsx
diff --git a/apps/carbon/app/modules/sales/interfaces/Customers/CustomerForm/components/index.ts b/apps/carbon/app/modules/sales/ui/Customers/CustomerForm/components/index.ts
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/Customers/CustomerForm/components/index.ts
rename to apps/carbon/app/modules/sales/ui/Customers/CustomerForm/components/index.ts
diff --git a/apps/carbon/app/modules/sales/interfaces/Customers/CustomerForm/index.ts b/apps/carbon/app/modules/sales/ui/Customers/CustomerForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/Customers/CustomerForm/index.ts
rename to apps/carbon/app/modules/sales/ui/Customers/CustomerForm/index.ts
diff --git a/apps/carbon/app/modules/sales/interfaces/Customers/CustomersTable/CustomersTable.tsx b/apps/carbon/app/modules/sales/ui/Customers/CustomersTable/CustomersTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/Customers/CustomersTable/CustomersTable.tsx
rename to apps/carbon/app/modules/sales/ui/Customers/CustomersTable/CustomersTable.tsx
diff --git a/apps/carbon/app/modules/sales/interfaces/Customers/CustomersTable/index.ts b/apps/carbon/app/modules/sales/ui/Customers/CustomersTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/Customers/CustomersTable/index.ts
rename to apps/carbon/app/modules/sales/ui/Customers/CustomersTable/index.ts
diff --git a/apps/carbon/app/modules/sales/interfaces/Customers/CustomersTableFilters/CustomersTableFilters.tsx b/apps/carbon/app/modules/sales/ui/Customers/CustomersTableFilters/CustomersTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/Customers/CustomersTableFilters/CustomersTableFilters.tsx
rename to apps/carbon/app/modules/sales/ui/Customers/CustomersTableFilters/CustomersTableFilters.tsx
diff --git a/apps/carbon/app/modules/sales/interfaces/Customers/CustomersTableFilters/index.ts b/apps/carbon/app/modules/sales/ui/Customers/CustomersTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/Customers/CustomersTableFilters/index.ts
rename to apps/carbon/app/modules/sales/ui/Customers/CustomersTableFilters/index.ts
diff --git a/apps/carbon/app/modules/sales/interfaces/Customers/index.ts b/apps/carbon/app/modules/sales/ui/Customers/index.ts
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/Customers/index.ts
rename to apps/carbon/app/modules/sales/ui/Customers/index.ts
diff --git a/apps/carbon/app/modules/sales/interfaces/index.ts b/apps/carbon/app/modules/sales/ui/index.ts
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/index.ts
rename to apps/carbon/app/modules/sales/ui/index.ts
diff --git a/apps/carbon/app/modules/sales/interfaces/useSalesSidebar.tsx b/apps/carbon/app/modules/sales/ui/useSalesSidebar.tsx
similarity index 100%
rename from apps/carbon/app/modules/sales/interfaces/useSalesSidebar.tsx
rename to apps/carbon/app/modules/sales/ui/useSalesSidebar.tsx
diff --git a/apps/carbon/app/modules/settings/index.ts b/apps/carbon/app/modules/settings/index.ts
index 684aed031a..83b8af135e 100644
--- a/apps/carbon/app/modules/settings/index.ts
+++ b/apps/carbon/app/modules/settings/index.ts
@@ -1,3 +1,3 @@
export * from "./services";
-export * from "./interfaces";
export * from "./types";
+export * from "./ui";
diff --git a/apps/carbon/app/modules/settings/interfaces/Sequences/SequenceForm/SequenceForm.tsx b/apps/carbon/app/modules/settings/ui/Sequences/SequenceForm/SequenceForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/settings/interfaces/Sequences/SequenceForm/SequenceForm.tsx
rename to apps/carbon/app/modules/settings/ui/Sequences/SequenceForm/SequenceForm.tsx
diff --git a/apps/carbon/app/modules/settings/interfaces/Sequences/SequenceForm/index.ts b/apps/carbon/app/modules/settings/ui/Sequences/SequenceForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/settings/interfaces/Sequences/SequenceForm/index.ts
rename to apps/carbon/app/modules/settings/ui/Sequences/SequenceForm/index.ts
diff --git a/apps/carbon/app/modules/settings/interfaces/Sequences/SequencesTable/SequencesTable.tsx b/apps/carbon/app/modules/settings/ui/Sequences/SequencesTable/SequencesTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/settings/interfaces/Sequences/SequencesTable/SequencesTable.tsx
rename to apps/carbon/app/modules/settings/ui/Sequences/SequencesTable/SequencesTable.tsx
diff --git a/apps/carbon/app/modules/settings/interfaces/Sequences/SequencesTable/index.ts b/apps/carbon/app/modules/settings/ui/Sequences/SequencesTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/settings/interfaces/Sequences/SequencesTable/index.ts
rename to apps/carbon/app/modules/settings/ui/Sequences/SequencesTable/index.ts
diff --git a/apps/carbon/app/modules/settings/interfaces/Sequences/SequencesTableFilters/SequencesTableFilters.tsx b/apps/carbon/app/modules/settings/ui/Sequences/SequencesTableFilters/SequencesTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/settings/interfaces/Sequences/SequencesTableFilters/SequencesTableFilters.tsx
rename to apps/carbon/app/modules/settings/ui/Sequences/SequencesTableFilters/SequencesTableFilters.tsx
diff --git a/apps/carbon/app/modules/settings/interfaces/Sequences/SequencesTableFilters/index.ts b/apps/carbon/app/modules/settings/ui/Sequences/SequencesTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/settings/interfaces/Sequences/SequencesTableFilters/index.ts
rename to apps/carbon/app/modules/settings/ui/Sequences/SequencesTableFilters/index.ts
diff --git a/apps/carbon/app/modules/settings/interfaces/Sequences/index.ts b/apps/carbon/app/modules/settings/ui/Sequences/index.ts
similarity index 100%
rename from apps/carbon/app/modules/settings/interfaces/Sequences/index.ts
rename to apps/carbon/app/modules/settings/ui/Sequences/index.ts
diff --git a/apps/carbon/app/modules/settings/interfaces/index.ts b/apps/carbon/app/modules/settings/ui/index.ts
similarity index 100%
rename from apps/carbon/app/modules/settings/interfaces/index.ts
rename to apps/carbon/app/modules/settings/ui/index.ts
diff --git a/apps/carbon/app/modules/settings/interfaces/useSettingsSidebar.tsx b/apps/carbon/app/modules/settings/ui/useSettingsSidebar.tsx
similarity index 100%
rename from apps/carbon/app/modules/settings/interfaces/useSettingsSidebar.tsx
rename to apps/carbon/app/modules/settings/ui/useSettingsSidebar.tsx
diff --git a/apps/carbon/app/modules/users/index.ts b/apps/carbon/app/modules/users/index.ts
index 684aed031a..83b8af135e 100644
--- a/apps/carbon/app/modules/users/index.ts
+++ b/apps/carbon/app/modules/users/index.ts
@@ -1,3 +1,3 @@
export * from "./services";
-export * from "./interfaces";
export * from "./types";
+export * from "./ui";
diff --git a/apps/carbon/app/modules/users/interfaces/Customers/CreateCustomerModal/CreateCustomerModal.tsx b/apps/carbon/app/modules/users/ui/Customers/CreateCustomerModal/CreateCustomerModal.tsx
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Customers/CreateCustomerModal/CreateCustomerModal.tsx
rename to apps/carbon/app/modules/users/ui/Customers/CreateCustomerModal/CreateCustomerModal.tsx
diff --git a/apps/carbon/app/modules/users/interfaces/Customers/CreateCustomerModal/index.ts b/apps/carbon/app/modules/users/ui/Customers/CreateCustomerModal/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Customers/CreateCustomerModal/index.ts
rename to apps/carbon/app/modules/users/ui/Customers/CreateCustomerModal/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/Customers/CustomerAccountsTable/CustomerAccountsTable.tsx b/apps/carbon/app/modules/users/ui/Customers/CustomerAccountsTable/CustomerAccountsTable.tsx
similarity index 97%
rename from apps/carbon/app/modules/users/interfaces/Customers/CustomerAccountsTable/CustomerAccountsTable.tsx
rename to apps/carbon/app/modules/users/ui/Customers/CustomerAccountsTable/CustomerAccountsTable.tsx
index e536a7667a..f7da18afb4 100644
--- a/apps/carbon/app/modules/users/interfaces/Customers/CustomerAccountsTable/CustomerAccountsTable.tsx
+++ b/apps/carbon/app/modules/users/ui/Customers/CustomerAccountsTable/CustomerAccountsTable.tsx
@@ -47,7 +47,7 @@ const CustomerAccountsTable = memo(
[data]
);
- const columns = useMemo<ColumnDef<typeof rows[number]>[]>(() => {
+ const columns = useMemo<ColumnDef<(typeof rows)[number]>[]>(() => {
return [
{
header: "User",
@@ -149,7 +149,7 @@ const CustomerAccountsTable = memo(
// );
const renderContextMenu = useCallback(
- (row: typeof data[number]) => {
+ (row: (typeof data)[number]) => {
if (Array.isArray(row.user) || !row.user) {
return null;
}
@@ -184,7 +184,7 @@ const CustomerAccountsTable = memo(
return (
<>
- <Table<typeof rows[number]>
+ <Table<(typeof rows)[number]>
actions={actions}
count={count}
columns={columns}
diff --git a/apps/carbon/app/modules/users/interfaces/Customers/CustomerAccountsTable/index.ts b/apps/carbon/app/modules/users/ui/Customers/CustomerAccountsTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Customers/CustomerAccountsTable/index.ts
rename to apps/carbon/app/modules/users/ui/Customers/CustomerAccountsTable/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/Customers/CustomerAccountsTableFilters/CustomerAccountsTableFilters.tsx b/apps/carbon/app/modules/users/ui/Customers/CustomerAccountsTableFilters/CustomerAccountsTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Customers/CustomerAccountsTableFilters/CustomerAccountsTableFilters.tsx
rename to apps/carbon/app/modules/users/ui/Customers/CustomerAccountsTableFilters/CustomerAccountsTableFilters.tsx
diff --git a/apps/carbon/app/modules/users/interfaces/Customers/CustomerAccountsTableFilters/index.ts b/apps/carbon/app/modules/users/ui/Customers/CustomerAccountsTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Customers/CustomerAccountsTableFilters/index.ts
rename to apps/carbon/app/modules/users/ui/Customers/CustomerAccountsTableFilters/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/Customers/index.ts b/apps/carbon/app/modules/users/ui/Customers/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Customers/index.ts
rename to apps/carbon/app/modules/users/ui/Customers/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/DeactivateUsersModal/DeactivateUsersModal.tsx b/apps/carbon/app/modules/users/ui/DeactivateUsersModal/DeactivateUsersModal.tsx
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/DeactivateUsersModal/DeactivateUsersModal.tsx
rename to apps/carbon/app/modules/users/ui/DeactivateUsersModal/DeactivateUsersModal.tsx
diff --git a/apps/carbon/app/modules/users/interfaces/DeactivateUsersModal/index.ts b/apps/carbon/app/modules/users/ui/DeactivateUsersModal/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/DeactivateUsersModal/index.ts
rename to apps/carbon/app/modules/users/ui/DeactivateUsersModal/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx b/apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx
similarity index 97%
rename from apps/carbon/app/modules/users/interfaces/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx
rename to apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx
index e3aba25643..6ddf5d5757 100644
--- a/apps/carbon/app/modules/users/interfaces/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx
+++ b/apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypeForm/EmployeeTypeForm.tsx
@@ -17,9 +17,9 @@ import { useState } from "react";
import { ValidatedForm } from "remix-validated-form";
import { Color, Hidden, Input, Submit } from "~/components/Form";
import { usePermissions } from "~/hooks";
-import PermissionCheckboxes from "~/modules/users/interfaces/components/Permission";
import type { Permission } from "~/modules/users";
import { employeeTypeValidator } from "~/modules/users";
+import PermissionCheckboxes from "~/modules/users/ui/components/Permission";
import type { TypeOfValidator } from "~/types/validators";
type EmployeeTypeFormProps = {
diff --git a/apps/carbon/app/modules/users/interfaces/EmployeeTypes/EmployeeTypeForm/index.ts b/apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypeForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/EmployeeTypes/EmployeeTypeForm/index.ts
rename to apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypeForm/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/EmployeeTypes/EmployeeTypesTable/EmployeeTypesTable.tsx b/apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypesTable/EmployeeTypesTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/EmployeeTypes/EmployeeTypesTable/EmployeeTypesTable.tsx
rename to apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypesTable/EmployeeTypesTable.tsx
diff --git a/apps/carbon/app/modules/users/interfaces/EmployeeTypes/EmployeeTypesTable/index.ts b/apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypesTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/EmployeeTypes/EmployeeTypesTable/index.ts
rename to apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypesTable/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/EmployeeTypes/EmployeeTypesTableFilters/EmployeeTypesTableFilters.tsx b/apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypesTableFilters/EmployeeTypesTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/EmployeeTypes/EmployeeTypesTableFilters/EmployeeTypesTableFilters.tsx
rename to apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypesTableFilters/EmployeeTypesTableFilters.tsx
diff --git a/apps/carbon/app/modules/users/interfaces/EmployeeTypes/EmployeeTypesTableFilters/index.ts b/apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypesTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/EmployeeTypes/EmployeeTypesTableFilters/index.ts
rename to apps/carbon/app/modules/users/ui/EmployeeTypes/EmployeeTypesTableFilters/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/EmployeeTypes/index.ts b/apps/carbon/app/modules/users/ui/EmployeeTypes/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/EmployeeTypes/index.ts
rename to apps/carbon/app/modules/users/ui/EmployeeTypes/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/Employees/BulkEditPermissionsForm/BulkEditPermissionsForm.tsx b/apps/carbon/app/modules/users/ui/Employees/BulkEditPermissionsForm/BulkEditPermissionsForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Employees/BulkEditPermissionsForm/BulkEditPermissionsForm.tsx
rename to apps/carbon/app/modules/users/ui/Employees/BulkEditPermissionsForm/BulkEditPermissionsForm.tsx
diff --git a/apps/carbon/app/modules/users/interfaces/Employees/BulkEditPermissionsForm/index.ts b/apps/carbon/app/modules/users/ui/Employees/BulkEditPermissionsForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Employees/BulkEditPermissionsForm/index.ts
rename to apps/carbon/app/modules/users/ui/Employees/BulkEditPermissionsForm/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/Employees/CreateEmployeeModal/CreateEmployeeModal.tsx b/apps/carbon/app/modules/users/ui/Employees/CreateEmployeeModal/CreateEmployeeModal.tsx
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Employees/CreateEmployeeModal/CreateEmployeeModal.tsx
rename to apps/carbon/app/modules/users/ui/Employees/CreateEmployeeModal/CreateEmployeeModal.tsx
diff --git a/apps/carbon/app/modules/users/interfaces/Employees/CreateEmployeeModal/index.ts b/apps/carbon/app/modules/users/ui/Employees/CreateEmployeeModal/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Employees/CreateEmployeeModal/index.ts
rename to apps/carbon/app/modules/users/ui/Employees/CreateEmployeeModal/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx b/apps/carbon/app/modules/users/ui/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx
similarity index 97%
rename from apps/carbon/app/modules/users/interfaces/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx
rename to apps/carbon/app/modules/users/ui/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx
index 221e1b2bf1..acb8491ff3 100644
--- a/apps/carbon/app/modules/users/interfaces/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx
+++ b/apps/carbon/app/modules/users/ui/Employees/EmployeePermissionsForm/EmployeePermissionsForm.tsx
@@ -17,9 +17,9 @@ import type { PostgrestResponse } from "@supabase/supabase-js";
import { useEffect, useState } from "react";
import { ValidatedForm } from "remix-validated-form";
import { Hidden, Select, Submit } from "~/components/Form";
-import PermissionCheckboxes from "~/modules/users/interfaces/components/Permission";
import type { EmployeeType, Permission } from "~/modules/users";
import { employeeValidator } from "~/modules/users";
+import PermissionCheckboxes from "~/modules/users/ui/components/Permission";
import type { TypeOfValidator } from "~/types/validators";
import { mapRowsToOptions } from "~/utils/form";
diff --git a/apps/carbon/app/modules/users/interfaces/Employees/EmployeePermissionsForm/index.ts b/apps/carbon/app/modules/users/ui/Employees/EmployeePermissionsForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Employees/EmployeePermissionsForm/index.ts
rename to apps/carbon/app/modules/users/ui/Employees/EmployeePermissionsForm/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/Employees/EmployeesTable/EmployeesTable.tsx b/apps/carbon/app/modules/users/ui/Employees/EmployeesTable/EmployeesTable.tsx
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Employees/EmployeesTable/EmployeesTable.tsx
rename to apps/carbon/app/modules/users/ui/Employees/EmployeesTable/EmployeesTable.tsx
diff --git a/apps/carbon/app/modules/users/interfaces/Employees/EmployeesTable/index.ts b/apps/carbon/app/modules/users/ui/Employees/EmployeesTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Employees/EmployeesTable/index.ts
rename to apps/carbon/app/modules/users/ui/Employees/EmployeesTable/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/Employees/EmployeesTableFilters/EmployeesTableFilters.tsx b/apps/carbon/app/modules/users/ui/Employees/EmployeesTableFilters/EmployeesTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Employees/EmployeesTableFilters/EmployeesTableFilters.tsx
rename to apps/carbon/app/modules/users/ui/Employees/EmployeesTableFilters/EmployeesTableFilters.tsx
diff --git a/apps/carbon/app/modules/users/interfaces/Employees/EmployeesTableFilters/index.ts b/apps/carbon/app/modules/users/ui/Employees/EmployeesTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Employees/EmployeesTableFilters/index.ts
rename to apps/carbon/app/modules/users/ui/Employees/EmployeesTableFilters/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/Employees/index.ts b/apps/carbon/app/modules/users/ui/Employees/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Employees/index.ts
rename to apps/carbon/app/modules/users/ui/Employees/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/Groups/GroupsForm/GroupsForm.tsx b/apps/carbon/app/modules/users/ui/Groups/GroupsForm/GroupsForm.tsx
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Groups/GroupsForm/GroupsForm.tsx
rename to apps/carbon/app/modules/users/ui/Groups/GroupsForm/GroupsForm.tsx
diff --git a/apps/carbon/app/modules/users/interfaces/Groups/GroupsForm/index.ts b/apps/carbon/app/modules/users/ui/Groups/GroupsForm/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Groups/GroupsForm/index.ts
rename to apps/carbon/app/modules/users/ui/Groups/GroupsForm/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/Groups/GroupsTable/GroupsTable.tsx b/apps/carbon/app/modules/users/ui/Groups/GroupsTable/GroupsTable.tsx
similarity index 95%
rename from apps/carbon/app/modules/users/interfaces/Groups/GroupsTable/GroupsTable.tsx
rename to apps/carbon/app/modules/users/ui/Groups/GroupsTable/GroupsTable.tsx
index e5620a4f68..384f1ee4b0 100644
--- a/apps/carbon/app/modules/users/interfaces/Groups/GroupsTable/GroupsTable.tsx
+++ b/apps/carbon/app/modules/users/ui/Groups/GroupsTable/GroupsTable.tsx
@@ -34,7 +34,7 @@ const GroupsTable = memo(({ data, count }: GroupsTableProps) => {
),
}));
- const columns = useMemo<ColumnDef<typeof rows[number]>[]>(() => {
+ const columns = useMemo<ColumnDef<(typeof rows)[number]>[]>(() => {
return [
{
accessorKey: "name",
@@ -66,7 +66,7 @@ const GroupsTable = memo(({ data, count }: GroupsTableProps) => {
}, []);
const renderContextMenu = useCallback(
- (row: typeof rows[number]) => {
+ (row: (typeof rows)[number]) => {
return (
<>
<MenuItem
@@ -104,7 +104,7 @@ const GroupsTable = memo(({ data, count }: GroupsTableProps) => {
);
return (
- <Table<typeof rows[number]>
+ <Table<(typeof rows)[number]>
data={rows}
count={count}
columns={columns}
diff --git a/apps/carbon/app/modules/users/interfaces/Groups/GroupsTable/index.ts b/apps/carbon/app/modules/users/ui/Groups/GroupsTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Groups/GroupsTable/index.ts
rename to apps/carbon/app/modules/users/ui/Groups/GroupsTable/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/Groups/GroupsTableFilters/GroupsTableFilters.tsx b/apps/carbon/app/modules/users/ui/Groups/GroupsTableFilters/GroupsTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Groups/GroupsTableFilters/GroupsTableFilters.tsx
rename to apps/carbon/app/modules/users/ui/Groups/GroupsTableFilters/GroupsTableFilters.tsx
diff --git a/apps/carbon/app/modules/users/interfaces/Groups/GroupsTableFilters/index.ts b/apps/carbon/app/modules/users/ui/Groups/GroupsTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Groups/GroupsTableFilters/index.ts
rename to apps/carbon/app/modules/users/ui/Groups/GroupsTableFilters/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/Groups/index.ts b/apps/carbon/app/modules/users/ui/Groups/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Groups/index.ts
rename to apps/carbon/app/modules/users/ui/Groups/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/ResendInviteModal/ResendInviteModal.tsx b/apps/carbon/app/modules/users/ui/ResendInviteModal/ResendInviteModal.tsx
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/ResendInviteModal/ResendInviteModal.tsx
rename to apps/carbon/app/modules/users/ui/ResendInviteModal/ResendInviteModal.tsx
diff --git a/apps/carbon/app/modules/users/interfaces/ResendInviteModal/index.ts b/apps/carbon/app/modules/users/ui/ResendInviteModal/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/ResendInviteModal/index.ts
rename to apps/carbon/app/modules/users/ui/ResendInviteModal/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/Suppliers/CreateSupplierModal/CreateSupplierModal.tsx b/apps/carbon/app/modules/users/ui/Suppliers/CreateSupplierModal/CreateSupplierModal.tsx
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Suppliers/CreateSupplierModal/CreateSupplierModal.tsx
rename to apps/carbon/app/modules/users/ui/Suppliers/CreateSupplierModal/CreateSupplierModal.tsx
diff --git a/apps/carbon/app/modules/users/interfaces/Suppliers/CreateSupplierModal/index.ts b/apps/carbon/app/modules/users/ui/Suppliers/CreateSupplierModal/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Suppliers/CreateSupplierModal/index.ts
rename to apps/carbon/app/modules/users/ui/Suppliers/CreateSupplierModal/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/Suppliers/SupplierAccountsTable/SuppliersAccountsTable.tsx b/apps/carbon/app/modules/users/ui/Suppliers/SupplierAccountsTable/SuppliersAccountsTable.tsx
similarity index 97%
rename from apps/carbon/app/modules/users/interfaces/Suppliers/SupplierAccountsTable/SuppliersAccountsTable.tsx
rename to apps/carbon/app/modules/users/ui/Suppliers/SupplierAccountsTable/SuppliersAccountsTable.tsx
index 397ec14c6f..c5cc529b7a 100644
--- a/apps/carbon/app/modules/users/interfaces/Suppliers/SupplierAccountsTable/SuppliersAccountsTable.tsx
+++ b/apps/carbon/app/modules/users/ui/Suppliers/SupplierAccountsTable/SuppliersAccountsTable.tsx
@@ -47,7 +47,7 @@ const SupplierAccountsTable = memo(
[data]
);
- const columns = useMemo<ColumnDef<typeof rows[number]>[]>(() => {
+ const columns = useMemo<ColumnDef<(typeof rows)[number]>[]>(() => {
return [
{
header: "User",
@@ -140,7 +140,7 @@ const SupplierAccountsTable = memo(
}, [deactivateSupplierModal, permissions, resendInviteModal]);
const renderContextMenu = useCallback(
- (row: typeof data[number]) => {
+ (row: (typeof data)[number]) => {
if (Array.isArray(row.user) || !row.user) {
return null;
}
@@ -175,7 +175,7 @@ const SupplierAccountsTable = memo(
return (
<>
- <Table<typeof rows[number]>
+ <Table<(typeof rows)[number]>
actions={actions}
count={count}
columns={columns}
diff --git a/apps/carbon/app/modules/users/interfaces/Suppliers/SupplierAccountsTable/index.ts b/apps/carbon/app/modules/users/ui/Suppliers/SupplierAccountsTable/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Suppliers/SupplierAccountsTable/index.ts
rename to apps/carbon/app/modules/users/ui/Suppliers/SupplierAccountsTable/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/Suppliers/SupplierAccountsTableFilters/SupplierAccountsTableFilters.tsx b/apps/carbon/app/modules/users/ui/Suppliers/SupplierAccountsTableFilters/SupplierAccountsTableFilters.tsx
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Suppliers/SupplierAccountsTableFilters/SupplierAccountsTableFilters.tsx
rename to apps/carbon/app/modules/users/ui/Suppliers/SupplierAccountsTableFilters/SupplierAccountsTableFilters.tsx
diff --git a/apps/carbon/app/modules/users/interfaces/Suppliers/SupplierAccountsTableFilters/index.ts b/apps/carbon/app/modules/users/ui/Suppliers/SupplierAccountsTableFilters/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Suppliers/SupplierAccountsTableFilters/index.ts
rename to apps/carbon/app/modules/users/ui/Suppliers/SupplierAccountsTableFilters/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/Suppliers/index.ts b/apps/carbon/app/modules/users/ui/Suppliers/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/Suppliers/index.ts
rename to apps/carbon/app/modules/users/ui/Suppliers/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/components/Permission/Permission.tsx b/apps/carbon/app/modules/users/ui/components/Permission/Permission.tsx
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/components/Permission/Permission.tsx
rename to apps/carbon/app/modules/users/ui/components/Permission/Permission.tsx
diff --git a/apps/carbon/app/modules/users/interfaces/components/Permission/index.ts b/apps/carbon/app/modules/users/ui/components/Permission/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/components/Permission/index.ts
rename to apps/carbon/app/modules/users/ui/components/Permission/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/index.ts b/apps/carbon/app/modules/users/ui/index.ts
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/index.ts
rename to apps/carbon/app/modules/users/ui/index.ts
diff --git a/apps/carbon/app/modules/users/interfaces/useUsersSidebar.tsx b/apps/carbon/app/modules/users/ui/useUsersSidebar.tsx
similarity index 100%
rename from apps/carbon/app/modules/users/interfaces/useUsersSidebar.tsx
rename to apps/carbon/app/modules/users/ui/useUsersSidebar.tsx
diff --git a/apps/carbon/app/routes/api+/accounting.accounts.tsx b/apps/carbon/app/routes/api+/accounting.accounts.tsx
index d6ff461d49..90cdc8a365 100644
--- a/apps/carbon/app/routes/api+/accounting.accounts.tsx
+++ b/apps/carbon/app/routes/api+/accounting.accounts.tsx
@@ -9,6 +9,12 @@ export async function loader({ request }: LoaderArgs) {
const url = new URL(request.url);
const searchParams = new URLSearchParams(url.search);
const type = searchParams.get("type");
+ const incomeBalance = searchParams.get("incomeBalance");
- return json(await getAccountsList(authorized.client, type));
+ return json(
+ await getAccountsList(authorized.client, {
+ type,
+ incomeBalance,
+ })
+ );
}
diff --git a/apps/carbon/app/routes/x+/accounting+/_layout.tsx b/apps/carbon/app/routes/x+/accounting+/_layout.tsx
index c01b663751..988f14d8cf 100644
--- a/apps/carbon/app/routes/x+/accounting+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/accounting+/_layout.tsx
@@ -1,10 +1,16 @@
import { Grid, VStack } from "@chakra-ui/react";
import type { LoaderArgs, MetaFunction } from "@remix-run/node";
-import { json } from "@remix-run/node";
+import { json, redirect } from "@remix-run/node";
import { Outlet } from "@remix-run/react";
import { GroupedContentSidebar } from "~/components/Layout/Sidebar";
-import { getBaseCurrency, useAccountingSidebar } from "~/modules/accounting";
+import {
+ getAccountsList,
+ getBaseCurrency,
+ useAccountingSidebar,
+} from "~/modules/accounting";
import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import { error } from "~/utils/result";
export const meta: MetaFunction = () => ({
title: "Carbon | Accounting",
@@ -15,10 +21,49 @@ export async function loader({ request }: LoaderArgs) {
view: "accounting",
});
- const [baseCurrency] = await Promise.all([getBaseCurrency(client)]);
+ const [baseCurrency, balanceSheetAccounts, incomeStatementAccounts] =
+ await Promise.all([
+ getBaseCurrency(client),
+ getAccountsList(client, {
+ type: "Posting",
+ incomeBalance: "Balance Sheet",
+ }),
+ getAccountsList(client, {
+ type: "Posting",
+ incomeBalance: "Income Statement",
+ }),
+ ]);
+
+ if (balanceSheetAccounts.error) {
+ return redirect(
+ "/x",
+ await flash(
+ request,
+ error(
+ balanceSheetAccounts.error,
+ "Failed to fetch balance sheet accounts"
+ )
+ )
+ );
+ }
+
+ if (incomeStatementAccounts.error) {
+ return redirect(
+ "/x",
+ await flash(
+ request,
+ error(
+ incomeStatementAccounts.error,
+ "Failed to fetch income statement accounts"
+ )
+ )
+ );
+ }
return json({
baseCurrency: baseCurrency.data,
+ balanceSheetAccounts: balanceSheetAccounts.data ?? [],
+ incomeStatementAccounts: incomeStatementAccounts.data ?? [],
});
}
@@ -26,7 +71,7 @@ export default function UsersRoute() {
const { groups } = useAccountingSidebar();
return (
- <Grid w="full" h="full" templateColumns="auto 1fr" overflow="auto">
+ <Grid w="full" h="full" templateColumns="auto 1fr">
<GroupedContentSidebar groups={groups} />
<VStack w="full" h="full" spacing={0}>
<Outlet />
diff --git a/apps/carbon/app/routes/x+/accounting+/charts.tsx b/apps/carbon/app/routes/x+/accounting+/charts.tsx
index af10592e8a..7c5541db97 100644
--- a/apps/carbon/app/routes/x+/accounting+/charts.tsx
+++ b/apps/carbon/app/routes/x+/accounting+/charts.tsx
@@ -1,10 +1,9 @@
import { VStack } from "@chakra-ui/react";
import type { LoaderArgs } from "@remix-run/node";
-import { redirect } from "@remix-run/node";
-import { json } from "@remix-run/node";
+import { json, redirect } from "@remix-run/node";
import { Outlet, useLoaderData } from "@remix-run/react";
import { ChartOfAccountsTable, getChartOfAccounts } from "~/modules/accounting";
-import ChartOfAccountsTableFilters from "~/modules/accounting/interfaces/ChartOfAccounts/ChartOfAccountsTableFilters";
+import ChartOfAccountsTableFilters from "~/modules/accounting/ui/ChartOfAccounts/ChartOfAccountsTableFilters";
import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session";
import { error } from "~/utils/result";
diff --git a/apps/carbon/app/routes/x+/accounting+/defaults.tsx b/apps/carbon/app/routes/x+/accounting+/defaults.tsx
new file mode 100644
index 0000000000..a446561743
--- /dev/null
+++ b/apps/carbon/app/routes/x+/accounting+/defaults.tsx
@@ -0,0 +1,98 @@
+import { useColor } from "@carbon/react";
+import { VStack } from "@chakra-ui/react";
+import type { ActionArgs, LoaderArgs } from "@remix-run/node";
+import { json, redirect } from "@remix-run/node";
+import { useLoaderData } from "@remix-run/react";
+import { validationError } from "remix-validated-form";
+import { PageTitle } from "~/components/Layout";
+import { useRouteData } from "~/hooks";
+import type { AccountListItem } from "~/modules/accounting";
+import {
+ AccountDefaultsForm,
+ defaultAcountValidator,
+ getDefaultAccounts,
+ updateDefaultAccounts,
+} from "~/modules/accounting";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import { assertIsPost } from "~/utils/http";
+import { error, success } from "~/utils/result";
+
+export async function loader({ request }: LoaderArgs) {
+ const { client } = await requirePermissions(request, {
+ view: "accounting",
+ });
+
+ const [defaultAccounts] = await Promise.all([getDefaultAccounts(client)]);
+
+ if (defaultAccounts.error || !defaultAccounts.data) {
+ return redirect(
+ "/x/accounting",
+ await flash(
+ request,
+ error(defaultAccounts.error, "Failed to load default accounts")
+ )
+ );
+ }
+
+ return json({
+ defaultAccounts: defaultAccounts.data,
+ });
+}
+
+export async function action({ request }: ActionArgs) {
+ assertIsPost(request);
+ const { client, userId } = await requirePermissions(request, {
+ create: "accounting",
+ });
+
+ const validation = await defaultAcountValidator.validate(
+ await request.formData()
+ );
+
+ if (validation.error) {
+ return validationError(validation.error);
+ }
+
+ const updateDefaults = await updateDefaultAccounts(client, {
+ ...validation.data,
+ updatedBy: userId,
+ });
+ if (updateDefaults.error) {
+ return json(
+ {},
+ await flash(
+ request,
+ error(updateDefaults.error, "Failed to update default accounts")
+ )
+ );
+ }
+
+ return redirect(
+ "/x/accounting/defaults",
+ await flash(request, success("Updated default accounts"))
+ );
+}
+
+export default function AccountDefaultsRoute() {
+ const { defaultAccounts } = useLoaderData<typeof loader>();
+ const routeData = useRouteData<{
+ balanceSheetAccounts: AccountListItem[];
+ incomeStatementAccounts: AccountListItem[];
+ }>("/x/accounting");
+
+ return (
+ <VStack bg={useColor("white")} w="full" h="full" p={8} overflowY="auto">
+ <PageTitle
+ title="Account Defaults"
+ subtitle="These accounts will be used to prepopulate posting grous when a new customer type, supplier type, part group, or location is created."
+ />
+
+ <AccountDefaultsForm
+ balanceSheetAccounts={routeData?.balanceSheetAccounts ?? []}
+ incomeStatementAccounts={routeData?.incomeStatementAccounts ?? []}
+ initialValues={defaultAccounts}
+ />
+ </VStack>
+ );
+}
diff --git a/apps/carbon/app/routes/x+/accounting+/groups.inventory.tsx b/apps/carbon/app/routes/x+/accounting+/groups.inventory.tsx
new file mode 100644
index 0000000000..e11685ed42
--- /dev/null
+++ b/apps/carbon/app/routes/x+/accounting+/groups.inventory.tsx
@@ -0,0 +1,84 @@
+import { VStack } from "@chakra-ui/react";
+import type { LoaderArgs } from "@remix-run/node";
+import { json, redirect } from "@remix-run/node";
+import { Outlet, useLoaderData } from "@remix-run/react";
+import { useRouteData } from "~/hooks";
+import type { AccountListItem } from "~/modules/accounting";
+import {
+ getInventoryPostingGroups,
+ InventoryPostingGroupsFilters,
+ InventoryPostingGroupsTable,
+} from "~/modules/accounting";
+import { getPartGroupsList } from "~/modules/parts";
+import { getLocationsList } from "~/modules/resources";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import { getGenericQueryFilters } from "~/utils/query";
+import { error } from "~/utils/result";
+
+export async function loader({ request }: LoaderArgs) {
+ const { client } = await requirePermissions(request, {
+ view: ["accounting", "inventory"],
+ });
+
+ const url = new URL(request.url);
+ const searchParams = new URLSearchParams(url.search);
+ const partGroup = searchParams.get("partGroup");
+ const location = searchParams.get("location");
+ const { limit, offset, sorts } = getGenericQueryFilters(searchParams);
+
+ const [inventoryGroups, partGroups, locations] = await Promise.all([
+ getInventoryPostingGroups(client, {
+ partGroup,
+ location,
+ limit,
+ offset,
+ sorts,
+ }),
+ getPartGroupsList(client),
+ getLocationsList(client),
+ ]);
+ if (inventoryGroups.error) {
+ return redirect(
+ "/x/accounting",
+ await flash(
+ request,
+ error(inventoryGroups.error, "Failed to fetch inventory posting groups")
+ )
+ );
+ }
+
+ return json({
+ data: inventoryGroups.data ?? [],
+ partGroups: partGroups.data ?? [],
+ locations: locations.data ?? [],
+ count: inventoryGroups.count ?? 0,
+ });
+}
+
+export default function InventoryPostingGroupsRoute() {
+ const { data, partGroups, locations, count } = useLoaderData<typeof loader>();
+
+ const routeData = useRouteData<{
+ balanceSheetAccounts: AccountListItem[];
+ incomeStatementAccounts: AccountListItem[];
+ }>("/x/accounting");
+
+ return (
+ <VStack w="full" h="full" spacing={0}>
+ <InventoryPostingGroupsFilters
+ partGroups={partGroups}
+ locations={locations}
+ />
+ <InventoryPostingGroupsTable
+ data={data}
+ count={count}
+ partGroups={partGroups}
+ locations={locations}
+ balanceSheetAccounts={routeData?.balanceSheetAccounts ?? []}
+ incomeStatementAccounts={routeData?.incomeStatementAccounts ?? []}
+ />
+ <Outlet />
+ </VStack>
+ );
+}
diff --git a/apps/carbon/app/routes/x+/accounting+/groups.purchasing.tsx b/apps/carbon/app/routes/x+/accounting+/groups.purchasing.tsx
new file mode 100644
index 0000000000..64c7fd4aba
--- /dev/null
+++ b/apps/carbon/app/routes/x+/accounting+/groups.purchasing.tsx
@@ -0,0 +1,88 @@
+import { VStack } from "@chakra-ui/react";
+import type { LoaderArgs } from "@remix-run/node";
+import { json, redirect } from "@remix-run/node";
+import { Outlet, useLoaderData } from "@remix-run/react";
+import { useRouteData } from "~/hooks";
+import type { AccountListItem } from "~/modules/accounting";
+import {
+ getPurchasingPostingGroups,
+ PurchasingPostingGroupsFilters,
+ PurchasingPostingGroupsTable,
+} from "~/modules/accounting";
+import { getPartGroupsList } from "~/modules/parts";
+import { getSupplierTypesList } from "~/modules/purchasing";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import { getGenericQueryFilters } from "~/utils/query";
+import { error } from "~/utils/result";
+
+export async function loader({ request }: LoaderArgs) {
+ const { client } = await requirePermissions(request, {
+ view: ["accounting", "purchasing"],
+ });
+
+ const url = new URL(request.url);
+ const searchParams = new URLSearchParams(url.search);
+ const partGroup = searchParams.get("partGroup");
+ const supplierType = searchParams.get("supplierType");
+ const { limit, offset, sorts } = getGenericQueryFilters(searchParams);
+
+ const [purchasingGroups, partGroups, supplierTypes] = await Promise.all([
+ getPurchasingPostingGroups(client, {
+ partGroup,
+ supplierType,
+ limit,
+ offset,
+ sorts,
+ }),
+ getPartGroupsList(client),
+ getSupplierTypesList(client),
+ ]);
+ if (purchasingGroups.error) {
+ return redirect(
+ "/x/accounting",
+ await flash(
+ request,
+ error(
+ purchasingGroups.error,
+ "Failed to fetch purchasing posting groups"
+ )
+ )
+ );
+ }
+
+ return json({
+ data: purchasingGroups.data ?? [],
+ partGroups: partGroups.data ?? [],
+ supplierTypes: supplierTypes.data ?? [],
+ count: purchasingGroups.count ?? 0,
+ });
+}
+
+export default function PurchasingPostingGroupsRoute() {
+ const { data, partGroups, supplierTypes, count } =
+ useLoaderData<typeof loader>();
+
+ const routeData = useRouteData<{
+ balanceSheetAccounts: AccountListItem[];
+ incomeStatementAccounts: AccountListItem[];
+ }>("/x/accounting");
+
+ return (
+ <VStack w="full" h="full" spacing={0}>
+ <PurchasingPostingGroupsFilters
+ partGroups={partGroups}
+ supplierTypes={supplierTypes}
+ />
+ <PurchasingPostingGroupsTable
+ data={data}
+ count={count}
+ partGroups={partGroups}
+ supplierTypes={supplierTypes}
+ balanceSheetAccounts={routeData?.balanceSheetAccounts ?? []}
+ incomeStatementAccounts={routeData?.incomeStatementAccounts ?? []}
+ />
+ <Outlet />
+ </VStack>
+ );
+}
diff --git a/apps/carbon/app/routes/x+/accounting+/groups.sales.tsx b/apps/carbon/app/routes/x+/accounting+/groups.sales.tsx
new file mode 100644
index 0000000000..e0e8b747eb
--- /dev/null
+++ b/apps/carbon/app/routes/x+/accounting+/groups.sales.tsx
@@ -0,0 +1,85 @@
+import { VStack } from "@chakra-ui/react";
+import type { LoaderArgs } from "@remix-run/node";
+import { json, redirect } from "@remix-run/node";
+import { Outlet, useLoaderData } from "@remix-run/react";
+import { useRouteData } from "~/hooks";
+import type { AccountListItem } from "~/modules/accounting";
+import {
+ getSalesPostingGroups,
+ SalesPostingGroupsFilters,
+ SalesPostingGroupsTable,
+} from "~/modules/accounting";
+import { getPartGroupsList } from "~/modules/parts";
+import { getCustomerTypesList } from "~/modules/sales";
+import { requirePermissions } from "~/services/auth";
+import { flash } from "~/services/session";
+import { getGenericQueryFilters } from "~/utils/query";
+import { error } from "~/utils/result";
+
+export async function loader({ request }: LoaderArgs) {
+ const { client } = await requirePermissions(request, {
+ view: ["accounting", "sales"],
+ });
+
+ const url = new URL(request.url);
+ const searchParams = new URLSearchParams(url.search);
+ const partGroup = searchParams.get("partGroup");
+ const customerType = searchParams.get("customerType");
+ const { limit, offset, sorts } = getGenericQueryFilters(searchParams);
+
+ const [salesGroups, partGroups, customerTypes] = await Promise.all([
+ getSalesPostingGroups(client, {
+ partGroup,
+ customerType,
+ limit,
+ offset,
+ sorts,
+ }),
+ getPartGroupsList(client),
+ getCustomerTypesList(client),
+ ]);
+ if (salesGroups.error) {
+ return redirect(
+ "/x/accounting",
+ await flash(
+ request,
+ error(salesGroups.error, "Failed to fetch sales posting groups")
+ )
+ );
+ }
+
+ return json({
+ data: salesGroups.data ?? [],
+ count: salesGroups.count ?? 0,
+ partGroups: partGroups.data ?? [],
+ customerTypes: customerTypes.data ?? [],
+ });
+}
+
+export default function SalesPostingGroupsRoute() {
+ const { data, count, partGroups, customerTypes } =
+ useLoaderData<typeof loader>();
+
+ const routeData = useRouteData<{
+ balanceSheetAccounts: AccountListItem[];
+ incomeStatementAccounts: AccountListItem[];
+ }>("/x/accounting");
+
+ return (
+ <VStack w="full" h="full" spacing={0}>
+ <SalesPostingGroupsFilters
+ partGroups={partGroups}
+ customerTypes={customerTypes}
+ />
+ <SalesPostingGroupsTable
+ data={data}
+ count={count}
+ partGroups={partGroups}
+ customerTypes={customerTypes}
+ balanceSheetAccounts={routeData?.balanceSheetAccounts ?? []}
+ incomeStatementAccounts={routeData?.incomeStatementAccounts ?? []}
+ />
+ <Outlet />
+ </VStack>
+ );
+}
diff --git a/apps/carbon/app/routes/x+/documents+/_layout.tsx b/apps/carbon/app/routes/x+/documents+/_layout.tsx
index 2dd09fe8af..ea37e33c43 100644
--- a/apps/carbon/app/routes/x+/documents+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/documents+/_layout.tsx
@@ -12,7 +12,7 @@ export default function DocumentsRoute() {
const { links } = useDocumentsSidebar();
return (
- <Grid w="full" h="full" templateColumns="auto 1fr" overflow="auto">
+ <Grid w="full" h="full" templateColumns="auto 1fr">
<ContentSidebar links={links} />
<VStack w="full" h="full">
<Outlet />
diff --git a/apps/carbon/app/routes/x+/inventory+/_layout.tsx b/apps/carbon/app/routes/x+/inventory+/_layout.tsx
index 15e15337f4..4c2be69135 100644
--- a/apps/carbon/app/routes/x+/inventory+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/inventory+/_layout.tsx
@@ -12,7 +12,7 @@ export default function UsersRoute() {
const { groups } = useInventorySidebar();
return (
- <Grid w="full" h="full" templateColumns="auto 1fr" overflow="auto">
+ <Grid w="full" h="full" templateColumns="auto 1fr">
<GroupedContentSidebar groups={groups} />
<VStack w="full" h="full" spacing={0}>
<Outlet />
diff --git a/apps/carbon/app/routes/x+/part+/$partId.costing.tsx b/apps/carbon/app/routes/x+/part+/$partId.costing.tsx
index 4f36a26fa0..0d1b8ad029 100644
--- a/apps/carbon/app/routes/x+/part+/$partId.costing.tsx
+++ b/apps/carbon/app/routes/x+/part+/$partId.costing.tsx
@@ -6,8 +6,8 @@ import { useRouteData } from "~/hooks";
import { getAccountsList } from "~/modules/accounting";
import type { PartCostingMethod } from "~/modules/parts";
import {
- PartCostingForm,
getPartCost,
+ PartCostingForm,
partCostValidator,
upsertPartCost,
} from "~/modules/parts";
@@ -90,11 +90,10 @@ export default function PartCostingRoute() {
partCostingMethods: PartCostingMethod[];
}>("/x/part");
- const { partCost, accounts } = useLoaderData<typeof loader>();
+ const { partCost } = useLoaderData<typeof loader>();
return (
<PartCostingForm
initialValues={partCost}
- accounts={accounts}
partCostingMethods={sharedPartsData?.partCostingMethods ?? []}
/>
);
diff --git a/apps/carbon/app/routes/x+/parts+/_layout.tsx b/apps/carbon/app/routes/x+/parts+/_layout.tsx
index b41fa0d29d..599b310f65 100644
--- a/apps/carbon/app/routes/x+/parts+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/parts+/_layout.tsx
@@ -12,7 +12,7 @@ export default function PartsRoute() {
const { groups } = usePartsSidebar();
return (
- <Grid w="full" h="full" templateColumns="auto 1fr" overflow="auto">
+ <Grid w="full" h="full" templateColumns="auto 1fr">
<GroupedContentSidebar groups={groups} />
<VStack w="full" h="full" spacing={0}>
<Outlet />
diff --git a/apps/carbon/app/routes/x+/parts+/groups.$groupId.tsx b/apps/carbon/app/routes/x+/parts+/groups.$groupId.tsx
index 17cb750a17..2b4a45d33a 100644
--- a/apps/carbon/app/routes/x+/parts+/groups.$groupId.tsx
+++ b/apps/carbon/app/routes/x+/parts+/groups.$groupId.tsx
@@ -1,13 +1,12 @@
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
-import { redirect } from "@remix-run/node";
-import { json } from "@remix-run/node";
+import { json, redirect } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import { validationError } from "remix-validated-form";
import { useRouteData } from "~/hooks";
-import { PartGroupForm } from "~/modules/parts";
import {
- partGroupValidator,
getPartGroup,
+ PartGroupForm,
+ partGroupValidator,
upsertPartGroup,
} from "~/modules/parts";
import { requirePermissions } from "~/services/auth";
@@ -48,21 +47,9 @@ export async function action({ request, params }: ActionArgs) {
return validationError(validation.error);
}
- const {
- name,
- description,
- salesAccountId,
- discountAccountId,
- inventoryAccountId,
- } = validation.data;
-
const updatePartGroup = await upsertPartGroup(client, {
id: groupId,
- name,
- description,
- salesAccountId: salesAccountId ?? null,
- discountAccountId: discountAccountId ?? null,
- inventoryAccountId: inventoryAccountId ?? null,
+ ...validation.data,
updatedBy: userId,
});
@@ -92,9 +79,6 @@ export default function EditPartGroupsRoute() {
id: partGroup?.id ?? undefined,
name: partGroup?.name ?? "",
description: partGroup?.description ?? "",
- salesAccountId: partGroup?.salesAccountId ?? "",
- discountAccountId: partGroup?.discountAccountId ?? "",
- inventoryAccountId: partGroup?.inventoryAccountId ?? "",
};
return (
diff --git a/apps/carbon/app/routes/x+/parts+/groups.new.tsx b/apps/carbon/app/routes/x+/parts+/groups.new.tsx
index 9430e7e3da..dadcf1b9d5 100644
--- a/apps/carbon/app/routes/x+/parts+/groups.new.tsx
+++ b/apps/carbon/app/routes/x+/parts+/groups.new.tsx
@@ -34,20 +34,10 @@ export async function action({ request }: ActionArgs) {
return validationError(validation.error);
}
- const {
- name,
- description,
- salesAccountId,
- discountAccountId,
- inventoryAccountId,
- } = validation.data;
+ const { id, ...data } = validation.data;
const insertPartGroup = await upsertPartGroup(client, {
- name,
- description,
- salesAccountId,
- discountAccountId,
- inventoryAccountId,
+ ...data,
createdBy: userId,
});
if (insertPartGroup.error) {
@@ -85,9 +75,6 @@ export default function NewPartGroupsRoute() {
const initialValues = {
name: "",
description: "",
- salesAccountId: "",
- discountAccountId: "",
- inventoryAccountId: "",
};
return (
diff --git a/apps/carbon/app/routes/x+/purchasing+/_layout.tsx b/apps/carbon/app/routes/x+/purchasing+/_layout.tsx
index b1a7320495..7dd97bcb25 100644
--- a/apps/carbon/app/routes/x+/purchasing+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/purchasing+/_layout.tsx
@@ -12,7 +12,7 @@ export default function UsersRoute() {
const { groups } = usePurchasingSidebar();
return (
- <Grid w="full" h="full" templateColumns="auto 1fr" overflow="auto">
+ <Grid w="full" h="full" templateColumns="auto 1fr">
<GroupedContentSidebar groups={groups} />
<VStack w="full" h="full" spacing={0}>
<Outlet />
diff --git a/apps/carbon/app/routes/x+/purchasing+/supplier-types.$supplierTypeId.tsx b/apps/carbon/app/routes/x+/purchasing+/supplier-types.$supplierTypeId.tsx
index b2f94b9ca0..6dca461716 100644
--- a/apps/carbon/app/routes/x+/purchasing+/supplier-types.$supplierTypeId.tsx
+++ b/apps/carbon/app/routes/x+/purchasing+/supplier-types.$supplierTypeId.tsx
@@ -1,11 +1,10 @@
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
-import { redirect } from "@remix-run/node";
-import { json } from "@remix-run/node";
+import { json, redirect } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import { validationError } from "remix-validated-form";
import {
- SupplierTypeForm,
getSupplierType,
+ SupplierTypeForm,
supplierTypeValidator,
upsertSupplierType,
} from "~/modules/purchasing";
@@ -48,7 +47,7 @@ export async function loader({ request, params }: LoaderArgs) {
export async function action({ request }: ActionArgs) {
assertIsPost(request);
- const { client } = await requirePermissions(request, {
+ const { client, userId } = await requirePermissions(request, {
update: "purchasing",
});
@@ -60,12 +59,13 @@ export async function action({ request }: ActionArgs) {
return validationError(validation.error);
}
- const { id, name, color } = validation.data;
+ const { id, ...data } = validation.data;
+ if (!id) throw new Error("id is required");
const updateSupplierType = await upsertSupplierType(client, {
id,
- name,
- color: color || null,
+ ...data,
+ updatedBy: userId,
});
if (updateSupplierType.error) {
diff --git a/apps/carbon/app/routes/x+/purchasing+/supplier-types.new.tsx b/apps/carbon/app/routes/x+/purchasing+/supplier-types.new.tsx
index 03471edae5..9b43c486e1 100644
--- a/apps/carbon/app/routes/x+/purchasing+/supplier-types.new.tsx
+++ b/apps/carbon/app/routes/x+/purchasing+/supplier-types.new.tsx
@@ -1,6 +1,5 @@
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
-import { redirect } from "@remix-run/node";
-import { json } from "@remix-run/node";
+import { json, redirect } from "@remix-run/node";
import { validationError } from "remix-validated-form";
import {
SupplierTypeForm,
@@ -22,7 +21,7 @@ export async function loader({ request }: LoaderArgs) {
export async function action({ request }: ActionArgs) {
assertIsPost(request);
- const { client } = await requirePermissions(request, {
+ const { client, userId } = await requirePermissions(request, {
create: "purchasing",
});
@@ -34,11 +33,11 @@ export async function action({ request }: ActionArgs) {
return validationError(validation.error);
}
- const { name, color } = validation.data;
+ const { id, ...data } = validation.data;
const insertSupplierType = await upsertSupplierType(client, {
- name,
- color: color || null,
+ ...data,
+ createdBy: userId,
});
if (insertSupplierType.error) {
return json(
@@ -50,17 +49,6 @@ export async function action({ request }: ActionArgs) {
);
}
- const supplierTypeId = insertSupplierType.data?.id;
- if (!supplierTypeId) {
- return json(
- {},
- await flash(
- request,
- error(insertSupplierType, "Failed to insert supplier type")
- )
- );
- }
-
return redirect(
"/x/purchasing/supplier-types",
await flash(request, success("Supplier type created"))
diff --git a/apps/carbon/app/routes/x+/resources+/_layout.tsx b/apps/carbon/app/routes/x+/resources+/_layout.tsx
index b55fb47529..243ed5b12b 100644
--- a/apps/carbon/app/routes/x+/resources+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/resources+/_layout.tsx
@@ -12,7 +12,7 @@ export default function ResourcesRoute() {
const { groups } = useResourcesSidebar();
return (
- <Grid w="full" h="full" templateColumns="auto 1fr" overflow="auto">
+ <Grid w="full" h="full" templateColumns="auto 1fr">
<GroupedContentSidebar groups={groups} />
<VStack w="full" h="full" spacing={0}>
<Outlet />
diff --git a/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.$id.tsx b/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.$id.tsx
index 138f1353f4..d5be2c7129 100644
--- a/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.$id.tsx
+++ b/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.$id.tsx
@@ -3,7 +3,6 @@ import { redirect } from "@remix-run/node";
import { useLoaderData, useNavigate, useParams } from "@remix-run/react";
import { validationError } from "remix-validated-form";
import { useRouteData } from "~/hooks";
-import { EmployeeAbilityForm } from "~/modules/resources/interfaces/Abilities";
import type { Ability } from "~/modules/resources";
import {
AbilityEmployeeStatus,
@@ -12,6 +11,7 @@ import {
getTrainingStatus,
upsertEmployeeAbility,
} from "~/modules/resources";
+import { EmployeeAbilityForm } from "~/modules/resources/ui/Abilities";
import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session";
import { error, success } from "~/utils/result";
diff --git a/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.new.tsx b/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.new.tsx
index 023b4638f7..8a05d7da68 100644
--- a/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.new.tsx
+++ b/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.new.tsx
@@ -3,14 +3,14 @@ import { redirect } from "@remix-run/node";
import { useNavigate, useParams } from "@remix-run/react";
import { validationError } from "remix-validated-form";
import { useRouteData } from "~/hooks";
-import { EmployeeAbilityForm } from "~/modules/resources/interfaces/Abilities";
import type { Ability } from "~/modules/resources";
-import { AbilityEmployeeStatus } from "~/modules/resources";
-import { requirePermissions } from "~/services/auth";
import {
+ AbilityEmployeeStatus,
employeeAbilityValidator,
upsertEmployeeAbility,
} from "~/modules/resources";
+import { EmployeeAbilityForm } from "~/modules/resources/ui/Abilities";
+import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session";
import { error, success } from "~/utils/result";
diff --git a/apps/carbon/app/routes/x+/sales+/_layout.tsx b/apps/carbon/app/routes/x+/sales+/_layout.tsx
index 3c4eff24ff..91a86cc3a6 100644
--- a/apps/carbon/app/routes/x+/sales+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/sales+/_layout.tsx
@@ -12,7 +12,7 @@ export default function UsersRoute() {
const { groups } = useSalesSidebar();
return (
- <Grid w="full" h="full" templateColumns="auto 1fr" overflow="auto">
+ <Grid w="full" h="full" templateColumns="auto 1fr">
<GroupedContentSidebar groups={groups} />
<VStack w="full" h="full" spacing={0}>
<Outlet />
diff --git a/apps/carbon/app/routes/x+/sales+/customer-types.$customerTypeId.tsx b/apps/carbon/app/routes/x+/sales+/customer-types.$customerTypeId.tsx
index 5c79495922..d923ca8bb4 100644
--- a/apps/carbon/app/routes/x+/sales+/customer-types.$customerTypeId.tsx
+++ b/apps/carbon/app/routes/x+/sales+/customer-types.$customerTypeId.tsx
@@ -1,15 +1,14 @@
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
-import { redirect } from "@remix-run/node";
-import { json } from "@remix-run/node";
+import { json, redirect } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import { validationError } from "remix-validated-form";
-import { CustomerTypeForm } from "~/modules/sales";
-import { requirePermissions } from "~/services/auth";
import {
+ CustomerTypeForm,
customerTypeValidator,
getCustomerType,
upsertCustomerType,
} from "~/modules/sales";
+import { requirePermissions } from "~/services/auth";
import { flash } from "~/services/session";
import { assertIsPost, notFound } from "~/utils/http";
import { error, success } from "~/utils/result";
@@ -39,7 +38,7 @@ export async function loader({ request, params }: LoaderArgs) {
export async function action({ request }: ActionArgs) {
assertIsPost(request);
- const { client } = await requirePermissions(request, {
+ const { client, userId } = await requirePermissions(request, {
update: "sales",
});
@@ -51,12 +50,13 @@ export async function action({ request }: ActionArgs) {
return validationError(validation.error);
}
- const { id, name, color } = validation.data;
+ const { id, ...data } = validation.data;
+ if (!id) throw new Error("id is required");
const updateCustomerType = await upsertCustomerType(client, {
id,
- name,
- color: color || null,
+ ...data,
+ updatedBy: userId,
});
if (updateCustomerType.error) {
diff --git a/apps/carbon/app/routes/x+/sales+/customer-types.new.tsx b/apps/carbon/app/routes/x+/sales+/customer-types.new.tsx
index fc5b4c4d0a..58d9b3d3e6 100644
--- a/apps/carbon/app/routes/x+/sales+/customer-types.new.tsx
+++ b/apps/carbon/app/routes/x+/sales+/customer-types.new.tsx
@@ -1,6 +1,5 @@
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
-import { redirect } from "@remix-run/node";
-import { json } from "@remix-run/node";
+import { json, redirect } from "@remix-run/node";
import { validationError } from "remix-validated-form";
import {
CustomerTypeForm,
@@ -22,7 +21,7 @@ export async function loader({ request }: LoaderArgs) {
export async function action({ request }: ActionArgs) {
assertIsPost(request);
- const { client } = await requirePermissions(request, {
+ const { client, userId } = await requirePermissions(request, {
create: "sales",
});
@@ -34,11 +33,11 @@ export async function action({ request }: ActionArgs) {
return validationError(validation.error);
}
- const { name, color } = validation.data;
+ const { id, ...data } = validation.data;
const insertCustomerType = await upsertCustomerType(client, {
- name,
- color: color || null,
+ ...data,
+ createdBy: userId,
});
if (insertCustomerType.error) {
return json(
@@ -50,17 +49,6 @@ export async function action({ request }: ActionArgs) {
);
}
- const customerTypeId = insertCustomerType.data?.id;
- if (!customerTypeId) {
- return json(
- {},
- await flash(
- request,
- error(insertCustomerType, "Failed to insert customer type")
- )
- );
- }
-
return redirect(
"/x/sales/customer-types",
await flash(request, success("Customer type created"))
diff --git a/apps/carbon/app/routes/x+/settings+/_layout.tsx b/apps/carbon/app/routes/x+/settings+/_layout.tsx
index a84132e373..514711e6c0 100644
--- a/apps/carbon/app/routes/x+/settings+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/settings+/_layout.tsx
@@ -12,7 +12,7 @@ export default function SettingsRoute() {
const { groups } = useSettingsSidebar();
return (
- <Grid w="full" h="full" templateColumns="auto 1fr" overflow="auto">
+ <Grid w="full" h="full" templateColumns="auto 1fr">
<GroupedContentSidebar groups={groups} />
<VStack w="full" h="full" spacing={0}>
<Outlet />
diff --git a/apps/carbon/app/routes/x+/users+/_layout.tsx b/apps/carbon/app/routes/x+/users+/_layout.tsx
index cf0b145b73..b6612bcda7 100644
--- a/apps/carbon/app/routes/x+/users+/_layout.tsx
+++ b/apps/carbon/app/routes/x+/users+/_layout.tsx
@@ -12,7 +12,7 @@ export default function UsersRoute() {
const { groups } = useUsersSidebar();
return (
- <Grid w="full" h="full" templateColumns="auto 1fr" overflow="auto">
+ <Grid w="full" h="full" templateColumns="auto 1fr">
<GroupedContentSidebar groups={groups} />
<VStack w="full" h="full" spacing={0}>
<Outlet />
diff --git a/apps/carbon/app/utils/form.ts b/apps/carbon/app/utils/form.ts
index 0e85cfc2d8..5047f27a3f 100644
--- a/apps/carbon/app/utils/form.ts
+++ b/apps/carbon/app/utils/form.ts
@@ -4,6 +4,9 @@ export const isValidEmail = (email: string) => {
return emailRegex.test(email);
};
+/**
+ * @deprecated Use regular map instead
+ */
export const mapRowsToOptions = <T extends Record<string, any>>({
data,
value,
diff --git a/packages/carbon-database/src/types.ts b/packages/carbon-database/src/types.ts
index db9aaa7910..5d62898775 100644
--- a/packages/carbon-database/src/types.ts
+++ b/packages/carbon-database/src/types.ts
@@ -250,6 +250,604 @@ export interface Database {
}
];
};
+ accountDefault: {
+ Row: {
+ accumulatedDepreciationAccount: string;
+ accumulatedDepreciationOnDisposalAccount: string;
+ assetAquisitionCostAccount: string;
+ assetAquisitionCostOnDisposalAccount: string;
+ assetDepreciationExpenseAccount: string;
+ assetGainsAndLossesAccount: string;
+ bankCashAccount: string;
+ bankForeignCurrencyAccount: string;
+ bankLocalCurrencyAccount: string;
+ capacityVarianceAccount: string;
+ costOfGoodsSoldAccount: string;
+ customerPaymentDiscountAccount: string;
+ directCostAppliedAccount: string;
+ id: boolean;
+ interestAccount: string;
+ inventoryAccount: string;
+ inventoryAdjustmentVarianceAccount: string;
+ inventoryInterimAccrualAccount: string;
+ inventoryReceivedNotInvoicedAccount: string;
+ inventoryShippedNotInvoicedAccount: string;
+ maintenanceAccount: string;
+ materialVarianceAccount: string;
+ overheadAccount: string;
+ overheadCostAppliedAccount: string;
+ payablesAccount: string;
+ prepaymentAccount: string;
+ purchaseAccount: string;
+ purchaseTaxPayableAccount: string;
+ purchaseVarianceAccount: string;
+ receivablesAccount: string;
+ retainedEarningsAccount: string;
+ reverseChargeSalesTaxPayableAccount: string;
+ roundingAccount: string;
+ salesAccount: string;
+ salesDiscountAccount: string;
+ salesTaxPayableAccount: string;
+ serviceChargeAccount: string;
+ supplierPaymentDiscountAccount: string;
+ updatedBy: string | null;
+ workInProgressAccount: string;
+ };
+ Insert: {
+ accumulatedDepreciationAccount: string;
+ accumulatedDepreciationOnDisposalAccount: string;
+ assetAquisitionCostAccount: string;
+ assetAquisitionCostOnDisposalAccount: string;
+ assetDepreciationExpenseAccount: string;
+ assetGainsAndLossesAccount: string;
+ bankCashAccount: string;
+ bankForeignCurrencyAccount: string;
+ bankLocalCurrencyAccount: string;
+ capacityVarianceAccount: string;
+ costOfGoodsSoldAccount: string;
+ customerPaymentDiscountAccount: string;
+ directCostAppliedAccount: string;
+ id?: boolean;
+ interestAccount: string;
+ inventoryAccount: string;
+ inventoryAdjustmentVarianceAccount: string;
+ inventoryInterimAccrualAccount: string;
+ inventoryReceivedNotInvoicedAccount: string;
+ inventoryShippedNotInvoicedAccount: string;
+ maintenanceAccount: string;
+ materialVarianceAccount: string;
+ overheadAccount: string;
+ overheadCostAppliedAccount: string;
+ payablesAccount: string;
+ prepaymentAccount: string;
+ purchaseAccount: string;
+ purchaseTaxPayableAccount: string;
+ purchaseVarianceAccount: string;
+ receivablesAccount: string;
+ retainedEarningsAccount: string;
+ reverseChargeSalesTaxPayableAccount: string;
+ roundingAccount: string;
+ salesAccount: string;
+ salesDiscountAccount: string;
+ salesTaxPayableAccount: string;
+ serviceChargeAccount: string;
+ supplierPaymentDiscountAccount: string;
+ updatedBy?: string | null;
+ workInProgressAccount: string;
+ };
+ Update: {
+ accumulatedDepreciationAccount?: string;
+ accumulatedDepreciationOnDisposalAccount?: string;
+ assetAquisitionCostAccount?: string;
+ assetAquisitionCostOnDisposalAccount?: string;
+ assetDepreciationExpenseAccount?: string;
+ assetGainsAndLossesAccount?: string;
+ bankCashAccount?: string;
+ bankForeignCurrencyAccount?: string;
+ bankLocalCurrencyAccount?: string;
+ capacityVarianceAccount?: string;
+ costOfGoodsSoldAccount?: string;
+ customerPaymentDiscountAccount?: string;
+ directCostAppliedAccount?: string;
+ id?: boolean;
+ interestAccount?: string;
+ inventoryAccount?: string;
+ inventoryAdjustmentVarianceAccount?: string;
+ inventoryInterimAccrualAccount?: string;
+ inventoryReceivedNotInvoicedAccount?: string;
+ inventoryShippedNotInvoicedAccount?: string;
+ maintenanceAccount?: string;
+ materialVarianceAccount?: string;
+ overheadAccount?: string;
+ overheadCostAppliedAccount?: string;
+ payablesAccount?: string;
+ prepaymentAccount?: string;
+ purchaseAccount?: string;
+ purchaseTaxPayableAccount?: string;
+ purchaseVarianceAccount?: string;
+ receivablesAccount?: string;
+ retainedEarningsAccount?: string;
+ reverseChargeSalesTaxPayableAccount?: string;
+ roundingAccount?: string;
+ salesAccount?: string;
+ salesDiscountAccount?: string;
+ salesTaxPayableAccount?: string;
+ serviceChargeAccount?: string;
+ supplierPaymentDiscountAccount?: string;
+ updatedBy?: string | null;
+ workInProgressAccount?: string;
+ };
+ Relationships: [
+ {
+ foreignKeyName: "accountDefault_accumulatedDepreciationAccount_fkey";
+ columns: ["accumulatedDepreciationAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_accumulatedDepreciationAccount_fkey";
+ columns: ["accumulatedDepreciationAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_accumulatedDepreciationOnDisposalAccount_fkey";
+ columns: ["accumulatedDepreciationOnDisposalAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_accumulatedDepreciationOnDisposalAccount_fkey";
+ columns: ["accumulatedDepreciationOnDisposalAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_aquisitionCostAccount_fkey";
+ columns: ["assetAquisitionCostAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_aquisitionCostAccount_fkey";
+ columns: ["assetAquisitionCostAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_aquisitionCostOnDisposalAccount_fkey";
+ columns: ["assetAquisitionCostOnDisposalAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_aquisitionCostOnDisposalAccount_fkey";
+ columns: ["assetAquisitionCostOnDisposalAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_assetDepreciationExpenseAccount_fkey";
+ columns: ["assetDepreciationExpenseAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_assetDepreciationExpenseAccount_fkey";
+ columns: ["assetDepreciationExpenseAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_assetGainsAndLossesAccount_fkey";
+ columns: ["assetGainsAndLossesAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_assetGainsAndLossesAccount_fkey";
+ columns: ["assetGainsAndLossesAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_bankCashAccount_fkey";
+ columns: ["bankCashAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_bankCashAccount_fkey";
+ columns: ["bankCashAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_bankForeignCurrencyAccount_fkey";
+ columns: ["bankForeignCurrencyAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_bankForeignCurrencyAccount_fkey";
+ columns: ["bankForeignCurrencyAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_bankLocalCurrencyAccount_fkey";
+ columns: ["bankLocalCurrencyAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_bankLocalCurrencyAccount_fkey";
+ columns: ["bankLocalCurrencyAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_capacityVarianceAccount_fkey";
+ columns: ["capacityVarianceAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_capacityVarianceAccount_fkey";
+ columns: ["capacityVarianceAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_costOfGoodsSoldAccount_fkey";
+ columns: ["costOfGoodsSoldAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_costOfGoodsSoldAccount_fkey";
+ columns: ["costOfGoodsSoldAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_customerPaymentDiscountAccount_fkey";
+ columns: ["customerPaymentDiscountAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_customerPaymentDiscountAccount_fkey";
+ columns: ["customerPaymentDiscountAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_directCostAppliedAccount_fkey";
+ columns: ["directCostAppliedAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_directCostAppliedAccount_fkey";
+ columns: ["directCostAppliedAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_interestAccount_fkey";
+ columns: ["interestAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_interestAccount_fkey";
+ columns: ["interestAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_inventoryAccount_fkey";
+ columns: ["inventoryAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_inventoryAccount_fkey";
+ columns: ["inventoryAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_inventoryAdjustmentVarianceAccount_fkey";
+ columns: ["inventoryAdjustmentVarianceAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_inventoryAdjustmentVarianceAccount_fkey";
+ columns: ["inventoryAdjustmentVarianceAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_inventoryInterimAccrualAccount_fkey";
+ columns: ["inventoryInterimAccrualAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_inventoryInterimAccrualAccount_fkey";
+ columns: ["inventoryInterimAccrualAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_inventoryReceivedNotInvoicedAccount_fkey";
+ columns: ["inventoryReceivedNotInvoicedAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_inventoryReceivedNotInvoicedAccount_fkey";
+ columns: ["inventoryReceivedNotInvoicedAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_inventoryShippedNotInvoicedAccount_fkey";
+ columns: ["inventoryShippedNotInvoicedAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_inventoryShippedNotInvoicedAccount_fkey";
+ columns: ["inventoryShippedNotInvoicedAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_maintenanceAccount_fkey";
+ columns: ["maintenanceAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_maintenanceAccount_fkey";
+ columns: ["maintenanceAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_materialVarianceAccount_fkey";
+ columns: ["materialVarianceAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_materialVarianceAccount_fkey";
+ columns: ["materialVarianceAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_overheadAccount_fkey";
+ columns: ["overheadAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_overheadAccount_fkey";
+ columns: ["overheadAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_overheadCostAppliedAccount_fkey";
+ columns: ["overheadCostAppliedAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_overheadCostAppliedAccount_fkey";
+ columns: ["overheadCostAppliedAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_payablesAccount_fkey";
+ columns: ["payablesAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_payablesAccount_fkey";
+ columns: ["payablesAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_prepaymentAccount_fkey";
+ columns: ["prepaymentAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_prepaymentAccount_fkey";
+ columns: ["prepaymentAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_purchaseAccount_fkey";
+ columns: ["purchaseAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_purchaseAccount_fkey";
+ columns: ["purchaseAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_purchaseTaxPayableAccount_fkey";
+ columns: ["purchaseTaxPayableAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_purchaseTaxPayableAccount_fkey";
+ columns: ["purchaseTaxPayableAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_purchaseVarianceAccount_fkey";
+ columns: ["purchaseVarianceAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_purchaseVarianceAccount_fkey";
+ columns: ["purchaseVarianceAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_receivablesAccount_fkey";
+ columns: ["receivablesAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_receivablesAccount_fkey";
+ columns: ["receivablesAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_retainedEarningsAccount_fkey";
+ columns: ["retainedEarningsAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_retainedEarningsAccount_fkey";
+ columns: ["retainedEarningsAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_reverseChargeSalesTaxPayableAccount_fkey";
+ columns: ["reverseChargeSalesTaxPayableAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_reverseChargeSalesTaxPayableAccount_fkey";
+ columns: ["reverseChargeSalesTaxPayableAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_roundingAccount_fkey";
+ columns: ["roundingAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_roundingAccount_fkey";
+ columns: ["roundingAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_salesAccount_fkey";
+ columns: ["salesAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_salesAccount_fkey";
+ columns: ["salesAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_salesDiscountAccount_fkey";
+ columns: ["salesDiscountAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_salesDiscountAccount_fkey";
+ columns: ["salesDiscountAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_salesTaxPayableAccount_fkey";
+ columns: ["salesTaxPayableAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_salesTaxPayableAccount_fkey";
+ columns: ["salesTaxPayableAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_serviceChargeAccount_fkey";
+ columns: ["serviceChargeAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_serviceChargeAccount_fkey";
+ columns: ["serviceChargeAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_supplierPaymentDiscountAccount_fkey";
+ columns: ["supplierPaymentDiscountAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_supplierPaymentDiscountAccount_fkey";
+ columns: ["supplierPaymentDiscountAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_updatedBy_fkey";
+ columns: ["updatedBy"];
+ referencedRelation: "user";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "accountDefault_updatedBy_fkey";
+ columns: ["updatedBy"];
+ referencedRelation: "user_default_view";
+ referencedColumns: ["userId"];
+ },
+ {
+ foreignKeyName: "accountDefault_workInProgressAccount_fkey";
+ columns: ["workInProgressAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "accountDefault_workInProgressAccount_fkey";
+ columns: ["workInProgressAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ }
+ ];
+ };
accountSubcategory: {
Row: {
accountCategoryId: string;
@@ -983,28 +1581,59 @@ export interface Database {
Row: {
color: string | null;
createdAt: string;
+ createdBy: string;
id: string;
name: string;
protected: boolean;
updatedAt: string | null;
+ updatedBy: string | null;
};
Insert: {
color?: string | null;
createdAt?: string;
+ createdBy: string;
id?: string;
name: string;
protected?: boolean;
updatedAt?: string | null;
+ updatedBy?: string | null;
};
Update: {
color?: string | null;
createdAt?: string;
+ createdBy?: string;
id?: string;
name?: string;
protected?: boolean;
updatedAt?: string | null;
+ updatedBy?: string | null;
};
- Relationships: [];
+ Relationships: [
+ {
+ foreignKeyName: "customerType_createdBy_fkey";
+ columns: ["createdBy"];
+ referencedRelation: "user";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "customerType_createdBy_fkey";
+ columns: ["createdBy"];
+ referencedRelation: "user_default_view";
+ referencedColumns: ["userId"];
+ },
+ {
+ foreignKeyName: "customerType_updatedBy_fkey";
+ columns: ["updatedBy"];
+ referencedRelation: "user";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "customerType_updatedBy_fkey";
+ columns: ["updatedBy"];
+ referencedRelation: "user_default_view";
+ referencedColumns: ["userId"];
+ }
+ ];
};
department: {
Row: {
@@ -2096,10 +2725,7 @@ export interface Database {
costIsAdjusted: boolean;
createdAt: string;
createdBy: string;
- discountAccountId: string | null;
- inventoryAccountId: string | null;
partId: string;
- salesAccountId: string | null;
standardCost: number;
unitCost: number;
updatedAt: string | null;
@@ -2110,10 +2736,7 @@ export interface Database {
costIsAdjusted?: boolean;
createdAt?: string;
createdBy: string;
- discountAccountId?: string | null;
- inventoryAccountId?: string | null;
partId: string;
- salesAccountId?: string | null;
standardCost?: number;
unitCost?: number;
updatedAt?: string | null;
@@ -2124,10 +2747,7 @@ export interface Database {
costIsAdjusted?: boolean;
createdAt?: string;
createdBy?: string;
- discountAccountId?: string | null;
- inventoryAccountId?: string | null;
partId?: string;
- salesAccountId?: string | null;
standardCost?: number;
unitCost?: number;
updatedAt?: string | null;
@@ -2158,42 +2778,6 @@ export interface Database {
referencedRelation: "user_default_view";
referencedColumns: ["userId"];
},
- {
- foreignKeyName: "partGroup_discountAccountId_fkey";
- columns: ["discountAccountId"];
- referencedRelation: "account";
- referencedColumns: ["number"];
- },
- {
- foreignKeyName: "partGroup_discountAccountId_fkey";
- columns: ["discountAccountId"];
- referencedRelation: "accounts_view";
- referencedColumns: ["number"];
- },
- {
- foreignKeyName: "partGroup_inventoryAccountId_fkey";
- columns: ["inventoryAccountId"];
- referencedRelation: "account";
- referencedColumns: ["number"];
- },
- {
- foreignKeyName: "partGroup_inventoryAccountId_fkey";
- columns: ["inventoryAccountId"];
- referencedRelation: "accounts_view";
- referencedColumns: ["number"];
- },
- {
- foreignKeyName: "partGroup_salesAccountId_fkey";
- columns: ["salesAccountId"];
- referencedRelation: "account";
- referencedColumns: ["number"];
- },
- {
- foreignKeyName: "partGroup_salesAccountId_fkey";
- columns: ["salesAccountId"];
- referencedRelation: "accounts_view";
- referencedColumns: ["number"];
- },
{
foreignKeyName: "partGroup_updatedBy_fkey";
columns: ["updatedBy"];
@@ -2211,104 +2795,35 @@ export interface Database {
partGroup: {
Row: {
active: boolean;
- costOfGoodsSoldLaborAccountId: string | null;
- costOfGoodsSoldMaterialAccountId: string | null;
- costOfGoodsSoldOverheadAccountId: string | null;
- costOfGoodsSoldSubcontractorAccountId: string | null;
createdAt: string;
createdBy: string;
description: string | null;
- discountAccountId: string | null;
id: string;
- inventoryAccountId: string | null;
name: string;
- salesAccountId: string | null;
updatedAt: string | null;
updatedBy: string | null;
};
Insert: {
active?: boolean;
- costOfGoodsSoldLaborAccountId?: string | null;
- costOfGoodsSoldMaterialAccountId?: string | null;
- costOfGoodsSoldOverheadAccountId?: string | null;
- costOfGoodsSoldSubcontractorAccountId?: string | null;
createdAt?: string;
createdBy: string;
description?: string | null;
- discountAccountId?: string | null;
id?: string;
- inventoryAccountId?: string | null;
name: string;
- salesAccountId?: string | null;
updatedAt?: string | null;
updatedBy?: string | null;
};
Update: {
active?: boolean;
- costOfGoodsSoldLaborAccountId?: string | null;
- costOfGoodsSoldMaterialAccountId?: string | null;
- costOfGoodsSoldOverheadAccountId?: string | null;
- costOfGoodsSoldSubcontractorAccountId?: string | null;
createdAt?: string;
createdBy?: string;
description?: string | null;
- discountAccountId?: string | null;
id?: string;
- inventoryAccountId?: string | null;
name?: string;
- salesAccountId?: string | null;
updatedAt?: string | null;
updatedBy?: string | null;
};
- Relationships: [
- {
- foreignKeyName: "partGroup_costOfGoodsSoldLaborAccountId_fkey";
- columns: ["costOfGoodsSoldLaborAccountId"];
- referencedRelation: "account";
- referencedColumns: ["number"];
- },
- {
- foreignKeyName: "partGroup_costOfGoodsSoldLaborAccountId_fkey";
- columns: ["costOfGoodsSoldLaborAccountId"];
- referencedRelation: "accounts_view";
- referencedColumns: ["number"];
- },
- {
- foreignKeyName: "partGroup_costOfGoodsSoldMaterialAccountId_fkey";
- columns: ["costOfGoodsSoldMaterialAccountId"];
- referencedRelation: "account";
- referencedColumns: ["number"];
- },
- {
- foreignKeyName: "partGroup_costOfGoodsSoldMaterialAccountId_fkey";
- columns: ["costOfGoodsSoldMaterialAccountId"];
- referencedRelation: "accounts_view";
- referencedColumns: ["number"];
- },
- {
- foreignKeyName: "partGroup_costOfGoodsSoldOverheadAccountId_fkey";
- columns: ["costOfGoodsSoldOverheadAccountId"];
- referencedRelation: "account";
- referencedColumns: ["number"];
- },
- {
- foreignKeyName: "partGroup_costOfGoodsSoldOverheadAccountId_fkey";
- columns: ["costOfGoodsSoldOverheadAccountId"];
- referencedRelation: "accounts_view";
- referencedColumns: ["number"];
- },
- {
- foreignKeyName: "partGroup_costOfGoodsSoldSubcontractorAccountId_fkey";
- columns: ["costOfGoodsSoldSubcontractorAccountId"];
- referencedRelation: "account";
- referencedColumns: ["number"];
- },
- {
- foreignKeyName: "partGroup_costOfGoodsSoldSubcontractorAccountId_fkey";
- columns: ["costOfGoodsSoldSubcontractorAccountId"];
- referencedRelation: "accounts_view";
- referencedColumns: ["number"];
- },
+ Relationships: [
{
foreignKeyName: "partGroup_createdBy_fkey";
columns: ["createdBy"];
@@ -2321,42 +2836,6 @@ export interface Database {
referencedRelation: "user_default_view";
referencedColumns: ["userId"];
},
- {
- foreignKeyName: "partGroup_discountAccountId_fkey";
- columns: ["discountAccountId"];
- referencedRelation: "account";
- referencedColumns: ["number"];
- },
- {
- foreignKeyName: "partGroup_discountAccountId_fkey";
- columns: ["discountAccountId"];
- referencedRelation: "accounts_view";
- referencedColumns: ["number"];
- },
- {
- foreignKeyName: "partGroup_inventoryAccountId_fkey";
- columns: ["inventoryAccountId"];
- referencedRelation: "account";
- referencedColumns: ["number"];
- },
- {
- foreignKeyName: "partGroup_inventoryAccountId_fkey";
- columns: ["inventoryAccountId"];
- referencedRelation: "accounts_view";
- referencedColumns: ["number"];
- },
- {
- foreignKeyName: "partGroup_salesAccountId_fkey";
- columns: ["salesAccountId"];
- referencedRelation: "account";
- referencedColumns: ["number"];
- },
- {
- foreignKeyName: "partGroup_salesAccountId_fkey";
- columns: ["salesAccountId"];
- referencedRelation: "accounts_view";
- referencedColumns: ["number"];
- },
{
foreignKeyName: "partGroup_updatedBy_fkey";
columns: ["updatedBy"];
@@ -2798,380 +3277,869 @@ export interface Database {
updatedBy: string | null;
};
Insert: {
- conversionFactor?: number;
+ conversionFactor?: number;
+ createdAt?: string;
+ createdBy: string;
+ lotSize?: number | null;
+ manufacturingBlocked?: boolean;
+ manufacturingLeadTime?: number;
+ manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"];
+ partId: string;
+ preferredSupplierId?: string | null;
+ purchasingBlocked?: boolean;
+ purchasingLeadTime?: number;
+ purchasingUnitOfMeasureCode?: string | null;
+ requiresConfiguration?: boolean;
+ scrapPercentage?: number;
+ updatedAt?: string | null;
+ updatedBy?: string | null;
+ };
+ Update: {
+ conversionFactor?: number;
+ createdAt?: string;
+ createdBy?: string;
+ lotSize?: number | null;
+ manufacturingBlocked?: boolean;
+ manufacturingLeadTime?: number;
+ manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"];
+ partId?: string;
+ preferredSupplierId?: string | null;
+ purchasingBlocked?: boolean;
+ purchasingLeadTime?: number;
+ purchasingUnitOfMeasureCode?: string | null;
+ requiresConfiguration?: boolean;
+ scrapPercentage?: number;
+ updatedAt?: string | null;
+ updatedBy?: string | null;
+ };
+ Relationships: [
+ {
+ foreignKeyName: "partReplenishment_createdBy_fkey";
+ columns: ["createdBy"];
+ referencedRelation: "user";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "partReplenishment_createdBy_fkey";
+ columns: ["createdBy"];
+ referencedRelation: "user_default_view";
+ referencedColumns: ["userId"];
+ },
+ {
+ foreignKeyName: "partReplenishment_partId_fkey";
+ columns: ["partId"];
+ referencedRelation: "part";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "partReplenishment_partId_fkey";
+ columns: ["partId"];
+ referencedRelation: "parts_view";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "partReplenishment_preferredSupplierId_fkey";
+ columns: ["preferredSupplierId"];
+ referencedRelation: "supplier";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "partReplenishment_preferredSupplierId_fkey";
+ columns: ["preferredSupplierId"];
+ referencedRelation: "contractors_view";
+ referencedColumns: ["supplierId"];
+ },
+ {
+ foreignKeyName: "partReplenishment_preferredSupplierId_fkey";
+ columns: ["preferredSupplierId"];
+ referencedRelation: "partners_view";
+ referencedColumns: ["supplierId"];
+ },
+ {
+ foreignKeyName: "partReplenishment_preferredSupplierId_fkey";
+ columns: ["preferredSupplierId"];
+ referencedRelation: "purchase_order_suppliers_view";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "partReplenishment_preferredSupplierId_fkey";
+ columns: ["preferredSupplierId"];
+ referencedRelation: "suppliers_view";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "partReplenishment_purchaseUnitOfMeasureCode_fkey";
+ columns: ["purchasingUnitOfMeasureCode"];
+ referencedRelation: "unitOfMeasure";
+ referencedColumns: ["code"];
+ },
+ {
+ foreignKeyName: "partReplenishment_updatedBy_fkey";
+ columns: ["updatedBy"];
+ referencedRelation: "user";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "partReplenishment_updatedBy_fkey";
+ columns: ["updatedBy"];
+ referencedRelation: "user_default_view";
+ referencedColumns: ["userId"];
+ }
+ ];
+ };
+ partSupplier: {
+ Row: {
+ active: boolean;
+ conversionFactor: number;
+ createdAt: string;
+ createdBy: string;
+ id: string;
+ minimumOrderQuantity: number | null;
+ partId: string;
+ supplierId: string;
+ supplierPartId: string | null;
+ supplierUnitOfMeasureCode: string | null;
+ updatedAt: string | null;
+ updatedBy: string | null;
+ };
+ Insert: {
+ active?: boolean;
+ conversionFactor?: number;
+ createdAt?: string;
+ createdBy: string;
+ id?: string;
+ minimumOrderQuantity?: number | null;
+ partId: string;
+ supplierId: string;
+ supplierPartId?: string | null;
+ supplierUnitOfMeasureCode?: string | null;
+ updatedAt?: string | null;
+ updatedBy?: string | null;
+ };
+ Update: {
+ active?: boolean;
+ conversionFactor?: number;
+ createdAt?: string;
+ createdBy?: string;
+ id?: string;
+ minimumOrderQuantity?: number | null;
+ partId?: string;
+ supplierId?: string;
+ supplierPartId?: string | null;
+ supplierUnitOfMeasureCode?: string | null;
+ updatedAt?: string | null;
+ updatedBy?: string | null;
+ };
+ Relationships: [
+ {
+ foreignKeyName: "partSupplier_createdBy_fkey";
+ columns: ["createdBy"];
+ referencedRelation: "user";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "partSupplier_createdBy_fkey";
+ columns: ["createdBy"];
+ referencedRelation: "user_default_view";
+ referencedColumns: ["userId"];
+ },
+ {
+ foreignKeyName: "partSupplier_partId_fkey";
+ columns: ["partId"];
+ referencedRelation: "part";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "partSupplier_partId_fkey";
+ columns: ["partId"];
+ referencedRelation: "parts_view";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "partSupplier_supplierId_fkey";
+ columns: ["supplierId"];
+ referencedRelation: "supplier";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "partSupplier_supplierId_fkey";
+ columns: ["supplierId"];
+ referencedRelation: "contractors_view";
+ referencedColumns: ["supplierId"];
+ },
+ {
+ foreignKeyName: "partSupplier_supplierId_fkey";
+ columns: ["supplierId"];
+ referencedRelation: "partners_view";
+ referencedColumns: ["supplierId"];
+ },
+ {
+ foreignKeyName: "partSupplier_supplierId_fkey";
+ columns: ["supplierId"];
+ referencedRelation: "purchase_order_suppliers_view";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "partSupplier_supplierId_fkey";
+ columns: ["supplierId"];
+ referencedRelation: "suppliers_view";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "partSupplier_updatedBy_fkey";
+ columns: ["updatedBy"];
+ referencedRelation: "user";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "partSupplier_updatedBy_fkey";
+ columns: ["updatedBy"];
+ referencedRelation: "user_default_view";
+ referencedColumns: ["userId"];
+ }
+ ];
+ };
+ partUnitSalePrice: {
+ Row: {
+ allowInvoiceDiscount: boolean;
+ createdAt: string;
+ createdBy: string;
+ currencyCode: string;
+ partId: string;
+ priceIncludesTax: boolean;
+ salesBlocked: boolean;
+ salesUnitOfMeasureCode: string | null;
+ unitSalePrice: number;
+ updatedAt: string | null;
+ updatedBy: string | null;
+ };
+ Insert: {
+ allowInvoiceDiscount?: boolean;
createdAt?: string;
createdBy: string;
- lotSize?: number | null;
- manufacturingBlocked?: boolean;
- manufacturingLeadTime?: number;
- manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"];
+ currencyCode: string;
partId: string;
- preferredSupplierId?: string | null;
- purchasingBlocked?: boolean;
- purchasingLeadTime?: number;
- purchasingUnitOfMeasureCode?: string | null;
- requiresConfiguration?: boolean;
- scrapPercentage?: number;
+ priceIncludesTax?: boolean;
+ salesBlocked?: boolean;
+ salesUnitOfMeasureCode?: string | null;
+ unitSalePrice?: number;
updatedAt?: string | null;
updatedBy?: string | null;
};
Update: {
- conversionFactor?: number;
+ allowInvoiceDiscount?: boolean;
createdAt?: string;
createdBy?: string;
- lotSize?: number | null;
- manufacturingBlocked?: boolean;
- manufacturingLeadTime?: number;
- manufacturingPolicy?: Database["public"]["Enums"]["partManufacturingPolicy"];
+ currencyCode?: string;
partId?: string;
- preferredSupplierId?: string | null;
- purchasingBlocked?: boolean;
- purchasingLeadTime?: number;
- purchasingUnitOfMeasureCode?: string | null;
- requiresConfiguration?: boolean;
- scrapPercentage?: number;
+ priceIncludesTax?: boolean;
+ salesBlocked?: boolean;
+ salesUnitOfMeasureCode?: string | null;
+ unitSalePrice?: number;
updatedAt?: string | null;
updatedBy?: string | null;
};
Relationships: [
{
- foreignKeyName: "partReplenishment_createdBy_fkey";
+ foreignKeyName: "partUnitSalePrice_createdBy_fkey";
columns: ["createdBy"];
referencedRelation: "user";
referencedColumns: ["id"];
},
{
- foreignKeyName: "partReplenishment_createdBy_fkey";
+ foreignKeyName: "partUnitSalePrice_createdBy_fkey";
columns: ["createdBy"];
referencedRelation: "user_default_view";
referencedColumns: ["userId"];
},
{
- foreignKeyName: "partReplenishment_partId_fkey";
+ foreignKeyName: "partUnitSalePrice_currencyCode_fkey";
+ columns: ["currencyCode"];
+ referencedRelation: "currency";
+ referencedColumns: ["code"];
+ },
+ {
+ foreignKeyName: "partUnitSalePrice_partId_fkey";
columns: ["partId"];
referencedRelation: "part";
referencedColumns: ["id"];
},
{
- foreignKeyName: "partReplenishment_partId_fkey";
+ foreignKeyName: "partUnitSalePrice_partId_fkey";
columns: ["partId"];
referencedRelation: "parts_view";
referencedColumns: ["id"];
},
{
- foreignKeyName: "partReplenishment_preferredSupplierId_fkey";
- columns: ["preferredSupplierId"];
- referencedRelation: "supplier";
- referencedColumns: ["id"];
- },
- {
- foreignKeyName: "partReplenishment_preferredSupplierId_fkey";
- columns: ["preferredSupplierId"];
- referencedRelation: "contractors_view";
- referencedColumns: ["supplierId"];
- },
- {
- foreignKeyName: "partReplenishment_preferredSupplierId_fkey";
- columns: ["preferredSupplierId"];
- referencedRelation: "partners_view";
- referencedColumns: ["supplierId"];
- },
- {
- foreignKeyName: "partReplenishment_preferredSupplierId_fkey";
- columns: ["preferredSupplierId"];
- referencedRelation: "purchase_order_suppliers_view";
- referencedColumns: ["id"];
- },
- {
- foreignKeyName: "partReplenishment_preferredSupplierId_fkey";
- columns: ["preferredSupplierId"];
- referencedRelation: "suppliers_view";
- referencedColumns: ["id"];
- },
- {
- foreignKeyName: "partReplenishment_purchaseUnitOfMeasureCode_fkey";
- columns: ["purchasingUnitOfMeasureCode"];
+ foreignKeyName: "partUnitSalePrice_salesUnitOfMeasureId_fkey";
+ columns: ["salesUnitOfMeasureCode"];
referencedRelation: "unitOfMeasure";
referencedColumns: ["code"];
},
{
- foreignKeyName: "partReplenishment_updatedBy_fkey";
+ foreignKeyName: "partUnitSalePrice_updatedBy_fkey";
columns: ["updatedBy"];
referencedRelation: "user";
referencedColumns: ["id"];
},
{
- foreignKeyName: "partReplenishment_updatedBy_fkey";
+ foreignKeyName: "partUnitSalePrice_updatedBy_fkey";
columns: ["updatedBy"];
referencedRelation: "user_default_view";
referencedColumns: ["userId"];
}
];
};
- partSupplier: {
+ paymentTerm: {
Row: {
active: boolean;
- conversionFactor: number;
+ calculationMethod: Database["public"]["Enums"]["paymentTermCalculationMethod"];
createdAt: string;
createdBy: string;
+ daysDiscount: number;
+ daysDue: number;
+ discountPercentage: number;
id: string;
- minimumOrderQuantity: number | null;
- partId: string;
- supplierId: string;
- supplierPartId: string | null;
- supplierUnitOfMeasureCode: string | null;
+ name: string;
updatedAt: string | null;
updatedBy: string | null;
};
Insert: {
active?: boolean;
- conversionFactor?: number;
+ calculationMethod?: Database["public"]["Enums"]["paymentTermCalculationMethod"];
createdAt?: string;
createdBy: string;
+ daysDiscount?: number;
+ daysDue?: number;
+ discountPercentage?: number;
id?: string;
- minimumOrderQuantity?: number | null;
- partId: string;
- supplierId: string;
- supplierPartId?: string | null;
- supplierUnitOfMeasureCode?: string | null;
+ name: string;
updatedAt?: string | null;
updatedBy?: string | null;
};
Update: {
active?: boolean;
- conversionFactor?: number;
+ calculationMethod?: Database["public"]["Enums"]["paymentTermCalculationMethod"];
createdAt?: string;
createdBy?: string;
+ daysDiscount?: number;
+ daysDue?: number;
+ discountPercentage?: number;
id?: string;
- minimumOrderQuantity?: number | null;
- partId?: string;
- supplierId?: string;
- supplierPartId?: string | null;
- supplierUnitOfMeasureCode?: string | null;
+ name?: string;
updatedAt?: string | null;
updatedBy?: string | null;
};
Relationships: [
{
- foreignKeyName: "partSupplier_createdBy_fkey";
+ foreignKeyName: "paymentTerm_createdBy_fkey";
columns: ["createdBy"];
referencedRelation: "user";
referencedColumns: ["id"];
},
{
- foreignKeyName: "partSupplier_createdBy_fkey";
+ foreignKeyName: "paymentTerm_createdBy_fkey";
columns: ["createdBy"];
referencedRelation: "user_default_view";
referencedColumns: ["userId"];
},
{
- foreignKeyName: "partSupplier_partId_fkey";
- columns: ["partId"];
- referencedRelation: "part";
+ foreignKeyName: "paymentTerm_updatedBy_fkey";
+ columns: ["updatedBy"];
+ referencedRelation: "user";
referencedColumns: ["id"];
},
{
- foreignKeyName: "partSupplier_partId_fkey";
- columns: ["partId"];
- referencedRelation: "parts_view";
- referencedColumns: ["id"];
+ foreignKeyName: "paymentTerm_updatedBy_fkey";
+ columns: ["updatedBy"];
+ referencedRelation: "user_default_view";
+ referencedColumns: ["userId"];
+ }
+ ];
+ };
+ postingGroupInventory: {
+ Row: {
+ capacityVarianceAccount: string;
+ costOfGoodsSoldAccount: string;
+ directCostAppliedAccount: string;
+ id: string;
+ inventoryAccount: string;
+ inventoryAdjustmentVarianceAccount: string;
+ inventoryInterimAccrualAccount: string;
+ inventoryReceivedNotInvoicedAccount: string;
+ inventoryShippedNotInvoicedAccount: string;
+ locationId: string | null;
+ materialVarianceAccount: string;
+ overheadAccount: string;
+ overheadCostAppliedAccount: string;
+ partGroupId: string | null;
+ purchaseVarianceAccount: string;
+ updatedBy: string | null;
+ workInProgressAccount: string;
+ };
+ Insert: {
+ capacityVarianceAccount: string;
+ costOfGoodsSoldAccount: string;
+ directCostAppliedAccount: string;
+ id?: string;
+ inventoryAccount: string;
+ inventoryAdjustmentVarianceAccount: string;
+ inventoryInterimAccrualAccount: string;
+ inventoryReceivedNotInvoicedAccount: string;
+ inventoryShippedNotInvoicedAccount: string;
+ locationId?: string | null;
+ materialVarianceAccount: string;
+ overheadAccount: string;
+ overheadCostAppliedAccount: string;
+ partGroupId?: string | null;
+ purchaseVarianceAccount: string;
+ updatedBy?: string | null;
+ workInProgressAccount: string;
+ };
+ Update: {
+ capacityVarianceAccount?: string;
+ costOfGoodsSoldAccount?: string;
+ directCostAppliedAccount?: string;
+ id?: string;
+ inventoryAccount?: string;
+ inventoryAdjustmentVarianceAccount?: string;
+ inventoryInterimAccrualAccount?: string;
+ inventoryReceivedNotInvoicedAccount?: string;
+ inventoryShippedNotInvoicedAccount?: string;
+ locationId?: string | null;
+ materialVarianceAccount?: string;
+ overheadAccount?: string;
+ overheadCostAppliedAccount?: string;
+ partGroupId?: string | null;
+ purchaseVarianceAccount?: string;
+ updatedBy?: string | null;
+ workInProgressAccount?: string;
+ };
+ Relationships: [
+ {
+ foreignKeyName: "postingGroupInventory_capacityVarianceAccount_fkey";
+ columns: ["capacityVarianceAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
},
{
- foreignKeyName: "partSupplier_supplierId_fkey";
- columns: ["supplierId"];
- referencedRelation: "supplier";
+ foreignKeyName: "postingGroupInventory_capacityVarianceAccount_fkey";
+ columns: ["capacityVarianceAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_costOfGoodsSoldAccount_fkey";
+ columns: ["costOfGoodsSoldAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_costOfGoodsSoldAccount_fkey";
+ columns: ["costOfGoodsSoldAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_directCostAppliedAccount_fkey";
+ columns: ["directCostAppliedAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_directCostAppliedAccount_fkey";
+ columns: ["directCostAppliedAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_inventoryAccount_fkey";
+ columns: ["inventoryAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_inventoryAccount_fkey";
+ columns: ["inventoryAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_inventoryAdjustmentVarianceAccount_fkey";
+ columns: ["inventoryAdjustmentVarianceAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_inventoryAdjustmentVarianceAccount_fkey";
+ columns: ["inventoryAdjustmentVarianceAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_inventoryInterimAccrualAccount_fkey";
+ columns: ["inventoryInterimAccrualAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_inventoryInterimAccrualAccount_fkey";
+ columns: ["inventoryInterimAccrualAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_inventoryReceivedNotInvoicedAccount_fkey";
+ columns: ["inventoryReceivedNotInvoicedAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_inventoryReceivedNotInvoicedAccount_fkey";
+ columns: ["inventoryReceivedNotInvoicedAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_inventoryShippedNotInvoicedAccount_fkey";
+ columns: ["inventoryShippedNotInvoicedAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_inventoryShippedNotInvoicedAccount_fkey";
+ columns: ["inventoryShippedNotInvoicedAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_locationId_fkey";
+ columns: ["locationId"];
+ referencedRelation: "location";
referencedColumns: ["id"];
},
{
- foreignKeyName: "partSupplier_supplierId_fkey";
- columns: ["supplierId"];
- referencedRelation: "contractors_view";
- referencedColumns: ["supplierId"];
+ foreignKeyName: "postingGroupInventory_locationId_fkey";
+ columns: ["locationId"];
+ referencedRelation: "purchase_order_view";
+ referencedColumns: ["locationId"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_materialVarianceAccount_fkey";
+ columns: ["materialVarianceAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_materialVarianceAccount_fkey";
+ columns: ["materialVarianceAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_overheadAccount_fkey";
+ columns: ["overheadAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_overheadAccount_fkey";
+ columns: ["overheadAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_overheadCostAppliedAccount_fkey";
+ columns: ["overheadCostAppliedAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
},
{
- foreignKeyName: "partSupplier_supplierId_fkey";
- columns: ["supplierId"];
- referencedRelation: "partners_view";
- referencedColumns: ["supplierId"];
+ foreignKeyName: "postingGroupInventory_overheadCostAppliedAccount_fkey";
+ columns: ["overheadCostAppliedAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
},
{
- foreignKeyName: "partSupplier_supplierId_fkey";
- columns: ["supplierId"];
- referencedRelation: "purchase_order_suppliers_view";
+ foreignKeyName: "postingGroupInventory_partGroupId_fkey";
+ columns: ["partGroupId"];
+ referencedRelation: "partGroup";
referencedColumns: ["id"];
},
{
- foreignKeyName: "partSupplier_supplierId_fkey";
- columns: ["supplierId"];
- referencedRelation: "suppliers_view";
- referencedColumns: ["id"];
+ foreignKeyName: "postingGroupInventory_purchaseVarianceAccount_fkey";
+ columns: ["purchaseVarianceAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
},
{
- foreignKeyName: "partSupplier_updatedBy_fkey";
+ foreignKeyName: "postingGroupInventory_purchaseVarianceAccount_fkey";
+ columns: ["purchaseVarianceAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_updatedBy_fkey";
columns: ["updatedBy"];
referencedRelation: "user";
referencedColumns: ["id"];
},
{
- foreignKeyName: "partSupplier_updatedBy_fkey";
+ foreignKeyName: "postingGroupInventory_updatedBy_fkey";
columns: ["updatedBy"];
referencedRelation: "user_default_view";
referencedColumns: ["userId"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_workInProgressAccount_fkey";
+ columns: ["workInProgressAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupInventory_workInProgressAccount_fkey";
+ columns: ["workInProgressAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
}
];
};
- partUnitSalePrice: {
+ postingGroupPurchasing: {
Row: {
- allowInvoiceDiscount: boolean;
- createdAt: string;
- createdBy: string;
- currencyCode: string;
- partId: string;
- priceIncludesTax: boolean;
- salesBlocked: boolean;
- salesUnitOfMeasureCode: string | null;
- unitSalePrice: number;
- updatedAt: string | null;
+ id: string;
+ partGroupId: string | null;
+ purchaseAccount: string;
+ purchaseCreditAccount: string;
+ purchaseDiscountAccount: string;
+ purchasePrepaymentAccount: string;
+ purchaseTaxPayableAccount: string;
+ supplierTypeId: string | null;
updatedBy: string | null;
};
Insert: {
- allowInvoiceDiscount?: boolean;
- createdAt?: string;
- createdBy: string;
- currencyCode: string;
- partId: string;
- priceIncludesTax?: boolean;
- salesBlocked?: boolean;
- salesUnitOfMeasureCode?: string | null;
- unitSalePrice?: number;
- updatedAt?: string | null;
+ id?: string;
+ partGroupId?: string | null;
+ purchaseAccount: string;
+ purchaseCreditAccount: string;
+ purchaseDiscountAccount: string;
+ purchasePrepaymentAccount: string;
+ purchaseTaxPayableAccount: string;
+ supplierTypeId?: string | null;
updatedBy?: string | null;
};
Update: {
- allowInvoiceDiscount?: boolean;
- createdAt?: string;
- createdBy?: string;
- currencyCode?: string;
- partId?: string;
- priceIncludesTax?: boolean;
- salesBlocked?: boolean;
- salesUnitOfMeasureCode?: string | null;
- unitSalePrice?: number;
- updatedAt?: string | null;
+ id?: string;
+ partGroupId?: string | null;
+ purchaseAccount?: string;
+ purchaseCreditAccount?: string;
+ purchaseDiscountAccount?: string;
+ purchasePrepaymentAccount?: string;
+ purchaseTaxPayableAccount?: string;
+ supplierTypeId?: string | null;
updatedBy?: string | null;
};
Relationships: [
{
- foreignKeyName: "partUnitSalePrice_createdBy_fkey";
- columns: ["createdBy"];
- referencedRelation: "user";
+ foreignKeyName: "postingGroupPurchasing_partGroupId_fkey";
+ columns: ["partGroupId"];
+ referencedRelation: "partGroup";
referencedColumns: ["id"];
},
{
- foreignKeyName: "partUnitSalePrice_createdBy_fkey";
- columns: ["createdBy"];
- referencedRelation: "user_default_view";
- referencedColumns: ["userId"];
+ foreignKeyName: "postingGroupPurchasing_purchaseAccount_fkey";
+ columns: ["purchaseAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
},
{
- foreignKeyName: "partUnitSalePrice_currencyCode_fkey";
- columns: ["currencyCode"];
- referencedRelation: "currency";
- referencedColumns: ["code"];
+ foreignKeyName: "postingGroupPurchasing_purchaseAccount_fkey";
+ columns: ["purchaseAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
},
{
- foreignKeyName: "partUnitSalePrice_partId_fkey";
- columns: ["partId"];
- referencedRelation: "part";
- referencedColumns: ["id"];
+ foreignKeyName: "postingGroupPurchasing_purchaseCreditAccount_fkey";
+ columns: ["purchaseCreditAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
},
{
- foreignKeyName: "partUnitSalePrice_partId_fkey";
- columns: ["partId"];
- referencedRelation: "parts_view";
- referencedColumns: ["id"];
+ foreignKeyName: "postingGroupPurchasing_purchaseCreditAccount_fkey";
+ columns: ["purchaseCreditAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
},
{
- foreignKeyName: "partUnitSalePrice_salesUnitOfMeasureId_fkey";
- columns: ["salesUnitOfMeasureCode"];
- referencedRelation: "unitOfMeasure";
- referencedColumns: ["code"];
+ foreignKeyName: "postingGroupPurchasing_purchaseDiscountAccount_fkey";
+ columns: ["purchaseDiscountAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
},
{
- foreignKeyName: "partUnitSalePrice_updatedBy_fkey";
+ foreignKeyName: "postingGroupPurchasing_purchaseDiscountAccount_fkey";
+ columns: ["purchaseDiscountAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupPurchasing_purchasePrepaymentAccount_fkey";
+ columns: ["purchasePrepaymentAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupPurchasing_purchasePrepaymentAccount_fkey";
+ columns: ["purchasePrepaymentAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupPurchasing_purchaseTaxPayableAccount_fkey";
+ columns: ["purchaseTaxPayableAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupPurchasing_purchaseTaxPayableAccount_fkey";
+ columns: ["purchaseTaxPayableAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupPurchasing_supplierTypeId_fkey";
+ columns: ["supplierTypeId"];
+ referencedRelation: "supplierType";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "postingGroupPurchasing_updatedBy_fkey";
columns: ["updatedBy"];
referencedRelation: "user";
referencedColumns: ["id"];
},
{
- foreignKeyName: "partUnitSalePrice_updatedBy_fkey";
+ foreignKeyName: "postingGroupPurchasing_updatedBy_fkey";
columns: ["updatedBy"];
referencedRelation: "user_default_view";
referencedColumns: ["userId"];
}
];
};
- paymentTerm: {
+ postingGroupSales: {
Row: {
- active: boolean;
- calculationMethod: Database["public"]["Enums"]["paymentTermCalculationMethod"];
- createdAt: string;
- createdBy: string;
- daysDiscount: number;
- daysDue: number;
- discountPercentage: number;
+ customerTypeId: string | null;
id: string;
- name: string;
- updatedAt: string | null;
+ partGroupId: string | null;
+ salesAccount: string;
+ salesCreditAccount: string;
+ salesDiscountAccount: string;
+ salesPrepaymentAccount: string;
+ salesTaxPayableAccount: string;
updatedBy: string | null;
};
Insert: {
- active?: boolean;
- calculationMethod?: Database["public"]["Enums"]["paymentTermCalculationMethod"];
- createdAt?: string;
- createdBy: string;
- daysDiscount?: number;
- daysDue?: number;
- discountPercentage?: number;
+ customerTypeId?: string | null;
id?: string;
- name: string;
- updatedAt?: string | null;
+ partGroupId?: string | null;
+ salesAccount: string;
+ salesCreditAccount: string;
+ salesDiscountAccount: string;
+ salesPrepaymentAccount: string;
+ salesTaxPayableAccount: string;
updatedBy?: string | null;
};
Update: {
- active?: boolean;
- calculationMethod?: Database["public"]["Enums"]["paymentTermCalculationMethod"];
- createdAt?: string;
- createdBy?: string;
- daysDiscount?: number;
- daysDue?: number;
- discountPercentage?: number;
+ customerTypeId?: string | null;
id?: string;
- name?: string;
- updatedAt?: string | null;
+ partGroupId?: string | null;
+ salesAccount?: string;
+ salesCreditAccount?: string;
+ salesDiscountAccount?: string;
+ salesPrepaymentAccount?: string;
+ salesTaxPayableAccount?: string;
updatedBy?: string | null;
};
Relationships: [
{
- foreignKeyName: "paymentTerm_createdBy_fkey";
- columns: ["createdBy"];
- referencedRelation: "user";
+ foreignKeyName: "postingGroupSales_customerTypeId_fkey";
+ columns: ["customerTypeId"];
+ referencedRelation: "customerType";
referencedColumns: ["id"];
},
{
- foreignKeyName: "paymentTerm_createdBy_fkey";
- columns: ["createdBy"];
- referencedRelation: "user_default_view";
- referencedColumns: ["userId"];
+ foreignKeyName: "postingGroupSales_partGroupId_fkey";
+ columns: ["partGroupId"];
+ referencedRelation: "partGroup";
+ referencedColumns: ["id"];
},
{
- foreignKeyName: "paymentTerm_updatedBy_fkey";
+ foreignKeyName: "postingGroupSales_salesAccount_fkey";
+ columns: ["salesAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupSales_salesAccount_fkey";
+ columns: ["salesAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupSales_salesCreditAccount_fkey";
+ columns: ["salesCreditAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupSales_salesCreditAccount_fkey";
+ columns: ["salesCreditAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupSales_salesDiscountAccount_fkey";
+ columns: ["salesDiscountAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupSales_salesDiscountAccount_fkey";
+ columns: ["salesDiscountAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupSales_salesPrepaymentAccount_fkey";
+ columns: ["salesPrepaymentAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupSales_salesPrepaymentAccount_fkey";
+ columns: ["salesPrepaymentAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupSales_salesTaxPayableAccount_fkey";
+ columns: ["salesTaxPayableAccount"];
+ referencedRelation: "account";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupSales_salesTaxPayableAccount_fkey";
+ columns: ["salesTaxPayableAccount"];
+ referencedRelation: "accounts_view";
+ referencedColumns: ["number"];
+ },
+ {
+ foreignKeyName: "postingGroupSales_updatedBy_fkey";
columns: ["updatedBy"];
referencedRelation: "user";
referencedColumns: ["id"];
},
{
- foreignKeyName: "paymentTerm_updatedBy_fkey";
+ foreignKeyName: "postingGroupSales_updatedBy_fkey";
columns: ["updatedBy"];
referencedRelation: "user_default_view";
referencedColumns: ["userId"];
@@ -4681,28 +5649,59 @@ export interface Database {
Row: {
color: string | null;
createdAt: string;
+ createdBy: string;
id: string;
name: string;
protected: boolean;
updatedAt: string | null;
+ updatedBy: string | null;
};
Insert: {
color?: string | null;
createdAt?: string;
+ createdBy: string;
id?: string;
name: string;
protected?: boolean;
updatedAt?: string | null;
+ updatedBy?: string | null;
};
Update: {
color?: string | null;
createdAt?: string;
+ createdBy?: string;
id?: string;
name?: string;
protected?: boolean;
updatedAt?: string | null;
+ updatedBy?: string | null;
};
- Relationships: [];
+ Relationships: [
+ {
+ foreignKeyName: "supplierType_createdBy_fkey";
+ columns: ["createdBy"];
+ referencedRelation: "user";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "supplierType_createdBy_fkey";
+ columns: ["createdBy"];
+ referencedRelation: "user_default_view";
+ referencedColumns: ["userId"];
+ },
+ {
+ foreignKeyName: "supplierType_updatedBy_fkey";
+ columns: ["updatedBy"];
+ referencedRelation: "user";
+ referencedColumns: ["id"];
+ },
+ {
+ foreignKeyName: "supplierType_updatedBy_fkey";
+ columns: ["updatedBy"];
+ referencedRelation: "user_default_view";
+ referencedColumns: ["userId"];
+ }
+ ];
};
unitOfMeasure: {
Row: {
diff --git a/packages/carbon-database/supabase/migrations/20230123004316_users.sql b/packages/carbon-database/supabase/migrations/20230123004316_users.sql
index 36773ad706..4c2b26b75e 100644
--- a/packages/carbon-database/supabase/migrations/20230123004316_users.sql
+++ b/packages/carbon-database/supabase/migrations/20230123004316_users.sql
@@ -14,9 +14,6 @@ CREATE TABLE "user" (
CONSTRAINT "user_pkey" PRIMARY KEY ("id")
);
-INSERT INTO "user" ("id", "email", "firstName", "lastName")
-VALUES ('system', '[email protected]', 'System', 'Operation');
-
CREATE UNIQUE INDEX "index_user_email_key" ON "user"("email");
CREATE INDEX "index_user_fullName" ON "user"("fullName");
diff --git a/packages/carbon-database/supabase/migrations/20230123004536_attributes.sql b/packages/carbon-database/supabase/migrations/20230123004536_attributes.sql
index 917c3975a0..2c093d8fb0 100644
--- a/packages/carbon-database/supabase/migrations/20230123004536_attributes.sql
+++ b/packages/carbon-database/supabase/migrations/20230123004536_attributes.sql
@@ -80,16 +80,6 @@ CREATE TABLE "attributeDataType" (
)
);
-INSERT INTO "attributeDataType" ("label", "isBoolean", "isDate", "isList", "isNumeric", "isText", "isUser")
-VALUES
- ('Yes/No', true, false, false, false, false, false),
- ('Date', false, true, false, false, false, false),
- ('List', false, false, true, false, false, false),
- ('Numeric', false, false, false, true, false, false),
- ('Text', false, false, false, false, true, false),
- ('User', false, false, false, false, false, true);
-
-
-- ALTER TABLE "attributeDataType" ENABLE ROW LEVEL SECURITY;
CREATE TABLE "userAttribute" (
diff --git a/packages/carbon-database/supabase/migrations/20230123004612_suppliers-and-customers.sql b/packages/carbon-database/supabase/migrations/20230123004612_suppliers-and-customers.sql
index 122b497812..f09509a6d0 100644
--- a/packages/carbon-database/supabase/migrations/20230123004612_suppliers-and-customers.sql
+++ b/packages/carbon-database/supabase/migrations/20230123004612_suppliers-and-customers.sql
@@ -49,21 +49,25 @@ CREATE TABLE "supplierStatus" (
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
"updatedAt" TIMESTAMP WITH TIME ZONE,
- CONSTRAINT "supplierStatus_pkey" PRIMARY KEY ("id")
+ CONSTRAINT "supplierStatus_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "supplierStatus_name_unique" UNIQUE ("name")
);
-INSERT INTO "supplierStatus" ("name") VALUES ('Active'), ('Inactive'), ('Pending'), ('Rejected');
-
CREATE TABLE "supplierType" (
"id" TEXT NOT NULL DEFAULT uuid_generate_v4(),
"name" TEXT NOT NULL,
"color" TEXT DEFAULT '#000000',
"protected" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ "createdBy" TEXT NOT NULL,
+ "updatedBy" TEXT,
"updatedAt" TIMESTAMP WITH TIME ZONE,
CONSTRAINT "supplierType_pkey" PRIMARY KEY ("id"),
- CONSTRAINT "supplierType_colorCheck" CHECK ("color" is null or "color" ~* '^#[a-f0-9]{6}$')
+ CONSTRAINT "supplierType_name_unique" UNIQUE ("name"),
+ CONSTRAINT "supplierType_colorCheck" CHECK ("color" is null or "color" ~* '^#[a-f0-9]{6}$'),
+ CONSTRAINT "supplierType_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON UPDATE CASCADE ON DELETE RESTRICT,
+ CONSTRAINT "supplierType_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON UPDATE CASCADE ON DELETE SET NULL
);
CREATE TABLE "supplier" (
@@ -131,21 +135,25 @@ CREATE TABLE "customerStatus" (
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
"updatedAt" TIMESTAMP WITH TIME ZONE,
- CONSTRAINT "customerStatus_pkey" PRIMARY KEY ("id")
+ CONSTRAINT "customerStatus_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "customerStatus_name_unique" UNIQUE ("name")
);
-INSERT INTO "customerStatus" ("name") VALUES ('Active'), ('Inactive'), ('Prospect'), ('Lead'), ('On Hold'), ('Cancelled'), ('Archived');
-
CREATE TABLE "customerType" (
"id" TEXT NOT NULL DEFAULT uuid_generate_v4(),
"name" TEXT NOT NULL,
"color" TEXT DEFAULT '#000000',
"protected" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
+ "createdBy" TEXT NOT NULL,
+ "updatedBy" TEXT,
"updatedAt" TIMESTAMP WITH TIME ZONE,
CONSTRAINT "customerType_pkey" PRIMARY KEY ("id"),
- CONSTRAINT "customerType_colorCheck" CHECK ("color" is null or "color" ~* '^#[a-f0-9]{6}$')
+ CONSTRAINT "customerType_name_unique" UNIQUE ("name"),
+ CONSTRAINT "customerType_colorCheck" CHECK ("color" is null or "color" ~* '^#[a-f0-9]{6}$'),
+ CONSTRAINT "customerType_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id") ON UPDATE CASCADE ON DELETE RESTRICT,
+ CONSTRAINT "customerType_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id") ON UPDATE CASCADE ON DELETE SET NULL
);
CREATE TABLE "customer" (
diff --git a/packages/carbon-database/supabase/migrations/20230330024715_accounts.sql b/packages/carbon-database/supabase/migrations/20230330024715_accounts.sql
index 42ac4f239e..20120238d8 100644
--- a/packages/carbon-database/supabase/migrations/20230330024715_accounts.sql
+++ b/packages/carbon-database/supabase/migrations/20230330024715_accounts.sql
@@ -18,9 +18,6 @@ CREATE TABLE "currency" (
CONSTRAINT "currency_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
-INSERT INTO "currency" ("name", "code", "symbol", "exchangeRate", "isBaseCurrency", "createdBy")
-VALUES ('US Dollar', 'USD', '$', 1.0000, true, 'system');
-
CREATE INDEX "currency_code_index" ON "currency" ("code");
ALTER TABLE "currency" ENABLE ROW LEVEL SECURITY;
@@ -108,27 +105,6 @@ CREATE TABLE "accountCategory" (
CONSTRAINT "accountCategory_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
-INSERT INTO "accountCategory" ("category", "incomeBalance", "normalBalance", "createdBy")
-VALUES
- ('Bank', 'Balance Sheet', 'Credit', 'system'),
- ('Accounts Receivable', 'Balance Sheet', 'Credit', 'system'),
- ('Inventory', 'Balance Sheet', 'Debit', 'system'),
- ('Other Current Asset', 'Balance Sheet', 'Debit', 'system'),
- ('Fixed Asset', 'Balance Sheet', 'Debit', 'system'),
- ('Accumulated Depreciation', 'Balance Sheet', 'Credit', 'system'),
- ('Other Asset', 'Balance Sheet', 'Debit', 'system'),
- ('Accounts Payable', 'Balance Sheet', 'Debit', 'system'),
- ('Other Current Liability', 'Balance Sheet', 'Debit', 'system'),
- ('Long Term Liability', 'Balance Sheet', 'Debit', 'system'),
- ('Equity - No Close', 'Balance Sheet', 'Credit', 'system'),
- ('Equity - Close', 'Balance Sheet', 'Credit', 'system'),
- ('Retained Earnings', 'Balance Sheet', 'Credit', 'system'),
- ('Income', 'Income Statement', 'Credit', 'system'),
- ('Cost of Goods Sold', 'Income Statement', 'Debit', 'system'),
- ('Expense', 'Income Statement', 'Debit', 'system'),
- ('Other Income', 'Income Statement', 'Credit', 'system'),
- ('Other Expense', 'Income Statement', 'Debit', 'system');
-
ALTER TABLE "accountCategory" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Employees with accounting_view can view account categories" ON "accountCategory"
diff --git a/packages/carbon-database/supabase/migrations/20230330024716_parts.sql b/packages/carbon-database/supabase/migrations/20230330024716_parts.sql
index 0b4d735438..4b63714d5d 100644
--- a/packages/carbon-database/supabase/migrations/20230330024716_parts.sql
+++ b/packages/carbon-database/supabase/migrations/20230330024716_parts.sql
@@ -2,13 +2,6 @@ CREATE TABLE "partGroup" (
"id" TEXT NOT NULL DEFAULT xid(),
"name" TEXT NOT NULL,
"description" TEXT,
- "salesAccountId" TEXT,
- "discountAccountId" TEXT,
- "inventoryAccountId" TEXT,
- "costOfGoodsSoldLaborAccountId" TEXT,
- "costOfGoodsSoldMaterialAccountId" TEXT,
- "costOfGoodsSoldOverheadAccountId" TEXT,
- "costOfGoodsSoldSubcontractorAccountId" TEXT,
"active" BOOLEAN NOT NULL DEFAULT true,
"createdBy" TEXT NOT NULL,
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
@@ -17,13 +10,6 @@ CREATE TABLE "partGroup" (
CONSTRAINT "partGroup_pkey" PRIMARY KEY ("id"),
CONSTRAINT "partGroup_name_key" UNIQUE ("name"),
- CONSTRAINT "partGroup_salesAccountId_fkey" FOREIGN KEY ("salesAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_discountAccountId_fkey" FOREIGN KEY ("discountAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_inventoryAccountId_fkey" FOREIGN KEY ("inventoryAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_costOfGoodsSoldLaborAccountId_fkey" FOREIGN KEY ("costOfGoodsSoldLaborAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_costOfGoodsSoldMaterialAccountId_fkey" FOREIGN KEY ("costOfGoodsSoldMaterialAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_costOfGoodsSoldOverheadAccountId_fkey" FOREIGN KEY ("costOfGoodsSoldOverheadAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_costOfGoodsSoldSubcontractorAccountId_fkey" FOREIGN KEY ("costOfGoodsSoldSubcontractorAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "partGroup_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
CONSTRAINT "partGroup_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
@@ -110,11 +96,6 @@ CREATE TABLE "unitOfMeasure" (
CREATE INDEX "unitOfMeasure_code_index" ON "unitOfMeasure"("code");
-INSERT INTO "unitOfMeasure" ("code", "name", "createdBy")
-VALUES
-( 'EA', 'Each', 'system'),
-( 'PCS', 'Pieces', 'system');
-
ALTER TABLE "unitOfMeasure" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Authenticated users can view units of measure" ON "unitOfMeasure"
@@ -264,9 +245,6 @@ CREATE TABLE "partCost" (
"costingMethod" "partCostingMethod" NOT NULL,
"standardCost" NUMERIC(15,5) NOT NULL DEFAULT 0,
"unitCost" NUMERIC(15,5) NOT NULL DEFAULT 0,
- "salesAccountId" TEXT,
- "discountAccountId" TEXT,
- "inventoryAccountId" TEXT,
"costIsAdjusted" BOOLEAN NOT NULL DEFAULT false,
"createdBy" TEXT NOT NULL,
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
@@ -274,9 +252,6 @@ CREATE TABLE "partCost" (
"updatedAt" TIMESTAMP WITH TIME ZONE,
CONSTRAINT "partCost_partId_fkey" FOREIGN KEY ("partId") REFERENCES "part"("id") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_salesAccountId_fkey" FOREIGN KEY ("salesAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_discountAccountId_fkey" FOREIGN KEY ("discountAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT "partGroup_inventoryAccountId_fkey" FOREIGN KEY ("inventoryAccountId") REFERENCES "account"("number") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "partGroup_createdBy_fkey" FOREIGN KEY ("createdBy") REFERENCES "user"("id"),
CONSTRAINT "partGroup_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user"("id")
);
@@ -685,7 +660,7 @@ CREATE TABLE "partPlanning" (
CREATE INDEX "partPlanning_partId_locationId_index" ON "partPlanning" ("partId", "locationId");
ALTER TABLE "partPlanning" ENABLE ROW LEVEL SECURITY;
-CREATE POLICY "Employees with part_view can view part planning" ON "partPlanning"
+CREATE POLICY "Employees with parts_view can view part planning" ON "partPlanning"
FOR SELECT
USING (
coalesce(get_my_claim('parts_view')::boolean,false)
@@ -693,7 +668,7 @@ CREATE POLICY "Employees with part_view can view part planning" ON "partPlanning
);
-- these are records are created lazily when a user attempts to view them
-CREATE POLICY "Employees with part_view can insert part planning" ON "partPlanning"
+CREATE POLICY "Employees with parts_view can insert part planning" ON "partPlanning"
FOR INSERT
WITH CHECK (
coalesce(get_my_claim('parts_view')::boolean,false)
diff --git a/packages/carbon-database/supabase/migrations/20230510035345_purchasing.sql b/packages/carbon-database/supabase/migrations/20230510035345_purchasing.sql
index 546378e71d..b04b1bfdef 100644
--- a/packages/carbon-database/supabase/migrations/20230510035345_purchasing.sql
+++ b/packages/carbon-database/supabase/migrations/20230510035345_purchasing.sql
@@ -23,18 +23,6 @@ CREATE TABLE "paymentTerm" (
CONSTRAINT "paymentTerm_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE CASCADE
);
-INSERT INTO "paymentTerm" ("name", "daysDue", "calculationMethod", "daysDiscount", "discountPercentage", "createdBy")
-VALUES
- ('Net 15', 15, 'Net', 0, 0, 'system'),
- ('Net 30', 30, 'Net', 0, 0, 'system'),
- ('Net 50', 50, 'Net', 0, 0, 'system'),
- ('Net 60', 60, 'Net', 0, 0, 'system'),
- ('Net 90', 90, 'Net', 0, 0, 'system'),
- ('1% 10 Net 30', 30, 'Net', 10, 1, 'system'),
- ('2% 10 Net 30', 30, 'Net', 10, 2, 'system'),
- ('Due on Receipt', 0, 'Net', 0, 0, 'system'),
- ('Net EOM 10', 10, 'End of Month', 0, 0, 'system');
-
ALTER TABLE "paymentTerm" ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Certain employees can view payment terms" ON "paymentTerm"
diff --git a/packages/carbon-database/supabase/migrations/20230525025310_sequences.sql b/packages/carbon-database/supabase/migrations/20230525025310_sequences.sql
index 189dcc4407..886565ed37 100644
--- a/packages/carbon-database/supabase/migrations/20230525025310_sequences.sql
+++ b/packages/carbon-database/supabase/migrations/20230525025310_sequences.sql
@@ -16,6 +16,3 @@ CREATE TABLE "sequence" (
CONSTRAINT "sequence_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-INSERT INTO "sequence" ("table", "name", "prefix", "suffix", "next", "size", "step")
-VALUES ('purchaseOrder', 'Purchase Order', 'PO', NULL, 0, 6, 1);
-
diff --git a/packages/carbon-database/supabase/migrations/20230728025201_receipts.sql b/packages/carbon-database/supabase/migrations/20230728025201_receipts.sql
index d95b9df03c..5c1511cd88 100644
--- a/packages/carbon-database/supabase/migrations/20230728025201_receipts.sql
+++ b/packages/carbon-database/supabase/migrations/20230728025201_receipts.sql
@@ -36,8 +36,36 @@ CREATE INDEX "receipt_locationId_idx" ON "receipt" ("locationId");
CREATE INDEX "receipt_sourceDocumentId_idx" ON "receipt" ("sourceDocumentId");
CREATE INDEX "receipt_supplierId_idx" ON "receipt" ("supplierId");
-INSERT INTO "sequence" ("table", "name", "prefix", "suffix", "next", "size", "step")
-VALUES ('receipt', 'Receipt', 'RE', NULL, 0, 6, 1);
+ALTER TABLE "receipt" ENABLE ROW LEVEL SECURITY;
+
+CREATE POLICY "Employees with inventory_view can view receipts" ON "receipt"
+ FOR SELECT
+ USING (
+ coalesce(get_my_claim('inventory_view')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+
+CREATE POLICY "Employees with inventory_create can insert receipts" ON "receipt"
+ FOR INSERT
+ WITH CHECK (
+ coalesce(get_my_claim('inventory_create')::boolean,false)
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+);
+
+CREATE POLICY "Employees with inventory_update can update receipts" ON "receipt"
+ FOR UPDATE
+ USING (
+ coalesce(get_my_claim('inventory_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+CREATE POLICY "Employees with inventory_delete can delete receipts" ON "receipt"
+ FOR DELETE
+ USING (
+ coalesce(get_my_claim('inventory_delete')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
CREATE TABLE "receiptLine" (
"id" TEXT NOT NULL DEFAULT xid(),
@@ -69,6 +97,37 @@ CREATE INDEX "receiptLine_receiptId_idx" ON "receiptLine" ("receiptId");
CREATE INDEX "receiptLine_lineId_idx" ON "receiptLine" ("lineId");
CREATE INDEX "receiptLine_receiptId_lineId_idx" ON "receiptLine" ("receiptId", "lineId");
+ALTER TABLE "receiptLine" ENABLE ROW LEVEL SECURITY;
+
+CREATE POLICY "Employees with inventory_view can view receipt lines" ON "receiptLine"
+ FOR SELECT
+ USING (
+ coalesce(get_my_claim('inventory_view')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+
+CREATE POLICY "Employees with inventory_create can insert receipt lines" ON "receiptLine"
+ FOR INSERT
+ WITH CHECK (
+ coalesce(get_my_claim('inventory_create')::boolean,false)
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+);
+
+CREATE POLICY "Employees with inventory_update can update receipt lines" ON "receiptLine"
+ FOR UPDATE
+ USING (
+ coalesce(get_my_claim('inventory_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+CREATE POLICY "Employees with inventory_delete can delete receipt lines" ON "receiptLine"
+ FOR DELETE
+ USING (
+ coalesce(get_my_claim('inventory_delete')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
CREATE VIEW "receipt_quantity_received_by_line" AS
SELECT
r."sourceDocumentId",
diff --git a/packages/carbon-database/supabase/migrations/20230820020844_posting-groups.sql b/packages/carbon-database/supabase/migrations/20230820020844_posting-groups.sql
new file mode 100644
index 0000000000..3ca83d6298
--- /dev/null
+++ b/packages/carbon-database/supabase/migrations/20230820020844_posting-groups.sql
@@ -0,0 +1,660 @@
+CREATE TABLE "accountDefault" (
+ "id" BOOLEAN NOT NULL DEFAULT TRUE,
+ -- income statement
+ -- revenue
+ "salesAccount" TEXT NOT NULL,
+ "salesDiscountAccount" TEXT NOT NULL,
+
+ -- part cost
+ "costOfGoodsSoldAccount" TEXT NOT NULL,
+ "purchaseAccount" TEXT NOT NULL,
+ "directCostAppliedAccount" TEXT NOT NULL,
+ "overheadCostAppliedAccount" TEXT NOT NULL,
+ "purchaseVarianceAccount" TEXT NOT NULL,
+ "inventoryAdjustmentVarianceAccount" TEXT NOT NULL,
+
+ -- direct costs
+ "materialVarianceAccount" TEXT NOT NULL,
+ "capacityVarianceAccount" TEXT NOT NULL,
+ "overheadAccount" TEXT NOT NULL,
+ "maintenanceAccount" TEXT NOT NULL,
+
+ -- depreciaition of fixed assets
+ "assetDepreciationExpenseAccount" TEXT NOT NULL,
+ "assetGainsAndLossesAccount" TEXT NOT NULL,
+ "serviceChargeAccount" TEXT NOT NULL,
+
+ -- interest
+ "interestAccount" TEXT NOT NULL,
+ "supplierPaymentDiscountAccount" TEXT NOT NULL,
+ "customerPaymentDiscountAccount" TEXT NOT NULL,
+ "roundingAccount" TEXT NOT NULL,
+
+ -- balance sheet
+ -- assets
+ "assetAquisitionCostAccount" TEXT NOT NULL,
+ "assetAquisitionCostOnDisposalAccount" TEXT NOT NULL,
+ "accumulatedDepreciationAccount" TEXT NOT NULL,
+ "accumulatedDepreciationOnDisposalAccount" TEXT NOT NULL,
+
+ -- current assets
+ "inventoryAccount" TEXT NOT NULL,
+ "inventoryInterimAccrualAccount" TEXT NOT NULL,
+ "workInProgressAccount" TEXT NOT NULL,
+ "receivablesAccount" TEXT NOT NULL,
+ "inventoryShippedNotInvoicedAccount" TEXT NOT NULL,
+ "bankCashAccount" TEXT NOT NULL,
+ "bankLocalCurrencyAccount" TEXT NOT NULL,
+ "bankForeignCurrencyAccount" TEXT NOT NULL,
+
+ -- liabilities
+ "prepaymentAccount" TEXT NOT NULL,
+ "payablesAccount" TEXT NOT NULL,
+ "inventoryReceivedNotInvoicedAccount" TEXT NOT NULL,
+ "salesTaxPayableAccount" TEXT NOT NULL,
+ "purchaseTaxPayableAccount" TEXT NOT NULL,
+ "reverseChargeSalesTaxPayableAccount" TEXT NOT NULL,
+
+ -- retained earnings
+ "retainedEarningsAccount" TEXT NOT NULL,
+
+ "updatedBy" TEXT,
+
+
+
+ CONSTRAINT "accountDefault_pkey" PRIMARY KEY ("id"),
+ -- this is a hack to make sure that this table only ever has one row
+ CONSTRAINT "accountDefault_id_check" CHECK ("id" = TRUE),
+ CONSTRAINT "accountDefault_id_unique" UNIQUE ("id"),
+ CONSTRAINT "accountDefault_salesAccount_fkey" FOREIGN KEY ("salesAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_salesDiscountAccount_fkey" FOREIGN KEY ("salesDiscountAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_costOfGoodsSoldAccount_fkey" FOREIGN KEY ("costOfGoodsSoldAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_purchaseAccount_fkey" FOREIGN KEY ("purchaseAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_directCostAppliedAccount_fkey" FOREIGN KEY ("directCostAppliedAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_overheadCostAppliedAccount_fkey" FOREIGN KEY ("overheadCostAppliedAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_purchaseVarianceAccount_fkey" FOREIGN KEY ("purchaseVarianceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_inventoryAdjustmentVarianceAccount_fkey" FOREIGN KEY ("inventoryAdjustmentVarianceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_materialVarianceAccount_fkey" FOREIGN KEY ("materialVarianceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_capacityVarianceAccount_fkey" FOREIGN KEY ("capacityVarianceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_overheadAccount_fkey" FOREIGN KEY ("overheadAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_maintenanceAccount_fkey" FOREIGN KEY ("maintenanceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_assetDepreciationExpenseAccount_fkey" FOREIGN KEY ("assetDepreciationExpenseAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_assetGainsAndLossesAccount_fkey" FOREIGN KEY ("assetGainsAndLossesAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_serviceChargeAccount_fkey" FOREIGN KEY ("serviceChargeAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_interestAccount_fkey" FOREIGN KEY ("interestAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_supplierPaymentDiscountAccount_fkey" FOREIGN KEY ("supplierPaymentDiscountAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_customerPaymentDiscountAccount_fkey" FOREIGN KEY ("customerPaymentDiscountAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_roundingAccount_fkey" FOREIGN KEY ("roundingAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_aquisitionCostAccount_fkey" FOREIGN KEY ("assetAquisitionCostAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_aquisitionCostOnDisposalAccount_fkey" FOREIGN KEY ("assetAquisitionCostOnDisposalAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_accumulatedDepreciationAccount_fkey" FOREIGN KEY ("accumulatedDepreciationAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_accumulatedDepreciationOnDisposalAccount_fkey" FOREIGN KEY ("accumulatedDepreciationOnDisposalAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_inventoryAccount_fkey" FOREIGN KEY ("inventoryAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_inventoryInterimAccrualAccount_fkey" FOREIGN KEY ("inventoryInterimAccrualAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_workInProgressAccount_fkey" FOREIGN KEY ("workInProgressAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_receivablesAccount_fkey" FOREIGN KEY ("receivablesAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_inventoryShippedNotInvoicedAccount_fkey" FOREIGN KEY ("inventoryShippedNotInvoicedAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_bankCashAccount_fkey" FOREIGN KEY ("bankCashAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_bankLocalCurrencyAccount_fkey" FOREIGN KEY ("bankLocalCurrencyAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_bankForeignCurrencyAccount_fkey" FOREIGN KEY ("bankForeignCurrencyAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_prepaymentAccount_fkey" FOREIGN KEY ("prepaymentAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_payablesAccount_fkey" FOREIGN KEY ("payablesAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_inventoryReceivedNotInvoicedAccount_fkey" FOREIGN KEY ("inventoryReceivedNotInvoicedAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_salesTaxPayableAccount_fkey" FOREIGN KEY ("salesTaxPayableAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_reverseChargeSalesTaxPayableAccount_fkey" FOREIGN KEY ("reverseChargeSalesTaxPayableAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_purchaseTaxPayableAccount_fkey" FOREIGN KEY ("purchaseTaxPayableAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_retainedEarningsAccount_fkey" FOREIGN KEY ("retainedEarningsAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "accountDefault_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
+);
+
+ALTER TABLE "accountDefault" ENABLE ROW LEVEL SECURITY;
+
+
+CREATE POLICY "Employees with accounting_view can view account defaults" ON "accountDefault"
+ FOR SELECT
+ USING (
+ coalesce(get_my_claim('accounting_view')::boolean,false)
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+CREATE POLICY "Employees with accounting_update can update account defaults" ON "accountDefault"
+ FOR UPDATE
+ USING (
+ coalesce(get_my_claim('accounting_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+
+
+CREATE TABLE "postingGroupInventory" (
+ "id" TEXT NOT NULL DEFAULT xid(),
+ "partGroupId" TEXT,
+ "locationId" TEXT,
+ "costOfGoodsSoldAccount" TEXT NOT NULL,
+ "inventoryAccount" TEXT NOT NULL,
+ "inventoryInterimAccrualAccount" TEXT NOT NULL,
+ "inventoryReceivedNotInvoicedAccount" TEXT NOT NULL,
+ "inventoryShippedNotInvoicedAccount" TEXT NOT NULL,
+ "workInProgressAccount" TEXT NOT NULL,
+ "directCostAppliedAccount" TEXT NOT NULL,
+ "overheadCostAppliedAccount" TEXT NOT NULL,
+ "purchaseVarianceAccount" TEXT NOT NULL,
+ "inventoryAdjustmentVarianceAccount" TEXT NOT NULL,
+ "materialVarianceAccount" TEXT NOT NULL,
+ "capacityVarianceAccount" TEXT NOT NULL,
+ "overheadAccount" TEXT NOT NULL,
+ "updatedBy" TEXT,
+
+ CONSTRAINT "postingGroupInventory_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "postingGroupInventory_id_partGroupId_locationId_key" UNIQUE ("partGroupId", "locationId"),
+ CONSTRAINT "postingGroupInventory_partGroupId_fkey" FOREIGN KEY ("partGroupId") REFERENCES "partGroup" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "location" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_costOfGoodsSoldAccount_fkey" FOREIGN KEY ("costOfGoodsSoldAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_inventoryAccount_fkey" FOREIGN KEY ("inventoryAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_inventoryInterimAccrualAccount_fkey" FOREIGN KEY ("inventoryInterimAccrualAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_inventoryReceivedNotInvoicedAccount_fkey" FOREIGN KEY ("inventoryReceivedNotInvoicedAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_inventoryShippedNotInvoicedAccount_fkey" FOREIGN KEY ("inventoryShippedNotInvoicedAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_workInProgressAccount_fkey" FOREIGN KEY ("workInProgressAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_directCostAppliedAccount_fkey" FOREIGN KEY ("directCostAppliedAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_overheadCostAppliedAccount_fkey" FOREIGN KEY ("overheadCostAppliedAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_purchaseVarianceAccount_fkey" FOREIGN KEY ("purchaseVarianceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_inventoryAdjustmentVarianceAccount_fkey" FOREIGN KEY ("inventoryAdjustmentVarianceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_materialVarianceAccount_fkey" FOREIGN KEY ("materialVarianceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_capacityVarianceAccount_fkey" FOREIGN KEY ("capacityVarianceAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_overheadAccount_fkey" FOREIGN KEY ("overheadAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupInventory_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE
+);
+
+CREATE INDEX "postingGroupInventory_partGroupId_locationId_idx" ON "postingGroupInventory" ("partGroupId", "locationId");
+
+ALTER TABLE "postingGroupInventory" ENABLE ROW LEVEL SECURITY;
+
+CREATE POLICY "Employees with accounting_view can view inventory posting groups" ON "postingGroupInventory"
+ FOR SELECT
+ USING (
+ coalesce(get_my_claim('accounting_view')::boolean,false)
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+CREATE POLICY "Employees with accounting_update can update inventory posting groups" ON "postingGroupInventory"
+ FOR UPDATE
+ USING (
+ coalesce(get_my_claim('accounting_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+
+CREATE TABLE "postingGroupPurchasing" (
+ "id" TEXT NOT NULL DEFAULT xid(),
+ "supplierTypeId" TEXT,
+ "partGroupId" TEXT,
+ "purchaseAccount" TEXT NOT NULL,
+ "purchaseDiscountAccount" TEXT NOT NULL,
+ "purchaseCreditAccount" TEXT NOT NULL,
+ "purchasePrepaymentAccount" TEXT NOT NULL,
+ "purchaseTaxPayableAccount" TEXT NOT NULL,
+ "updatedBy" TEXT,
+
+ CONSTRAINT "postingGroupPurchasing_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "postingGroupPurchasing_id_supplierTypeId_partGroupId_key" UNIQUE ("supplierTypeId", "partGroupId"),
+ CONSTRAINT "postingGroupPurchasing_partGroupId_fkey" FOREIGN KEY ("partGroupId") REFERENCES "partGroup" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupPurchasing_supplierTypeId_fkey" FOREIGN KEY ("supplierTypeId") REFERENCES "supplierType" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupPurchasing_purchaseAccount_fkey" FOREIGN KEY ("purchaseAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupPurchasing_purchaseDiscountAccount_fkey" FOREIGN KEY ("purchaseDiscountAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupPurchasing_purchaseCreditAccount_fkey" FOREIGN KEY ("purchaseCreditAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupPurchasing_purchasePrepaymentAccount_fkey" FOREIGN KEY ("purchasePrepaymentAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupPurchasing_purchaseTaxPayableAccount_fkey" FOREIGN KEY ("purchaseTaxPayableAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupPurchasing_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE
+);
+
+CREATE INDEX "postingGroupPurchasing_partGroupId_supplierTypeId_idx" ON "postingGroupPurchasing" ("partGroupId", "supplierTypeId");
+
+ALTER TABLE "postingGroupPurchasing" ENABLE ROW LEVEL SECURITY;
+
+CREATE POLICY "Employees with accounting_view can view purchasing posting groups" ON "postingGroupPurchasing"
+ FOR SELECT
+ USING (
+ coalesce(get_my_claim('accounting_view')::boolean,false)
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+CREATE POLICY "Employees with accounting_update can update purchasing posting groups" ON "postingGroupPurchasing"
+ FOR UPDATE
+ USING (
+ coalesce(get_my_claim('accounting_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+CREATE TABLE "postingGroupSales" (
+ "id" TEXT NOT NULL DEFAULT xid(),
+ "customerTypeId" TEXT,
+ "partGroupId" TEXT,
+ "salesAccount" TEXT NOT NULL,
+ "salesDiscountAccount" TEXT NOT NULL,
+ "salesCreditAccount" TEXT NOT NULL,
+ "salesPrepaymentAccount" TEXT NOT NULL,
+ "salesTaxPayableAccount" TEXT NOT NULL,
+ "updatedBy" TEXT,
+
+ CONSTRAINT "postingGroupSales_pkey" PRIMARY KEY ("id"),
+ CONSTRAINT "postingGroupSales_id_customerTypeId_partGroupId_key" UNIQUE ("customerTypeId", "partGroupId"),
+ CONSTRAINT "postingGroupSales_partGroupId_fkey" FOREIGN KEY ("partGroupId") REFERENCES "partGroup" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupSales_customerTypeId_fkey" FOREIGN KEY ("customerTypeId") REFERENCES "customerType" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupSales_salesAccount_fkey" FOREIGN KEY ("salesAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupSales_salesDiscountAccount_fkey" FOREIGN KEY ("salesDiscountAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupSales_salesCreditAccount_fkey" FOREIGN KEY ("salesCreditAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupSales_salesPrepaymentAccount_fkey" FOREIGN KEY ("salesPrepaymentAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupSales_salesTaxPayableAccount_fkey" FOREIGN KEY ("salesTaxPayableAccount") REFERENCES "account" ("number") ON DELETE RESTRICT ON UPDATE CASCADE,
+ CONSTRAINT "postingGroupSales_updatedBy_fkey" FOREIGN KEY ("updatedBy") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE
+);
+
+CREATE INDEX "postingGroupSales_partGroupId_customerTypeId_idx" ON "postingGroupSales" ("partGroupId", "customerTypeId");
+
+CREATE POLICY "Employees with accounting_view can view sales posting groups" ON "postingGroupSales"
+ FOR SELECT
+ USING (
+ coalesce(get_my_claim('accounting_view')::boolean,false)
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+CREATE POLICY "Employees with accounting_update can update sales posting groups" ON "postingGroupSales"
+ FOR UPDATE
+ USING (
+ coalesce(get_my_claim('accounting_update')::boolean, false) = true
+ AND (get_my_claim('role'::text)) = '"employee"'::jsonb
+ );
+
+CREATE FUNCTION public.create_posting_groups_for_location()
+RETURNS TRIGGER AS $$
+DECLARE
+ part_group RECORD;
+ account_defaults RECORD;
+BEGIN
+ SELECT * INTO account_defaults FROM "accountDefault" WHERE "id" = TRUE;
+
+ FOR part_group IN SELECT "id" FROM "partGroup"
+ LOOP
+ INSERT INTO "postingGroupInventory" (
+ "partGroupId",
+ "locationId",
+ "costOfGoodsSoldAccount",
+ "inventoryAccount",
+ "inventoryInterimAccrualAccount",
+ "inventoryReceivedNotInvoicedAccount",
+ "inventoryShippedNotInvoicedAccount",
+ "workInProgressAccount",
+ "directCostAppliedAccount",
+ "overheadCostAppliedAccount",
+ "purchaseVarianceAccount",
+ "inventoryAdjustmentVarianceAccount",
+ "materialVarianceAccount",
+ "capacityVarianceAccount",
+ "overheadAccount",
+ "updatedBy"
+ ) VALUES (
+ part_group."id",
+ new."id",
+ account_defaults."costOfGoodsSoldAccount",
+ account_defaults."inventoryAccount",
+ account_defaults."inventoryInterimAccrualAccount",
+ account_defaults."inventoryReceivedNotInvoicedAccount",
+ account_defaults."inventoryShippedNotInvoicedAccount",
+ account_defaults."workInProgressAccount",
+ account_defaults."directCostAppliedAccount",
+ account_defaults."overheadCostAppliedAccount",
+ account_defaults."purchaseVarianceAccount",
+ account_defaults."inventoryAdjustmentVarianceAccount",
+ account_defaults."materialVarianceAccount",
+ account_defaults."capacityVarianceAccount",
+ account_defaults."overheadAccount",
+ new."createdBy"
+ );
+ END LOOP;
+
+ -- insert the null part group
+ INSERT INTO "postingGroupInventory" (
+ "partGroupId",
+ "locationId",
+ "costOfGoodsSoldAccount",
+ "inventoryAccount",
+ "inventoryInterimAccrualAccount",
+ "inventoryReceivedNotInvoicedAccount",
+ "inventoryShippedNotInvoicedAccount",
+ "workInProgressAccount",
+ "directCostAppliedAccount",
+ "overheadCostAppliedAccount",
+ "purchaseVarianceAccount",
+ "inventoryAdjustmentVarianceAccount",
+ "materialVarianceAccount",
+ "capacityVarianceAccount",
+ "overheadAccount",
+ "updatedBy"
+ ) VALUES (
+ NULL,
+ new."id",
+ account_defaults."costOfGoodsSoldAccount",
+ account_defaults."inventoryAccount",
+ account_defaults."inventoryInterimAccrualAccount",
+ account_defaults."inventoryReceivedNotInvoicedAccount",
+ account_defaults."inventoryShippedNotInvoicedAccount",
+ account_defaults."workInProgressAccount",
+ account_defaults."directCostAppliedAccount",
+ account_defaults."overheadCostAppliedAccount",
+ account_defaults."purchaseVarianceAccount",
+ account_defaults."inventoryAdjustmentVarianceAccount",
+ account_defaults."materialVarianceAccount",
+ account_defaults."capacityVarianceAccount",
+ account_defaults."overheadAccount",
+ new."createdBy"
+ );
+
+ RETURN new;
+END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+CREATE TRIGGER create_location
+ AFTER INSERT on public."location"
+ FOR EACH ROW EXECUTE PROCEDURE public.create_posting_groups_for_location();
+
+
+CREATE FUNCTION public.create_posting_groups_for_part_group()
+RETURNS TRIGGER AS $$
+DECLARE
+ rec RECORD;
+ account_defaults RECORD;
+BEGIN
+ SELECT * INTO account_defaults FROM "accountDefault" WHERE "id" = TRUE;
+
+ FOR rec IN SELECT "id" FROM "customerType"
+ LOOP
+ INSERT INTO "postingGroupSales" (
+ "partGroupId",
+ "customerTypeId",
+ "salesAccount",
+ "salesDiscountAccount",
+ "salesCreditAccount",
+ "salesPrepaymentAccount",
+ "salesTaxPayableAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ rec."id",
+ account_defaults."salesAccount",
+ account_defaults."salesDiscountAccount",
+ account_defaults."receivablesAccount",
+ account_defaults."prepaymentAccount",
+ account_defaults."salesTaxPayableAccount",
+ new."createdBy"
+ );
+ END LOOP;
+
+ -- insert the null customer type
+ INSERT INTO "postingGroupSales" (
+ "partGroupId",
+ "customerTypeId",
+ "salesAccount",
+ "salesDiscountAccount",
+ "salesCreditAccount",
+ "salesPrepaymentAccount",
+ "salesTaxPayableAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ NULL,
+ account_defaults."salesAccount",
+ account_defaults."salesDiscountAccount",
+ account_defaults."receivablesAccount",
+ account_defaults."prepaymentAccount",
+ account_defaults."salesTaxPayableAccount",
+ new."createdBy"
+ );
+
+ FOR rec IN SELECT "id" FROM "supplierType"
+ LOOP
+ INSERT INTO "postingGroupPurchasing" (
+ "partGroupId",
+ "supplierTypeId",
+ "purchaseAccount",
+ "purchaseDiscountAccount",
+ "purchaseCreditAccount",
+ "purchasePrepaymentAccount",
+ "purchaseTaxPayableAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ rec."id",
+ account_defaults."purchaseAccount",
+ account_defaults."purchaseAccount",
+ account_defaults."payablesAccount",
+ account_defaults."prepaymentAccount",
+ account_defaults."purchaseTaxPayableAccount",
+ new."createdBy"
+ );
+ END LOOP;
+
+ -- insert the null supplier type
+ INSERT INTO "postingGroupPurchasing" (
+ "partGroupId",
+ "supplierTypeId",
+ "purchaseAccount",
+ "purchaseDiscountAccount",
+ "purchaseCreditAccount",
+ "purchasePrepaymentAccount",
+ "purchaseTaxPayableAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ NULL,
+ account_defaults."purchaseAccount",
+ account_defaults."purchaseAccount",
+ account_defaults."payablesAccount",
+ account_defaults."prepaymentAccount",
+ account_defaults."purchaseTaxPayableAccount",
+ new."createdBy"
+ );
+
+ FOR rec IN SELECT "id" FROM "location"
+ LOOP
+ INSERT INTO "postingGroupInventory" (
+ "partGroupId",
+ "locationId",
+ "costOfGoodsSoldAccount",
+ "inventoryAccount",
+ "inventoryInterimAccrualAccount",
+ "inventoryReceivedNotInvoicedAccount",
+ "inventoryShippedNotInvoicedAccount",
+ "workInProgressAccount",
+ "directCostAppliedAccount",
+ "overheadCostAppliedAccount",
+ "purchaseVarianceAccount",
+ "inventoryAdjustmentVarianceAccount",
+ "materialVarianceAccount",
+ "capacityVarianceAccount",
+ "overheadAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ rec."id",
+ account_defaults."costOfGoodsSoldAccount",
+ account_defaults."inventoryAccount",
+ account_defaults."inventoryInterimAccrualAccount",
+ account_defaults."inventoryReceivedNotInvoicedAccount",
+ account_defaults."inventoryShippedNotInvoicedAccount",
+ account_defaults."workInProgressAccount",
+ account_defaults."directCostAppliedAccount",
+ account_defaults."overheadCostAppliedAccount",
+ account_defaults."purchaseVarianceAccount",
+ account_defaults."inventoryAdjustmentVarianceAccount",
+ account_defaults."materialVarianceAccount",
+ account_defaults."capacityVarianceAccount",
+ account_defaults."overheadAccount",
+ new."createdBy"
+ );
+ END LOOP;
+
+ -- insert the null location
+ INSERT INTO "postingGroupInventory" (
+ "partGroupId",
+ "locationId",
+ "costOfGoodsSoldAccount",
+ "inventoryAccount",
+ "inventoryInterimAccrualAccount",
+ "inventoryReceivedNotInvoicedAccount",
+ "inventoryShippedNotInvoicedAccount",
+ "workInProgressAccount",
+ "directCostAppliedAccount",
+ "overheadCostAppliedAccount",
+ "purchaseVarianceAccount",
+ "inventoryAdjustmentVarianceAccount",
+ "materialVarianceAccount",
+ "capacityVarianceAccount",
+ "overheadAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ NULL,
+ account_defaults."costOfGoodsSoldAccount",
+ account_defaults."inventoryAccount",
+ account_defaults."inventoryInterimAccrualAccount",
+ account_defaults."inventoryReceivedNotInvoicedAccount",
+ account_defaults."inventoryShippedNotInvoicedAccount",
+ account_defaults."workInProgressAccount",
+ account_defaults."directCostAppliedAccount",
+ account_defaults."overheadCostAppliedAccount",
+ account_defaults."purchaseVarianceAccount",
+ account_defaults."inventoryAdjustmentVarianceAccount",
+ account_defaults."materialVarianceAccount",
+ account_defaults."capacityVarianceAccount",
+ account_defaults."overheadAccount",
+ new."createdBy"
+ );
+
+ RETURN new;
+END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+
+CREATE TRIGGER create_part_group
+ AFTER INSERT on public."partGroup"
+ FOR EACH ROW EXECUTE PROCEDURE public.create_posting_groups_for_part_group();
+
+CREATE FUNCTION public.create_posting_groups_for_customer_type()
+RETURNS TRIGGER AS $$
+DECLARE
+ rec RECORD;
+ account_defaults RECORD;
+BEGIN
+ SELECT * INTO account_defaults FROM "accountDefault" WHERE "id" = TRUE;
+
+ FOR rec IN SELECT "id" FROM "partGroup"
+ LOOP
+ INSERT INTO "postingGroupSales" (
+ "customerTypeId",
+ "partGroupId",
+ "salesAccount",
+ "salesDiscountAccount",
+ "salesCreditAccount",
+ "salesPrepaymentAccount",
+ "salesTaxPayableAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ rec."id",
+ account_defaults."salesAccount",
+ account_defaults."salesDiscountAccount",
+ account_defaults."salesAccount",
+ account_defaults."prepaymentAccount",
+ account_defaults."salesTaxPayableAccount",
+ new."createdBy"
+ );
+ END LOOP;
+
+ -- insert the null part group
+ INSERT INTO "postingGroupSales" (
+ "customerTypeId",
+ "partGroupId",
+ "salesAccount",
+ "salesDiscountAccount",
+ "salesCreditAccount",
+ "salesPrepaymentAccount",
+ "salesTaxPayableAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ NULL,
+ account_defaults."salesAccount",
+ account_defaults."salesDiscountAccount",
+ account_defaults."salesAccount",
+ account_defaults."prepaymentAccount",
+ account_defaults."salesTaxPayableAccount",
+ new."createdBy"
+ );
+
+ RETURN new;
+END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+CREATE TRIGGER create_posting_groups_for_customer_type
+ AFTER INSERT on public."customerType"
+ FOR EACH ROW EXECUTE PROCEDURE public.create_posting_groups_for_customer_type();
+
+
+CREATE FUNCTION public.create_posting_groups_for_supplier_type()
+RETURNS TRIGGER AS $$
+DECLARE
+ rec RECORD;
+ account_defaults RECORD;
+BEGIN
+ SELECT * INTO account_defaults FROM "accountDefault" WHERE "id" = TRUE;
+
+ FOR rec IN SELECT "id" FROM "partGroup"
+ LOOP
+ INSERT INTO "postingGroupPurchasing" (
+ "supplierTypeId",
+ "partGroupId",
+ "purchaseAccount",
+ "purchaseDiscountAccount",
+ "purchaseCreditAccount",
+ "purchasePrepaymentAccount",
+ "purchaseTaxPayableAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ rec."id",
+ account_defaults."purchaseAccount",
+ account_defaults."purchaseAccount",
+ account_defaults."purchaseAccount",
+ account_defaults."prepaymentAccount",
+ account_defaults."purchaseTaxPayableAccount",
+ new."createdBy"
+ );
+ END LOOP;
+
+ -- insert the null part group
+ INSERT INTO "postingGroupPurchasing" (
+ "supplierTypeId",
+ "partGroupId",
+ "purchaseAccount",
+ "purchaseDiscountAccount",
+ "purchaseCreditAccount",
+ "purchasePrepaymentAccount",
+ "purchaseTaxPayableAccount",
+ "updatedBy"
+ ) VALUES (
+ new."id",
+ NULL,
+ account_defaults."purchaseAccount",
+ account_defaults."purchaseAccount",
+ account_defaults."purchaseAccount",
+ account_defaults."prepaymentAccount",
+ account_defaults."purchaseTaxPayableAccount",
+ new."createdBy"
+ );
+
+ RETURN new;
+END;
+$$ LANGUAGE plpgsql SECURITY DEFINER;
+
+CREATE TRIGGER create_posting_groups_for_supplier_type
+ AFTER INSERT on public."supplierType"
+ FOR EACH ROW EXECUTE PROCEDURE public.create_posting_groups_for_supplier_type();
diff --git a/packages/carbon-database/supabase/seed.sql b/packages/carbon-database/supabase/seed.sql
index e69de29bb2..3afeb91b58 100644
--- a/packages/carbon-database/supabase/seed.sql
+++ b/packages/carbon-database/supabase/seed.sql
@@ -0,0 +1,307 @@
+-- users
+
+INSERT INTO "user" ("id", "email", "firstName", "lastName")
+VALUES ('system', '[email protected]', 'System', 'Operation');
+
+-- currencies
+
+INSERT INTO "currency" ("name", "code", "symbol", "exchangeRate", "isBaseCurrency", "createdBy")
+VALUES ('US Dollar', 'USD', '$', 1.0000, true, 'system');
+
+-- attribute types
+
+
+INSERT INTO "attributeDataType" ("label", "isBoolean", "isDate", "isList", "isNumeric", "isText", "isUser")
+VALUES
+ ('Yes/No', true, false, false, false, false, false),
+ ('Date', false, true, false, false, false, false),
+ ('List', false, false, true, false, false, false),
+ ('Numeric', false, false, false, true, false, false),
+ ('Text', false, false, false, false, true, false),
+ ('User', false, false, false, false, false, true);
+
+
+-- supplier status
+
+INSERT INTO "supplierStatus" ("name") VALUES ('Active'), ('Inactive'), ('Pending'), ('Rejected');
+
+-- customer status
+
+INSERT INTO "customerStatus" ("name") VALUES ('Active'), ('Inactive'), ('Prospect'), ('Lead'), ('On Hold'), ('Cancelled'), ('Archived');
+
+-- unit of measure
+
+INSERT INTO "unitOfMeasure" ("code", "name", "createdBy")
+VALUES
+( 'EA', 'Each', 'system'),
+( 'PCS', 'Pieces', 'system');
+
+-- payment terms
+
+INSERT INTO "paymentTerm" ("name", "daysDue", "calculationMethod", "daysDiscount", "discountPercentage", "createdBy")
+VALUES
+ ('Net 15', 15, 'Net', 0, 0, 'system'),
+ ('Net 30', 30, 'Net', 0, 0, 'system'),
+ ('Net 50', 50, 'Net', 0, 0, 'system'),
+ ('Net 60', 60, 'Net', 0, 0, 'system'),
+ ('Net 90', 90, 'Net', 0, 0, 'system'),
+ ('1% 10 Net 30', 30, 'Net', 10, 1, 'system'),
+ ('2% 10 Net 30', 30, 'Net', 10, 2, 'system'),
+ ('Due on Receipt', 0, 'Net', 0, 0, 'system'),
+ ('Net EOM 10', 10, 'End of Month', 0, 0, 'system');
+
+-- sequences
+
+INSERT INTO "sequence" ("table", "name", "prefix", "suffix", "next", "size", "step")
+VALUES
+ ('purchaseOrder', 'Purchase Order', 'PO', NULL, 0, 6, 1),
+ ('receipt', 'Receipt', 'RE', NULL, 0, 6, 1);
+
+-- account categories
+
+INSERT INTO public."accountCategory" (id, category, "incomeBalance", "normalBalance", "createdBy")
+VALUES
+ ('cjgo71si60lg1aoj5p40', 'Bank', 'Balance Sheet', 'Credit', 'system'),
+ ('cjgo71si60lg1aoj5p4g', 'Accounts Receivable', 'Balance Sheet', 'Credit', 'system'),
+ ('cjgo71si60lg1aoj5p50', 'Inventory', 'Balance Sheet', 'Debit', 'system'),
+ ('cjgo71si60lg1aoj5p5g', 'Other Current Asset', 'Balance Sheet', 'Debit', 'system'),
+ ('cjgo71si60lg1aoj5p60', 'Fixed Asset', 'Balance Sheet', 'Debit', 'system'),
+ ('cjgo71si60lg1aoj5p6g', 'Accumulated Depreciation', 'Balance Sheet', 'Credit', 'system'),
+ ('cjgo71si60lg1aoj5p70', 'Other Asset', 'Balance Sheet', 'Debit', 'system'),
+ ('cjgo71si60lg1aoj5p7g', 'Accounts Payable', 'Balance Sheet', 'Debit', 'system'),
+ ('cjgo71si60lg1aoj5p80', 'Other Current Liability', 'Balance Sheet', 'Debit', 'system'),
+ ('cjgo71si60lg1aoj5p8g', 'Long Term Liability', 'Balance Sheet', 'Debit', 'system'),
+ ('cjgo71si60lg1aoj5p90', 'Equity - No Close', 'Balance Sheet', 'Credit', 'system'),
+ ('cjgo71si60lg1aoj5p9g', 'Equity - Close', 'Balance Sheet', 'Credit', 'system'),
+ ('cjgo71si60lg1aoj5pa0', 'Retained Earnings', 'Balance Sheet', 'Credit', 'system'),
+ ('cjgo71si60lg1aoj5pag', 'Income', 'Income Statement', 'Credit', 'system'),
+ ('cjgo71si60lg1aoj5pb0', 'Cost of Goods Sold', 'Income Statement', 'Debit', 'system'),
+ ('cjgo71si60lg1aoj5pbg', 'Expense', 'Income Statement', 'Debit', 'system'),
+ ('cjgo71si60lg1aoj5pc0', 'Other Income', 'Income Statement', 'Credit', 'system'),
+ ('cjgo71si60lg1aoj5pcg', 'Other Expense', 'Income Statement', 'Debit', 'system');
+
+-- accounts
+
+INSERT INTO public.account
+ (number, name, type, "accountCategoryId", "accountSubcategoryId", "incomeBalance", "normalBalance", "consolidatedRate", "directPosting", active, "createdBy")
+VALUES
+ ('10000', 'Income Statement', 'Begin Total', 'cjgo71si60lg1aoj5pag', NULL, 'Income Statement', 'Both', 'Average', false, true, 'system'),
+ ('11000', 'Revenue', 'Begin Total', 'cjgo71si60lg1aoj5pag', NULL, 'Income Statement', 'Credit', 'Average', false, true, 'system'),
+ ('11210', 'Sales', 'Posting', 'cjgo71si60lg1aoj5pag', NULL, 'Income Statement', 'Credit', 'Average', true, true, 'system'),
+ ('11600', 'Sales Discounts', 'Posting', 'cjgo71si60lg1aoj5pag', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('19999', 'Revenue, Total', 'End Total', 'cjgo71si60lg1aoj5pag', NULL, 'Income Statement', 'Credit', 'Average', false, true, 'system'),
+ ('20000', 'Costs of Goods Sold', 'Begin Total', 'cjgo71si60lg1aoj5pb0', NULL, 'Income Statement', 'Debit', 'Average', false, true, 'system'),
+ ('21210', 'Cost of Goods Sold', 'Posting', 'cjgo71si60lg1aoj5pb0', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('21410', 'Purchases', 'Posting', 'cjgo71si60lg1aoj5pb0', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('21590', 'Direct Cost Applied', 'Posting', 'cjgo71si60lg1aoj5pb0', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('21600', 'Overhead Applied', 'Posting', 'cjgo71si60lg1aoj5pb0', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('21610', 'Purchase Variance', 'Posting', 'cjgo71si60lg1aoj5pb0', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('21700', 'Inventory Adjustment', 'Posting', 'cjgo71si60lg1aoj5pb0', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('24999', 'Costs of Goods Sold, Total', 'End Total', 'cjgo71si60lg1aoj5pbg', NULL, 'Income Statement', 'Debit', 'Average', false, true, 'system'),
+ ('25000', 'Direct Capacity Cost', 'Begin Total', 'cjgo71si60lg1aoj5pbg', NULL, 'Income Statement', 'Debit', 'Average', false, true, 'system'),
+ ('25705', 'Material Variance', 'Posting', 'cjgo71si60lg1aoj5pbg', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('25710', 'Capacity Variance', 'Posting', 'cjgo71si60lg1aoj5pbg', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('25720', 'Overhead Accounts', 'Posting', 'cjgo71si60lg1aoj5pbg', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('47045', 'Maintenance Expense', 'Posting', 'cjgo71si60lg1aoj5pbg', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('49999', 'Direct Capacity Cost, Total', 'End Total', 'cjgo71si60lg1aoj5pbg', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('50000', 'Depreciation of Fixed Assets', 'Begin Total', 'cjgo71si60lg1aoj5pcg', NULL, 'Income Statement', 'Debit', 'Average', false, true, 'system'),
+ ('50015', 'Depreciation Expense', 'Posting', 'cjgo71si60lg1aoj5pcg', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('50040', 'Gains and Losses on Disposal', 'Posting', 'cjgo71si60lg1aoj5pcg', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('50045', 'Service Charge Account', 'Posting', 'cjgo71si60lg1aoj5pcg', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('50999', 'Depreciation of Fixed Assets, Total', 'End Total', 'cjgo71si60lg1aoj5pcg', NULL, 'Income Statement', 'Debit', 'Average', false, true, 'system'),
+ ('51000', 'Interest', 'Begin Total', 'cjgo71si60lg1aoj5pcg', NULL, 'Income Statement', 'Debit', 'Average', false, true, 'system'),
+ ('51110', 'Interest Account', 'Posting', 'cjgo71si60lg1aoj5pcg', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('51115', 'Supplier Payment Discounts', 'Posting', 'cjgo71si60lg1aoj5pcg', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('51120', 'Customer Payment Discounts', 'Posting', 'cjgo71si60lg1aoj5pcg', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('51235', 'Rounding Account', 'Posting', 'cjgo71si60lg1aoj5pcg', NULL, 'Income Statement', 'Debit', 'Average', true, true, 'system'),
+ ('51999', 'Interest, Total', 'End Total', 'cjgo71si60lg1aoj5pcg', NULL, 'Income Statement', 'Debit', 'Average', false, true, 'system'),
+ ('79999', 'Income Statement, Total', 'End Total', 'cjgo71si60lg1aoj5pag', NULL, 'Income Statement', 'Both', 'Average', true, true, 'system'),
+ ('80000', 'Balance Sheet', 'Begin Total', NULL, NULL, 'Balance Sheet', 'Both', 'Average', false, true, 'system'),
+ ('80001', 'Assets', 'Begin Total', NULL, NULL, 'Balance Sheet', 'Debit', 'Average', false, true, 'system'),
+ ('81000', 'Fixed Assets', 'Begin Total', NULL, NULL, 'Balance Sheet', 'Debit', 'Average', false, true, 'system'),
+ ('81010', 'Fixed Asset Acquisition Cost', 'Posting', 'cjgo71si60lg1aoj5p60', NULL, 'Balance Sheet', 'Debit', 'Average', true, true, 'system'),
+ ('81015', 'Fixed Asset Acquisition Cost on Disposal', 'Posting', 'cjgo71si60lg1aoj5p60', NULL, 'Balance Sheet', 'Debit', 'Average', true, true, 'system'),
+ ('81020', 'Accumulated Depreciation', 'Posting', 'cjgo71si60lg1aoj5p6g', NULL, 'Balance Sheet', 'Credit', 'Average', true, true, 'system'),
+ ('81030', 'Fixed Asset Acquisition Depreciation on Disposal', 'Posting', 'cjgo71si60lg1aoj5p6g', NULL, 'Balance Sheet', 'Credit', 'Average', true, true, 'system'),
+ ('81999', 'Fixed Assets, Total', 'End Total', NULL, NULL, 'Balance Sheet', 'Debit', 'Average', false, true, 'system'),
+ ('83000', 'Current Assets', 'Begin Total', NULL, NULL, 'Balance Sheet', 'Both', 'Average', false, true, 'system'),
+ ('83105', 'Inventory', 'Posting', 'cjgo71si60lg1aoj5p50', NULL, 'Balance Sheet', 'Debit', 'Average', true, true, 'system'),
+ ('83120', 'Inventory Interim', 'Posting', 'cjgo71si60lg1aoj5p50', NULL, 'Balance Sheet', 'Debit', 'Average', true, true, 'system'),
+ ('83125', 'Work In Progress (WIP)', 'Posting', 'cjgo71si60lg1aoj5p50', NULL, 'Balance Sheet', 'Debit', 'Average', true, true, 'system'),
+ ('85005', 'Receivables', 'Posting', 'cjgo71si60lg1aoj5p4g', NULL, 'Balance Sheet', 'Credit', 'Average', true, true, 'system'),
+ ('85010', 'Inventory Shipped Not Invoiced', 'Posting', 'cjgo71si60lg1aoj5p4g', NULL, 'Balance Sheet', 'Credit', 'Average', true, true, 'system'),
+ ('86005', 'Bank - Cash', 'Posting', 'cjgo71si60lg1aoj5p40', NULL, 'Balance Sheet', 'Credit', 'Average', true, true, 'system'),
+ ('86010', 'Bank - Local Currency', 'Posting', 'cjgo71si60lg1aoj5p40', NULL, 'Balance Sheet', 'Credit', 'Average', false, true, 'system'),
+ ('86015', 'Bank - Foreign Currency', 'Posting', 'cjgo71si60lg1aoj5p40', NULL, 'Balance Sheet', 'Credit', 'Average', false, true, 'system'),
+ ('87999', 'Current Assets, Total', 'End Total', NULL, NULL, 'Balance Sheet', 'Both', 'Average', false, true, 'system'),
+ ('89999', 'Assets, Total', 'End Total', NULL, NULL, 'Balance Sheet', 'Debit', 'Average', false, true, 'system'),
+ ('90000', 'Liabilities', 'Begin Total', NULL, NULL, 'Balance Sheet', 'Debit', 'Average', false, true, 'system'),
+ ('92210', 'Prepayments', 'Posting', 'cjgo71si60lg1aoj5p80', NULL, 'Balance Sheet', 'Debit', 'Average', true, true, 'system'),
+ ('93005', 'Payables', 'Posting', 'cjgo71si60lg1aoj5p7g', NULL, 'Balance Sheet', 'Debit', 'Average', true, true, 'system'),
+ ('93010', 'Inventory Received Not Invoiced', 'Posting', 'cjgo71si60lg1aoj5p7g', NULL, 'Balance Sheet', 'Debit', 'Average', true, true, 'system'),
+ ('94100', 'Sales Tax Payable', 'Posting', 'cjgo71si60lg1aoj5p80', NULL, 'Balance Sheet', 'Debit', 'Average', true, true, 'system'),
+ ('94110', 'Purchase Tax Payable', 'Posting', 'cjgo71si60lg1aoj5p80', NULL, 'Balance Sheet', 'Debit', 'Average', true, true, 'system'),
+ ('94115', 'Reverse Charge Tax Payable', 'Posting', 'cjgo71si60lg1aoj5p80', NULL, 'Balance Sheet', 'Debit', 'Average', true, true, 'system'),
+ ('94999', 'Liabilities, Total', 'End Total', NULL, NULL, 'Balance Sheet', 'Debit', 'Average', false, true, 'system'),
+ ('95000', 'Equity', 'Begin Total', NULL, NULL, 'Balance Sheet', 'Debit', 'Average', false, true, 'system'),
+ ('95010', 'Retained Earnings', 'Posting', 'cjgo71si60lg1aoj5pa0', NULL, 'Balance Sheet', 'Credit', 'Average', false, true, 'system'),
+ ('96010', 'Owner Equity', 'Posting', 'cjgo71si60lg1aoj5p90', NULL, 'Balance Sheet', 'Both', 'Average', true, true, 'system'),
+ ('96999', 'Equity, Total', 'End Total', NULL, NULL, 'Balance Sheet', 'Debit', 'Average', false, true, 'system'),
+ ('99999', 'Balance Sheet, Total', 'End Total', NULL, NULL, 'Balance Sheet', 'Both', 'Average', false, true, 'system');
+
+ INSERT INTO public."accountDefault" (
+ "id",
+ "salesAccount",
+ "salesDiscountAccount",
+ "costOfGoodsSoldAccount",
+ "purchaseAccount",
+ "directCostAppliedAccount",
+ "overheadCostAppliedAccount",
+ "purchaseVarianceAccount",
+ "inventoryAdjustmentVarianceAccount",
+ "materialVarianceAccount",
+ "capacityVarianceAccount",
+ "overheadAccount",
+ "maintenanceAccount",
+ "assetDepreciationExpenseAccount",
+ "assetGainsAndLossesAccount",
+ "serviceChargeAccount",
+ "interestAccount",
+ "supplierPaymentDiscountAccount",
+ "customerPaymentDiscountAccount",
+ "roundingAccount",
+ "assetAquisitionCostAccount",
+ "assetAquisitionCostOnDisposalAccount",
+ "accumulatedDepreciationAccount",
+ "accumulatedDepreciationOnDisposalAccount",
+ "inventoryAccount",
+ "inventoryInterimAccrualAccount",
+ "workInProgressAccount",
+ "receivablesAccount",
+ "inventoryShippedNotInvoicedAccount",
+ "bankCashAccount",
+ "bankLocalCurrencyAccount",
+ "bankForeignCurrencyAccount",
+ "prepaymentAccount",
+ "payablesAccount",
+ "inventoryReceivedNotInvoicedAccount",
+ "salesTaxPayableAccount",
+ "purchaseTaxPayableAccount",
+ "reverseChargeSalesTaxPayableAccount",
+ "retainedEarningsAccount",
+ "updatedBy"
+ ) VALUES (
+ true,
+ '11210',
+ '11600',
+ '21210',
+ '21410',
+ '21590',
+ '21600',
+ '21610',
+ '21700',
+ '25705',
+ '25710',
+ '25720',
+ '47045',
+ '50015',
+ '50040',
+ '50045',
+ '51110',
+ '51115',
+ '51120',
+ '51235',
+ '81010',
+ '81015',
+ '81020',
+ '81030',
+ '83105',
+ '83120',
+ '83125',
+ '85005',
+ '85010',
+ '86005',
+ '86010',
+ '86015',
+ '92210',
+ '93005',
+ '93010',
+ '94100',
+ '94110',
+ '94115',
+ '95010',
+ 'system'
+ );
+
+
+INSERT INTO "postingGroupInventory" (
+ "partGroupId",
+ "costOfGoodsSoldAccount",
+ "inventoryAccount",
+ "inventoryInterimAccrualAccount",
+ "inventoryReceivedNotInvoicedAccount",
+ "inventoryShippedNotInvoicedAccount",
+ "workInProgressAccount",
+ "directCostAppliedAccount",
+ "overheadCostAppliedAccount",
+ "purchaseVarianceAccount",
+ "inventoryAdjustmentVarianceAccount",
+ "materialVarianceAccount",
+ "capacityVarianceAccount",
+ "overheadAccount"
+) SELECT
+ NULL,
+ "costOfGoodsSoldAccount",
+ "inventoryAccount",
+ "inventoryInterimAccrualAccount",
+ "inventoryReceivedNotInvoicedAccount",
+ "inventoryShippedNotInvoicedAccount",
+ "workInProgressAccount",
+ "directCostAppliedAccount",
+ "overheadCostAppliedAccount",
+ "purchaseVarianceAccount",
+ "inventoryAdjustmentVarianceAccount",
+ "materialVarianceAccount",
+ "capacityVarianceAccount",
+ "overheadAccount"
+FROM "accountDefault" WHERE "id" = true;
+
+INSERT INTO "postingGroupPurchasing" (
+ "partGroupId",
+ "supplierTypeId",
+ "purchaseAccount",
+ "purchaseDiscountAccount",
+ "purchaseCreditAccount",
+ "purchasePrepaymentAccount",
+ "purchaseTaxPayableAccount",
+ "updatedBy"
+) SELECT
+ NULL,
+ NULL,
+ "purchaseAccount",
+ "purchaseAccount",
+ "purchaseAccount",
+ "prepaymentAccount",
+ "purchaseTaxPayableAccount",
+ 'system'
+FROM "accountDefault" WHERE "id" = true;
+
+INSERT INTO "postingGroupSales" (
+ "partGroupId",
+ "customerTypeId",
+ "salesAccount",
+ "salesDiscountAccount",
+ "salesCreditAccount",
+ "salesPrepaymentAccount",
+ "salesTaxPayableAccount",
+ "updatedBy"
+) SELECT
+ NULL,
+ NULL,
+ "salesAccount",
+ "salesDiscountAccount",
+ "salesAccount",
+ "prepaymentAccount",
+ "salesTaxPayableAccount",
+ 'system'
+FROM "accountDefault" WHERE "id" = true;
\ No newline at end of file
diff --git a/packages/carbon-react/src/DataTable/DataTable.tsx b/packages/carbon-react/src/DataTable/DataTable.tsx
index 899bd66b49..edfa694128 100644
--- a/packages/carbon-react/src/DataTable/DataTable.tsx
+++ b/packages/carbon-react/src/DataTable/DataTable.tsx
@@ -33,11 +33,13 @@ import { DataTablePagination } from "./DataTablePagination";
interface DataTableProps<TData, TValue> {
columns: ColumnDef<TData, TValue>[];
data: TData[];
+ defaultPageSize?: number;
}
const DataTable = <TData, TValue>({
columns,
data,
+ defaultPageSize = 25,
}: DataTableProps<TData, TValue>) => {
const [rowSelection, setRowSelection] = useState({});
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({});
@@ -55,7 +57,7 @@ const DataTable = <TData, TValue>({
},
initialState: {
pagination: {
- pageSize: 25,
+ pageSize: defaultPageSize,
},
},
enableRowSelection: true,