add fcs shipment apis

This commit is contained in:
Sai Naw Wun
2020-10-08 03:32:52 +06:30
parent ad1999f5c9
commit 6105b45cb8
23 changed files with 442 additions and 531 deletions

View File

@@ -1,31 +0,0 @@
class BankAccount {
int index;
String bankName;
String bankLogo;
String accountName;
String accountNumber;
BankAccount(
{this.index,
this.bankName,
this.bankLogo,
this.accountName,
this.accountNumber});
BankAccount.fromMap(int index, Map<String, dynamic> json) {
this.index = index;
bankName = json['bank_name'];
bankLogo = json['bank_logo'];
accountName = json['account_name'];
accountNumber = json['account_number'];
}
Map<String, dynamic> toMap() {
return {
"index": index,
'bank_name': bankName,
'bank_logo': bankLogo,
'account_name': accountName,
'account_number': accountNumber,
};
}
}

View File

@@ -1,6 +1,9 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import '../constants.dart';
class FcsShipment {
String id;
DateTime shipDate;
String shipmentNumber;
DateTime cutoffDate;
String shipType;
@@ -10,25 +13,41 @@ class FcsShipment {
String port;
String destination;
String status;
String remark;
FcsShipment(
{this.id,
this.shipDate,
this.shipmentNumber,
this.cutoffDate,
this.shipType,
this.status,
this.arrivalDate,
this.departureDate,
this.consignee,
this.port,
this.destination,
this.remark});
FcsShipment({
this.id,
this.shipmentNumber,
this.cutoffDate,
this.shipType,
this.status,
this.arrivalDate,
this.departureDate,
this.consignee,
this.port,
this.destination,
});
factory FcsShipment.fromMap(Map<String, dynamic> map, String docID) {
var _cutoffDate = (map['cutoff_date'] as Timestamp);
var _arrivalDate = (map['arrival_date'] as Timestamp);
var _departureDate = (map['departure_date'] as Timestamp);
return FcsShipment(
id: docID,
cutoffDate: _cutoffDate != null ? _cutoffDate.toDate() : null,
arrivalDate: _arrivalDate != null ? _arrivalDate.toDate() : null,
departureDate: _departureDate != null ? _departureDate.toDate() : null,
shipmentNumber: map['shipment_number'],
shipType: map['shipment_type'],
status: map['status'],
consignee: map['consignee'],
port: map['port'],
destination: map['destination'],
);
}
Map<String, dynamic> toMap() {
return {
"id": id,
'shipment_date': shipDate?.toUtc()?.toIso8601String(),
'shipment_number': shipmentNumber,
'cutoff_date': cutoffDate?.toUtc()?.toIso8601String(),
'shipment_type': shipType,
@@ -38,7 +57,10 @@ class FcsShipment {
'port': port,
'destination': destination,
'status': status,
'remark': remark,
};
}
bool isConfirmed() {
return status == fcs_shipment_confirmed_status;
}
}

View File

@@ -1,7 +1,3 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'bank_account.dart';
List<Day> dayLists = [
Day(id: 1, name: 'Sun'),
Day(id: 2, name: 'Mon'),
@@ -26,140 +22,42 @@ class Setting {
String appUrl;
final String termsEng;
final String termsMm;
String about;
final String okEnergyId;
final String about;
int poExpireInHours;
int doExpireInHours;
int poOpenAt;
int poCloseAt;
List<int> poCloseOn;
int latestDeliveryDay;
int firstStorageChargeIn;
int firstStorageCharge;
int secondStorageChargeIn;
int secondStorageCharge;
int deliveryStartWaitMin;
String reportURL;
String helpVersion;
String helpURL;
List<String> shipmentTypes;
List<String> phones;
String deliveryPhone;
String address;
String website;
DateTime priceLastUpdate;
String bankAccountInfo;
List<BankAccount> bankAccounts;
String get getPoOpenAt => poOpenAt > 12
? (poOpenAt - 12).toString() + "PM"
: poOpenAt.toString() + "AM";
String get getPoCloseAt => poCloseAt > 12
? (poCloseAt - 12).toString() + "PM"
: poCloseAt.toString() + "AM";
String get getPoCloseOn => poCloseOn.fold(
"", (p, e) => p + (p == "" ? "" : ", ") + dayLists[e - 1].name);
String get getPoOpenOn => dayLists.fold(
"",
(p, e) =>
p +
(p == "" ? "" : poCloseOn.contains(e.id) ? "" : ", ") +
(poCloseOn.contains(e.id) ? "" : e.name));
bool get isPOClose {
DateTime now = DateTime.now();
// dart starts from monday width starting index one
// server starts from sunday with starting index one
var day = (now.weekday + 1) == 8 ? 1 : now.weekday + 1;
return poCloseOn.contains(day) ||
(now.hour < poOpenAt || now.hour >= poCloseAt);
}
Setting(
{this.supportBuildNum,
this.usaAddress,
this.mmAddress,
this.usaContactNumber,
this.mmContactNumber,
this.emailAddress,
this.facebookLink,
this.inviteRequired,
this.appUrl,
this.termsEng,
this.termsMm,
this.about,
this.okEnergyId,
this.poExpireInHours,
this.doExpireInHours,
this.poOpenAt,
this.poCloseAt,
this.poCloseOn,
this.latestDeliveryDay,
this.firstStorageCharge,
this.firstStorageChargeIn,
this.secondStorageCharge,
this.secondStorageChargeIn,
this.deliveryStartWaitMin,
this.reportURL,
this.helpVersion,
this.helpURL,
this.phones,
this.website,
this.priceLastUpdate,
this.bankAccountInfo,
this.bankAccounts,
this.deliveryPhone,
this.address});
Setting({
this.supportBuildNum,
this.usaAddress,
this.mmAddress,
this.usaContactNumber,
this.mmContactNumber,
this.emailAddress,
this.facebookLink,
this.inviteRequired,
this.appUrl,
this.termsEng,
this.termsMm,
this.about,
this.shipmentTypes,
});
factory Setting.fromMap(Map<String, dynamic> map) {
var ts = (map['price_last_update'] as Timestamp);
var list = (map['bank_accounts'] as List);
List<BankAccount> bankAccounts = [];
if (list != null) {
list.asMap().forEach((index, item) {
bankAccounts
.add(BankAccount.fromMap(index, item.cast<String, dynamic>()));
});
}
return Setting(
supportBuildNum: map['support_build_number'],
inviteRequired: map['invite_required'],
appUrl: map['app_url'],
usaAddress: map['usa_address'],
mmAddress: map['mm_address'],
usaContactNumber: map['usa_contact_number'],
mmContactNumber: map['mm_contact_number'],
emailAddress: map['email_address'],
facebookLink: map['facebook_link'],
about: map['about'],
termsEng: map['terms_eng'],
termsMm: map['terms_mm'],
priceLastUpdate: ts?.toDate(),
okEnergyId: map['ok_energy_id'],
poExpireInHours: map['po_expire_hours'],
doExpireInHours: map['do_expire_hours'],
poOpenAt: map['po_open_at'],
poCloseAt: map['po_close_at'],
latestDeliveryDay: map['latest_delivery_days'],
firstStorageChargeIn: map['first_storage_charge_in'],
firstStorageCharge: map['first_storage_charge'],
secondStorageChargeIn: map['second_storage_charge_in'],
secondStorageCharge: map['second_storage_charge'],
deliveryStartWaitMin: map['delivery_start_wait_min'],
reportURL: map['report_url'],
helpVersion: map['help_version'],
helpURL: map['help_url'],
deliveryPhone: map['delivery_phone'],
address: map['address'],
website: map['website'],
bankAccountInfo: map['bank_account_info'],
bankAccounts: bankAccounts);
supportBuildNum: map['support_build_number'],
inviteRequired: map['invite_required'],
appUrl: map['app_url'],
usaAddress: map['usa_address'],
mmAddress: map['mm_address'],
usaContactNumber: map['usa_contact_number'],
mmContactNumber: map['mm_contact_number'],
emailAddress: map['email_address'],
facebookLink: map['facebook_link'],
about: map['about'],
termsEng: map['terms_eng'],
termsMm: map['terms_mm'],
shipmentTypes: List.from(map['shipment_types']),
);
}
Map<String, dynamic> toMap() {
@@ -169,13 +67,9 @@ class Setting {
};
}
String helpFileName() {
return "help-v$helpVersion.zip";
}
@override
String toString() {
return 'Setting{supportBuildNum:$supportBuildNum,about:$about,okEnergyId:$okEnergyId}';
return 'Setting{supportBuildNum:$supportBuildNum,about:$about}';
}
}