From 9d3bb1a166e4d20846008e69cab6bba0adbf7c42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Batuhan=20Ba=C5=9F?= Date: Wed, 7 Nov 2018 13:25:01 +0300 Subject: [PATCH] Transaction Test --- tests/Feature/Banking/Transaction.php | 92 +++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 tests/Feature/Banking/Transaction.php diff --git a/tests/Feature/Banking/Transaction.php b/tests/Feature/Banking/Transaction.php new file mode 100644 index 000000000..75465d7f4 --- /dev/null +++ b/tests/Feature/Banking/Transaction.php @@ -0,0 +1,92 @@ +get(); + + foreach ($bills as $bill) { + $bill_payments = $bill->payments; + + if ($bill_payments) { + foreach ($bill_payments as $bill_payment) { + $transactions[] = (object) [ + 'date' => $bill_payment->paid_at, + 'account' => $bill_payment->account->name, + 'type' => trans('invoices.status.partial'), + 'category' => trans_choice('general.invoices', 1), + 'description' => $bill_payment->description, + 'amount' => $bill_payment->amount, + 'currency_code' => $bill_payment->currency_code, + ]; + } + } + } + + $payments = Payment::where('vendor_id', $user_id)->get(); + + foreach ($payments as $payment) { + $transactions[] = (object) [ + 'date' => $payment->paid_at, + 'account' => $payment->account->name, + 'type' => 'Expense', + 'category' => $payment->category->name, + 'description' => $payment->description, + 'amount' => $payment->amount, + 'currency_code' => $payment->currency_code, + ]; + } + break; + case 'revenues': + $invoices = Invoice::where('customer_id', $user_id)->get(); + + foreach ($invoices as $invoice) { + $invoice_payments = $invoice->payments; + + if ($invoice_payments) { + foreach ($invoice_payments as $invoice_payment) { + $transactions[] = (object) [ + 'date' => $invoice_payment->paid_at, + 'account' => $invoice_payment->account->name, + 'type' => trans('invoices.status.partial'), + 'category' => trans_choice('general.invoices', 1), + 'description' => $invoice_payment->description, + 'amount' => $invoice_payment->amount, + 'currency_code' => $invoice_payment->currency_code, + ]; + } + } + } + + $revenues = Revenue::where('customer_id', $user_id)->get(); + + foreach ($revenues as $revenue) { + $transactions[] = (object) [ + 'date' => $revenue->paid_at, + 'account' => $revenue->account->name, + 'type' => trans_choice('general.payments', 1), + 'category' => $revenue->category->name, + 'description' => $revenue->description, + 'amount' => $revenue->amount, + 'currency_code' => $revenue->currency_code, + ]; + } + break; + } + + return $transactions; + } +}