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 {
|
||||
return {
|
||||
accessor: 'description',
|
||||
|
||||
@@ -91,6 +91,7 @@ export function extraLineItemFields(): ApiFormFieldSet {
|
||||
quantity: {},
|
||||
price: {},
|
||||
price_currency: {},
|
||||
discount: {},
|
||||
project_code: ProjectCodeField(),
|
||||
notes: {},
|
||||
link: {}
|
||||
|
||||
@@ -186,6 +186,7 @@ export function usePurchaseOrderLineItemFields({
|
||||
value: purchasePriceCurrency,
|
||||
onValueChange: setPurchasePriceCurrency
|
||||
},
|
||||
discount: {},
|
||||
auto_pricing: {
|
||||
default: create !== false,
|
||||
value: autoPricing,
|
||||
|
||||
@@ -133,6 +133,7 @@ export function useReturnOrderLineItemFields({
|
||||
},
|
||||
price: {},
|
||||
price_currency: {},
|
||||
discount: {},
|
||||
project_code: ProjectCodeField(),
|
||||
target_date: {},
|
||||
notes: {},
|
||||
|
||||
@@ -197,6 +197,7 @@ export function useSalesOrderLineItemFields({
|
||||
value: partCurrency,
|
||||
onValueChange: setPartCurrency
|
||||
},
|
||||
discount: {},
|
||||
project_code: ProjectCodeField(),
|
||||
target_date: {},
|
||||
notes: {},
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
LineItemColumn,
|
||||
LinkColumn,
|
||||
NoteColumn,
|
||||
PercentageColumn,
|
||||
ProjectCodeColumn
|
||||
} from '../../components/tables/ColumnRenderers';
|
||||
import { InvenTreeTable } from '../../components/tables/InvenTreeTable';
|
||||
@@ -69,13 +70,17 @@ export default function ExtraLineItemTable({
|
||||
currency: record.price_currency
|
||||
})
|
||||
},
|
||||
PercentageColumn({
|
||||
accessor: 'discount',
|
||||
title: t`Discount`,
|
||||
defaultVisible: false
|
||||
}),
|
||||
{
|
||||
accessor: 'total_price',
|
||||
title: t`Total Price`,
|
||||
render: (record: any) =>
|
||||
formatCurrency(record.price, {
|
||||
currency: record.price_currency,
|
||||
multiplier: record.quantity
|
||||
formatCurrency(record.total_price, {
|
||||
currency: record.price_currency
|
||||
})
|
||||
},
|
||||
ProjectCodeColumn({}),
|
||||
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
LocationColumn,
|
||||
NoteColumn,
|
||||
PartColumn,
|
||||
PercentageColumn,
|
||||
ProjectCodeColumn,
|
||||
ReferenceColumn,
|
||||
TargetDateColumn
|
||||
@@ -254,13 +255,17 @@ export function PurchaseOrderLineItemTable({
|
||||
accessor: 'purchase_price',
|
||||
title: t`Unit Price`
|
||||
}),
|
||||
PercentageColumn({
|
||||
accessor: 'discount',
|
||||
title: t`Discount`,
|
||||
defaultVisible: false
|
||||
}),
|
||||
{
|
||||
accessor: 'total_price',
|
||||
title: t`Total Price`,
|
||||
render: (record: any) =>
|
||||
formatCurrency(record.purchase_price, {
|
||||
currency: record.purchase_price_currency,
|
||||
multiplier: record.quantity
|
||||
formatCurrency(record.total_price, {
|
||||
currency: record.purchase_price_currency
|
||||
})
|
||||
},
|
||||
TargetDateColumn({}),
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
LinkColumn,
|
||||
NoteColumn,
|
||||
PartColumn,
|
||||
PercentageColumn,
|
||||
ProjectCodeColumn,
|
||||
ReferenceColumn,
|
||||
StatusColumn,
|
||||
@@ -148,6 +149,11 @@ export default function ReturnOrderLineItemTable({
|
||||
render: (record: any) =>
|
||||
formatCurrency(record.price, { currency: record.price_currency })
|
||||
},
|
||||
PercentageColumn({
|
||||
accessor: 'discount',
|
||||
title: t`Discount`,
|
||||
defaultVisible: false
|
||||
}),
|
||||
DateColumn({
|
||||
accessor: 'target_date',
|
||||
title: t`Target Date`
|
||||
|
||||
@@ -36,6 +36,7 @@ import {
|
||||
IPNColumn,
|
||||
LineItemColumn,
|
||||
LinkColumn,
|
||||
PercentageColumn,
|
||||
ProjectCodeColumn,
|
||||
ReferenceColumn,
|
||||
RenderPartColumn
|
||||
@@ -119,13 +120,18 @@ export default function SalesOrderLineItemTable({
|
||||
currency: record.sale_price_currency
|
||||
})
|
||||
},
|
||||
PercentageColumn({
|
||||
accessor: 'discount',
|
||||
title: t`Discount`,
|
||||
defaultVisible: false
|
||||
}),
|
||||
{
|
||||
accessor: 'total_price',
|
||||
title: t`Total Price`,
|
||||
render: (record: any) =>
|
||||
formatCurrency(record.sale_price, {
|
||||
currency: record.sale_price_currency,
|
||||
multiplier: record.quantity
|
||||
multiplier: record.quantity * (1 - (record.discount ?? 0) / 100)
|
||||
})
|
||||
},
|
||||
DateColumn({
|
||||
|
||||
Reference in New Issue
Block a user