mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for credit paymentables
This commit is contained in:
parent
5f1267d495
commit
5c835a1fc7
@ -39,18 +39,17 @@ class PaymentCreatedActivity implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle($event)
|
public function handle($event)
|
||||||
{
|
{
|
||||||
|
|
||||||
MultiDB::setDb($event->company->db);
|
MultiDB::setDb($event->company->db);
|
||||||
|
|
||||||
$payment = $event->payment;
|
$payment = $event->payment;
|
||||||
$invoice_id = null;
|
$invoice_id = null;
|
||||||
|
|
||||||
if($payment->invoices()->exists())
|
if($payment->invoices()->exists())
|
||||||
$invoice_id = $payment->invoices->first()->id;
|
$invoice_id = $payment->invoices()->first()->id;
|
||||||
|
|
||||||
$user_id = array_key_exists('user_id', $event->event_vars) ? $event->event_vars['user_id'] : $event->payment->user_id;
|
$user_id = array_key_exists('user_id', $event->event_vars) ? $event->event_vars['user_id'] : $event->payment->user_id;
|
||||||
|
|
||||||
$invoices = $payment->invoices;
|
|
||||||
|
|
||||||
$fields = new stdClass;
|
$fields = new stdClass;
|
||||||
|
|
||||||
$fields->payment_id = $payment->id;
|
$fields->payment_id = $payment->id;
|
||||||
@ -60,8 +59,7 @@ class PaymentCreatedActivity implements ShouldQueue
|
|||||||
$fields->company_id = $payment->company_id;
|
$fields->company_id = $payment->company_id;
|
||||||
$fields->activity_type_id = Activity::CREATE_PAYMENT;
|
$fields->activity_type_id = Activity::CREATE_PAYMENT;
|
||||||
|
|
||||||
if (count($invoices) == 0) {
|
$this->activity_repo->save($fields, $payment, $event->event_vars);
|
||||||
$this->activity_repo->save($fields, $payment, $event->event_vars);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ class PaymentRepository extends BaseRepository
|
|||||||
$paymentable->payment_id = $payment->id;
|
$paymentable->payment_id = $payment->id;
|
||||||
$paymentable->paymentable_id = $credit->id;
|
$paymentable->paymentable_id = $credit->id;
|
||||||
$paymentable->paymentable_type = Credit::class;
|
$paymentable->paymentable_type = Credit::class;
|
||||||
$paymentable->amount = $paid_invoice['amount'];
|
$paymentable->amount = $paid_credit['amount'];
|
||||||
$paymentable->save();
|
$paymentable->save();
|
||||||
|
|
||||||
$credit = $credit->service()->markSent()->save();
|
$credit = $credit->service()->markSent()->save();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user