From be2f97cc0ed80c885ce3c0f14be325c53ff79ce1 Mon Sep 17 00:00:00 2001 From: Vaibhav Surve Date: Tue, 11 Nov 2025 19:34:54 +0530 Subject: [PATCH] fixed the make expense button display issue on creaying expense also --- .../payment_request_detail_controller.dart | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/lib/controller/finance/payment_request_detail_controller.dart b/lib/controller/finance/payment_request_detail_controller.dart index 65e455c..b0d17fb 100644 --- a/lib/controller/finance/payment_request_detail_controller.dart +++ b/lib/controller/finance/payment_request_detail_controller.dart @@ -333,32 +333,35 @@ class PaymentRequestDetailController extends GetxController { isSubmitting.value = true; try { - // Prepare attachments with all required fields - final attachmentsPayload = attachments.map((file) { - final bytes = file.readAsBytesSync(); - final mimeType = - lookupMimeType(file.path) ?? 'application/octet-stream'; - - return { - "fileName": file.path.split('/').last, - "base64Data": base64Encode(bytes), - "contentType": mimeType, - "description": "", - "fileSize": bytes.length, - "isActive": true, - }; - }).toList(); - - // Call API - return await ApiService.createExpenseForPRApi( + // prepare attachments + final success = await ApiService.createExpenseForPRApi( paymentModeId: selectedPaymentMode.value!.id, location: locationController.text, gstNumber: gstNumberController.text, paymentRequestId: _requestId, - billAttachments: attachmentsPayload, + billAttachments: attachments.map((file) { + final bytes = file.readAsBytesSync(); + final mimeType = + lookupMimeType(file.path) ?? 'application/octet-stream'; + return { + "fileName": file.path.split('/').last, + "base64Data": base64Encode(bytes), + "contentType": mimeType, + "description": "", + "fileSize": bytes.length, + "isActive": true, + }; + }).toList(), statusId: statusId, comment: comment ?? '', ); + + if (success) { + // Refresh the payment request details so the UI updates + await fetchPaymentRequestDetail(); + } + + return success; } finally { isSubmitting.value = false; }