From aece165c3892e2b9d7218dfeaa8f0f91376ecfec Mon Sep 17 00:00:00 2001 From: Manish Date: Mon, 24 Nov 2025 15:10:31 +0530 Subject: [PATCH] added needed vaiables for employee selector --- .../finance/add_payment_request_controller.dart | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/controller/finance/add_payment_request_controller.dart b/lib/controller/finance/add_payment_request_controller.dart index e7688b9..38afe15 100644 --- a/lib/controller/finance/add_payment_request_controller.dart +++ b/lib/controller/finance/add_payment_request_controller.dart @@ -14,6 +14,7 @@ import 'package:on_field_work/helpers/widgets/my_snackbar.dart'; import 'package:on_field_work/helpers/widgets/time_stamp_image_helper.dart'; import 'package:on_field_work/model/finance/expense_category_model.dart'; import 'package:on_field_work/model/finance/currency_list_model.dart'; +import 'package:on_field_work/model/employees/employee_model.dart'; class AddPaymentRequestController extends GetxController { // Loading States @@ -32,7 +33,7 @@ class AddPaymentRequestController extends GetxController { // Selected Values final selectedProject = Rx?>(null); final selectedCategory = Rx(null); - final selectedPayee = ''.obs; + final selectedPayee = Rx(null); final selectedCurrency = Rx(null); final isAdvancePayment = false.obs; final selectedDueDate = Rx(null); @@ -161,7 +162,7 @@ class AddPaymentRequestController extends GetxController { try { final pickedFile = await _picker.pickImage(source: ImageSource.camera); if (pickedFile != null) { - isProcessingAttachment.value = true; + isProcessingAttachment.value = true; File imageFile = File(pickedFile.path); // Add timestamp to the captured image @@ -184,7 +185,7 @@ class AddPaymentRequestController extends GetxController { selectedProject.value = project; void selectCategory(ExpenseCategory category) => selectedCategory.value = category; - void selectPayee(String payee) => selectedPayee.value = payee; + void selectPayee(EmployeeModel payee) => selectedPayee.value = payee; void selectCurrency(Currency currency) => selectedCurrency.value = currency; void addAttachment(File file) => attachments.add(file); @@ -268,7 +269,7 @@ class AddPaymentRequestController extends GetxController { "amount": double.tryParse(amountController.text.trim()) ?? 0, "currencyId": selectedCurrency.value?.id ?? '', "description": descriptionController.text.trim(), - "payee": selectedPayee.value, + "payee": selectedPayee.value?.id ?? "", "dueDate": selectedDueDate.value?.toIso8601String(), "isAdvancePayment": isAdvancePayment.value, "billAttachments": billAttachments.map((a) { @@ -337,7 +338,7 @@ class AddPaymentRequestController extends GetxController { "amount": double.tryParse(amountController.text.trim()) ?? 0, "currencyId": selectedCurrency.value?.id ?? '', "description": descriptionController.text.trim(), - "payee": selectedPayee.value, + "payee": selectedPayee.value?.id ?? "", "dueDate": selectedDueDate.value?.toIso8601String(), "isAdvancePayment": isAdvancePayment.value, "billAttachments": billAttachments.map((a) { @@ -388,7 +389,7 @@ class AddPaymentRequestController extends GetxController { return _errorSnackbar("Please select a project"); if (selectedCategory.value == null) return _errorSnackbar("Please select a category"); - if (selectedPayee.value.isEmpty) + if (selectedPayee.value == null) return _errorSnackbar("Please select a payee"); if (selectedCurrency.value == null) return _errorSnackbar("Please select currency"); @@ -408,7 +409,7 @@ class AddPaymentRequestController extends GetxController { descriptionController.clear(); selectedProject.value = null; selectedCategory.value = null; - selectedPayee.value = ''; + selectedPayee.value = null; selectedCurrency.value = null; isAdvancePayment.value = false; attachments.clear();