mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-09-20 08:21:34 +02:00
Transaction logs
This commit is contained in:
parent
b1887f8fa8
commit
7cd6327649
@ -50,19 +50,19 @@ class TransactionLog implements ShouldQueue
|
||||
private $event_transformer;
|
||||
|
||||
private array $transformer_array = [
|
||||
TransactionEvent::INVOICE_MARK_PAID => MarkPaidTransaction::class,
|
||||
TransactionEvent::INVOICE_UPDATED => InvoiceUpdatedTransaction::class,
|
||||
TransactionEvent::INVOICE_DELETED => InvoiceDeletedTransaction::class,
|
||||
TransactionEvent::INVOICE_MARK_PAID => MarkPaidTransaction::class, //
|
||||
TransactionEvent::INVOICE_UPDATED => InvoiceUpdatedTransaction::class, //
|
||||
TransactionEvent::INVOICE_DELETED => InvoiceDeletedTransaction::class, //
|
||||
TransactionEvent::INVOICE_PAYMENT_APPLIED => InvoicePaymentTransaction::class,
|
||||
TransactionEvent::INVOICE_CANCELLED => InvoiceCancelledTransaction::class,
|
||||
TransactionEvent::INVOICE_REVERSED => InvoiceReversalTransaction::class,
|
||||
TransactionEvent::INVOICE_FEE_APPLIED => InvoiceFeeAppliedTransaction::class,
|
||||
TransactionEvent::INVOICE_REVERSED => InvoiceReversalTransaction::class, //
|
||||
TransactionEvent::INVOICE_FEE_APPLIED => InvoiceFeeAppliedTransaction::class, //
|
||||
TransactionEvent::PAYMENT_MADE => PaymentMadeTransaction::class,
|
||||
TransactionEvent::GATEWAY_PAYMENT_MADE => GatewayPaymentMadeTransaction::class,
|
||||
TransactionEvent::PAYMENT_APPLIED => PaymentAppliedTransaction::class,
|
||||
TransactionEvent::PAYMENT_REFUND => PaymentRefundedTransaction::class,
|
||||
TransactionEvent::PAYMENT_FAILED => PaymentFailedTransaction::class,
|
||||
TransactionEvent::PAYMENT_DELETED => PaymentDeletedTransaction::class,
|
||||
TransactionEvent::PAYMENT_DELETED => PaymentDeletedTransaction::class, //
|
||||
TransactionEvent::CLIENT_STATUS => ClientStatusTransaction::class,
|
||||
];
|
||||
|
||||
|
@ -53,7 +53,7 @@ class RefundPayment
|
||||
|
||||
public function run()
|
||||
{
|
||||
return $this->calculateTotalRefund() //sets amount for the refund (needed if we are refunding multiple invoices in one payment)
|
||||
$this->payment = $this->calculateTotalRefund() //sets amount for the refund (needed if we are refunding multiple invoices in one payment)
|
||||
->setStatus() //sets status of payment
|
||||
//->reversePayment()
|
||||
//->buildCreditNote() //generate the credit note
|
||||
@ -64,7 +64,6 @@ class RefundPayment
|
||||
->processGatewayRefund() //process the gateway refund if needed
|
||||
->save();
|
||||
|
||||
|
||||
$transaction = [
|
||||
'invoice' => [],
|
||||
'payment' => $this->payment->transaction_event(),
|
||||
@ -74,6 +73,8 @@ class RefundPayment
|
||||
];
|
||||
|
||||
TransactionLog::dispatch(TransactionEvent::PAYMENT_REFUND, $transaction, $this->payment->company->db);
|
||||
|
||||
return $this->payment;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -269,27 +270,51 @@ class RefundPayment
|
||||
|
||||
$adjustment_amount += $refunded_invoice['amount'];
|
||||
$client->balance += $refunded_invoice['amount'];
|
||||
//$client->paid_to_date -= $refunded_invoice['amount'];//todo refund balancing
|
||||
$client->save();
|
||||
|
||||
//todo adjust ledger balance here? or after and reference the credit and its total
|
||||
|
||||
$transaction = [
|
||||
'invoice' => $invoice->transaction_event(),
|
||||
'payment' => [],
|
||||
'client' => $client->transaction_event(),
|
||||
'credit' => [],
|
||||
'metadata' => [],
|
||||
];
|
||||
|
||||
TransactionLog::dispatch(TransactionEvent::PAYMENT_REFUND, $transaction, $invoice->company->db);
|
||||
|
||||
}
|
||||
|
||||
// $ledger_string = "Refund for Invoice {$invoice->number} for amount " . $refunded_invoice['amount']; //todo
|
||||
|
||||
// $this->credit_note->ledger()->updateCreditBalance($adjustment_amount, $ledger_string);
|
||||
|
||||
$client = $this->payment->client->fresh();
|
||||
|
||||
$client = $this->payment->client->fresh();
|
||||
$client->service()->updatePaidToDate(-1 * $refunded_invoice['amount'])->save();
|
||||
|
||||
|
||||
$transaction = [
|
||||
'invoice' => [],
|
||||
'payment' => [],
|
||||
'client' => $client->transaction_event(),
|
||||
'credit' => [],
|
||||
'metadata' => [],
|
||||
];
|
||||
|
||||
TransactionLog::dispatch(TransactionEvent::PAYMENT_REFUND, $transaction, $client->company->db);
|
||||
|
||||
}
|
||||
else{
|
||||
//if we are refunding and no payments have been tagged, then we need to decrement the client->paid_to_date by the total refund amount.
|
||||
|
||||
$client = $this->payment->client->fresh();
|
||||
|
||||
$client->service()->updatePaidToDate(-1 * $this->total_refund)->save();
|
||||
|
||||
$transaction = [
|
||||
'invoice' => [],
|
||||
'payment' => [],
|
||||
'client' => $client->transaction_event(),
|
||||
'credit' => [],
|
||||
'metadata' => [],
|
||||
];
|
||||
|
||||
TransactionLog::dispatch(TransactionEvent::PAYMENT_REFUND, $transaction, $client->company->db);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
Loading…
Reference in New Issue
Block a user