Mhamdans17 commited on
Commit
bc89757
·
1 Parent(s): e70dcc5

fix: include tripay transactions in fee report non-cash calculation

Browse files
Files changed (1) hide show
  1. controllers/fee_controller.go +4 -4
controllers/fee_controller.go CHANGED
@@ -112,9 +112,9 @@ func GetFeeReport(c *gin.Context) {
112
  coalesce(sum(orders.total_amount), 0) as total_revenue,
113
  coalesce(sum(orders.platform_fee), 0) as total_fee,
114
  coalesce(sum(case when orders.payment_method = 'cash' then orders.total_amount else 0 end), 0) as total_cash,
115
- coalesce(sum(case when orders.payment_method = 'midtrans' then orders.total_amount else 0 end), 0) as total_midtrans,
116
  coalesce(sum(case when orders.payment_method = 'cash' then orders.platform_fee else 0 end), 0) as fee_cash,
117
- coalesce(sum(case when orders.payment_method = 'midtrans' then orders.platform_fee else 0 end), 0) as fee_midtrans
118
  `).Scan(&summary)
119
 
120
  // 2. Summary per perusahaan
@@ -127,7 +127,7 @@ func GetFeeReport(c *gin.Context) {
127
  coalesce(sum(orders.total_amount), 0) as total_revenue,
128
  coalesce(sum(orders.platform_fee), 0) as total_fee,
129
  coalesce(sum(case when orders.payment_method = 'cash' then orders.total_amount else 0 end), 0) as total_cash,
130
- coalesce(sum(case when orders.payment_method = 'midtrans' then orders.total_amount else 0 end), 0) as total_midtrans
131
  `).
132
  Joins("join companies on companies.id = orders.company_id").
133
  Group("orders.company_id, companies.name, companies.fee_percentage").
@@ -145,7 +145,7 @@ func GetFeeReport(c *gin.Context) {
145
  coalesce(sum(orders.total_amount), 0) as total_revenue,
146
  coalesce(sum(orders.platform_fee), 0) as total_fee,
147
  coalesce(sum(case when orders.payment_method = 'cash' then orders.total_amount else 0 end), 0) as total_cash,
148
- coalesce(sum(case when orders.payment_method = 'midtrans' then orders.total_amount else 0 end), 0) as total_midtrans
149
  `).
150
  Joins("join companies on companies.id = orders.company_id").
151
  Joins("left join branches on branches.id = orders.branch_id").
 
112
  coalesce(sum(orders.total_amount), 0) as total_revenue,
113
  coalesce(sum(orders.platform_fee), 0) as total_fee,
114
  coalesce(sum(case when orders.payment_method = 'cash' then orders.total_amount else 0 end), 0) as total_cash,
115
+ coalesce(sum(case when orders.payment_method != 'cash' then orders.total_amount else 0 end), 0) as total_midtrans,
116
  coalesce(sum(case when orders.payment_method = 'cash' then orders.platform_fee else 0 end), 0) as fee_cash,
117
+ coalesce(sum(case when orders.payment_method != 'cash' then orders.platform_fee else 0 end), 0) as fee_midtrans
118
  `).Scan(&summary)
119
 
120
  // 2. Summary per perusahaan
 
127
  coalesce(sum(orders.total_amount), 0) as total_revenue,
128
  coalesce(sum(orders.platform_fee), 0) as total_fee,
129
  coalesce(sum(case when orders.payment_method = 'cash' then orders.total_amount else 0 end), 0) as total_cash,
130
+ coalesce(sum(case when orders.payment_method != 'cash' then orders.total_amount else 0 end), 0) as total_midtrans
131
  `).
132
  Joins("join companies on companies.id = orders.company_id").
133
  Group("orders.company_id, companies.name, companies.fee_percentage").
 
145
  coalesce(sum(orders.total_amount), 0) as total_revenue,
146
  coalesce(sum(orders.platform_fee), 0) as total_fee,
147
  coalesce(sum(case when orders.payment_method = 'cash' then orders.total_amount else 0 end), 0) as total_cash,
148
+ coalesce(sum(case when orders.payment_method != 'cash' then orders.total_amount else 0 end), 0) as total_midtrans
149
  `).
150
  Joins("join companies on companies.id = orders.company_id").
151
  Joins("left join branches on branches.id = orders.branch_id").