update invoice section show download option

This commit is contained in:
Abhishek Mali
2025-12-18 12:45:26 +05:30
parent b9fb9455e7
commit d606156a6d
12 changed files with 179 additions and 121 deletions

View File

@@ -4,55 +4,30 @@ class InvoiceService {
final Dio dio;
InvoiceService(this.dio);
// -------------------------------------------------------
// ⭐ GET ALL INVOICES
// -------------------------------------------------------
Future<Map<String, dynamic>> getAllInvoices() async {
try {
final res = await dio.get("/user/invoices");
print("🔵 ALL INVOICES RESPONSE:");
print(res.data);
return Map<String, dynamic>.from(res.data);
} catch (e) {
print("❌ ERROR (All Invoices): $e");
return {"success": false, "message": e.toString()};
}
}
// -------------------------------------------------------
// ⭐ GET INSTALLMENTS
// -------------------------------------------------------
Future<Map<String, dynamic>> getInstallments(int invoiceId) async {
try {
final res =
await dio.get("/user/invoice/$invoiceId/installments");
print("🔵 INSTALLMENTS RESPONSE:");
print(res.data);
final res = await dio.get("/user/invoice/$invoiceId/installments");
return Map<String, dynamic>.from(res.data);
} catch (e) {
print("❌ ERROR (Installments): $e");
return {"success": false, "message": e.toString()};
}
}
// -------------------------------------------------------
// ⭐ GET FULL INVOICE DETAILS (PRINT JSON HERE)
// -------------------------------------------------------
/// 🔵 NEW FUNCTION — Fetch Full Invoice Details
Future<Map<String, dynamic>> getInvoiceDetails(int invoiceId) async {
try {
final res = await dio.get("/user/invoice/$invoiceId/details");
print("👇👇👇 INVOICE API RESPONSE START 👇👇👇");
print(res.data); // <-- THIS IS WHAT YOU NEED
print("👆👆👆 INVOICE API RESPONSE END 👆👆👆");
return Map<String, dynamic>.from(res.data);
} catch (e) {
print("❌ ERROR (Invoice Details): $e");
return {"success": false, "message": e.toString()};
}
}