json(['error' => false, 'data' => $this->billingService->getInvoices($uuid)]); } public function updateInvoice(string $uuid, int $invoiceId, Request $request): JsonResponse { $data = $request->validate([ 'invoice_number' => 'nullable|string|max:50', 'status' => 'nullable|integer|in:1,2,3,4,5', 'payment_method' => 'nullable|in:transfer,balance', 'date' => 'nullable|date', 'due_date' => 'nullable|date', 'date_paid' => 'nullable|date', 'note' => 'nullable|string', 'sub_total' => 'nullable|integer|min:0', 'tax' => 'nullable|integer|min:0', 'total' => 'nullable|integer|min:0', ]); $invoice = $this->billingService->updateInvoice($uuid, $invoiceId, $data); return response()->json(['error' => false, 'message' => 'Đã cập nhật hóa đơn', 'data' => $invoice]); } public function getTransactions(string $uuid): JsonResponse { return response()->json(['error' => false, 'data' => $this->billingService->getTransactions($uuid)]); } public function updateTransaction(string $uuid, int $transactionId, Request $request): JsonResponse { $data = $request->validate([ 'trans' => 'nullable|string|max:255', 'note' => 'nullable|string', 'type' => 'nullable|string|max:50', 'amount' => 'nullable|integer', ]); $transaction = $this->billingService->updateTransaction($uuid, $transactionId, $data); return response()->json(['error' => false, 'message' => 'Đã cập nhật giao dịch', 'data' => $transaction]); } public function getOrders(string $uuid): JsonResponse { return response()->json(['error' => false, 'data' => $this->billingService->getOrders($uuid)]); } public function updateOrder(string $uuid, int $orderId, Request $request): JsonResponse { $data = $request->validate([ 'order_num' => 'nullable|string|max:255', 'status' => 'nullable|integer|in:0,1,2,3', 'payment_method' => 'nullable|in:transfer,balance', 'date' => 'nullable|date', 'sub_total' => 'nullable|integer|min:0', 'discount_amount' => 'nullable|integer|min:0', 'total' => 'nullable|integer|min:0', ]); $order = $this->billingService->updateOrder($uuid, $orderId, $data); return response()->json(['error' => false, 'message' => 'Đã cập nhật đơn hàng', 'data' => $order]); } }