fix: division by zero error
This commit is contained in:
@@ -99,8 +99,11 @@ class DailyChange extends Model
|
|||||||
'tx1.quantity',
|
'tx1.quantity',
|
||||||
])
|
])
|
||||||
->selectRaw("(CASE
|
->selectRaw("(CASE
|
||||||
WHEN tx1.transaction_type = 'BUY'
|
WHEN
|
||||||
THEN COALESCE(cr.rate, 1)
|
tx1.transaction_type = 'BUY'
|
||||||
|
OR SUM(tx1.cost_basis_base) = 0
|
||||||
|
THEN
|
||||||
|
COALESCE(cr.rate, 1)
|
||||||
ELSE (
|
ELSE (
|
||||||
SELECT
|
SELECT
|
||||||
SUM(COALESCE(cr2.rate, 1) * buy.cost_basis_base)
|
SUM(COALESCE(cr2.rate, 1) * buy.cost_basis_base)
|
||||||
|
|||||||
@@ -302,8 +302,11 @@ class Holding extends Model
|
|||||||
])
|
])
|
||||||
->selectRaw(
|
->selectRaw(
|
||||||
"(CASE
|
"(CASE
|
||||||
WHEN transactions.transaction_type = 'BUY'
|
WHEN
|
||||||
THEN COALESCE(cr.rate, 1)
|
transactions.transaction_type = 'BUY'
|
||||||
|
OR SUM(transactions.cost_basis_base) = 0
|
||||||
|
THEN
|
||||||
|
COALESCE(cr.rate, 1)
|
||||||
ELSE (
|
ELSE (
|
||||||
SELECT
|
SELECT
|
||||||
SUM(COALESCE(cr2.rate, 1) * buy.cost_basis_base)
|
SUM(COALESCE(cr2.rate, 1) * buy.cost_basis_base)
|
||||||
|
|||||||
Reference in New Issue
Block a user