IO-1708 Add shop timezone & update server side calculations.
This commit is contained in:
@@ -17,7 +17,7 @@ const {
|
||||
setNewRefreshToken,
|
||||
} = require("./qbo-callback");
|
||||
const OAuthClient = require("intuit-oauth");
|
||||
const moment = require("moment");
|
||||
const moment = require("moment-timezone");
|
||||
const GraphQLClient = require("graphql-request").GraphQLClient;
|
||||
const findTaxCode = require("../qb-receivables-lines").findTaxCode;
|
||||
|
||||
@@ -178,7 +178,9 @@ async function InsertBill(oauthClient, qbo_realmId, req, bill, vendor) {
|
||||
VendorRef: {
|
||||
value: vendor.Id,
|
||||
},
|
||||
TxnDate: moment(bill.date).format("YYYY-MM-DD"),
|
||||
TxnDate: moment(bill.date)
|
||||
.tz(bill.job.bodyshop.timezone)
|
||||
.format("YYYY-MM-DD"),
|
||||
//DueDate: bill.due_date && moment(bill.due_date).format("YYYY-MM-DD"),
|
||||
DocNumber: bill.invoice_number,
|
||||
//...(bill.job.class ? { ClassRef: { Id: classes[bill.job.class] } } : {}),
|
||||
|
||||
@@ -15,7 +15,7 @@ const {
|
||||
setNewRefreshToken,
|
||||
} = require("./qbo-callback");
|
||||
const OAuthClient = require("intuit-oauth");
|
||||
const moment = require("moment");
|
||||
const moment = require("moment-timezone");
|
||||
const GraphQLClient = require("graphql-request").GraphQLClient;
|
||||
const {
|
||||
QueryInsuranceCo,
|
||||
@@ -137,14 +137,22 @@ exports.default = async (req, res) => {
|
||||
}
|
||||
|
||||
if (payment.amount > 0) {
|
||||
await InsertPayment(oauthClient, qbo_realmId, req, payment, jobTier);
|
||||
await InsertPayment(
|
||||
oauthClient,
|
||||
qbo_realmId,
|
||||
req,
|
||||
payment,
|
||||
jobTier,
|
||||
bodyshop
|
||||
);
|
||||
} else {
|
||||
await InsertCreditMemo(
|
||||
oauthClient,
|
||||
qbo_realmId,
|
||||
req,
|
||||
payment,
|
||||
jobTier
|
||||
jobTier,
|
||||
bodyshop
|
||||
);
|
||||
}
|
||||
ret.push({ paymentid: payment.id, success: true });
|
||||
@@ -178,7 +186,8 @@ async function InsertPayment(
|
||||
qbo_realmId,
|
||||
req,
|
||||
payment,
|
||||
parentRef
|
||||
parentRef,
|
||||
bodyshop
|
||||
) {
|
||||
const { paymentMethods, invoices } = await QueryMetaData(
|
||||
oauthClient,
|
||||
@@ -198,7 +207,7 @@ async function InsertPayment(
|
||||
CustomerRef: {
|
||||
value: parentRef.Id,
|
||||
},
|
||||
TxnDate: moment(payment.date).format("YYYY-MM-DD"),
|
||||
TxnDate: moment(payment.date).tz(bodyshop.timezone).format("YYYY-MM-DD"),
|
||||
//DueDate: bill.due_date && moment(bill.due_date).format("YYYY-MM-DD"),
|
||||
DocNumber: payment.paymentnum,
|
||||
TotalAmt: Dinero({
|
||||
@@ -362,7 +371,8 @@ async function InsertCreditMemo(
|
||||
qbo_realmId,
|
||||
req,
|
||||
payment,
|
||||
parentRef
|
||||
parentRef,
|
||||
bodyshop
|
||||
) {
|
||||
const { paymentMethods, invoices, items, taxCodes } = await QueryMetaData(
|
||||
oauthClient,
|
||||
@@ -382,7 +392,7 @@ async function InsertCreditMemo(
|
||||
CustomerRef: {
|
||||
value: parentRef.Id,
|
||||
},
|
||||
TxnDate: moment(payment.date).format("YYYY-MM-DD"),
|
||||
TxnDate: moment(payment.date).tz(bodyshop.timezone).format("YYYY-MM-DD"),
|
||||
DocNumber: payment.paymentnum,
|
||||
...(invoices && invoices[0]
|
||||
? { InvoiceRef: { value: invoices[0].Id } }
|
||||
|
||||
@@ -17,7 +17,7 @@ const {
|
||||
} = require("./qbo-callback");
|
||||
const OAuthClient = require("intuit-oauth");
|
||||
const CreateInvoiceLines = require("../qb-receivables-lines").default;
|
||||
const moment = require("moment");
|
||||
const moment = require("moment-timezone");
|
||||
|
||||
const GraphQLClient = require("graphql-request").GraphQLClient;
|
||||
const { generateOwnerTier } = require("../qbxml/qbxml-utils");
|
||||
@@ -440,7 +440,9 @@ async function InsertInvoice(
|
||||
|
||||
const invoiceObj = {
|
||||
Line: InvoiceLineAdd,
|
||||
TxnDate: moment(job.date_invoiced).format("YYYY-MM-DD"),
|
||||
TxnDate: moment(job.date_invoiced)
|
||||
.tz(bodyshop.timezone)
|
||||
.format("YYYY-MM-DD"),
|
||||
DocNumber: job.ro_number,
|
||||
...(job.class ? { ClassRef: { value: classes[job.class] } } : {}),
|
||||
CustomerMemo: {
|
||||
|
||||
Reference in New Issue
Block a user