add rate service
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'package:fcs/domain/entities/box.dart';
|
||||
import 'package:fcs/domain/entities/cargo.dart';
|
||||
import 'package:fcs/domain/entities/custom.dart';
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||
import 'package:fcs/domain/entities/discount.dart';
|
||||
import 'package:fcs/domain/entities/invoice.dart';
|
||||
import 'package:fcs/domain/entities/payment_method.dart';
|
||||
@@ -14,6 +14,7 @@ import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/payment_methods/model/payment_method_model.dart';
|
||||
import 'package:fcs/pages/rates/custom_list.dart';
|
||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||
import 'package:fcs/pages/user_search/user_serach.dart';
|
||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||
import 'package:fcs/pages/widgets/discount_dropdown.dart';
|
||||
@@ -67,7 +68,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
List<Box> _boxes = [];
|
||||
bool isSwitched = false;
|
||||
int deliveryfee = 0;
|
||||
int customFee = 10;
|
||||
double customFee = 10;
|
||||
int handlingFee = 0;
|
||||
double total = 0;
|
||||
Discount _discount;
|
||||
@@ -78,12 +79,12 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
double volumetricRatio = 0;
|
||||
|
||||
List<Box> selectedBoxes = [];
|
||||
List<Custom> customs = [];
|
||||
List<CustomDuty> customs = [];
|
||||
|
||||
List<Cargo> _cargoTypes = [
|
||||
Cargo(type: 'General Cargo', weight: 33, price: 6),
|
||||
Cargo(type: 'Medicine', weight: 33, price: 7),
|
||||
Cargo(type: 'Dangerous Cargo', weight: 33, price: 8)
|
||||
List<CargoType> _cargoTypes = [
|
||||
CargoType(name: 'General Cargo', weight: 33, rate: 6),
|
||||
CargoType(name: 'Medicine', weight: 33, rate: 7),
|
||||
CargoType(name: 'Dangerous Cargo', weight: 33, rate: 8)
|
||||
];
|
||||
|
||||
List<String> _receipts = [
|
||||
@@ -94,8 +95,9 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
volumetricRatio =
|
||||
Provider.of<MainModel>(context, listen: false).setting.volumetricRatio;
|
||||
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
|
||||
.rate
|
||||
.volumetricRatio;
|
||||
|
||||
if (widget.invoice != null) {
|
||||
_invoice = widget.invoice;
|
||||
@@ -148,9 +150,9 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
// packages: packages,
|
||||
// statusHistory: statusHistory,
|
||||
cargoTypes: [
|
||||
Cargo(type: 'General Cargo', weight: 25),
|
||||
Cargo(type: 'Medicine', weight: 20),
|
||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
||||
CargoType(name: 'General Cargo', weight: 25),
|
||||
CargoType(name: 'Medicine', weight: 20),
|
||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||
]),
|
||||
Box(
|
||||
shipmentNumber: "A202",
|
||||
@@ -170,9 +172,9 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
// packages: packages,
|
||||
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
|
||||
cargoTypes: [
|
||||
Cargo(type: 'General Cargo', weight: 25),
|
||||
Cargo(type: 'Medicine', weight: 20),
|
||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
||||
CargoType(name: 'General Cargo', weight: 25),
|
||||
CargoType(name: 'Medicine', weight: 20),
|
||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||
])
|
||||
];
|
||||
}
|
||||
@@ -257,7 +259,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
trailing: IconButton(
|
||||
icon: Icon(Icons.add_circle, color: primaryColor),
|
||||
onPressed: () async {
|
||||
Custom custom = await Navigator.of(context).push(
|
||||
CustomDuty custom = await Navigator.of(context).push(
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => CustomList()));
|
||||
setState(() {
|
||||
@@ -492,7 +494,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
var discountModel = Provider.of<DiscountModel>(context);
|
||||
total = 0;
|
||||
List<Widget> dataRow = _cargoTypes.map((cargo) {
|
||||
var amount = cargo.weight * cargo.price;
|
||||
var amount = cargo.weight * cargo.rate;
|
||||
total += amount;
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
@@ -501,10 +503,10 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
left: 5.0, right: 5.0, top: 15.0, bottom: 15.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(flex: 2, child: Text('${cargo.type}')),
|
||||
Expanded(flex: 2, child: Text('${cargo.name}')),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text('${cargo.weight} x ${cargo.price}',
|
||||
child: Text('${cargo.weight} x ${cargo.rate}',
|
||||
textAlign: TextAlign.center)),
|
||||
Expanded(
|
||||
child: Text('\$ $amount',
|
||||
@@ -820,7 +822,7 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
return _boxes.map((p) {
|
||||
p.cargoTypes.map((cargo) {
|
||||
_cargoTypes.asMap().map((index, _cargo) {
|
||||
if (_cargo.type == cargo.type) {
|
||||
if (_cargo.id == cargo.id) {
|
||||
setState(() {
|
||||
_cargoTypes[index].weight += cargo.weight;
|
||||
});
|
||||
@@ -860,16 +862,16 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
|
||||
List<MyDataRow> getCargoDataRow(BuildContext context) {
|
||||
return _cargoTypes.asMap().entries.map((c) {
|
||||
var cargo = c.value;
|
||||
var amt = cargo.weight * cargo.price;
|
||||
var amt = cargo.weight * cargo.rate;
|
||||
return MyDataRow(
|
||||
onSelectChanged: (bool selected) {},
|
||||
cells: [
|
||||
MyDataCell(new Text(
|
||||
cargo.type,
|
||||
cargo.name,
|
||||
style: textStyle,
|
||||
)),
|
||||
MyDataCell(new Text(
|
||||
cargo.weight.toString() + ' x ' + cargo.price.toString(),
|
||||
cargo.weight.toString() + ' x ' + cargo.rate.toString(),
|
||||
style: textStyle,
|
||||
)),
|
||||
MyDataCell(new Text(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:fcs/domain/entities/box.dart';
|
||||
import 'package:fcs/domain/entities/cargo.dart';
|
||||
import 'package:fcs/domain/entities/custom.dart';
|
||||
import 'package:fcs/domain/entities/cargo_type.dart';
|
||||
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||
import 'package:fcs/domain/entities/discount.dart';
|
||||
import 'package:fcs/domain/entities/invoice.dart';
|
||||
import 'package:fcs/domain/entities/payment_method.dart';
|
||||
@@ -15,6 +15,7 @@ import 'package:fcs/pages/main/model/main_model.dart';
|
||||
import 'package:fcs/pages/main/util.dart';
|
||||
import 'package:fcs/pages/payment_methods/model/payment_method_model.dart';
|
||||
import 'package:fcs/pages/rates/custom_list.dart';
|
||||
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
|
||||
import 'package:fcs/pages/user_search/user_serach.dart';
|
||||
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
||||
import 'package:fcs/pages/widgets/discount_dropdown.dart';
|
||||
@@ -67,7 +68,7 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
||||
List<Box> _boxes = [];
|
||||
bool isSwitched = false;
|
||||
int deliveryfee = 0;
|
||||
int customFee = 0;
|
||||
double customFee = 0;
|
||||
double total = 0;
|
||||
Discount _discount;
|
||||
bool isNew = false;
|
||||
@@ -77,12 +78,12 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
||||
double volumetricRatio = 0;
|
||||
|
||||
List<Box> selectedBoxes = [];
|
||||
List<Custom> customs = [];
|
||||
List<CustomDuty> customs = [];
|
||||
|
||||
List<Cargo> _cargoTypes = [
|
||||
Cargo(type: 'General Cargo', weight: 33, price: 6),
|
||||
Cargo(type: 'Medicine', weight: 33, price: 7),
|
||||
Cargo(type: 'Dangerous Cargo', weight: 33, price: 8)
|
||||
List<CargoType> _cargoTypes = [
|
||||
CargoType(id: "1", name: 'General Cargo', weight: 33, rate: 6),
|
||||
CargoType(id: "2", name: 'Medicine', weight: 33, rate: 7),
|
||||
CargoType(id: "3", name: 'Dangerous Cargo', weight: 33, rate: 8)
|
||||
];
|
||||
|
||||
List<String> _receipts = [
|
||||
@@ -92,8 +93,9 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
volumetricRatio =
|
||||
Provider.of<MainModel>(context, listen: false).setting.volumetricRatio;
|
||||
volumetricRatio = Provider.of<ShipmentRateModel>(context, listen: false)
|
||||
.rate
|
||||
.volumetricRatio;
|
||||
|
||||
if (widget.invoice != null) {
|
||||
_invoice = widget.invoice;
|
||||
@@ -142,9 +144,9 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
||||
// packages: packages,
|
||||
// statusHistory: statusHistory,
|
||||
cargoTypes: [
|
||||
Cargo(type: 'General Cargo', weight: 25),
|
||||
Cargo(type: 'Medicine', weight: 20),
|
||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
||||
CargoType(name: 'General Cargo', weight: 25),
|
||||
CargoType(name: 'Medicine', weight: 20),
|
||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||
]),
|
||||
Box(
|
||||
shipmentNumber: "A202",
|
||||
@@ -164,9 +166,9 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
||||
// packages: packages,
|
||||
receiverAddress: '1 Bo Yar Nyunt St.\nDagon Tsp, Yangon',
|
||||
cargoTypes: [
|
||||
Cargo(type: 'General Cargo', weight: 25),
|
||||
Cargo(type: 'Medicine', weight: 20),
|
||||
Cargo(type: 'Dangerous Cargo', weight: 30)
|
||||
CargoType(name: 'General Cargo', weight: 25),
|
||||
CargoType(name: 'Medicine', weight: 20),
|
||||
CargoType(name: 'Dangerous Cargo', weight: 30)
|
||||
])
|
||||
];
|
||||
}
|
||||
@@ -444,7 +446,7 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
||||
getCargoTableByBox(BuildContext context) {
|
||||
total = 0;
|
||||
List<Widget> dataRow = _cargoTypes.map((cargo) {
|
||||
var amount = cargo.weight * cargo.price;
|
||||
var amount = cargo.weight * cargo.rate;
|
||||
total += amount;
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
@@ -453,10 +455,10 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
||||
left: 5.0, right: 5.0, top: 15.0, bottom: 15.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(flex: 2, child: Text('${cargo.type}')),
|
||||
Expanded(flex: 2, child: Text('${cargo.rate}')),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text('${cargo.weight} x ${cargo.price}',
|
||||
child: Text('${cargo.weight} x ${cargo.rate}',
|
||||
textAlign: TextAlign.center)),
|
||||
Expanded(
|
||||
child: Text('\$ $amount',
|
||||
@@ -736,7 +738,7 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
||||
return _boxes.map((p) {
|
||||
p.cargoTypes.map((cargo) {
|
||||
_cargoTypes.asMap().map((index, _cargo) {
|
||||
if (_cargo.type == cargo.type) {
|
||||
if (_cargo.id == cargo.id) {
|
||||
setState(() {
|
||||
_cargoTypes[index].weight += cargo.weight;
|
||||
});
|
||||
@@ -776,16 +778,16 @@ class _InvoiceInfoPageState extends State<InvoiceInfoPage> {
|
||||
List<MyDataRow> getCargoDataRow(BuildContext context) {
|
||||
return _cargoTypes.asMap().entries.map((c) {
|
||||
var cargo = c.value;
|
||||
var amt = cargo.weight * cargo.price;
|
||||
var amt = cargo.weight * cargo.rate;
|
||||
return MyDataRow(
|
||||
onSelectChanged: (bool selected) {},
|
||||
cells: [
|
||||
MyDataCell(new Text(
|
||||
cargo.type,
|
||||
cargo.name,
|
||||
style: textStyle,
|
||||
)),
|
||||
MyDataCell(new Text(
|
||||
cargo.weight.toString() + ' x ' + cargo.price.toString(),
|
||||
cargo.weight.toString() + ' x ' + cargo.rate.toString(),
|
||||
style: textStyle,
|
||||
)),
|
||||
MyDataCell(new Text(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:fcs/domain/entities/pickup.dart';
|
||||
import 'package:fcs/domain/entities/shipment.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Reference in New Issue
Block a user