IO-1950 Parts Order Discounts
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<babeledit_project be_version="2.7.1" version="1.2">
|
<babeledit_project version="1.2" be_version="2.7.1">
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
BabelEdit project file
|
BabelEdit project file
|
||||||
@@ -34350,6 +34350,48 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</translations>
|
</translations>
|
||||||
</concept_node>
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>custompercent</name>
|
||||||
|
<definition_loaded>false</definition_loaded>
|
||||||
|
<description></description>
|
||||||
|
<comment></comment>
|
||||||
|
<default_text></default_text>
|
||||||
|
<translations>
|
||||||
|
<translation>
|
||||||
|
<language>en-US</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>es-MX</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>fr-CA</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
</translations>
|
||||||
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>discount</name>
|
||||||
|
<definition_loaded>false</definition_loaded>
|
||||||
|
<description></description>
|
||||||
|
<comment></comment>
|
||||||
|
<default_text></default_text>
|
||||||
|
<translations>
|
||||||
|
<translation>
|
||||||
|
<language>en-US</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>es-MX</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>fr-CA</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
</translations>
|
||||||
|
</concept_node>
|
||||||
<concept_node>
|
<concept_node>
|
||||||
<name>email</name>
|
<name>email</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
import { DownOutlined } from "@ant-design/icons";
|
||||||
|
import { Dropdown, InputNumber, Menu, Space } from "antd";
|
||||||
|
import React from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
export default function PartsOrderModalPriceChange({ form, field }) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const menu = (
|
||||||
|
<Menu
|
||||||
|
onClick={({ key }) => {
|
||||||
|
if (key === "custom") return;
|
||||||
|
const values = form.getFieldsValue();
|
||||||
|
|
||||||
|
const { parts_order_lines } = values;
|
||||||
|
|
||||||
|
form.setFieldsValue({
|
||||||
|
parts_order_lines: {
|
||||||
|
data: parts_order_lines.data.map((p, idx) => {
|
||||||
|
if (idx !== field.name) return p;
|
||||||
|
return {
|
||||||
|
...p,
|
||||||
|
act_price: (p.act_price || 0) * ((100 - key) / 100),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
items={[
|
||||||
|
{
|
||||||
|
key: "5",
|
||||||
|
label: t("parts_orders.labels.discount", { percent: "5%" }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "10",
|
||||||
|
label: t("parts_orders.labels.discount", { percent: "10%" }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "15",
|
||||||
|
label: t("parts_orders.labels.discount", { percent: "15%" }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "20",
|
||||||
|
label: t("parts_orders.labels.discount", { percent: "20%" }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "25",
|
||||||
|
label: t("parts_orders.labels.discount", { percent: "25%" }),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "custom",
|
||||||
|
label: (
|
||||||
|
<InputNumber
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
addonAfter="%"
|
||||||
|
onKeyUp={(e) => {
|
||||||
|
if (e.key === "Enter") {
|
||||||
|
const values = form.getFieldsValue();
|
||||||
|
const { parts_order_lines } = values;
|
||||||
|
|
||||||
|
form.setFieldsValue({
|
||||||
|
parts_order_lines: {
|
||||||
|
data: parts_order_lines.data.map((p, idx) => {
|
||||||
|
if (idx !== field.name) return p;
|
||||||
|
console.log(
|
||||||
|
p,
|
||||||
|
e.target.value,
|
||||||
|
(p.act_price || 0) *
|
||||||
|
((100 - (e.target.value || 0)) / 100)
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
...p,
|
||||||
|
act_price:
|
||||||
|
(p.act_price || 0) *
|
||||||
|
((100 - (e.target.value || 0)) / 100),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
e.target.value = 0;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
min={0}
|
||||||
|
max={100}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<Dropdown overlay={menu} trigger="click">
|
||||||
|
<Space>
|
||||||
|
%
|
||||||
|
<DownOutlined />
|
||||||
|
</Space>
|
||||||
|
</Dropdown>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -23,6 +23,7 @@ import CurrencyInput from "../form-items-formatted/currency-form-item.component"
|
|||||||
import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component";
|
import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component";
|
||||||
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||||
import VendorSearchSelect from "../vendor-search-select/vendor-search-select.component";
|
import VendorSearchSelect from "../vendor-search-select/vendor-search-select.component";
|
||||||
|
import PartsOrderModalPriceChange from "./parts-order-modal-price-change.component";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
@@ -246,7 +247,14 @@ export function PartsOrderModalComponent({
|
|||||||
key={`${index}act_price`}
|
key={`${index}act_price`}
|
||||||
name={[field.name, "act_price"]}
|
name={[field.name, "act_price"]}
|
||||||
>
|
>
|
||||||
<CurrencyInput />
|
<CurrencyInput
|
||||||
|
addonBefore={
|
||||||
|
<PartsOrderModalPriceChange
|
||||||
|
form={form}
|
||||||
|
field={field}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
{isReturn && (
|
{isReturn && (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
|
|||||||
@@ -2033,6 +2033,8 @@
|
|||||||
"labels": {
|
"labels": {
|
||||||
"allpartsto": "All Parts Location",
|
"allpartsto": "All Parts Location",
|
||||||
"confirmdelete": "Are you sure you want to delete this item? It cannot be recovered. Job line statuses will not be updated and may require manual review. ",
|
"confirmdelete": "Are you sure you want to delete this item? It cannot be recovered. Job line statuses will not be updated and may require manual review. ",
|
||||||
|
"custompercent": "Custom %",
|
||||||
|
"discount": "Discount {{percent}}",
|
||||||
"email": "Send by Email",
|
"email": "Send by Email",
|
||||||
"inthisorder": "Parts in this Order",
|
"inthisorder": "Parts in this Order",
|
||||||
"is_quote": "Parts Quote?",
|
"is_quote": "Parts Quote?",
|
||||||
|
|||||||
@@ -2033,6 +2033,8 @@
|
|||||||
"labels": {
|
"labels": {
|
||||||
"allpartsto": "",
|
"allpartsto": "",
|
||||||
"confirmdelete": "",
|
"confirmdelete": "",
|
||||||
|
"custompercent": "",
|
||||||
|
"discount": "",
|
||||||
"email": "Enviar por correo electrónico",
|
"email": "Enviar por correo electrónico",
|
||||||
"inthisorder": "Partes en este pedido",
|
"inthisorder": "Partes en este pedido",
|
||||||
"is_quote": "",
|
"is_quote": "",
|
||||||
|
|||||||
@@ -2033,6 +2033,8 @@
|
|||||||
"labels": {
|
"labels": {
|
||||||
"allpartsto": "",
|
"allpartsto": "",
|
||||||
"confirmdelete": "",
|
"confirmdelete": "",
|
||||||
|
"custompercent": "",
|
||||||
|
"discount": "",
|
||||||
"email": "Envoyé par email",
|
"email": "Envoyé par email",
|
||||||
"inthisorder": "Pièces dans cette commande",
|
"inthisorder": "Pièces dans cette commande",
|
||||||
"is_quote": "",
|
"is_quote": "",
|
||||||
|
|||||||
Reference in New Issue
Block a user