added needed vaiables for employee selector

This commit is contained in:
Manish 2025-11-24 15:10:31 +05:30
parent 38626ebef0
commit aece165c38

View File

@ -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/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/expense_category_model.dart';
import 'package:on_field_work/model/finance/currency_list_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 { class AddPaymentRequestController extends GetxController {
// Loading States // Loading States
@ -32,7 +33,7 @@ class AddPaymentRequestController extends GetxController {
// Selected Values // Selected Values
final selectedProject = Rx<Map<String, dynamic>?>(null); final selectedProject = Rx<Map<String, dynamic>?>(null);
final selectedCategory = Rx<ExpenseCategory?>(null); final selectedCategory = Rx<ExpenseCategory?>(null);
final selectedPayee = ''.obs; final selectedPayee = Rx<EmployeeModel?>(null);
final selectedCurrency = Rx<Currency?>(null); final selectedCurrency = Rx<Currency?>(null);
final isAdvancePayment = false.obs; final isAdvancePayment = false.obs;
final selectedDueDate = Rx<DateTime?>(null); final selectedDueDate = Rx<DateTime?>(null);
@ -184,7 +185,7 @@ class AddPaymentRequestController extends GetxController {
selectedProject.value = project; selectedProject.value = project;
void selectCategory(ExpenseCategory category) => void selectCategory(ExpenseCategory category) =>
selectedCategory.value = 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 selectCurrency(Currency currency) => selectedCurrency.value = currency;
void addAttachment(File file) => attachments.add(file); void addAttachment(File file) => attachments.add(file);
@ -268,7 +269,7 @@ class AddPaymentRequestController extends GetxController {
"amount": double.tryParse(amountController.text.trim()) ?? 0, "amount": double.tryParse(amountController.text.trim()) ?? 0,
"currencyId": selectedCurrency.value?.id ?? '', "currencyId": selectedCurrency.value?.id ?? '',
"description": descriptionController.text.trim(), "description": descriptionController.text.trim(),
"payee": selectedPayee.value, "payee": selectedPayee.value?.id ?? "",
"dueDate": selectedDueDate.value?.toIso8601String(), "dueDate": selectedDueDate.value?.toIso8601String(),
"isAdvancePayment": isAdvancePayment.value, "isAdvancePayment": isAdvancePayment.value,
"billAttachments": billAttachments.map((a) { "billAttachments": billAttachments.map((a) {
@ -337,7 +338,7 @@ class AddPaymentRequestController extends GetxController {
"amount": double.tryParse(amountController.text.trim()) ?? 0, "amount": double.tryParse(amountController.text.trim()) ?? 0,
"currencyId": selectedCurrency.value?.id ?? '', "currencyId": selectedCurrency.value?.id ?? '',
"description": descriptionController.text.trim(), "description": descriptionController.text.trim(),
"payee": selectedPayee.value, "payee": selectedPayee.value?.id ?? "",
"dueDate": selectedDueDate.value?.toIso8601String(), "dueDate": selectedDueDate.value?.toIso8601String(),
"isAdvancePayment": isAdvancePayment.value, "isAdvancePayment": isAdvancePayment.value,
"billAttachments": billAttachments.map((a) { "billAttachments": billAttachments.map((a) {
@ -388,7 +389,7 @@ class AddPaymentRequestController extends GetxController {
return _errorSnackbar("Please select a project"); return _errorSnackbar("Please select a project");
if (selectedCategory.value == null) if (selectedCategory.value == null)
return _errorSnackbar("Please select a category"); return _errorSnackbar("Please select a category");
if (selectedPayee.value.isEmpty) if (selectedPayee.value == null)
return _errorSnackbar("Please select a payee"); return _errorSnackbar("Please select a payee");
if (selectedCurrency.value == null) if (selectedCurrency.value == null)
return _errorSnackbar("Please select currency"); return _errorSnackbar("Please select currency");
@ -408,7 +409,7 @@ class AddPaymentRequestController extends GetxController {
descriptionController.clear(); descriptionController.clear();
selectedProject.value = null; selectedProject.value = null;
selectedCategory.value = null; selectedCategory.value = null;
selectedPayee.value = ''; selectedPayee.value = null;
selectedCurrency.value = null; selectedCurrency.value = null;
isAdvancePayment.value = false; isAdvancePayment.value = false;
attachments.clear(); attachments.clear();