hotfix(segment): remove tax from revenue calculation (#174)
This commit is contained in:
1 parent
0f045ae619
commit
f32ae72782
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,
|
||||||
|
|||||||
Reference in new issue
Block a user