added validation for payment request in and expense reumbersemrnt bottomsheet
This commit is contained in:
parent
be2f97cc0e
commit
5db53c29df
@ -142,6 +142,10 @@ class ExpenseDetailController extends GetxController {
|
|||||||
required String reimburseDate,
|
required String reimburseDate,
|
||||||
required String reimburseById,
|
required String reimburseById,
|
||||||
required String statusId,
|
required String statusId,
|
||||||
|
double? baseAmount,
|
||||||
|
double? taxAmount,
|
||||||
|
double? tdsPercent,
|
||||||
|
double? netPayable,
|
||||||
}) async {
|
}) async {
|
||||||
final success = await _apiCallWrapper(
|
final success = await _apiCallWrapper(
|
||||||
() => ApiService.updateExpenseStatusApi(
|
() => ApiService.updateExpenseStatusApi(
|
||||||
@ -151,13 +155,16 @@ class ExpenseDetailController extends GetxController {
|
|||||||
reimburseTransactionId: reimburseTransactionId,
|
reimburseTransactionId: reimburseTransactionId,
|
||||||
reimburseDate: reimburseDate,
|
reimburseDate: reimburseDate,
|
||||||
reimbursedById: reimburseById,
|
reimbursedById: reimburseById,
|
||||||
|
baseAmount: baseAmount,
|
||||||
|
taxAmount: taxAmount,
|
||||||
|
tdsPercent: tdsPercent,
|
||||||
|
netPayable: netPayable,
|
||||||
),
|
),
|
||||||
"submit reimbursement",
|
"submit reimbursement",
|
||||||
);
|
);
|
||||||
|
|
||||||
if (success == true) {
|
if (success == true) {
|
||||||
// Explicitly check for true as _apiCallWrapper returns T?
|
await fetchExpenseDetails();
|
||||||
await fetchExpenseDetails(); // Refresh details after successful update
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
errorMessage.value = "Failed to submit reimbursement.";
|
errorMessage.value = "Failed to submit reimbursement.";
|
||||||
|
|||||||
@ -1705,34 +1705,32 @@ class ApiService {
|
|||||||
String? reimburseTransactionId,
|
String? reimburseTransactionId,
|
||||||
String? reimburseDate,
|
String? reimburseDate,
|
||||||
String? reimbursedById,
|
String? reimbursedById,
|
||||||
|
double? baseAmount,
|
||||||
|
double? taxAmount,
|
||||||
|
double? tdsPercent,
|
||||||
|
double? netPayable,
|
||||||
}) async {
|
}) async {
|
||||||
final Map<String, dynamic> payload = {
|
final Map<String, dynamic> payload = {
|
||||||
"expenseId": expenseId,
|
"expenseId": expenseId,
|
||||||
"statusId": statusId,
|
"statusId": statusId,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (comment != null) {
|
if (comment != null) payload["comment"] = comment;
|
||||||
payload["comment"] = comment;
|
if (reimburseTransactionId != null)
|
||||||
}
|
|
||||||
if (reimburseTransactionId != null) {
|
|
||||||
payload["reimburseTransactionId"] = reimburseTransactionId;
|
payload["reimburseTransactionId"] = reimburseTransactionId;
|
||||||
}
|
if (reimburseDate != null) payload["reimburseDate"] = reimburseDate;
|
||||||
if (reimburseDate != null) {
|
if (reimbursedById != null) payload["reimburseById"] = reimbursedById;
|
||||||
payload["reimburseDate"] = reimburseDate;
|
if (baseAmount != null) payload["baseAmount"] = baseAmount;
|
||||||
}
|
if (taxAmount != null) payload["taxAmount"] = taxAmount;
|
||||||
if (reimbursedById != null) {
|
if (tdsPercent != null) payload["tdsPercent"] = tdsPercent;
|
||||||
payload["reimburseById"] = reimbursedById;
|
if (netPayable != null) payload["netPayable"] = netPayable;
|
||||||
}
|
|
||||||
|
|
||||||
const endpoint = ApiEndpoints.updateExpenseStatus;
|
const endpoint = ApiEndpoints.updateExpenseStatus;
|
||||||
logSafe("Updating expense status with payload: $payload");
|
logSafe("Updating expense status with payload: $payload");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final response = await _postRequest(
|
final response =
|
||||||
endpoint,
|
await _postRequest(endpoint, payload, customTimeout: extendedTimeout);
|
||||||
payload,
|
|
||||||
customTimeout: extendedTimeout,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
logSafe("Update expense status failed: null response",
|
logSafe("Update expense status failed: null response",
|
||||||
|
|||||||
@ -20,6 +20,10 @@ class ReimbursementBottomSheet extends StatefulWidget {
|
|||||||
required String reimburseDate,
|
required String reimburseDate,
|
||||||
required String reimburseById,
|
required String reimburseById,
|
||||||
required String statusId,
|
required String statusId,
|
||||||
|
required double baseAmount,
|
||||||
|
required double taxAmount,
|
||||||
|
required double tdsPercent,
|
||||||
|
required double netPayable,
|
||||||
}) onSubmit;
|
}) onSubmit;
|
||||||
|
|
||||||
const ReimbursementBottomSheet({
|
const ReimbursementBottomSheet({
|
||||||
@ -41,15 +45,44 @@ class _ReimbursementBottomSheetState extends State<ReimbursementBottomSheet> {
|
|||||||
|
|
||||||
final TextEditingController commentCtrl = TextEditingController();
|
final TextEditingController commentCtrl = TextEditingController();
|
||||||
final TextEditingController txnCtrl = TextEditingController();
|
final TextEditingController txnCtrl = TextEditingController();
|
||||||
|
final TextEditingController baseAmountCtrl = TextEditingController();
|
||||||
|
final TextEditingController gstAmountCtrl = TextEditingController();
|
||||||
|
final TextEditingController tdsCtrl = TextEditingController(text: '0');
|
||||||
|
|
||||||
final RxString dateStr = ''.obs;
|
final RxString dateStr = ''.obs;
|
||||||
|
final RxDouble tdsAmount = 0.0.obs;
|
||||||
|
final RxDouble netPayable = 0.0.obs;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
baseAmountCtrl.addListener(_recalculate);
|
||||||
|
gstAmountCtrl.addListener(_recalculate);
|
||||||
|
tdsCtrl.addListener(_recalculate);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
commentCtrl.dispose();
|
commentCtrl.dispose();
|
||||||
txnCtrl.dispose();
|
txnCtrl.dispose();
|
||||||
|
baseAmountCtrl.dispose();
|
||||||
|
gstAmountCtrl.dispose();
|
||||||
|
tdsCtrl.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _recalculate() {
|
||||||
|
final double base = double.tryParse(baseAmountCtrl.text.trim()) ?? 0.0;
|
||||||
|
final double gst = double.tryParse(gstAmountCtrl.text.trim()) ?? 0.0;
|
||||||
|
final double tdsPercent = double.tryParse(tdsCtrl.text.trim()) ?? 0.0;
|
||||||
|
|
||||||
|
final double calculatedTds = (base * tdsPercent) / 100;
|
||||||
|
final double net = (base + gst) - calculatedTds;
|
||||||
|
|
||||||
|
tdsAmount.value = double.parse(calculatedTds.toStringAsFixed(2));
|
||||||
|
netPayable.value = double.parse(net.toStringAsFixed(2));
|
||||||
|
}
|
||||||
|
|
||||||
void _showEmployeeList() async {
|
void _showEmployeeList() async {
|
||||||
await showModalBottomSheet(
|
await showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
@ -67,7 +100,6 @@ class _ReimbursementBottomSheetState extends State<ReimbursementBottomSheet> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Optional cleanup
|
|
||||||
controller.employeeSearchController.clear();
|
controller.employeeSearchController.clear();
|
||||||
controller.employeeSearchResults.clear();
|
controller.employeeSearchResults.clear();
|
||||||
}
|
}
|
||||||
@ -94,6 +126,29 @@ class _ReimbursementBottomSheetState extends State<ReimbursementBottomSheet> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _readOnlyValueBox(String label, String value, Color color) {
|
||||||
|
return Container(
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: color.withOpacity(0.1),
|
||||||
|
border: Border.all(color: color.withOpacity(0.3)),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
MyText.labelMedium(label),
|
||||||
|
MyText.bodyMedium(
|
||||||
|
"₹$value",
|
||||||
|
color: color,
|
||||||
|
fontWeight: 700,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Obx(() {
|
return Obx(() {
|
||||||
@ -105,31 +160,73 @@ class _ReimbursementBottomSheetState extends State<ReimbursementBottomSheet> {
|
|||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
onSubmit: () async {
|
onSubmit: () async {
|
||||||
|
final expenseTransactionDateStr =
|
||||||
|
controller.expense.value?.transactionDate;
|
||||||
|
DateTime? expenseTransactionDate;
|
||||||
|
if (expenseTransactionDateStr != null) {
|
||||||
|
try {
|
||||||
|
expenseTransactionDate =
|
||||||
|
DateTime.parse(expenseTransactionDateStr);
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
|
||||||
if (commentCtrl.text.trim().isEmpty ||
|
if (commentCtrl.text.trim().isEmpty ||
|
||||||
txnCtrl.text.trim().isEmpty ||
|
|
||||||
dateStr.value.isEmpty ||
|
dateStr.value.isEmpty ||
|
||||||
controller.selectedReimbursedBy.value == null) {
|
controller.selectedReimbursedBy.value == null ||
|
||||||
|
baseAmountCtrl.text.trim().isEmpty ||
|
||||||
|
gstAmountCtrl.text.trim().isEmpty) {
|
||||||
showAppSnackbar(
|
showAppSnackbar(
|
||||||
title: "Incomplete",
|
title: "Incomplete",
|
||||||
message: "Please fill all fields",
|
message: "Please fill all required fields",
|
||||||
type: SnackbarType.warning,
|
type: SnackbarType.warning,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate reimbursement date
|
||||||
|
final DateTime? selectedDate = DateTime.tryParse(dateStr.value);
|
||||||
|
if (selectedDate != null) {
|
||||||
|
final now = DateTime.now();
|
||||||
|
|
||||||
|
if (selectedDate.isAfter(now)) {
|
||||||
|
showAppSnackbar(
|
||||||
|
title: "Invalid Date",
|
||||||
|
message: "Reimbursement date cannot be in the future.",
|
||||||
|
type: SnackbarType.warning,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expenseTransactionDate != null &&
|
||||||
|
selectedDate.isBefore(expenseTransactionDate)) {
|
||||||
|
showAppSnackbar(
|
||||||
|
title: "Invalid Date",
|
||||||
|
message:
|
||||||
|
"Reimbursement date cannot be before the transaction date (${DateFormat('yyyy-MM-dd').format(expenseTransactionDate)}).",
|
||||||
|
type: SnackbarType.warning,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final success = await widget.onSubmit(
|
final success = await widget.onSubmit(
|
||||||
comment: commentCtrl.text.trim(),
|
comment: commentCtrl.text.trim(),
|
||||||
reimburseTransactionId: txnCtrl.text.trim(),
|
reimburseTransactionId: txnCtrl.text
|
||||||
|
.trim(),
|
||||||
reimburseDate: dateStr.value,
|
reimburseDate: dateStr.value,
|
||||||
reimburseById: controller.selectedReimbursedBy.value!.id,
|
reimburseById: controller.selectedReimbursedBy.value!.id,
|
||||||
statusId: widget.statusId,
|
statusId: widget.statusId,
|
||||||
|
baseAmount: double.tryParse(baseAmountCtrl.text.trim()) ?? 0,
|
||||||
|
taxAmount: double.tryParse(gstAmountCtrl.text.trim()) ?? 0,
|
||||||
|
tdsPercent: double.tryParse(tdsCtrl.text.trim()) ?? 0,
|
||||||
|
netPayable: netPayable.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
Get.back();
|
Get.back();
|
||||||
showAppSnackbar(
|
showAppSnackbar(
|
||||||
title: "Success",
|
title: "Success",
|
||||||
message: "Reimbursement submitted",
|
message: "Reimbursement submitted successfully",
|
||||||
type: SnackbarType.success,
|
type: SnackbarType.success,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -140,35 +237,46 @@ class _ReimbursementBottomSheetState extends State<ReimbursementBottomSheet> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
MyText.labelMedium("Comment"),
|
MyText.labelMedium("Transaction ID*"),
|
||||||
MySpacing.height(8),
|
|
||||||
TextField(
|
|
||||||
controller: commentCtrl,
|
|
||||||
decoration: _inputDecoration("Enter comment"),
|
|
||||||
),
|
|
||||||
MySpacing.height(16),
|
|
||||||
MyText.labelMedium("Transaction ID"),
|
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
TextField(
|
TextField(
|
||||||
controller: txnCtrl,
|
controller: txnCtrl,
|
||||||
decoration: _inputDecoration("Enter transaction ID"),
|
decoration: _inputDecoration("Enter transaction ID"),
|
||||||
),
|
),
|
||||||
MySpacing.height(16),
|
MySpacing.height(16),
|
||||||
MyText.labelMedium("Reimbursement Date"),
|
MyText.labelMedium("Reimbursement Date*"),
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
|
// Get transaction date from expense
|
||||||
|
DateTime? transactionDate;
|
||||||
|
if (controller.expense.value?.transactionDate != null) {
|
||||||
|
try {
|
||||||
|
transactionDate = DateTime.parse(
|
||||||
|
controller.expense.value!.transactionDate);
|
||||||
|
} catch (_) {
|
||||||
|
transactionDate = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final DateTime now = DateTime.now();
|
||||||
|
final DateTime firstDate =
|
||||||
|
transactionDate ?? DateTime(2020); // fallback if null
|
||||||
|
final DateTime lastDate = now;
|
||||||
|
|
||||||
final picked = await showDatePicker(
|
final picked = await showDatePicker(
|
||||||
context: context,
|
context: context,
|
||||||
initialDate: dateStr.value.isEmpty
|
initialDate: now.isBefore(firstDate)
|
||||||
? DateTime.now()
|
? firstDate
|
||||||
: DateFormat('yyyy-MM-dd').parse(dateStr.value),
|
: now, // initial date inside the range
|
||||||
firstDate: DateTime(2020),
|
firstDate: firstDate,
|
||||||
lastDate: DateTime(2100),
|
lastDate: lastDate,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (picked != null) {
|
if (picked != null) {
|
||||||
dateStr.value = DateFormat('yyyy-MM-dd').format(picked);
|
dateStr.value = DateFormat('yyyy-MM-dd').format(picked);
|
||||||
}
|
}
|
||||||
@ -183,7 +291,7 @@ class _ReimbursementBottomSheetState extends State<ReimbursementBottomSheet> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
MySpacing.height(16),
|
MySpacing.height(16),
|
||||||
MyText.labelMedium("Reimbursed By"),
|
MyText.labelMedium("Reimbursed By*"),
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: _showEmployeeList,
|
onTap: _showEmployeeList,
|
||||||
@ -209,7 +317,72 @@ class _ReimbursementBottomSheetState extends State<ReimbursementBottomSheet> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
MySpacing.height(16),
|
||||||
|
MyText.labelMedium("Base Amount*"),
|
||||||
|
MySpacing.height(8),
|
||||||
|
TextField(
|
||||||
|
controller: baseAmountCtrl,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
decoration: _inputDecoration("Enter Base Amount"),
|
||||||
|
),
|
||||||
|
MySpacing.height(16),
|
||||||
|
MyText.labelMedium("GST Amount*"),
|
||||||
|
MySpacing.height(8),
|
||||||
|
TextField(
|
||||||
|
controller: gstAmountCtrl,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
decoration: _inputDecoration("Enter GST Amount"),
|
||||||
|
),
|
||||||
|
MySpacing.height(16),
|
||||||
|
MyText.labelMedium("TDS Percent"),
|
||||||
|
MySpacing.height(8),
|
||||||
|
TextField(
|
||||||
|
controller: tdsCtrl,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
decoration: _inputDecoration("Enter TDS Percent").copyWith(
|
||||||
|
suffixIcon: Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 12),
|
||||||
|
child: Icon(Icons.percent,
|
||||||
|
size: 20, color: Colors.grey.shade600),
|
||||||
|
),
|
||||||
|
suffixIconConstraints:
|
||||||
|
const BoxConstraints(minWidth: 0, minHeight: 0),
|
||||||
|
),
|
||||||
|
onChanged: (_) => _recalculate(),
|
||||||
|
),
|
||||||
|
MySpacing.height(4),
|
||||||
|
MyText.bodySmall(
|
||||||
|
"TDS is applied on base amount only.",
|
||||||
|
color: Colors.grey.shade600,
|
||||||
|
),
|
||||||
|
MySpacing.height(16),
|
||||||
|
Obx(() => Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_readOnlyValueBox(
|
||||||
|
"TDS Amount",
|
||||||
|
tdsAmount.value.toStringAsFixed(2),
|
||||||
|
Colors.orange,
|
||||||
|
),
|
||||||
|
MySpacing.height(12),
|
||||||
|
_readOnlyValueBox(
|
||||||
|
"Net Payable",
|
||||||
|
netPayable.value.toStringAsFixed(2),
|
||||||
|
Colors.green,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
|
)),
|
||||||
|
MySpacing.height(16),
|
||||||
|
MyText.labelMedium("Comment*"),
|
||||||
|
MySpacing.height(8),
|
||||||
|
TextField(
|
||||||
|
controller: commentCtrl,
|
||||||
|
maxLines: 2,
|
||||||
|
decoration: _inputDecoration("Enter comment"),
|
||||||
|
),
|
||||||
|
MySpacing.height(16),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -117,6 +117,21 @@ class _UpdatePaymentRequestWithReimbursementState
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _requiredLabel(String label) {
|
||||||
|
return RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
text: label,
|
||||||
|
style: MyTextStyle.labelMedium(),
|
||||||
|
children: const [
|
||||||
|
TextSpan(
|
||||||
|
text: ' *',
|
||||||
|
style: TextStyle(color: Colors.red),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Widget _readOnlyValueBox(String label, String value, Color color) {
|
Widget _readOnlyValueBox(String label, String value, Color color) {
|
||||||
return Container(
|
return Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
@ -151,11 +166,11 @@ class _UpdatePaymentRequestWithReimbursementState
|
|||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
onSubmit: () async {
|
onSubmit: () async {
|
||||||
if (commentCtrl.text.trim().isEmpty ||
|
if (txnCtrl.text.trim().isEmpty ||
|
||||||
txnCtrl.text.trim().isEmpty ||
|
|
||||||
dateStr.value.isEmpty ||
|
dateStr.value.isEmpty ||
|
||||||
baseAmountCtrl.text.trim().isEmpty ||
|
baseAmountCtrl.text.trim().isEmpty ||
|
||||||
taxAmountCtrl.text.trim().isEmpty) {
|
taxAmountCtrl.text.trim().isEmpty ||
|
||||||
|
commentCtrl.text.trim().isEmpty) {
|
||||||
showAppSnackbar(
|
showAppSnackbar(
|
||||||
title: "Incomplete",
|
title: "Incomplete",
|
||||||
message: "Please fill all mandatory fields",
|
message: "Please fill all mandatory fields",
|
||||||
@ -199,8 +214,7 @@ class _UpdatePaymentRequestWithReimbursementState
|
|||||||
Get.close(1);
|
Get.close(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e, st) {
|
} catch (e) {
|
||||||
print("Error updating payment: $e\n$st");
|
|
||||||
showAppSnackbar(
|
showAppSnackbar(
|
||||||
title: 'Error',
|
title: 'Error',
|
||||||
message: 'Something went wrong. Please try again.',
|
message: 'Something went wrong. Please try again.',
|
||||||
@ -212,7 +226,7 @@ class _UpdatePaymentRequestWithReimbursementState
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
MyText.labelMedium("Transaction ID*"),
|
_requiredLabel("Transaction ID"),
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
TextField(
|
TextField(
|
||||||
controller: txnCtrl,
|
controller: txnCtrl,
|
||||||
@ -220,16 +234,24 @@ class _UpdatePaymentRequestWithReimbursementState
|
|||||||
),
|
),
|
||||||
MySpacing.height(16),
|
MySpacing.height(16),
|
||||||
|
|
||||||
MyText.labelMedium("Transaction Date*"),
|
_requiredLabel("Transaction Date"),
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
|
final DateTime submittedDate =
|
||||||
|
controller.paymentRequest.value?.createdAt ??
|
||||||
|
DateTime.now();
|
||||||
|
final DateTime today = DateTime.now();
|
||||||
|
|
||||||
final picked = await showDatePicker(
|
final picked = await showDatePicker(
|
||||||
context: context,
|
context: context,
|
||||||
initialDate: DateTime.now(),
|
initialDate:
|
||||||
firstDate: DateTime(2020),
|
today.isBefore(submittedDate) ? submittedDate : today,
|
||||||
lastDate: DateTime.now(),
|
firstDate: submittedDate,
|
||||||
|
lastDate: today,
|
||||||
|
helpText: 'Select Transaction Date',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (picked != null) {
|
if (picked != null) {
|
||||||
dateStr.value = DateFormat('dd-MM-yyyy').format(picked);
|
dateStr.value = DateFormat('dd-MM-yyyy').format(picked);
|
||||||
}
|
}
|
||||||
@ -273,7 +295,7 @@ class _UpdatePaymentRequestWithReimbursementState
|
|||||||
),
|
),
|
||||||
MySpacing.height(16),
|
MySpacing.height(16),
|
||||||
|
|
||||||
MyText.labelMedium("Base Amount"),
|
_requiredLabel("Base Amount"),
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
TextField(
|
TextField(
|
||||||
controller: baseAmountCtrl,
|
controller: baseAmountCtrl,
|
||||||
@ -282,7 +304,7 @@ class _UpdatePaymentRequestWithReimbursementState
|
|||||||
),
|
),
|
||||||
MySpacing.height(16),
|
MySpacing.height(16),
|
||||||
|
|
||||||
MyText.labelMedium("GST Amount"),
|
_requiredLabel("GST Amount"),
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
TextField(
|
TextField(
|
||||||
controller: taxAmountCtrl,
|
controller: taxAmountCtrl,
|
||||||
@ -307,7 +329,6 @@ class _UpdatePaymentRequestWithReimbursementState
|
|||||||
),
|
),
|
||||||
onChanged: (_) => _recalculateTds(),
|
onChanged: (_) => _recalculateTds(),
|
||||||
),
|
),
|
||||||
|
|
||||||
MySpacing.height(4),
|
MySpacing.height(4),
|
||||||
MyText.bodySmall(
|
MyText.bodySmall(
|
||||||
"TDS is applied on base amount only.",
|
"TDS is applied on base amount only.",
|
||||||
@ -315,7 +336,6 @@ class _UpdatePaymentRequestWithReimbursementState
|
|||||||
),
|
),
|
||||||
MySpacing.height(16),
|
MySpacing.height(16),
|
||||||
|
|
||||||
// ✅ Proper display section for TDS and Net Payable
|
|
||||||
Obx(() => Column(
|
Obx(() => Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@ -334,7 +354,7 @@ class _UpdatePaymentRequestWithReimbursementState
|
|||||||
)),
|
)),
|
||||||
MySpacing.height(20),
|
MySpacing.height(20),
|
||||||
|
|
||||||
MyText.labelMedium("Comment*"),
|
_requiredLabel("Comment"),
|
||||||
MySpacing.height(8),
|
MySpacing.height(8),
|
||||||
TextField(
|
TextField(
|
||||||
controller: commentCtrl,
|
controller: commentCtrl,
|
||||||
|
|||||||
@ -31,10 +31,11 @@ class ExpenseDetailScreen extends StatefulWidget {
|
|||||||
State<ExpenseDetailScreen> createState() => _ExpenseDetailScreenState();
|
State<ExpenseDetailScreen> createState() => _ExpenseDetailScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ExpenseDetailScreenState extends State<ExpenseDetailScreen> with UIMixin {
|
class _ExpenseDetailScreenState extends State<ExpenseDetailScreen>
|
||||||
|
with UIMixin {
|
||||||
final controller = Get.put(ExpenseDetailController());
|
final controller = Get.put(ExpenseDetailController());
|
||||||
final projectController = Get.find<ProjectController>();
|
final projectController = Get.find<ProjectController>();
|
||||||
final permissionController = Get.put(PermissionController());
|
final permissionController = Get.put(PermissionController());
|
||||||
|
|
||||||
EmployeeInfo? employeeInfo;
|
EmployeeInfo? employeeInfo;
|
||||||
final RxBool canSubmit = false.obs;
|
final RxBool canSubmit = false.obs;
|
||||||
@ -198,8 +199,8 @@ final permissionController = Get.put(PermissionController());
|
|||||||
},
|
},
|
||||||
backgroundColor: contentTheme.primary,
|
backgroundColor: contentTheme.primary,
|
||||||
icon: const Icon(Icons.edit),
|
icon: const Icon(Icons.edit),
|
||||||
label: MyText.bodyMedium(
|
label: MyText.bodyMedium("Edit Expense",
|
||||||
"Edit Expense", fontWeight: 600, color: Colors.white),
|
fontWeight: 600, color: Colors.white),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
bottomNavigationBar: Obx(() {
|
bottomNavigationBar: Obx(() {
|
||||||
@ -292,6 +293,10 @@ final permissionController = Get.put(PermissionController());
|
|||||||
required String reimburseDate,
|
required String reimburseDate,
|
||||||
required String reimburseById,
|
required String reimburseById,
|
||||||
required String statusId,
|
required String statusId,
|
||||||
|
required double baseAmount,
|
||||||
|
required double taxAmount,
|
||||||
|
required double tdsPercent,
|
||||||
|
required double netPayable,
|
||||||
}) async {
|
}) async {
|
||||||
final transactionDate = DateTime.tryParse(
|
final transactionDate = DateTime.tryParse(
|
||||||
controller.expense.value?.transactionDate ?? '');
|
controller.expense.value?.transactionDate ?? '');
|
||||||
@ -302,7 +307,7 @@ final permissionController = Get.put(PermissionController());
|
|||||||
if (transactionDate == null ||
|
if (transactionDate == null ||
|
||||||
selectedReimburseDate == null) {
|
selectedReimburseDate == null) {
|
||||||
showAppSnackbar(
|
showAppSnackbar(
|
||||||
title: 'Invalid date',
|
title: 'Invalid Date',
|
||||||
message:
|
message:
|
||||||
'Could not parse transaction or reimbursement date.',
|
'Could not parse transaction or reimbursement date.',
|
||||||
type: SnackbarType.error,
|
type: SnackbarType.error,
|
||||||
@ -325,7 +330,8 @@ final permissionController = Get.put(PermissionController());
|
|||||||
.isAfter(onlyDate(today))) {
|
.isAfter(onlyDate(today))) {
|
||||||
showAppSnackbar(
|
showAppSnackbar(
|
||||||
title: 'Invalid Date',
|
title: 'Invalid Date',
|
||||||
message: 'Reimbursement date cannot be in the future.',
|
message:
|
||||||
|
'Reimbursement date cannot be in the future.',
|
||||||
type: SnackbarType.error,
|
type: SnackbarType.error,
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
@ -338,6 +344,10 @@ final permissionController = Get.put(PermissionController());
|
|||||||
reimburseDate: reimburseDate,
|
reimburseDate: reimburseDate,
|
||||||
reimburseById: reimburseById,
|
reimburseById: reimburseById,
|
||||||
statusId: statusId,
|
statusId: statusId,
|
||||||
|
baseAmount: baseAmount,
|
||||||
|
taxAmount: taxAmount,
|
||||||
|
tdsPercent: tdsPercent,
|
||||||
|
netPayable: netPayable,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
@ -357,8 +367,8 @@ final permissionController = Get.put(PermissionController());
|
|||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}),
|
},
|
||||||
);
|
));
|
||||||
} else {
|
} else {
|
||||||
final comment = await showCommentBottomSheet(context, next.name);
|
final comment = await showCommentBottomSheet(context, next.name);
|
||||||
if (comment == null) return;
|
if (comment == null) return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user