fixed the make expense button display issue on creaying expense also

This commit is contained in:
Vaibhav Surve 2025-11-11 19:34:54 +05:30
parent 44bbbf9bfb
commit be2f97cc0e

View File

@ -333,12 +333,16 @@ class PaymentRequestDetailController extends GetxController {
isSubmitting.value = true; isSubmitting.value = true;
try { try {
// Prepare attachments with all required fields // prepare attachments
final attachmentsPayload = attachments.map((file) { final success = await ApiService.createExpenseForPRApi(
paymentModeId: selectedPaymentMode.value!.id,
location: locationController.text,
gstNumber: gstNumberController.text,
paymentRequestId: _requestId,
billAttachments: attachments.map((file) {
final bytes = file.readAsBytesSync(); final bytes = file.readAsBytesSync();
final mimeType = final mimeType =
lookupMimeType(file.path) ?? 'application/octet-stream'; lookupMimeType(file.path) ?? 'application/octet-stream';
return { return {
"fileName": file.path.split('/').last, "fileName": file.path.split('/').last,
"base64Data": base64Encode(bytes), "base64Data": base64Encode(bytes),
@ -347,18 +351,17 @@ class PaymentRequestDetailController extends GetxController {
"fileSize": bytes.length, "fileSize": bytes.length,
"isActive": true, "isActive": true,
}; };
}).toList(); }).toList(),
// Call API
return await ApiService.createExpenseForPRApi(
paymentModeId: selectedPaymentMode.value!.id,
location: locationController.text,
gstNumber: gstNumberController.text,
paymentRequestId: _requestId,
billAttachments: attachmentsPayload,
statusId: statusId, statusId: statusId,
comment: comment ?? '', comment: comment ?? '',
); );
if (success) {
// Refresh the payment request details so the UI updates
await fetchPaymentRequestDetail();
}
return success;
} finally { } finally {
isSubmitting.value = false; isSubmitting.value = false;
} }