1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 12:42:36 +01:00

Label credits created by deleting payments

This commit is contained in:
Hillel Coren 2016-12-06 12:04:30 +02:00
parent 018960105b
commit 7c4d0a2af5
3 changed files with 2 additions and 22 deletions

View File

@ -41,27 +41,7 @@ class CreditListener
$credit->client_id = $payment->client_id;
$credit->credit_date = Carbon::now()->toDateTimeString();
$credit->balance = $credit->amount = $payment->getCompletedAmount();
$credit->private_notes = $payment->transaction_reference;
$credit->save();
}
/**
* @param PaymentWasRefunded $event
*/
public function refundedPayment(PaymentWasRefunded $event)
{
$payment = $event->payment;
// if the payment was from a credit we need to refund the credit
if ($payment->payment_type_id != PAYMENT_TYPE_CREDIT) {
return;
}
$credit = Credit::createNew();
$credit->client_id = $payment->client_id;
$credit->credit_date = Carbon::now()->toDateTimeString();
$credit->balance = $credit->amount = $event->refundAmount;
$credit->private_notes = $payment->transaction_reference;
$credit->private_notes = trans('texts.refunded_credit_payment');
$credit->save();
}
}

View File

@ -112,7 +112,6 @@ class EventServiceProvider extends ServiceProvider {
'App\Events\PaymentWasRefunded' => [
'App\Listeners\ActivityListener@refundedPayment',
'App\Listeners\InvoiceListener@refundedPayment',
'App\Listeners\CreditListener@refundedPayment',
],
'App\Events\PaymentWasVoided' => [
'App\Listeners\ActivityListener@voidedPayment',

View File

@ -2258,6 +2258,7 @@ $LANG = array(
'redirect_url' => 'Redirect URL',
'redirect_url_help' => 'Optionally specify a URL to redirect to after a payment is made entered.',
'save_draft' => 'Save Draft',
'refunded_credit_payment' => 'Refunded credit payment',
);