From 4ac0845003066fdd6d8d60f0f727051349bccf74 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 29 Sep 2021 15:08:10 +0300 Subject: [PATCH] updates & fixes --- lib/core/service/insurance_service.dart | 6 ++- lib/extensions/list_extension.dart | 8 +++ .../fragments/home_page_fragment2.dart | 4 +- .../active_medications/reminder_page.dart | 20 ++++---- .../medical/balance/advance_payment_page.dart | 1 + .../dialogs/SelectPatientFamilyDialog.dart | 15 ++++-- lib/pages/medical/eye/EyeHomePage.dart | 2 +- .../my_invoices/invoice_detail_page.dart | 49 +++++++++++++++---- .../bloodPressureWeeklyPage.dart | 3 +- .../my_invoice_services.dart | 2 +- .../others/app_expandable_notifier.dart | 6 +-- 11 files changed, 83 insertions(+), 33 deletions(-) create mode 100644 lib/extensions/list_extension.dart diff --git a/lib/core/service/insurance_service.dart b/lib/core/service/insurance_service.dart index 4f0ff3dc..a4917f03 100644 --- a/lib/core/service/insurance_service.dart +++ b/lib/core/service/insurance_service.dart @@ -99,8 +99,10 @@ class InsuranceCardService extends BaseService { } Future getSharedRecordByStatus() async { - if (await sharedPref.getObject(FAMILY_FILE) != null) { - return Future.value(GetAllSharedRecordsByStatusResponse.fromJson(await sharedPref.getObject(FAMILY_FILE))); + var myFamily = await sharedPref.getObject(FAMILY_FILE); + if (myFamily != null) { + getAllSharedRecordsByStatusResponse = GetAllSharedRecordsByStatusResponse.fromJson(myFamily); + return Future.value(GetAllSharedRecordsByStatusResponse.fromJson(myFamily)); } else { try { dynamic localRes; diff --git a/lib/extensions/list_extension.dart b/lib/extensions/list_extension.dart new file mode 100644 index 00000000..ef56ff07 --- /dev/null +++ b/lib/extensions/list_extension.dart @@ -0,0 +1,8 @@ +extension Unique on List { + List unique([Id Function(E element) id, bool inplace = true]) { + final ids = Set(); + var list = inplace ? this : List.from(this); + list.retainWhere((x) => ids.add(id != null ? id(x) : x as Id)); + return list; + } +} \ No newline at end of file diff --git a/lib/pages/landing/fragments/home_page_fragment2.dart b/lib/pages/landing/fragments/home_page_fragment2.dart index d9440990..f9a8ebf7 100644 --- a/lib/pages/landing/fragments/home_page_fragment2.dart +++ b/lib/pages/landing/fragments/home_page_fragment2.dart @@ -96,8 +96,8 @@ class _HomePageFragment2State extends State { margin: EdgeInsets.only(left: 20, right: 20, top: 8, bottom: 6), child: SliderView( onLoginClick: () { - // widget.onLoginClick(); - navigateTo(context, CallHomePage()); + widget.onLoginClick(); + // navigateTo(context, CallHomePage()); }, ), // height: MediaQuery.of(context).size.width / 2.6, diff --git a/lib/pages/medical/active_medications/reminder_page.dart b/lib/pages/medical/active_medications/reminder_page.dart index ec5b5eba..a6df5f28 100644 --- a/lib/pages/medical/active_medications/reminder_page.dart +++ b/lib/pages/medical/active_medications/reminder_page.dart @@ -212,6 +212,16 @@ class _ReminderPageState extends State { child: Row( mainAxisSize: MainAxisSize.min, children: [ + // Expanded( + // child: DefaultButton( + // TranslationBase.of(context).cancel, + // () { + // Navigator.pop(context); + // }, + // color: Color(0xffC5272D), + // ), + // ), + // SizedBox(width: 10), Expanded( child: DefaultButton( TranslationBase.of(context).ok.toUpperCase(), @@ -221,16 +231,6 @@ class _ReminderPageState extends State { color: Color(0xff359846), ), ), - SizedBox(width: 10), - Expanded( - child: DefaultButton( - TranslationBase.of(context).cancel, - () { - Navigator.pop(context); - }, - color: Color(0xffC5272D), - ), - ), ], ), ), diff --git a/lib/pages/medical/balance/advance_payment_page.dart b/lib/pages/medical/balance/advance_payment_page.dart index beec5f66..26971713 100644 --- a/lib/pages/medical/balance/advance_payment_page.dart +++ b/lib/pages/medical/balance/advance_payment_page.dart @@ -155,6 +155,7 @@ class _AdvancePaymentPageState extends State { NewTextFields( hintText: TranslationBase.of(context).fileNumber, controller: _fileTextController, + readOnly: true, ), if (beneficiaryType == BeneficiaryType.OtherAccount) SizedBox( diff --git a/lib/pages/medical/balance/dialogs/SelectPatientFamilyDialog.dart b/lib/pages/medical/balance/dialogs/SelectPatientFamilyDialog.dart index 667f156d..d4b2e8fb 100644 --- a/lib/pages/medical/balance/dialogs/SelectPatientFamilyDialog.dart +++ b/lib/pages/medical/balance/dialogs/SelectPatientFamilyDialog.dart @@ -10,6 +10,8 @@ class SelectPatientFamilyDialog extends StatefulWidget { final Function(GetAllSharedRecordsByStatusList) onValueSelected; GetAllSharedRecordsByStatusList selectedPatientFamily; + List getAllSharedRecordsByStatusApprovedList = new List(); + SelectPatientFamilyDialog({Key key, this.getAllSharedRecordsByStatusList, this.onValueSelected, this.selectedPatientFamily}); @override @@ -21,6 +23,11 @@ class _SelectPatientFamilyDialogState extends State { void initState() { super.initState(); widget.selectedPatientFamily = widget.selectedPatientFamily ?? widget.getAllSharedRecordsByStatusList[0]; + + if (widget.getAllSharedRecordsByStatusList.isNotEmpty) + widget.getAllSharedRecordsByStatusList.forEach((element) { + if (element.status == 3) widget.getAllSharedRecordsByStatusApprovedList.add(element); + }); } @override @@ -31,7 +38,7 @@ class _SelectPatientFamilyDialogState extends State { children: [ Divider(), ...List.generate( - widget.getAllSharedRecordsByStatusList.length, + widget.getAllSharedRecordsByStatusApprovedList.length, (index) => Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -45,12 +52,12 @@ class _SelectPatientFamilyDialogState extends State { child: InkWell( onTap: () { setState(() { - widget.selectedPatientFamily = widget.getAllSharedRecordsByStatusList[index]; + widget.selectedPatientFamily = widget.getAllSharedRecordsByStatusApprovedList[index]; }); }, child: ListTile( title: Text( - widget.getAllSharedRecordsByStatusList[index].patientName, + widget.getAllSharedRecordsByStatusApprovedList[index].patientName, style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, @@ -58,7 +65,7 @@ class _SelectPatientFamilyDialogState extends State { ), ), leading: Radio( - value: widget.getAllSharedRecordsByStatusList[index], + value: widget.getAllSharedRecordsByStatusApprovedList[index], groupValue: widget.selectedPatientFamily, activeColor: secondaryColor, onChanged: (value) { diff --git a/lib/pages/medical/eye/EyeHomePage.dart b/lib/pages/medical/eye/EyeHomePage.dart index 77beae34..4c945f7a 100644 --- a/lib/pages/medical/eye/EyeHomePage.dart +++ b/lib/pages/medical/eye/EyeHomePage.dart @@ -94,7 +94,7 @@ class _EyeHomePageState extends State with SingleTickerProviderStat projectName: widget.appointmentAllHistoryResultList.projectName, projectID: widget.appointmentAllHistoryResultList.projectID); GifLoaderDialogUtils.hideDialog(context); - }, model.user.emailAddress); + }, projectViewModel.user.emailAddress); }, ), Container( diff --git a/lib/pages/medical/my_invoices/invoice_detail_page.dart b/lib/pages/medical/my_invoices/invoice_detail_page.dart index 0ef58a5d..6d6dabaa 100644 --- a/lib/pages/medical/my_invoices/invoice_detail_page.dart +++ b/lib/pages/medical/my_invoices/invoice_detail_page.dart @@ -13,6 +13,7 @@ import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:diplomaticquarterapp/extensions/list_extension.dart'; class InvoiceDetail extends StatelessWidget { final DoctorList doctor; @@ -31,6 +32,7 @@ class InvoiceDetail extends StatelessWidget { @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); + generateInvoiceDetails(); return AppScaffold( appBarTitle: TranslationBase.of(context).myInvoice, isShowAppBar: true, @@ -83,7 +85,7 @@ class InvoiceDetail extends StatelessWidget { ), Container( child: AppExpandableNotifier( - title: TranslationBase.of(context).patientShareTotal.toString() + " " + dentalInvoiceDetailResponse.listEInvoiceForDental[0].listConsultation[0].grandTotal.toString() + " SAR", + title: TranslationBase.of(context).patientShareTotal.toString() + " " + this.grandTotal.toString() + " " + TranslationBase.of(context).sar, isExpand: true, bodyWidget: Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Table( @@ -95,19 +97,21 @@ class InvoiceDetail extends StatelessWidget { ), Container( margin: EdgeInsets.only(top: 10.0), - child: Text(dentalInvoiceDetailResponse.listEInvoiceForDental[0].listConsultation[0].discountAmount.toString() + " " + TranslationBase.of(context).sar, + child: Text(this.totalDiscount.toString() + " " + TranslationBase.of(context).sar, textAlign: TextAlign.center, style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold)), ), ]), TableRow(children: [ Container( margin: EdgeInsets.only(top: 10.0), - child: Text(TranslationBase.of(context).totalVAT.toString() + " (" + dentalInvoiceDetailResponse.listEInvoiceForDental[0].listConsultation[0].vATPercentage.toString() + "%): ", - textAlign: TextAlign.center, style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold)), + child: Text( + TranslationBase.of(context).totalVAT.toString() + " (" + dentalInvoiceDetailResponse.listEInvoiceForDental[0].listConsultation[0].vATPercentage.toString() + "%): ", + textAlign: TextAlign.center, + style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold)), ), Container( margin: EdgeInsets.only(top: 10.0), - child: Text(dentalInvoiceDetailResponse.listEInvoiceForDental[0].listConsultation[0].patientVATAmount.toString() + " " + TranslationBase.of(context).sar, + child: Text(num.tryParse(this.totalVAT.toString()).toStringAsFixed(2) + " " + TranslationBase.of(context).sar, textAlign: TextAlign.center, style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold)), ), ]), @@ -118,8 +122,8 @@ class InvoiceDetail extends StatelessWidget { ), Container( margin: EdgeInsets.only(top: 10.0), - child: Text(dentalInvoiceDetailResponse.listEInvoiceForDental[0].listConsultation[0].totalPatientShare.toString() + " " + TranslationBase.of(context).sar, - textAlign: TextAlign.center, style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold)), + child: + Text(this.subTotal.toString() + " " + TranslationBase.of(context).sar, textAlign: TextAlign.center, style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold)), ), ]), TableRow(children: [ @@ -129,7 +133,7 @@ class InvoiceDetail extends StatelessWidget { ), Container( margin: EdgeInsets.only(top: 10.0, bottom: 10.0), - child: Text(dentalInvoiceDetailResponse.listEInvoiceForDental[0].listConsultation[0].totalPatientShare.toString() + " " + TranslationBase.of(context).sar, + child: Text(this.grandTotal.toString() + " " + TranslationBase.of(context).sar, textAlign: TextAlign.center, style: TextStyle(color: Colors.black, fontWeight: FontWeight.bold)), ), ]), @@ -181,7 +185,7 @@ class InvoiceDetail extends StatelessWidget { ), bottomSheet: Container( width: MediaQuery.of(context).size.width, - // height: 70.0, + color: Theme.of(context).scaffoldBackgroundColor, margin: EdgeInsets.only(left: 15.0, right: 15.0, top: 10.0, bottom: 20.0), child: DefaultButton(TranslationBase.of(context).sendEmail, () { showDialog( @@ -198,6 +202,33 @@ class InvoiceDetail extends StatelessWidget { ); } + void generateInvoiceDetails() { + totalServiceRate = 0; + totalDiscount = 0; + totalVAT = 0; + subTotal = 0; + grandTotal = 0; + + List listConsultations = new List(); + + dentalInvoiceDetailResponse.listEInvoiceForDental[0].listConsultation.forEach((item) { + var i = listConsultations.indexWhere((x) => x.procedureID == item.procedureID); + if (i <= -1) { + listConsultations.add(item); + } + }); + + listConsultations.forEach((element) { + print(element.procedureID); + this.totalServiceRate += element.total; + this.totalDiscount += element.discountAmount; + this.totalVAT += element.totalVATAmount; + }); + + this.subTotal = this.totalServiceRate - this.totalDiscount; + this.grandTotal = this.subTotal + this.totalVAT; + } + sendInvoiceEmail() { GifLoaderDialogUtils.showMyDialog(context); MyInvoicesService myInvoicesService = new MyInvoicesService(); diff --git a/lib/pages/medical/my_trackers/blood_pressure/bloodPressureWeeklyPage.dart b/lib/pages/medical/my_trackers/blood_pressure/bloodPressureWeeklyPage.dart index b325aff7..1262897c 100644 --- a/lib/pages/medical/my_trackers/blood_pressure/bloodPressureWeeklyPage.dart +++ b/lib/pages/medical/my_trackers/blood_pressure/bloodPressureWeeklyPage.dart @@ -25,7 +25,8 @@ class BloodPressureWeeklyPage extends StatelessWidget { body: ListView( children: [ Container( - margin: EdgeInsets.only(top: 12, left: 8, right: 8), + margin: EdgeInsets.only(top: 12, left: 8, right: 8, bottom: 12.0), + padding: EdgeInsets.only(bottom: 12.0), color: Colors.white, child: CurvedChartBloodPressure( horizontalInterval: 3.0, diff --git a/lib/services/my_invoice_service/my_invoice_services.dart b/lib/services/my_invoice_service/my_invoice_services.dart index 69d3ea19..c7f957c0 100644 --- a/lib/services/my_invoice_service/my_invoice_services.dart +++ b/lib/services/my_invoice_service/my_invoice_services.dart @@ -99,7 +99,7 @@ class MyInvoicesService extends BaseService { "PatientID": authUser.patientID, "License": true, "AppointmentNo": appoNo, - "To": authUser.emailAddress, + "To": authProvider.authenticatedUserObject.user.emailAddress, "IsRegistered": true, "ProjectID": projectID, "PatientTypeID": authUser.patientIdentificationType, diff --git a/lib/widgets/others/app_expandable_notifier.dart b/lib/widgets/others/app_expandable_notifier.dart index b4c1ce13..e4412f69 100644 --- a/lib/widgets/others/app_expandable_notifier.dart +++ b/lib/widgets/others/app_expandable_notifier.dart @@ -41,11 +41,11 @@ class _AppExpandableNotifier extends State { String _subTitle = _mainTitle.replaceAll(_title, "").trim(); if (_subTitle.length < 1) { - _subTitle = _title.toLowerCase().capitalizeFirstofEach; + _subTitle = double.tryParse(_subTitle) != null ? _title : _title.toLowerCase().capitalizeFirstofEach; _title = ""; } else { - _subTitle = _subTitle.toLowerCase().capitalizeFirstofEach; - _title = _title.toLowerCase().capitalizeFirstofEach; + _subTitle = double.tryParse(_subTitle) == null ? _subTitle : _subTitle.toLowerCase().capitalizeFirstofEach; + _title = double.tryParse(_subTitle) == null ? _title : _title.toLowerCase().capitalizeFirstofEach; } return ExpandableNotifier( child: Container(