Fixes for credit creation after downgrading a subscription service

This commit is contained in:
David Bomba 2023-01-10 14:32:53 +11:00
parent 490c026a08
commit 5d459aaa2f
3 changed files with 4 additions and 5 deletions

View File

@ -83,9 +83,8 @@ class PaymentRepository extends BaseRepository {
if ($data['amount'] == '') { if ($data['amount'] == '') {
$data['amount'] = array_sum(array_column($data['invoices'], 'amount')); $data['amount'] = array_sum(array_column($data['invoices'], 'amount'));
} }
$client->service()->updatePaidToDate($data['amount'])->save(); $client->service()->updatePaidToDate($data['amount'])->save();
// $client->paid_to_date += $data['amount'];
$client->save(); $client->save();
} }

View File

@ -105,8 +105,8 @@ class ApplyPayment
private function addPaymentToLedger() private function addPaymentToLedger()
{ {
$this->payment->amount += $this->amount_applied; // $this->payment->amount += $this->amount_applied;
$this->payment->applied += $this->amount_applied; // $this->payment->applied += $this->amount_applied;
$this->payment->status_id = Payment::STATUS_COMPLETED; $this->payment->status_id = Payment::STATUS_COMPLETED;
$this->payment->currency_id = $this->credit->client->getSetting('currency_id'); $this->payment->currency_id = $this->credit->client->getSetting('currency_id');
$this->payment->save(); $this->payment->save();

View File

@ -416,7 +416,7 @@ else
foreach($invoice->line_items as $item) foreach($invoice->line_items as $item)
{ {
if($item->product_key != ctrans('texts.refund')) if($item->product_key != ctrans('texts.refund') && ($item->type_id == "1" || $item->type_id == "2"))
{ {
$item->cost = ($item->cost*$ratio*$multiplier); $item->cost = ($item->cost*$ratio*$multiplier);