Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 49 |
|
0.00% |
0 / 14 |
CRAP | |
0.00% |
0 / 1 |
| ReportController | |
0.00% |
0 / 49 |
|
0.00% |
0 / 14 |
342 | |
0.00% |
0 / 1 |
| sale_report | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
| sale_report_search | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| customer_report | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| customer_report_order_list | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| customer_order_details | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| report_purchases | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| suppliers_purchase_list | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| supplier_purchases_list | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| supplier_purchases_details | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| supplier_report | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| customer_due_list | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| customer_due_payment | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
12 | |||
| customer_due_payment_update | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| supplier_purchase_details | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Controllers\admin; |
| 4 | |
| 5 | use App\Http\Controllers\Controller; |
| 6 | use App\Models\admin\Customer; |
| 7 | use App\Models\admin\Purchase; |
| 8 | use App\Models\admin\Sale; |
| 9 | use App\Models\admin\Supplier; |
| 10 | use App\Models\Order; |
| 11 | use App\Models\PaymentType; |
| 12 | use App\Services\Location\BranchContext; |
| 13 | use Illuminate\Http\Request; |
| 14 | |
| 15 | class ReportController extends Controller |
| 16 | { |
| 17 | /* |
| 18 | * customer Report method start |
| 19 | */ |
| 20 | |
| 21 | // total sale report method |
| 22 | public function sale_report(Request $request) |
| 23 | { |
| 24 | |
| 25 | if (isset($request->from) && ! empty($request->from)) { |
| 26 | |
| 27 | $data['sales'] = Sale::getSearcheData($request->only(['from', 'to', 'customer_id'])); |
| 28 | $data['customers'] = Customer::getAll(false, true); |
| 29 | } else { |
| 30 | $data['sales'] = Sale::getAll('Desc'); |
| 31 | $data['customers'] = Customer::getAll(false, true); |
| 32 | } |
| 33 | |
| 34 | return view('admin.report.sale_report')->with($data); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Bla bla bla bla |
| 39 | * |
| 40 | * @incomingParams $from |
| 41 | * |
| 42 | * */ |
| 43 | public function sale_report_search(Request $request) |
| 44 | { |
| 45 | |
| 46 | $data['sales'] = Sale::getSearcheData($request->all()); |
| 47 | $data['customers'] = Customer::getAll(false, true); |
| 48 | |
| 49 | return view('admin.report.sale_report')->with($data); |
| 50 | } |
| 51 | |
| 52 | // customers order list |
| 53 | public function customer_report() |
| 54 | { |
| 55 | $data['customers'] = Customer::getAll('true'); |
| 56 | |
| 57 | return view('admin.report.customer')->with($data); |
| 58 | } |
| 59 | |
| 60 | /* customer order list */ |
| 61 | public function customer_report_order_list($customer_id) |
| 62 | { |
| 63 | $data['customer'] = Customer::getById($customer_id, true); |
| 64 | |
| 65 | return view('admin.report.customer.order_list')->with($data); |
| 66 | } |
| 67 | |
| 68 | /* customer order details start */ |
| 69 | public function customer_order_details($sale_id) |
| 70 | { |
| 71 | $data['order_details'] = Sale::getById($sale_id, true); |
| 72 | |
| 73 | return view('admin.report.customer.order_details')->with($data); |
| 74 | } |
| 75 | /* customer order details end */ |
| 76 | /* |
| 77 | * customer Report method start |
| 78 | */ |
| 79 | |
| 80 | /* |
| 81 | * supplier report method start |
| 82 | * */ |
| 83 | // purchase all report |
| 84 | public function report_purchases() |
| 85 | { |
| 86 | // $data['purchases'] = Purchase:: |
| 87 | return view('admin.report.purchase_report'); |
| 88 | } |
| 89 | |
| 90 | // suppliers purchase list report |
| 91 | public function suppliers_purchase_list() |
| 92 | { |
| 93 | $data['suppliers'] = Supplier::getAll(false, false, true); |
| 94 | |
| 95 | return view('admin.report.supplier.suppliers_purchases_list')->with($data); |
| 96 | } |
| 97 | |
| 98 | // single supplier purchases list |
| 99 | public function supplier_purchases_list($supplier_id) |
| 100 | { |
| 101 | $data['supplier'] = Supplier::findById($supplier_id, true); |
| 102 | |
| 103 | return view('admin.report.supplier.supplier_purchases_list')->with($data); |
| 104 | } |
| 105 | |
| 106 | // supplier purchase details |
| 107 | public function supplier_purchases_details($purchase_id) |
| 108 | { |
| 109 | $data['purchases'] = Purchase::query() |
| 110 | ->with(['supplier', 'purchase_details', 'purchase_payment', 'user']) |
| 111 | ->where('id', '=', $purchase_id) |
| 112 | ->first(); |
| 113 | |
| 114 | return view('admin.report.supplier.supplier_purchases_details')->with($data); |
| 115 | } |
| 116 | /* |
| 117 | * supplier Report method end |
| 118 | */ |
| 119 | |
| 120 | // supplier All time total purchase report |
| 121 | public function supplier_report() |
| 122 | { |
| 123 | return view('admin.report.supplier_report'); |
| 124 | } |
| 125 | /* |
| 126 | * supplier report end |
| 127 | */ |
| 128 | |
| 129 | // show customer all due list |
| 130 | public function customer_due_list($customer_id) |
| 131 | { |
| 132 | return redirect()->route('admin.customer.due.payment', ['customer_id' => $customer_id]); |
| 133 | } |
| 134 | |
| 135 | public function customer_due_payment(?int $id = null, ?int $customer_id = null) |
| 136 | { |
| 137 | $branchContext = app(BranchContext::class); |
| 138 | $selectedOrder = $id |
| 139 | ? $branchContext->scope(Order::query())->with(['customer', 'payment'])->findOrFail($id) |
| 140 | : null; |
| 141 | $customerId = $customer_id ?: $selectedOrder?->customer_id; |
| 142 | $customer = Customer::query()->findOrFail($customerId); |
| 143 | $orders = $branchContext->scope(Order::query()) |
| 144 | ->where('customer_id', $customer->id) |
| 145 | ->with('payment') |
| 146 | ->latest() |
| 147 | ->get() |
| 148 | ->filter(fn (Order $order) => $order->grandTotal() > (float) $order->payment->sum('paid')) |
| 149 | ->values(); |
| 150 | |
| 151 | return view('admin.payment.customer', [ |
| 152 | 'customer' => $customer, |
| 153 | 'orders' => $orders, |
| 154 | 'selectedOrder' => $selectedOrder, |
| 155 | 'paymentTypes' => PaymentType::query()->orderBy('name')->pluck('name', 'id'), |
| 156 | ]); |
| 157 | } |
| 158 | |
| 159 | public function customer_due_payment_update($id) |
| 160 | { |
| 161 | return redirect()->route('admin.customer.due.payment', ['id' => $id]) |
| 162 | ->with('error', 'Use the payment form to record this due payment.'); |
| 163 | } |
| 164 | |
| 165 | /* |
| 166 | * Supplier Report Start |
| 167 | */ |
| 168 | |
| 169 | // single supplier purchase list details |
| 170 | public function supplier_purchase_details() |
| 171 | { |
| 172 | return 'purchase details'; |
| 173 | } |
| 174 | } |