Changed global Dinero rounding IO-469.
This commit is contained in:
@@ -97,20 +97,12 @@ function BillEnterModalContainer({
|
|||||||
const newAdjustments = _.cloneDeep(
|
const newAdjustments = _.cloneDeep(
|
||||||
existingAdjustments.data.jobs_by_pk.lbr_adjustments
|
existingAdjustments.data.jobs_by_pk.lbr_adjustments
|
||||||
);
|
);
|
||||||
console.log(
|
|
||||||
"🚀 ~ file: bill-enter-modal.container.jsx ~ line 99 ~ handleFinish ~ newAdjustments",
|
|
||||||
newAdjustments
|
|
||||||
);
|
|
||||||
|
|
||||||
adjKeys.forEach((key) => {
|
adjKeys.forEach((key) => {
|
||||||
newAdjustments[key] =
|
newAdjustments[key] =
|
||||||
(newAdjustments[key] || 0) + adjustmentsToInsert[key];
|
(newAdjustments[key] || 0) + adjustmentsToInsert[key];
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(
|
|
||||||
"🚀 ~ file: bill-enter-modal.container.jsx ~ line 109 ~ adjKeys.forEach ~ newAdjustments",
|
|
||||||
newAdjustments
|
|
||||||
);
|
|
||||||
const jobUpdate = client.mutate({
|
const jobUpdate = client.mutate({
|
||||||
mutation: UPDATE_JOB,
|
mutation: UPDATE_JOB,
|
||||||
variables: {
|
variables: {
|
||||||
|
|||||||
@@ -140,8 +140,12 @@ export function BillEnterModalLinesComponent({
|
|||||||
...item,
|
...item,
|
||||||
actual_cost: !!item.actual_cost
|
actual_cost: !!item.actual_cost
|
||||||
? item.actual_cost
|
? item.actual_cost
|
||||||
: parseFloat(e.target.value) *
|
: Math.round(
|
||||||
(1 - discount),
|
(parseFloat(e.target.value) *
|
||||||
|
(1 - discount) +
|
||||||
|
Number.EPSILON) *
|
||||||
|
100
|
||||||
|
) / 100,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
|
|||||||
@@ -22,9 +22,12 @@ export const CalculateBillTotal = (invoice) => {
|
|||||||
|
|
||||||
billlines.forEach((i) => {
|
billlines.forEach((i) => {
|
||||||
if (!!i) {
|
if (!!i) {
|
||||||
|
console.log("Amount:", (i.actual_cost || 0) * 100);
|
||||||
const itemTotal = Dinero({
|
const itemTotal = Dinero({
|
||||||
amount: Math.round((i.actual_cost || 0) * 100) || 0,
|
amount:
|
||||||
|
Math.round(((i.actual_cost || 0) * 100 + Number.EPSILON) * 100) / 100,
|
||||||
}).multiply(i.quantity || 1);
|
}).multiply(i.quantity || 1);
|
||||||
|
|
||||||
subtotal = subtotal.add(itemTotal);
|
subtotal = subtotal.add(itemTotal);
|
||||||
if (i.applicable_taxes.federal) {
|
if (i.applicable_taxes.federal) {
|
||||||
federalTax = federalTax.add(
|
federalTax = federalTax.add(
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ require("dotenv").config();
|
|||||||
|
|
||||||
Dinero.defaultCurrency = "CAD";
|
Dinero.defaultCurrency = "CAD";
|
||||||
Dinero.globalLocale = "en-CA";
|
Dinero.globalLocale = "en-CA";
|
||||||
|
Dinero.globalRoundingMode = "HALF_UP";
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const Dinero = require("dinero.js");
|
|||||||
|
|
||||||
Dinero.defaultCurrency = "CAD";
|
Dinero.defaultCurrency = "CAD";
|
||||||
Dinero.globalLocale = "en-CA";
|
Dinero.globalLocale = "en-CA";
|
||||||
|
Dinero.globalRoundingMode = "HALF_UP";
|
||||||
|
|
||||||
exports.default = async function (req, res) {
|
exports.default = async function (req, res) {
|
||||||
const { job } = req.body;
|
const { job } = req.body;
|
||||||
|
|||||||
Reference in New Issue
Block a user