IO-1672 Updated bill line discount display.
This commit is contained in:
@@ -245,7 +245,7 @@ function BillEnterModalContainer({
|
||||
return (
|
||||
<Modal
|
||||
title={t("bills.labels.new")}
|
||||
width={"90%"}
|
||||
width={"98%"}
|
||||
visible={billEnterModal.visible}
|
||||
okText={t("general.actions.save")}
|
||||
keyboard="false"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DeleteFilled, WarningOutlined } from "@ant-design/icons";
|
||||
import { DeleteFilled, DollarCircleFilled } from "@ant-design/icons";
|
||||
import {
|
||||
Button,
|
||||
Form,
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
Space,
|
||||
Switch,
|
||||
Table,
|
||||
Tooltip,
|
||||
} from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@@ -201,23 +202,56 @@ export function BillEnterModalLinesComponent({
|
||||
};
|
||||
},
|
||||
formInput: (record, index) => (
|
||||
<CurrencyInput min={0} disabled={disabled} />
|
||||
),
|
||||
additional: (record, index) => (
|
||||
<Form.Item shouldUpdate>
|
||||
{() => {
|
||||
const line = getFieldsValue(["billlines"]).billlines[index];
|
||||
if (!!!line) return null;
|
||||
const lineDiscount = (
|
||||
1 -
|
||||
Math.round((line.actual_cost / line.actual_price) * 100) / 100
|
||||
).toPrecision(2);
|
||||
<CurrencyInput
|
||||
min={0}
|
||||
disabled={disabled}
|
||||
controls={false}
|
||||
addonAfter={
|
||||
<Form.Item shouldUpdate noStyle>
|
||||
{() => {
|
||||
const line = getFieldsValue(["billlines"]).billlines[index];
|
||||
if (!!!line) return null;
|
||||
const lineDiscount = 1 - line.actual_cost / line.actual_price;
|
||||
|
||||
if (lineDiscount - discount === 0) return <div />;
|
||||
return <WarningOutlined style={{ color: "red" }} />;
|
||||
}}
|
||||
</Form.Item>
|
||||
return (
|
||||
<Tooltip title={`${(lineDiscount * 100).toFixed(2) || 0}%`}>
|
||||
<DollarCircleFilled
|
||||
style={{
|
||||
color:
|
||||
Math.abs(lineDiscount - discount) > 0.005
|
||||
? "red"
|
||||
: "green",
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
);
|
||||
}}
|
||||
</Form.Item>
|
||||
}
|
||||
/>
|
||||
),
|
||||
// additional: (record, index) => (
|
||||
// <Form.Item shouldUpdate>
|
||||
// {() => {
|
||||
// const line = getFieldsValue(["billlines"]).billlines[index];
|
||||
// if (!!!line) return null;
|
||||
// const lineDiscount = (
|
||||
// 1 -
|
||||
// Math.round((line.actual_cost / line.actual_price) * 100) / 100
|
||||
// ).toPrecision(2);
|
||||
|
||||
// return (
|
||||
// <Tooltip title={`${(lineDiscount * 100).toFixed(0) || 0}%`}>
|
||||
// <DollarCircleFilled
|
||||
// style={{
|
||||
// color: lineDiscount - discount !== 0 ? "red" : "green",
|
||||
// }}
|
||||
// />
|
||||
// </Tooltip>
|
||||
// );
|
||||
// }}
|
||||
// </Form.Item>
|
||||
// ),
|
||||
},
|
||||
{
|
||||
title: t("billlines.fields.cost_center"),
|
||||
|
||||
Reference in New Issue
Block a user