Successful 2tier and 3 tier export of invoices. BOD-83 BOD-131
This commit is contained in:
@@ -68,7 +68,7 @@ export default connect(
|
||||
|
||||
try {
|
||||
const response2 = await axios.post(
|
||||
"http://localhost:1337/qb/receivables",
|
||||
"http://e9c5a8ed9079.ngrok.io/qb/receivables",
|
||||
response.data,
|
||||
{
|
||||
headers: {
|
||||
|
||||
@@ -19,6 +19,7 @@ export function JobsCloseLabmatAllocationButton({
|
||||
allocation,
|
||||
setAllocations,
|
||||
bodyshop,
|
||||
invoiced
|
||||
}) {
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [state, setState] = useState({ center: "", amount: 0 });
|
||||
@@ -87,7 +88,7 @@ export function JobsCloseLabmatAllocationButton({
|
||||
<Button
|
||||
onClick={handleAllocate}
|
||||
disabled={
|
||||
state.amount === 0 || state.center === "" || remainingAmount === 0
|
||||
state.amount === 0 || state.center === "" || remainingAmount === 0 || invoiced
|
||||
}
|
||||
>
|
||||
{t("jobs.actions.allocate")}
|
||||
@@ -95,9 +96,9 @@ export function JobsCloseLabmatAllocationButton({
|
||||
</div>
|
||||
<div>
|
||||
{visible ? (
|
||||
<CloseCircleFilled onClick={() => setVisible(false)} />
|
||||
<CloseCircleFilled onClick={() => setVisible(false)} disabled={invoiced} />
|
||||
) : (
|
||||
<PlusCircleFilled onClick={() => setVisible(true)} />
|
||||
<PlusCircleFilled onClick={() => setVisible(true)} disabled={invoiced}/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,14 +4,15 @@ export default function JobsCloseLabMatAllocationTags({
|
||||
allocationKey,
|
||||
allocation,
|
||||
setAllocations,
|
||||
invoiced,
|
||||
}) {
|
||||
return (
|
||||
<div>
|
||||
{allocation.allocations.map((a, idx) => (
|
||||
<Tag
|
||||
closable
|
||||
closable={!invoiced} //Value is whether it is invoiced.
|
||||
visible
|
||||
color='green'
|
||||
color="green"
|
||||
onClose={() => {
|
||||
setAllocations((state) => {
|
||||
return {
|
||||
|
||||
@@ -14,6 +14,7 @@ export function JobsCloseAutoAllocate({
|
||||
setLabmatAllocations,
|
||||
partsAllocations,
|
||||
setPartsAllocations,
|
||||
invoiced
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const handleAllocate = () => {
|
||||
@@ -62,6 +63,6 @@ export function JobsCloseAutoAllocate({
|
||||
});
|
||||
};
|
||||
|
||||
return <Button onClick={handleAllocate}>{t("jobs.actions.autoallocate")}</Button>;
|
||||
return <Button onClick={handleAllocate} disabled={invoiced}>{t("jobs.actions.autoallocate")}</Button>;
|
||||
}
|
||||
export default connect(mapStateToProps, null)(JobsCloseAutoAllocate);
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import { Button } from "antd";
|
||||
import axios from "axios";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { auth } from "../../firebase/firebase.utils";
|
||||
|
||||
export default function JobsCloseExportButton({ jobId, disabled }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleQbxml = async () => {
|
||||
const response = await axios.post(
|
||||
"/accounting/qbxml/receivables",
|
||||
{ jobId: jobId },
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${await auth.currentUser.getIdToken(true)}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
console.log("handle -> XML", response);
|
||||
|
||||
try {
|
||||
const response2 = await axios.post(
|
||||
"http://e9c5a8ed9079.ngrok.io/qb/receivables",
|
||||
response.data,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${await auth.currentUser.getIdToken(true)}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
console.log("handle -> result", response2);
|
||||
} catch (error) {
|
||||
console.log("error", error, JSON.stringify(error));
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Button onClick={handleQbxml} disabled={disabled} type="dashed">
|
||||
{t("jobs.actions.export")}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ export default function JobCloseLabMatAllocation({
|
||||
labmatAllocations,
|
||||
setLabmatAllocations,
|
||||
labMatTotalAllocation,
|
||||
invoiced
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -50,6 +51,7 @@ export default function JobCloseLabMatAllocation({
|
||||
<td>
|
||||
<AllocationButton
|
||||
allocationKey={alloc}
|
||||
invoiced={invoiced}
|
||||
remainingAmount={labmatAllocations[alloc].total
|
||||
.subtract(
|
||||
Dinero({
|
||||
@@ -69,6 +71,7 @@ export default function JobCloseLabMatAllocation({
|
||||
<td>
|
||||
<AllocationTags
|
||||
allocationKey={alloc}
|
||||
invoiced={invoiced}
|
||||
allocation={labmatAllocations[alloc]}
|
||||
setAllocations={setLabmatAllocations}
|
||||
/>
|
||||
|
||||
@@ -8,6 +8,7 @@ export default function JobsClosePartsAllocation({
|
||||
partsAllocations,
|
||||
setPartsAllocations,
|
||||
partsAllocatedTotal,
|
||||
invoiced,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -50,6 +51,7 @@ export default function JobsClosePartsAllocation({
|
||||
<td>
|
||||
<AllocationButton
|
||||
allocationKey={alloc}
|
||||
invoiced={invoiced}
|
||||
remainingAmount={partsAllocations[alloc].total
|
||||
.subtract(
|
||||
Dinero({
|
||||
@@ -68,6 +70,7 @@ export default function JobsClosePartsAllocation({
|
||||
</td>
|
||||
<td>
|
||||
<AllocationTags
|
||||
invoiced={invoiced}
|
||||
allocationKey={alloc}
|
||||
allocation={partsAllocations[alloc]}
|
||||
setAllocations={setPartsAllocations}
|
||||
|
||||
@@ -18,6 +18,8 @@ export function JobsCloseSaveButton({
|
||||
jobTotals,
|
||||
labMatAllocations,
|
||||
partsAllocations,
|
||||
setInvoicedState,
|
||||
disabled,
|
||||
}) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const { t } = useTranslation();
|
||||
@@ -38,9 +40,23 @@ export function JobsCloseSaveButton({
|
||||
},
|
||||
},
|
||||
},
|
||||
optimisticResponse: {
|
||||
update_jobs: {
|
||||
returning: {
|
||||
id: jobId,
|
||||
date_invoiced: new Date(),
|
||||
status: bodyshop.md_ro_statuses.default_invoiced || "Invoiced*",
|
||||
invoice_allocation: {
|
||||
labMatAllocations,
|
||||
partsAllocations,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!!!result.errors) {
|
||||
notification["success"]({ message: t("jobs.successes.invoiced") });
|
||||
setInvoicedState(true);
|
||||
} else {
|
||||
notification["error"]({
|
||||
message: t("jobs.errors.invoicing", {
|
||||
@@ -50,14 +66,14 @@ export function JobsCloseSaveButton({
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<Button
|
||||
onClick={handleSave}
|
||||
disabled={suspenseAmount > 0}
|
||||
disabled={suspenseAmount > 0 || disabled}
|
||||
loading={loading}
|
||||
>
|
||||
{t("general.actions.close")}
|
||||
{t("general.actions.save")}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user