IO-3001 Additional tax changes.

This commit is contained in:
Patrick Fic
2024-11-15 10:56:07 -08:00
parent cb80b79e1d
commit e363dca3f0
2 changed files with 31 additions and 31 deletions

View File

@@ -1,5 +1,5 @@
import { useMutation } from "@apollo/client"; import { useMutation } from "@apollo/client";
import { Button, Form, notification, Popover, Tooltip } from "antd"; import { Button, Checkbox, Form, notification, Popover, Tooltip } from "antd";
import axios from "axios"; import axios from "axios";
import { t } from "i18next"; import { t } from "i18next";
import React, { useState } from "react"; import React, { useState } from "react";
@@ -60,27 +60,30 @@ export function JobLinesPartPriceChange({ job, line, refetch, technician }) {
} }
}; };
const popcontent = !technician && InstanceRenderManager({ const popcontent =
imex: null, !technician &&
rome: ( InstanceRenderManager({
<Form layout="vertical" onFinish={handleFinish} initialValues={{ act_price: line.act_price }}> imex: null,
<Form.Item name="act_price" label={t("jobs.labels.act_price_ppc")} rules={[{ required: true }]}> rome: (
<CurrencyFormItemComponent /> <Form layout="vertical" onFinish={handleFinish} initialValues={{ act_price: line.act_price }}>
</Form.Item> <Form.Item name="act_price" label={t("jobs.labels.act_price_ppc")} rules={[{ required: true }]}>
<Button <CurrencyFormItemComponent />
disabled={InstanceRenderManager({ imex: true, rome: false, promanager: true })} </Form.Item>
loading={loading} <Button
htmlType="primary" disabled={InstanceRenderManager({ imex: true, rome: false, promanager: true })}
> loading={loading}
{t("general.actions.save")} htmlType="primary"
</Button> >
</Form> {t("general.actions.save")}
), </Button>
promanager: null </Form>
}); ),
promanager: null
});
return ( return (
<JobLineConvertToLabor jobline={line} job={job}> <JobLineConvertToLabor jobline={line} job={job}>
{import.meta.env.DEV && <Checkbox checked={line.tax_part} />}
<Popover trigger="click" disabled={true || line.manual_line} content={popcontent}> <Popover trigger="click" disabled={true || line.manual_line} content={popcontent}>
<CurrencyFormatter> <CurrencyFormatter>
{line.db_ref === "900510" || line.db_ref === "900511" ? line.prt_dsmk_m : line.act_price} {line.db_ref === "900510" || line.db_ref === "900511" ? line.prt_dsmk_m : line.act_price}

View File

@@ -49,7 +49,7 @@ exports.totalsSsu = async function (req, res) {
} catch (error) { } catch (error) {
logger.log("job-totals-ssu-USA-error", "ERROR", req?.user?.email, id, { logger.log("job-totals-ssu-USA-error", "ERROR", req?.user?.email, id, {
jobid: id, jobid: id,
error error: error.message
}); });
res.status(503).send(); res.status(503).send();
} }
@@ -75,7 +75,7 @@ async function TotalsServerSide(req, res) {
: job.cieca_ttl.data.n_ttl_amt - job.cieca_ttl.data.g_tax; : job.cieca_ttl.data.n_ttl_amt - job.cieca_ttl.data.g_tax;
const ttlDifference = emsTotal - ret.totals.subtotal.getAmount() / 100; const ttlDifference = emsTotal - ret.totals.subtotal.getAmount() / 100;
if (Math.abs(ttlDifference) > 0.00) { if (Math.abs(ttlDifference) > 0.0) {
//If difference is greater than a pennny, we need to adjust it. //If difference is greater than a pennny, we need to adjust it.
ret.totals.ttl_adjustment = Dinero({ amount: Math.round(ttlDifference * 100) }); ret.totals.ttl_adjustment = Dinero({ amount: Math.round(ttlDifference * 100) });
ret.totals.subtotal = ret.totals.subtotal.add(ret.totals.ttl_adjustment); ret.totals.subtotal = ret.totals.subtotal.add(ret.totals.ttl_adjustment);
@@ -97,7 +97,7 @@ async function TotalsServerSide(req, res) {
100; 100;
const ttlTaxDifference = emsTaxTotal - totalUsTaxes; const ttlTaxDifference = emsTaxTotal - totalUsTaxes;
if (Math.abs(ttlTaxDifference) > 0.00) { if (Math.abs(ttlTaxDifference) > 0.0) {
//If difference is greater than a pennny, we need to adjust it. //If difference is greater than a pennny, we need to adjust it.
ret.totals.ttl_tax_adjustment = Dinero({ amount: Math.round(ttlTaxDifference * 100) }); ret.totals.ttl_tax_adjustment = Dinero({ amount: Math.round(ttlTaxDifference * 100) });
ret.totals.total_repairs = ret.totals.total_repairs.add(ret.totals.ttl_tax_adjustment); ret.totals.total_repairs = ret.totals.total_repairs.add(ret.totals.ttl_tax_adjustment);
@@ -998,7 +998,7 @@ function CalculateTaxesTotals(job, otherTotals) {
} }
} }
} catch (error) { } catch (error) {
logger.log("job-totals-USA Key with issue", "error", null, null, { logger.log("job-totals-USA Key with issue", "error", null, job.id, {
key key
}); });
} }
@@ -1028,7 +1028,7 @@ function CalculateTaxesTotals(job, otherTotals) {
for (let threshCounter = 1; threshCounter <= 5; threshCounter++) { for (let threshCounter = 1; threshCounter <= 5; threshCounter++) {
const thresholdAmount = parseFloat(job.cieca_pft[`ty${tyCounter}_thres${threshCounter}`]) || 0; const thresholdAmount = parseFloat(job.cieca_pft[`ty${tyCounter}_thres${threshCounter}`]) || 0;
const thresholdTaxRate = parseFloat(job.cieca_pft[`ty${tyCounter}_rate${threshCounter}`]) || 0; const thresholdTaxRate = parseFloat(job.cieca_pft[`ty${tyCounter}_rate${threshCounter}`]) || 0;
// console.log(taxTierKey, tyCounter, threshCounter, thresholdAmount, thresholdTaxRate);
let taxableAmountInThisThreshold; let taxableAmountInThisThreshold;
if ( if (
thresholdAmount === 9999.99 || thresholdAmount === 9999.99 ||
@@ -1052,11 +1052,8 @@ function CalculateTaxesTotals(job, otherTotals) {
taxableAmountInThisThreshold = Dinero({ taxableAmountInThisThreshold = Dinero({
amount: Math.round(thresholdAmount * 100) amount: Math.round(thresholdAmount * 100)
}); });
remainingTaxableAmounts[taxTierKey] = remainingTaxableAmounts[taxTierKey].subtract( remainingTaxableAmounts[taxTierKey] =
Dinero({ remainingTaxableAmounts[taxTierKey].subtract(taxableAmountInThisThreshold);
amount: Math.round(taxableAmountInThisThreshold * 100)
})
);
} }
} }
@@ -1065,8 +1062,8 @@ function CalculateTaxesTotals(job, otherTotals) {
totalTaxByTier[taxTierKey] = totalTaxByTier[taxTierKey].add(taxAmountToAdd); totalTaxByTier[taxTierKey] = totalTaxByTier[taxTierKey].add(taxAmountToAdd);
} }
} catch (error) { } catch (error) {
logger.log("job-totals-USA - PFP Calculation Error", "error", null, null, { logger.log("job-totals-USA - PFP Calculation Error", "error", null, job.id, {
error error: error.message
}); });
} }
}); });