IO-233 CDK Shop Config

This commit is contained in:
Patrick Fic
2021-08-10 08:40:38 -07:00
parent ac18e78897
commit 124d68ef68
24 changed files with 2540 additions and 816 deletions

View File

@@ -6,6 +6,7 @@ const Dinero = require("dinero.js");
var builder = require("xmlbuilder2");
const QbXmlUtils = require("./qbxml-utils");
const moment = require("moment");
const logger = require("../../utils/logger");
require("dotenv").config({
path: path.resolve(
@@ -45,7 +46,13 @@ exports.default = async (req, res) => {
res.status(200).json(QbXmlToExecute);
} catch (error) {
console.log("error", error);
logger.log(
"qbxml-payable-error",
"error",
req.body.user,
req.body.billsToQuery,
error
);
res.status(400).send(JSON.stringify(error));
}
};
@@ -89,7 +96,6 @@ const generateBill = (bill) => {
.end({ pretty: true });
const billQbxml_Full = QbXmlUtils.addQbxmlHeader(billQbxml_partial);
console.log("generateBill -> billQbxml_Full", billQbxml_Full);
return billQbxml_Full;
};
@@ -131,7 +137,6 @@ const findTaxCode = (billLine, taxcode) => {
!!t.federal === !!federal
);
if (t.length === 1) {
console.log(t);
return t[0].code;
} else if (t.length > 1) {
return "Multiple Tax Codes Match";

View File

@@ -7,6 +7,8 @@ var builder = require("xmlbuilder2");
const moment = require("moment");
const QbXmlUtils = require("./qbxml-utils");
const QbxmlReceivables = require("./qbxml-receivables");
const logger = require("../../utils/logger");
require("dotenv").config({
path: path.resolve(
process.cwd(),
@@ -80,13 +82,18 @@ exports.default = async (req, res) => {
res.status(200).json(QbXmlToExecute);
} catch (error) {
console.log("error", error);
logger.log(
"qbxml-payments-error",
"error",
req.body.user,
req.body.paymentsToQuery,
error
);
res.status(400).send(JSON.stringify(error));
}
};
const generatePayment = (payment, isThreeTier, twoTierPref) => {
console.log("generatePayment -> payment", payment);
let paymentQbxmlObj;
if (payment.amount > 0) {
paymentQbxmlObj = {
@@ -194,7 +201,6 @@ const generatePayment = (payment, isThreeTier, twoTierPref) => {
.end({ pretty: true });
const paymentQbxmlFull = QbXmlUtils.addQbxmlHeader(paymentQbxmlPartial);
console.log("generateBill -> paymentQbxmlFull", paymentQbxmlFull);
return paymentQbxmlFull;
};

View File

@@ -6,6 +6,8 @@ const Dinero = require("dinero.js");
const moment = require("moment");
var builder = require("xmlbuilder2");
const QbXmlUtils = require("./qbxml-utils");
const logger = require("../../utils/logger");
require("dotenv").config({
path: path.resolve(
process.cwd(),
@@ -93,7 +95,13 @@ exports.default = async (req, res) => {
res.status(200).json(QbXmlToExecute);
} catch (error) {
console.log("error", error);
logger.log(
"qbxml-payments-error",
"error",
req.body.user,
req.body.jobIds,
error
);
res.status(400).send(JSON.stringify(error));
}
};
@@ -220,7 +228,7 @@ const generateInvoiceQbxml = (
}).multiply(jobline.part_qty || 1);
if (jobline.prt_dsmk_p && jobline.prt_dsmk_p !== 0) {
console.log("Have a part discount", jobline);
// console.log("Have a part discount", jobline);
DineroAmount = DineroAmount.add(
DineroAmount.percentage(jobline.prt_dsmk_p || 0)
);
@@ -230,6 +238,13 @@ const generateInvoiceQbxml = (
);
if (!account) {
logger.log(
"qbxml-receivables-no-account",
"warn",
null,
jobline.id,
null
);
throw new Error(
`A matching account does not exist for the part allocation. Center: ${jobline.profitcenter_part}`
);
@@ -309,7 +324,7 @@ const generateInvoiceQbxml = (
},
});
} else {
console.log("NO MAPA ACCOUNT FOUND!!");
//console.log("NO MAPA ACCOUNT FOUND!!");
}
}