IO-2371 Closing Period
This commit is contained in:
@@ -8,7 +8,6 @@ import {
|
||||
Form,
|
||||
Input,
|
||||
InputNumber,
|
||||
notification,
|
||||
PageHeader,
|
||||
Popconfirm,
|
||||
Row,
|
||||
@@ -17,12 +16,14 @@ import {
|
||||
Statistic,
|
||||
Switch,
|
||||
Typography,
|
||||
notification,
|
||||
} from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
//import { useHistory } from "react-router-dom";
|
||||
import { useTreatments } from "@splitsoftware/splitio-react";
|
||||
import Dinero from "dinero.js";
|
||||
import moment from "moment";
|
||||
import { Link } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -37,7 +38,6 @@ import { generateJobLinesUpdatesForInvoicing } from "../../graphql/jobs-lines.qu
|
||||
import { UPDATE_JOB } from "../../graphql/jobs.queries";
|
||||
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import Dinero from "dinero.js";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
jobRO: selectJobReadOnly,
|
||||
@@ -55,6 +55,11 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) {
|
||||
{},
|
||||
bodyshop && bodyshop.imexshopid
|
||||
);
|
||||
const { ClosingPeriod } = useTreatments(
|
||||
["ClosingPeriod"],
|
||||
{},
|
||||
bodyshop && bodyshop.imexshopid
|
||||
);
|
||||
|
||||
const handleFinish = async ({ removefromproduction, ...values }) => {
|
||||
setLoading(true);
|
||||
@@ -250,14 +255,42 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) {
|
||||
},
|
||||
({ getFieldValue }) => ({
|
||||
validator(_, value) {
|
||||
if (!bodyshop.cdk_dealerid) return Promise.resolve();
|
||||
if (!value || moment(value).isSameOrAfter(moment(), "day")) {
|
||||
return Promise.resolve();
|
||||
if (!bodyshop.cdk_dealerid) {
|
||||
if (
|
||||
ClosingPeriod.treatment === "on" &&
|
||||
bodyshop.accountingconfig.ClosingPeriod
|
||||
) {
|
||||
if (
|
||||
Date.parse(value).valueOf() >=
|
||||
Date.parse(
|
||||
bodyshop.accountingconfig.ClosingPeriod[0]
|
||||
).valueOf() &&
|
||||
Date.parse(value).valueOf() <=
|
||||
Date.parse(
|
||||
bodyshop.accountingconfig.ClosingPeriod[1]
|
||||
).valueOf()
|
||||
) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
return Promise.reject(
|
||||
new Error(t("jobs.labels.closingperiod"))
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
!value ||
|
||||
moment(value).isSameOrAfter(moment(), "day")
|
||||
) {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
return Promise.reject(
|
||||
new Error(t("jobs.labels.dms.invoicedatefuture"))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.reject(
|
||||
new Error(t("jobs.labels.dms.invoicedatefuture"))
|
||||
);
|
||||
},
|
||||
}),
|
||||
]}
|
||||
|
||||
Reference in New Issue
Block a user