|
|
|
@ -345,9 +345,9 @@ class _WithdrawRequestCreatePageState extends State<WithdrawRequestCreatePage> {
|
|
|
|
final isStep2Valid = vm.selectedWithdrawMethod != null &&
|
|
|
|
final isStep2Valid = vm.selectedWithdrawMethod != null &&
|
|
|
|
(isCash
|
|
|
|
(isCash
|
|
|
|
? !vm.isCashWithdrawAmountExceeded // Cash: check amount limit
|
|
|
|
? !vm.isCashWithdrawAmountExceeded // Cash: check amount limit
|
|
|
|
: (isBankTransfer &&
|
|
|
|
: (isBankTransfer
|
|
|
|
_bankDetailsController.text.trim().isNotEmpty &&
|
|
|
|
? (_bankDetailsController.text.trim().isNotEmpty && _descriptionController.text.trim().isNotEmpty) // Bank: check IBAN and description
|
|
|
|
_descriptionController.text.trim().isNotEmpty)); // Bank: check fields
|
|
|
|
: true)); // HMG Wallet: no additional validation
|
|
|
|
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
return Container(
|
|
|
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
|
|
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
|
|
|
@ -460,10 +460,10 @@ class _WithdrawRequestCreatePageState extends State<WithdrawRequestCreatePage> {
|
|
|
|
child: SelectHospitalBottomSheet(
|
|
|
|
child: SelectHospitalBottomSheet(
|
|
|
|
onHospitalSelected: (hospital) {
|
|
|
|
onHospitalSelected: (hospital) {
|
|
|
|
habibWalletViewModel.setSelectedHospital(hospital);
|
|
|
|
habibWalletViewModel.setSelectedHospital(hospital);
|
|
|
|
habibWalletViewModel.fetchAdvancesForHospital();
|
|
|
|
|
|
|
|
if (hospital.iD != null) {
|
|
|
|
if (hospital.iD != null) {
|
|
|
|
final projectId = hospital.iD is int ? hospital.iD as int : int.tryParse(hospital.iD.toString());
|
|
|
|
final projectId = hospital.iD is int ? hospital.iD as int : int.tryParse(hospital.iD.toString());
|
|
|
|
if (projectId != null) {
|
|
|
|
if (projectId != null) {
|
|
|
|
|
|
|
|
habibWalletViewModel.fetchAdvancesForHospital(projectId: projectId);
|
|
|
|
habibWalletViewModel.getThresholdAmount(projectId: projectId);
|
|
|
|
habibWalletViewModel.getThresholdAmount(projectId: projectId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -492,6 +492,7 @@ class _WithdrawRequestCreatePageState extends State<WithdrawRequestCreatePage> {
|
|
|
|
Widget _buildBankInputDetails() {
|
|
|
|
Widget _buildBankInputDetails() {
|
|
|
|
return Consumer<HabibWalletViewModel>(
|
|
|
|
return Consumer<HabibWalletViewModel>(
|
|
|
|
builder: (context, viewModel, _) {
|
|
|
|
builder: (context, viewModel, _) {
|
|
|
|
|
|
|
|
final isBankTransfer = viewModel.selectedWithdrawMethod == RefundTabType.invoices;
|
|
|
|
final hasError = viewModel.ibanError != null || viewModel.withdrawDescriptionError != null;
|
|
|
|
final hasError = viewModel.ibanError != null || viewModel.withdrawDescriptionError != null;
|
|
|
|
return Container(
|
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.all(16.h),
|
|
|
|
padding: EdgeInsets.all(16.h),
|
|
|
|
@ -505,6 +506,7 @@ class _WithdrawRequestCreatePageState extends State<WithdrawRequestCreatePage> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
|
|
|
|
if (isBankTransfer) ...[
|
|
|
|
TextInputWidget(
|
|
|
|
TextInputWidget(
|
|
|
|
labelText: LocaleKeys.addIbanDetails.tr(),
|
|
|
|
labelText: LocaleKeys.addIbanDetails.tr(),
|
|
|
|
hintText: "SA0000000000000000000000",
|
|
|
|
hintText: "SA0000000000000000000000",
|
|
|
|
@ -531,6 +533,7 @@ class _WithdrawRequestCreatePageState extends State<WithdrawRequestCreatePage> {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Divider(color: AppColors.bottomNAVBorder, thickness: 1).withVerticalPadding(16.h),
|
|
|
|
Divider(color: AppColors.bottomNAVBorder, thickness: 1).withVerticalPadding(16.h),
|
|
|
|
|
|
|
|
],
|
|
|
|
TextInputWidget(
|
|
|
|
TextInputWidget(
|
|
|
|
labelText: LocaleKeys.description.tr(),
|
|
|
|
labelText: LocaleKeys.description.tr(),
|
|
|
|
hintText: LocaleKeys.enterDescription.tr(),
|
|
|
|
hintText: LocaleKeys.enterDescription.tr(),
|
|
|
|
@ -733,9 +736,17 @@ class _WithdrawRequestCreatePageState extends State<WithdrawRequestCreatePage> {
|
|
|
|
final user = _appState.getAuthenticatedUser();
|
|
|
|
final user = _appState.getAuthenticatedUser();
|
|
|
|
final hospital = vm.selectedHospital;
|
|
|
|
final hospital = vm.selectedHospital;
|
|
|
|
|
|
|
|
|
|
|
|
// Determine refund destination: '2' = Bank Transfer, '3' = Cash
|
|
|
|
// Determine refund destination: 1 = HMG Wallet, 2 = Bank Transfer, 3 = Cash
|
|
|
|
|
|
|
|
String refundDestination;
|
|
|
|
|
|
|
|
final isBankTransfer = vm.selectedWithdrawMethod == RefundTabType.invoices;
|
|
|
|
final isCash = vm.selectedWithdrawMethod == RefundTabType.cash;
|
|
|
|
final isCash = vm.selectedWithdrawMethod == RefundTabType.cash;
|
|
|
|
final refundDestination = isCash ? '3' : '2';
|
|
|
|
if (isCash) {
|
|
|
|
|
|
|
|
refundDestination = '3';
|
|
|
|
|
|
|
|
} else if (isBankTransfer) {
|
|
|
|
|
|
|
|
refundDestination = '2';
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
refundDestination = '1'; // HMG Wallet
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
await vm.submitWalletWithdrawalRequest(
|
|
|
|
await vm.submitWalletWithdrawalRequest(
|
|
|
|
iban: _bankDetailsController.text.trim(),
|
|
|
|
iban: _bankDetailsController.text.trim(),
|
|
|
|
@ -904,11 +915,9 @@ class _WithdrawRequestCreatePageState extends State<WithdrawRequestCreatePage> {
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
_buildRefundMethodSelection(habibWalletViewModel),
|
|
|
|
_buildRefundMethodSelection(habibWalletViewModel),
|
|
|
|
if (habibWalletViewModel.selectedWithdrawMethod == RefundTabType.invoices) ...[
|
|
|
|
if (habibWalletViewModel.selectedWithdrawMethod != null) ...[
|
|
|
|
SizedBox(height: 16.h),
|
|
|
|
SizedBox(height: 16.h),
|
|
|
|
_buildBankInputDetails(),
|
|
|
|
_buildBankInputDetails(),
|
|
|
|
],
|
|
|
|
|
|
|
|
if (habibWalletViewModel.selectedWithdrawMethod != null) ...[
|
|
|
|
|
|
|
|
SizedBox(height: 16.h),
|
|
|
|
SizedBox(height: 16.h),
|
|
|
|
_buildImageUploadSection(habibWalletViewModel),
|
|
|
|
_buildImageUploadSection(habibWalletViewModel),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
|