hotfix: remove tax from revenue calculation

This commit is contained in:
Sebastian Rindom committed 2021-02-18 11:46:46 +01:00
1 parent 0f045ae619
commit 8963f38023
1 file changed
+10 -4
@@ -66,6 +66,8 @@ class SegmentService extends BaseService {
coupon = order.discounts[0] && order.discounts[0].code coupon = order.discounts[0] && order.discounts[0].code
} }
const taxRate = order.tax_rate / 100
const orderData = { const orderData = {
checkout_id: order.cart_id, checkout_id: order.cart_id,
order_id: order.id, order_id: order.id,
@@ -104,12 +106,16 @@ class SegmentService extends BaseService {
products: await Promise.all( products: await Promise.all(
order.items.map(async (item) => { order.items.map(async (item) => {
let name = item.title let name = item.title
const lineTotalTax = this.totalsService_.getLineItemRefund(
order,
item
)
const lineTotal = lineTotalTax / (1 + taxRate)
const unit_price = item.unit_price
const line_total = this.totalsService_.getLineItemRefund(order, item)
const revenue = await this.getReportingValue( const revenue = await this.getReportingValue(
order.currency_code, order.currency_code,
line_total / 100 lineTotal / 100
) )
let sku = "" let sku = ""
@@ -126,7 +132,7 @@ class SegmentService extends BaseService {
return { return {
name, name,
variant, variant,
price: line_total / 100 / item.quantity, price: lineTotal / 100 / item.quantity,
reporting_revenue: revenue, reporting_revenue: revenue,
product_id: item.variant.product_id, product_id: item.variant.product_id,
sku, sku,