|
|
|
|
@ -16,12 +16,15 @@ import 'package:hmg_patient_app_new/features/todo_section/models/resp_models/anc
|
|
|
|
|
import 'package:hmg_patient_app_new/features/todo_section/models/resp_models/ancillary_order_procedures_detail_response_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/todo_section/todo_section_view_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/home/navigation_screen.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/todo_section/ancillary_order_payment_page.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/todo_section/widgets/ancillary_orders_list.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
@ -678,20 +681,24 @@ class _AncillaryOrderDetailsListState extends State<AncillaryOrderDetailsList> {
|
|
|
|
|
onPressed: () {
|
|
|
|
|
// Navigate to payment page with selected procedures
|
|
|
|
|
todoSectionViewModel.setIsAncillaryOrdersNeedReloading(true);
|
|
|
|
|
Navigator.of(context).push(
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: AncillaryOrderPaymentPage(
|
|
|
|
|
appointmentNoVida: widget.appointmentNoVida,
|
|
|
|
|
orderNo: widget.orderNo,
|
|
|
|
|
projectID: widget.projectID,
|
|
|
|
|
clinicID: widget.clinicID,
|
|
|
|
|
selectedProcedures: selectedProcedures,
|
|
|
|
|
totalAmount: _getTotalAmount(),
|
|
|
|
|
appointmentDate: orderData.appointmentDate,
|
|
|
|
|
setupID: widget.setupID,
|
|
|
|
|
if (_getTotalAmount() == 0 || _getTotalAmount() == 0.0) {
|
|
|
|
|
_autoGenerateInvoice();
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.of(context).push(
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: AncillaryOrderPaymentPage(
|
|
|
|
|
appointmentNoVida: widget.appointmentNoVida,
|
|
|
|
|
orderNo: widget.orderNo,
|
|
|
|
|
projectID: widget.projectID,
|
|
|
|
|
clinicID: widget.clinicID,
|
|
|
|
|
selectedProcedures: selectedProcedures,
|
|
|
|
|
totalAmount: _getTotalAmount(),
|
|
|
|
|
appointmentDate: orderData.appointmentDate,
|
|
|
|
|
setupID: widget.setupID,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
isDisabled: !isButtonEnabled,
|
|
|
|
|
textColor: Colors.white,
|
|
|
|
|
@ -704,4 +711,49 @@ class _AncillaryOrderDetailsListState extends State<AncillaryOrderDetailsList> {
|
|
|
|
|
).paddingOnly(left: 16.h, top: 24.h, right: 16.h, bottom: 0.h),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _autoGenerateInvoice() {
|
|
|
|
|
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.generatingInvoicePleaseWait.tr(context: context));
|
|
|
|
|
|
|
|
|
|
List<dynamic> selectedProcListAPI = selectedProcedures.map((element) {
|
|
|
|
|
return {
|
|
|
|
|
"ApprovalLineItemNo": element.approvalLineItemNo,
|
|
|
|
|
"OrderLineItemNo": element.orderLineItemNo,
|
|
|
|
|
"ProcedureID": element.procedureID,
|
|
|
|
|
};
|
|
|
|
|
}).toList();
|
|
|
|
|
|
|
|
|
|
todoSectionViewModel.autoGenerateAncillaryOrdersInvoice(
|
|
|
|
|
orderNo: widget.orderNo,
|
|
|
|
|
projectID: widget.projectID,
|
|
|
|
|
appointmentNo: widget.appointmentNoVida,
|
|
|
|
|
selectedProcedures: selectedProcListAPI,
|
|
|
|
|
languageID: appState.isArabic() ? 1 : 2,
|
|
|
|
|
onSuccess: (response) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
final invoiceNo = response['AncillaryOrderInvoiceList']?[0]?['InvoiceNo'];
|
|
|
|
|
showCommonBottomSheetWithoutHeight(context,
|
|
|
|
|
child: Utils.getSuccessWidget(loadingText: "${LocaleKeys.paymentCompletedSuccessfully.tr(context: context)}, ${LocaleKeys.hereIsYourInvoiceNumber.tr(context: context)}$invoiceNo"),
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
isDismissible: true,
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isAutoDismiss: true, callBackFunc: () {
|
|
|
|
|
// Pop until we reach the LandingPage
|
|
|
|
|
todoSectionViewModel.setIsAncillaryOrdersNeedReloading(true);
|
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
|
context,
|
|
|
|
|
CustomPageRoute(
|
|
|
|
|
page: LandingNavigation(),
|
|
|
|
|
),
|
|
|
|
|
(r) => false);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onError: (error) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
todoSectionViewModel.setProcessingPayment(false);
|
|
|
|
|
showCommonBottomSheetWithoutHeight(context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: error.toString()), isCloseButtonVisible: true, isDismissible: true, isFullScreen: false, callBackFunc: () {});
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|