added needed vaiables for employee selector
This commit is contained in:
parent
38626ebef0
commit
aece165c38
@ -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);
|
||||||
@ -161,7 +162,7 @@ class AddPaymentRequestController extends GetxController {
|
|||||||
try {
|
try {
|
||||||
final pickedFile = await _picker.pickImage(source: ImageSource.camera);
|
final pickedFile = await _picker.pickImage(source: ImageSource.camera);
|
||||||
if (pickedFile != null) {
|
if (pickedFile != null) {
|
||||||
isProcessingAttachment.value = true;
|
isProcessingAttachment.value = true;
|
||||||
File imageFile = File(pickedFile.path);
|
File imageFile = File(pickedFile.path);
|
||||||
|
|
||||||
// Add timestamp to the captured image
|
// Add timestamp to the captured image
|
||||||
@ -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();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user