|
|
|
@ -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<ListConsultation> 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();
|
|
|
|
|