Breaking Changes as a part of BOD-63 on invoice enter. WIP for all invoices screen editing + lookup.
This commit is contained in:
@@ -9,7 +9,7 @@ export default function InvoiceEnterModalLinesComponent({
|
||||
lineData,
|
||||
discount,
|
||||
form,
|
||||
responsibilityCenters
|
||||
responsibilityCenters,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const { setFieldsValue, getFieldsValue } = form;
|
||||
@@ -25,14 +25,15 @@ export default function InvoiceEnterModalLinesComponent({
|
||||
acc + (value && value.actual_cost ? value.actual_cost : 0),
|
||||
0
|
||||
)
|
||||
: 0
|
||||
: 0,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Form.List name="invoicelines" >
|
||||
<Form.List name="invoicelines">
|
||||
{(fields, { add, remove }) => {
|
||||
console.log("fields", fields);
|
||||
return (
|
||||
<div>
|
||||
{fields.map((field, index) => (
|
||||
@@ -44,8 +45,8 @@ export default function InvoiceEnterModalLinesComponent({
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required")
|
||||
}
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Select
|
||||
@@ -55,7 +56,7 @@ export default function InvoiceEnterModalLinesComponent({
|
||||
onSelect={(value, opt) => {
|
||||
setFieldsValue({
|
||||
invoicelines: getFieldsValue([
|
||||
"invoicelines"
|
||||
"invoicelines",
|
||||
]).invoicelines.map((item, idx) => {
|
||||
if (idx === index) {
|
||||
return {
|
||||
@@ -71,11 +72,11 @@ export default function InvoiceEnterModalLinesComponent({
|
||||
? responsibilityCenters.defaults[
|
||||
opt.part_type
|
||||
] || null
|
||||
: null
|
||||
: null,
|
||||
};
|
||||
}
|
||||
return item;
|
||||
})
|
||||
}),
|
||||
});
|
||||
}}
|
||||
showSearch
|
||||
@@ -88,7 +89,7 @@ export default function InvoiceEnterModalLinesComponent({
|
||||
{t("invoicelines.labels.other")}
|
||||
</Select.Option>
|
||||
{lineData
|
||||
? lineData.map(item => (
|
||||
? lineData.map((item) => (
|
||||
<Select.Option
|
||||
key={item.id}
|
||||
value={item.line_desc}
|
||||
@@ -103,7 +104,7 @@ export default function InvoiceEnterModalLinesComponent({
|
||||
<Col span={4}>
|
||||
<Tag color="green">
|
||||
<CurrencyFormatter>
|
||||
{item.act_price}
|
||||
{item.act_price || 0}
|
||||
</CurrencyFormatter>
|
||||
</Tag>
|
||||
</Col>
|
||||
@@ -113,26 +114,29 @@ export default function InvoiceEnterModalLinesComponent({
|
||||
: null}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
{getFieldsValue("invoicelines").invoicelines[index] &&
|
||||
getFieldsValue("invoicelines").invoicelines[index]
|
||||
.joblinename &&
|
||||
!getFieldsValue("invoicelines").invoicelines[index]
|
||||
.joblineid ? (
|
||||
<Form.Item
|
||||
label={t("invoicelines.fields.line_desc")}
|
||||
key={`${index}line_desc`}
|
||||
name={[field.name, "line_desc"]}
|
||||
rules={[
|
||||
{
|
||||
required: !getFieldsValue("invoicelines")
|
||||
.invoicelines[index].joblineid,
|
||||
message: t("general.validation.required")
|
||||
}
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
) : null}
|
||||
|
||||
{
|
||||
//TODO Will need to refactor this to use proper form components in the search select above.
|
||||
getFieldsValue("invoicelines")[index] &&
|
||||
// getFieldsValue("invoicelines")[index].joblinename &&
|
||||
!getFieldsValue("invoicelines").invoicelines[index]
|
||||
.joblineid ? (
|
||||
<Form.Item
|
||||
label={t("invoicelines.fields.line_desc")}
|
||||
key={`${index}line_desc`}
|
||||
name={[field.name, "line_desc"]}
|
||||
rules={[
|
||||
{
|
||||
required: !getFieldsValue("invoicelines")[index]
|
||||
.joblineid,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
) : null
|
||||
}
|
||||
|
||||
<Form.Item
|
||||
label={t("invoicelines.fields.actual")}
|
||||
@@ -141,12 +145,12 @@ export default function InvoiceEnterModalLinesComponent({
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required")
|
||||
}
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<CurrencyInput
|
||||
onBlur={e => {
|
||||
onBlur={(e) => {
|
||||
setFieldsValue({
|
||||
invoicelines: getFieldsValue(
|
||||
"invoicelines"
|
||||
@@ -157,11 +161,11 @@ export default function InvoiceEnterModalLinesComponent({
|
||||
actual_cost: !!item.actual_cost
|
||||
? item.actual_cost
|
||||
: parseFloat(e.target.value) *
|
||||
(1 - discount)
|
||||
(1 - discount),
|
||||
};
|
||||
}
|
||||
return item;
|
||||
})
|
||||
}),
|
||||
});
|
||||
}}
|
||||
/>
|
||||
@@ -173,8 +177,8 @@ export default function InvoiceEnterModalLinesComponent({
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required")
|
||||
}
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<CurrencyInput onBlur={() => calculateTotals()} />
|
||||
@@ -186,12 +190,12 @@ export default function InvoiceEnterModalLinesComponent({
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required")
|
||||
}
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Select style={{ width: "150px" }}>
|
||||
{responsibilityCenters.costs.map(item => (
|
||||
{responsibilityCenters.costs.map((item) => (
|
||||
<Select.Option key={item}>{item}</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
|
||||
Reference in New Issue
Block a user