fix unit tests as well as missing code
API CI/CD / Validate (composer + pint) (push) Successful in 2m7s
API CI/CD / Test (PHPUnit) (push) Failing after 2m23s
API CI/CD / Build frontend assets (push) Successful in 2m18s
API CI/CD / Security audit (push) Successful in 31s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 2m7s
API CI/CD / Test (PHPUnit) (push) Failing after 2m23s
API CI/CD / Build frontend assets (push) Successful in 2m18s
API CI/CD / Security audit (push) Successful in 31s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
This commit is contained in:
@@ -310,8 +310,8 @@ class Invoice extends BaseModel
|
||||
|
||||
$affected = DB::update(
|
||||
"UPDATE invoices
|
||||
SET total_amount = GREATEST(total_amount - {$val}, 0),
|
||||
balance = GREATEST(balance - {$val}, 0)
|
||||
SET total_amount = CASE WHEN total_amount - {$val} < 0 THEN 0 ELSE total_amount - {$val} END,
|
||||
balance = CASE WHEN balance - {$val} < 0 THEN 0 ELSE balance - {$val} END
|
||||
WHERE id = ?",
|
||||
[$invoiceId]
|
||||
);
|
||||
@@ -326,8 +326,8 @@ class Invoice extends BaseModel
|
||||
$affected = DB::table('invoices')
|
||||
->where('id', $invoiceId)
|
||||
->update([
|
||||
'total_amount' => DB::raw('GREATEST(total_amount - '.$amount.', 0)'),
|
||||
'balance' => DB::raw('GREATEST(balance - '.$amount.', 0)'),
|
||||
'total_amount' => DB::raw('CASE WHEN total_amount - '.$amount.' < 0 THEN 0 ELSE total_amount - '.$amount.' END'),
|
||||
'balance' => DB::raw('CASE WHEN balance - '.$amount.' < 0 THEN 0 ELSE balance - '.$amount.' END'),
|
||||
]);
|
||||
|
||||
return $affected >= 0;
|
||||
|
||||
Reference in New Issue
Block a user