mirror of
https://github.com/inventree/InvenTree.git
synced 2026-07-21 22:23:03 +00:00
Add frontend support
This commit is contained in:
@@ -461,6 +461,22 @@ export function DecimalColumn(props: TableColumn): TableColumn {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function PercentageColumn(props: TableColumn): TableColumn {
|
||||||
|
return {
|
||||||
|
sortable: true,
|
||||||
|
render: (record: any) => {
|
||||||
|
const value = resolveItem(record, props.accessor ?? '');
|
||||||
|
|
||||||
|
if (value == null || value === 0) {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${formatDecimal(value)}%`;
|
||||||
|
},
|
||||||
|
...props
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function DescriptionColumn(props: TableColumnProps): TableColumn {
|
export function DescriptionColumn(props: TableColumnProps): TableColumn {
|
||||||
return {
|
return {
|
||||||
accessor: 'description',
|
accessor: 'description',
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ export function extraLineItemFields(): ApiFormFieldSet {
|
|||||||
quantity: {},
|
quantity: {},
|
||||||
price: {},
|
price: {},
|
||||||
price_currency: {},
|
price_currency: {},
|
||||||
|
discount: {},
|
||||||
project_code: ProjectCodeField(),
|
project_code: ProjectCodeField(),
|
||||||
notes: {},
|
notes: {},
|
||||||
link: {}
|
link: {}
|
||||||
|
|||||||
@@ -186,6 +186,7 @@ export function usePurchaseOrderLineItemFields({
|
|||||||
value: purchasePriceCurrency,
|
value: purchasePriceCurrency,
|
||||||
onValueChange: setPurchasePriceCurrency
|
onValueChange: setPurchasePriceCurrency
|
||||||
},
|
},
|
||||||
|
discount: {},
|
||||||
auto_pricing: {
|
auto_pricing: {
|
||||||
default: create !== false,
|
default: create !== false,
|
||||||
value: autoPricing,
|
value: autoPricing,
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ export function useReturnOrderLineItemFields({
|
|||||||
},
|
},
|
||||||
price: {},
|
price: {},
|
||||||
price_currency: {},
|
price_currency: {},
|
||||||
|
discount: {},
|
||||||
project_code: ProjectCodeField(),
|
project_code: ProjectCodeField(),
|
||||||
target_date: {},
|
target_date: {},
|
||||||
notes: {},
|
notes: {},
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ export function useSalesOrderLineItemFields({
|
|||||||
value: partCurrency,
|
value: partCurrency,
|
||||||
onValueChange: setPartCurrency
|
onValueChange: setPartCurrency
|
||||||
},
|
},
|
||||||
|
discount: {},
|
||||||
project_code: ProjectCodeField(),
|
project_code: ProjectCodeField(),
|
||||||
target_date: {},
|
target_date: {},
|
||||||
notes: {},
|
notes: {},
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
LineItemColumn,
|
LineItemColumn,
|
||||||
LinkColumn,
|
LinkColumn,
|
||||||
NoteColumn,
|
NoteColumn,
|
||||||
|
PercentageColumn,
|
||||||
ProjectCodeColumn
|
ProjectCodeColumn
|
||||||
} from '../../components/tables/ColumnRenderers';
|
} from '../../components/tables/ColumnRenderers';
|
||||||
import { InvenTreeTable } from '../../components/tables/InvenTreeTable';
|
import { InvenTreeTable } from '../../components/tables/InvenTreeTable';
|
||||||
@@ -69,13 +70,17 @@ export default function ExtraLineItemTable({
|
|||||||
currency: record.price_currency
|
currency: record.price_currency
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
PercentageColumn({
|
||||||
|
accessor: 'discount',
|
||||||
|
title: t`Discount`,
|
||||||
|
defaultVisible: false
|
||||||
|
}),
|
||||||
{
|
{
|
||||||
accessor: 'total_price',
|
accessor: 'total_price',
|
||||||
title: t`Total Price`,
|
title: t`Total Price`,
|
||||||
render: (record: any) =>
|
render: (record: any) =>
|
||||||
formatCurrency(record.price, {
|
formatCurrency(record.total_price, {
|
||||||
currency: record.price_currency,
|
currency: record.price_currency
|
||||||
multiplier: record.quantity
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
ProjectCodeColumn({}),
|
ProjectCodeColumn({}),
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import {
|
|||||||
LocationColumn,
|
LocationColumn,
|
||||||
NoteColumn,
|
NoteColumn,
|
||||||
PartColumn,
|
PartColumn,
|
||||||
|
PercentageColumn,
|
||||||
ProjectCodeColumn,
|
ProjectCodeColumn,
|
||||||
ReferenceColumn,
|
ReferenceColumn,
|
||||||
TargetDateColumn
|
TargetDateColumn
|
||||||
@@ -254,13 +255,17 @@ export function PurchaseOrderLineItemTable({
|
|||||||
accessor: 'purchase_price',
|
accessor: 'purchase_price',
|
||||||
title: t`Unit Price`
|
title: t`Unit Price`
|
||||||
}),
|
}),
|
||||||
|
PercentageColumn({
|
||||||
|
accessor: 'discount',
|
||||||
|
title: t`Discount`,
|
||||||
|
defaultVisible: false
|
||||||
|
}),
|
||||||
{
|
{
|
||||||
accessor: 'total_price',
|
accessor: 'total_price',
|
||||||
title: t`Total Price`,
|
title: t`Total Price`,
|
||||||
render: (record: any) =>
|
render: (record: any) =>
|
||||||
formatCurrency(record.purchase_price, {
|
formatCurrency(record.total_price, {
|
||||||
currency: record.purchase_price_currency,
|
currency: record.purchase_price_currency
|
||||||
multiplier: record.quantity
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
TargetDateColumn({}),
|
TargetDateColumn({}),
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import {
|
|||||||
LinkColumn,
|
LinkColumn,
|
||||||
NoteColumn,
|
NoteColumn,
|
||||||
PartColumn,
|
PartColumn,
|
||||||
|
PercentageColumn,
|
||||||
ProjectCodeColumn,
|
ProjectCodeColumn,
|
||||||
ReferenceColumn,
|
ReferenceColumn,
|
||||||
StatusColumn,
|
StatusColumn,
|
||||||
@@ -148,6 +149,11 @@ export default function ReturnOrderLineItemTable({
|
|||||||
render: (record: any) =>
|
render: (record: any) =>
|
||||||
formatCurrency(record.price, { currency: record.price_currency })
|
formatCurrency(record.price, { currency: record.price_currency })
|
||||||
},
|
},
|
||||||
|
PercentageColumn({
|
||||||
|
accessor: 'discount',
|
||||||
|
title: t`Discount`,
|
||||||
|
defaultVisible: false
|
||||||
|
}),
|
||||||
DateColumn({
|
DateColumn({
|
||||||
accessor: 'target_date',
|
accessor: 'target_date',
|
||||||
title: t`Target Date`
|
title: t`Target Date`
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import {
|
|||||||
IPNColumn,
|
IPNColumn,
|
||||||
LineItemColumn,
|
LineItemColumn,
|
||||||
LinkColumn,
|
LinkColumn,
|
||||||
|
PercentageColumn,
|
||||||
ProjectCodeColumn,
|
ProjectCodeColumn,
|
||||||
ReferenceColumn,
|
ReferenceColumn,
|
||||||
RenderPartColumn
|
RenderPartColumn
|
||||||
@@ -119,13 +120,18 @@ export default function SalesOrderLineItemTable({
|
|||||||
currency: record.sale_price_currency
|
currency: record.sale_price_currency
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
PercentageColumn({
|
||||||
|
accessor: 'discount',
|
||||||
|
title: t`Discount`,
|
||||||
|
defaultVisible: false
|
||||||
|
}),
|
||||||
{
|
{
|
||||||
accessor: 'total_price',
|
accessor: 'total_price',
|
||||||
title: t`Total Price`,
|
title: t`Total Price`,
|
||||||
render: (record: any) =>
|
render: (record: any) =>
|
||||||
formatCurrency(record.sale_price, {
|
formatCurrency(record.sale_price, {
|
||||||
currency: record.sale_price_currency,
|
currency: record.sale_price_currency,
|
||||||
multiplier: record.quantity
|
multiplier: record.quantity * (1 - (record.discount ?? 0) / 100)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
DateColumn({
|
DateColumn({
|
||||||
|
|||||||
Reference in New Issue
Block a user