Skip to content

Commit

Permalink
show total stock
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardarhia committed Aug 23, 2024
1 parent 80033d7 commit 719c049
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/interfaces/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ export interface ProductProps extends DefaultPluginProps {
productQuantity?: ProductQuantityProps;
productUnit?: ProductUnitProps;
productCode?: ProductCodeProps;
totalProductPrice?: number;
}
43 changes: 41 additions & 2 deletions src/tableSchema/products.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ProductProps, ProductStatus } from "@/interfaces/products";
import TableStatus from "@/components/TableStatus";
import { Calendar, Currency, Settings2 } from "lucide-react";
import { DataFilterProps } from "@/components/table/type";
import { formatCurrency } from "@/helpers";

export const PRODUCT_STATUS_OPTIONS = [
{
Expand Down Expand Up @@ -114,7 +115,16 @@ export const productTableSchema: ColumnDef<ProductProps>[] = [
header: ({ column }) => <DataTableColumnHeader column={column} title="Unit Price" />,
cell: ({ row }) => {
const value: number = row.getValue("productUnitPrice");
return <div className="flex space-x-2">&#8373;{value.toFixed(2)}</div>;
return (
<div className="flex space-x-2">
&#8373;
{formatCurrency({
value,
currencyDisplay: "symbol",
showCurrencySign: false
})}
</div>
);
},
filterFn: (row, id, value) => {
return value.includes(row.getValue(id));
Expand All @@ -125,7 +135,36 @@ export const productTableSchema: ColumnDef<ProductProps>[] = [
header: ({ column }) => <DataTableColumnHeader column={column} title="Selling Price" />,
cell: ({ row }) => {
const value: number = row.getValue("productSellingPrice");
return <div className="flex space-x-2">&#8373;{value.toFixed(2)}</div>;
return (
<div className="flex space-x-2">
&#8373;
{formatCurrency({
value,
currencyDisplay: "symbol",
showCurrencySign: false
})}
</div>
);
},
filterFn: (row, id, value) => {
return value.includes(row.getValue(id));
}
},
{
accessorKey: "totalProductPrice",
header: ({ column }) => <DataTableColumnHeader column={column} title="Total Stock Amount" />,
cell: ({ row }) => {
const value: number = row.getValue("totalProductPrice");
return (
<div className="flex space-x-2">
&#8373;
{formatCurrency({
value,
currencyDisplay: "symbol",
showCurrencySign: false
})}
</div>
);
},
filterFn: (row, id, value) => {
return value.includes(row.getValue(id));
Expand Down

0 comments on commit 719c049

Please sign in to comment.