first commit
This commit is contained in:
31
lib/model/add_to_cart_model.dart
Normal file
31
lib/model/add_to_cart_model.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
class SaleCartModel {
|
||||
SaleCartModel({
|
||||
required this.productId,
|
||||
this.productCode,
|
||||
this.productType,
|
||||
required this.batchName,
|
||||
required this.stockId,
|
||||
this.productName,
|
||||
this.unitPrice,
|
||||
this.quantity = 1,
|
||||
this.itemCartIndex = -1,
|
||||
this.stock,
|
||||
this.productPurchasePrice,
|
||||
this.lossProfit,
|
||||
this.discountAmount,
|
||||
});
|
||||
|
||||
num productId;
|
||||
num stockId;
|
||||
String batchName;
|
||||
String? productType;
|
||||
String? productCode;
|
||||
String? productName;
|
||||
num? unitPrice;
|
||||
num? productPurchasePrice;
|
||||
num quantity = 1;
|
||||
int itemCartIndex;
|
||||
num? stock;
|
||||
num? lossProfit;
|
||||
num? discountAmount;
|
||||
}
|
||||
72
lib/model/balance_sheet_model.dart
Normal file
72
lib/model/balance_sheet_model.dart
Normal file
@@ -0,0 +1,72 @@
|
||||
class BalanceSheetModel {
|
||||
final num? totalAsset;
|
||||
final List<AssetData>? data;
|
||||
|
||||
BalanceSheetModel({this.totalAsset, this.data});
|
||||
|
||||
factory BalanceSheetModel.fromJson(Map<String, dynamic> json) {
|
||||
return BalanceSheetModel(
|
||||
totalAsset: json["total_asset"],
|
||||
data: json["asset_datas"] == null
|
||||
? []
|
||||
: List<AssetData>.from(json["asset_datas"]!.map((x) => AssetData.fromJson(x))),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AssetData {
|
||||
final int? id;
|
||||
final String? name;
|
||||
final num? amount;
|
||||
|
||||
AssetData({this.id, this.name, this.amount});
|
||||
|
||||
factory AssetData.fromJson(Map<String, dynamic> json) {
|
||||
final _source = json["source"]?.toString().trim().toLowerCase();
|
||||
final _productType = json["product_type"]?.toString().trim().toLowerCase();
|
||||
|
||||
final String? _name = switch (_source) {
|
||||
"product" => json["productName"],
|
||||
"bank" => json["meta"]?["bank_name"] ?? "Bank Account",
|
||||
_ => null,
|
||||
};
|
||||
|
||||
num _amount = 0;
|
||||
|
||||
if (_source == "product") {
|
||||
if (_productType == "single" || _productType == "variation") {
|
||||
final stocks = json["stocks"];
|
||||
|
||||
if (stocks is List && stocks.isNotEmpty) {
|
||||
final _firstStock = stocks.first as Map<String, dynamic>;
|
||||
|
||||
final _purchasePrice = (_firstStock["productPurchasePrice"] as num?) ?? 0;
|
||||
final _stockQty = (_firstStock["productStock"] as num?) ?? 0;
|
||||
|
||||
_amount = _purchasePrice * _stockQty;
|
||||
}
|
||||
} else if (_productType == "combo") {
|
||||
final comboProducts = json["combo_products"];
|
||||
|
||||
if (comboProducts is List) {
|
||||
_amount = comboProducts.fold<num>(0, (sum, item) {
|
||||
if (item is Map<String, dynamic>) {
|
||||
final _price = (item["purchase_price"] as num?) ?? 0;
|
||||
final _qty = (item["quantity"] as num?) ?? 0;
|
||||
return sum + (_price * _qty);
|
||||
}
|
||||
return sum;
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (_source == "bank") {
|
||||
_amount = (json["balance"] as num?) ?? 0;
|
||||
}
|
||||
|
||||
return AssetData(
|
||||
id: json["id"],
|
||||
name: _name,
|
||||
amount: _amount,
|
||||
);
|
||||
}
|
||||
}
|
||||
91
lib/model/bill_wise_loss_profit_report_model.dart
Normal file
91
lib/model/bill_wise_loss_profit_report_model.dart
Normal file
@@ -0,0 +1,91 @@
|
||||
class BillWiseLossProfitReportModel {
|
||||
final num? totalSaleAmount;
|
||||
final num? totalProfit;
|
||||
final num? totalLoss;
|
||||
final List<TransactionModel>? transactions;
|
||||
|
||||
BillWiseLossProfitReportModel({
|
||||
this.totalSaleAmount,
|
||||
this.totalProfit,
|
||||
this.totalLoss,
|
||||
this.transactions,
|
||||
});
|
||||
|
||||
factory BillWiseLossProfitReportModel.fromJson(Map<String, dynamic> json) {
|
||||
return BillWiseLossProfitReportModel(
|
||||
totalSaleAmount: json["total_amount"],
|
||||
totalProfit: json['total_bill_profit'],
|
||||
totalLoss: json['total_bill_loss'],
|
||||
transactions: json['data'] == null
|
||||
? null
|
||||
: List<TransactionModel>.from(json['data'].map((x) => TransactionModel.fromJson(x))),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TransactionModel {
|
||||
final int? id;
|
||||
final String? partyName;
|
||||
final String? invoiceNumber;
|
||||
final DateTime? transactionDate;
|
||||
final num? totalAmount;
|
||||
final num? lossProfit;
|
||||
final List<TransactionItem>? items;
|
||||
|
||||
bool get isProfit => (lossProfit ?? 0) > 0;
|
||||
|
||||
TransactionModel({
|
||||
this.id,
|
||||
this.partyName,
|
||||
this.invoiceNumber,
|
||||
this.transactionDate,
|
||||
this.totalAmount,
|
||||
this.lossProfit,
|
||||
this.items,
|
||||
});
|
||||
|
||||
factory TransactionModel.fromJson(Map<String, dynamic> json) {
|
||||
return TransactionModel(
|
||||
id: json['id'],
|
||||
partyName: json['party']?['name'],
|
||||
invoiceNumber: json['invoiceNumber'],
|
||||
transactionDate: json["saleDate"] == null ? null : DateTime.parse(json['saleDate']),
|
||||
totalAmount: json['totalAmount'],
|
||||
lossProfit: json['lossProfit'],
|
||||
items: json['details'] == null
|
||||
? null
|
||||
: List<TransactionItem>.from(json['details'].map((x) => TransactionItem.fromJson(x))),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TransactionItem {
|
||||
final int? id;
|
||||
final String? name;
|
||||
final int? quantity;
|
||||
final num? purchasePrice;
|
||||
final num? salesPrice;
|
||||
final num? lossProfit;
|
||||
|
||||
bool get isProfit => (lossProfit ?? 0) > 0;
|
||||
|
||||
TransactionItem({
|
||||
this.id,
|
||||
this.name,
|
||||
this.quantity,
|
||||
this.purchasePrice,
|
||||
this.salesPrice,
|
||||
this.lossProfit,
|
||||
});
|
||||
|
||||
factory TransactionItem.fromJson(Map<String, dynamic> json) {
|
||||
return TransactionItem(
|
||||
id: json['id'],
|
||||
name: json['product']?['productName'],
|
||||
quantity: json['quantities'],
|
||||
purchasePrice: json['productPurchasePrice'],
|
||||
salesPrice: json['price'],
|
||||
lossProfit: json['lossProfit'],
|
||||
);
|
||||
}
|
||||
}
|
||||
21
lib/model/business_category_model.dart
Normal file
21
lib/model/business_category_model.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
class BusinessCategory {
|
||||
final int id;
|
||||
final String name;
|
||||
final String description;
|
||||
|
||||
// Add other fields as needed
|
||||
|
||||
BusinessCategory({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.description,
|
||||
});
|
||||
|
||||
factory BusinessCategory.fromJson(Map<String, dynamic> json) {
|
||||
return BusinessCategory(
|
||||
id: json['id'] ?? 0,
|
||||
name: json['name'] ?? '',
|
||||
description: json['description'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
428
lib/model/business_info_model.dart
Normal file
428
lib/model/business_info_model.dart
Normal file
@@ -0,0 +1,428 @@
|
||||
class BusinessInformationModel {
|
||||
BusinessInformationModel({
|
||||
this.message,
|
||||
this.data,
|
||||
});
|
||||
|
||||
BusinessInformationModel.fromJson(dynamic json) {
|
||||
message = json['message'];
|
||||
data = json['data'] != null ? BusinessInfoData.fromJson(json['data']) : null;
|
||||
}
|
||||
String? message;
|
||||
BusinessInfoData? data;
|
||||
}
|
||||
|
||||
class BusinessInfoData {
|
||||
BusinessInfoData({
|
||||
this.id,
|
||||
this.planSubscribeId,
|
||||
this.businessCategoryId,
|
||||
this.affiliatorId,
|
||||
this.companyName,
|
||||
this.willExpire,
|
||||
this.address,
|
||||
this.phoneNumber,
|
||||
this.pictureUrl,
|
||||
this.subscriptionDate,
|
||||
this.remainingShopBalance,
|
||||
this.shopOpeningBalance,
|
||||
this.vatNo,
|
||||
this.vatName,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.category,
|
||||
this.enrolledPlan,
|
||||
this.user,
|
||||
this.businessCurrency,
|
||||
this.invoiceLogo,
|
||||
this.saleRoundingOption,
|
||||
this.invoiceSize,
|
||||
this.invoiceNoteLevel,
|
||||
this.invoiceNote,
|
||||
this.gratitudeMessage,
|
||||
this.developByLevel,
|
||||
this.developBy,
|
||||
this.developByLink,
|
||||
this.branchCount,
|
||||
this.invoiceLanguage,
|
||||
this.addons,
|
||||
this.invoiceEmail,
|
||||
this.showNote,
|
||||
this.warrantyVoidLabel,
|
||||
this.warrantyVoid,
|
||||
this.meta,
|
||||
this.showGratitudeMsg,
|
||||
this.showInvoiceScannerLogo,
|
||||
this.showA4InvoiceLogo,
|
||||
this.showThermalInvoiceLogo,
|
||||
this.showWarranty,
|
||||
});
|
||||
|
||||
BusinessInfoData.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
planSubscribeId = json['plan_subscribe_id'];
|
||||
invoiceEmail = json['email'];
|
||||
businessCategoryId = json['business_category_id'];
|
||||
affiliatorId = json['affiliator_id'];
|
||||
companyName = json['companyName'];
|
||||
willExpire = json['will_expire'];
|
||||
address = json['address'];
|
||||
phoneNumber = json['phoneNumber'];
|
||||
pictureUrl = json['pictureUrl'];
|
||||
subscriptionDate = json['subscriptionDate'];
|
||||
remainingShopBalance = json['remainingShopBalance'];
|
||||
shopOpeningBalance = json['shopOpeningBalance'];
|
||||
vatNo = json['vat_no'];
|
||||
vatName = json['vat_name'];
|
||||
createdAt = json['created_at'];
|
||||
updatedAt = json['updated_at'];
|
||||
category = json['category'] != null ? Category.fromJson(json['category']) : null;
|
||||
enrolledPlan = json['enrolled_plan'] != null ? EnrolledPlan.fromJson(json['enrolled_plan']) : null;
|
||||
user = json['user'] != null ? User.fromJson(json['user']) : null;
|
||||
meta = json['meta'] != null ? BusinessMeta.fromJson(json['meta']) : null;
|
||||
businessCurrency = json['business_currency'] != null ? BusinessCurrency.fromJson(json['business_currency']) : null;
|
||||
invoiceLogo = json['invoice_logo'];
|
||||
thermalInvoiceLogo = json['thermal_invoice_logo'];
|
||||
a4InvoiceLogo = json['a4_invoice_logo'];
|
||||
invoiceScannerLogo = json['invoice_scanner_logo'];
|
||||
saleRoundingOption = json['sale_rounding_option'];
|
||||
invoiceSize = json['invoice_size'];
|
||||
invoiceNoteLevel = json['note_label'];
|
||||
invoiceNote = json['note'];
|
||||
gratitudeMessage = json['gratitude_message'];
|
||||
warrantyVoidLabel = json['warranty_void_label'];
|
||||
warrantyVoid = json['warranty_void'];
|
||||
developByLevel = json['develop_by_level'];
|
||||
developBy = json['develop_by'];
|
||||
developByLink = json['develop_by_link'];
|
||||
branchCount = json['branch_count'];
|
||||
addons = json['addons'] != null ? Addons.fromJson(json['addons']) : null;
|
||||
invoiceLanguage = json['invoice_language'];
|
||||
showNote = json['show_note'];
|
||||
showGratitudeMsg = json['show_gratitude_msg'];
|
||||
showInvoiceScannerLogo = json['show_invoice_scanner_logo'];
|
||||
showA4InvoiceLogo = json['show_a4_invoice_logo'];
|
||||
showThermalInvoiceLogo = json['show_thermal_invoice_logo'];
|
||||
showWarranty = json['show_warranty'];
|
||||
}
|
||||
num? id;
|
||||
num? planSubscribeId;
|
||||
num? businessCategoryId;
|
||||
num? affiliatorId;
|
||||
String? companyName;
|
||||
String? willExpire;
|
||||
String? address;
|
||||
String? phoneNumber;
|
||||
String? pictureUrl;
|
||||
String? subscriptionDate;
|
||||
num? remainingShopBalance;
|
||||
num? shopOpeningBalance;
|
||||
String? vatNo;
|
||||
String? vatName;
|
||||
String? createdAt;
|
||||
String? updatedAt;
|
||||
Category? category;
|
||||
EnrolledPlan? enrolledPlan;
|
||||
User? user;
|
||||
BusinessCurrency? businessCurrency;
|
||||
String? invoiceLogo;
|
||||
String? thermalInvoiceLogo;
|
||||
String? a4InvoiceLogo;
|
||||
String? invoiceScannerLogo;
|
||||
String? saleRoundingOption;
|
||||
String? invoiceSize;
|
||||
String? invoiceLanguage;
|
||||
String? invoiceNoteLevel;
|
||||
String? invoiceNote;
|
||||
String? gratitudeMessage;
|
||||
String? warrantyVoidLabel;
|
||||
String? warrantyVoid;
|
||||
String? developByLevel;
|
||||
String? developBy;
|
||||
int? showNote;
|
||||
int? showGratitudeMsg;
|
||||
int? showInvoiceScannerLogo;
|
||||
int? showA4InvoiceLogo;
|
||||
int? showThermalInvoiceLogo;
|
||||
int? showWarranty;
|
||||
String? invoiceEmail;
|
||||
BusinessMeta? meta;
|
||||
|
||||
String? developByLink;
|
||||
num? branchCount;
|
||||
Addons? addons;
|
||||
}
|
||||
|
||||
class BusinessMeta {
|
||||
BusinessMeta(
|
||||
{this.showCompanyName, this.showPhoneNumber, this.showAddress, this.showEmail, this.showVat, this.showVatName});
|
||||
|
||||
BusinessMeta.fromJson(dynamic json) {
|
||||
showCompanyName = json['show_company_name'];
|
||||
showPhoneNumber = json['show_phone_number'];
|
||||
showAddress = json['show_address'];
|
||||
showEmail = json['show_email'];
|
||||
showVat = json['show_vat'];
|
||||
}
|
||||
|
||||
num? showCompanyName;
|
||||
num? showPhoneNumber;
|
||||
num? showAddress;
|
||||
num? showEmail;
|
||||
num? showVat;
|
||||
num? showVatName;
|
||||
}
|
||||
|
||||
class Addons {
|
||||
Addons({
|
||||
this.affiliateAddon,
|
||||
this.multiBranchAddon,
|
||||
this.warehouseAddon,
|
||||
this.thermalPrinterAddon,
|
||||
this.hrmAddon,
|
||||
this.domainAddon,
|
||||
});
|
||||
|
||||
Addons.fromJson(dynamic json) {
|
||||
affiliateAddon = json['AffiliateAddon'];
|
||||
multiBranchAddon = json['MultiBranchAddon'];
|
||||
warehouseAddon = json['WarehouseAddon'];
|
||||
thermalPrinterAddon = json['ThermalPrinterAddon'];
|
||||
hrmAddon = json['HrmAddon'];
|
||||
domainAddon = json['DomainAddon'];
|
||||
}
|
||||
bool? affiliateAddon;
|
||||
bool? multiBranchAddon;
|
||||
bool? warehouseAddon;
|
||||
bool? thermalPrinterAddon;
|
||||
bool? hrmAddon;
|
||||
bool? domainAddon;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['AffiliateAddon'] = affiliateAddon;
|
||||
map['MultiBranchAddon'] = multiBranchAddon;
|
||||
map['WarehouseAddon'] = warehouseAddon;
|
||||
map['ThermalPrinterAddon'] = thermalPrinterAddon;
|
||||
map['HrmAddon'] = hrmAddon;
|
||||
map['DomainAddon'] = domainAddon;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class BusinessCurrency {
|
||||
BusinessCurrency({
|
||||
this.id,
|
||||
this.name,
|
||||
this.code,
|
||||
this.symbol,
|
||||
this.position,
|
||||
});
|
||||
|
||||
BusinessCurrency.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
code = json['code'];
|
||||
symbol = json['symbol'];
|
||||
position = json['position'];
|
||||
}
|
||||
num? id;
|
||||
String? name;
|
||||
String? code;
|
||||
String? symbol;
|
||||
String? position;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['name'] = name;
|
||||
map['code'] = code;
|
||||
map['symbol'] = symbol;
|
||||
map['position'] = position;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class User {
|
||||
User({
|
||||
this.id,
|
||||
this.name,
|
||||
this.role,
|
||||
required this.visibility,
|
||||
this.lang,
|
||||
this.email,
|
||||
this.visibilityIsNull = false,
|
||||
this.activeBranch,
|
||||
this.activeBranchId,
|
||||
this.branchId,
|
||||
});
|
||||
|
||||
factory User.fromJson(Map<String, dynamic> json) {
|
||||
final rawVisibility = json['visibility'];
|
||||
Map<String, Map<String, String>> parsedVisibility = {};
|
||||
bool visibilityIsNull = false;
|
||||
|
||||
if (rawVisibility == null) {
|
||||
visibilityIsNull = true;
|
||||
} else if (rawVisibility is Map<String, dynamic>) {
|
||||
parsedVisibility = rawVisibility.map((moduleKey, perms) {
|
||||
if (perms is Map<String, dynamic>) {
|
||||
return MapEntry(
|
||||
moduleKey,
|
||||
perms.map((permKey, value) => MapEntry(permKey, value.toString())),
|
||||
);
|
||||
}
|
||||
return MapEntry(moduleKey, <String, String>{});
|
||||
});
|
||||
}
|
||||
|
||||
return User(
|
||||
id: json['id'],
|
||||
email: json['email'],
|
||||
name: json['name'],
|
||||
role: json['role'],
|
||||
lang: json['lang'],
|
||||
visibility: parsedVisibility,
|
||||
visibilityIsNull: visibilityIsNull,
|
||||
activeBranch: json['active_branch'] != null ? ActiveBranch.fromJson(json['active_branch']) : null,
|
||||
activeBranchId: json['active_branch_id'],
|
||||
branchId: json['branch_id'],
|
||||
);
|
||||
}
|
||||
|
||||
final bool visibilityIsNull; // new field
|
||||
|
||||
/// 🔍 Get all enabled permissions in format: `module.permission`
|
||||
List<String> getAllPermissions() {
|
||||
if (visibilityIsNull) {
|
||||
return [];
|
||||
}
|
||||
|
||||
final List<String> permissions = [];
|
||||
visibility.forEach((module, perms) {
|
||||
perms.forEach((action, value) {
|
||||
if (value == "1") {
|
||||
permissions.add('$module.$action');
|
||||
}
|
||||
});
|
||||
});
|
||||
return permissions;
|
||||
}
|
||||
|
||||
num? id;
|
||||
String? name;
|
||||
String? role;
|
||||
final Map<String, Map<String, String>> visibility;
|
||||
dynamic lang;
|
||||
String? email;
|
||||
num? branchId;
|
||||
num? activeBranchId;
|
||||
|
||||
ActiveBranch? activeBranch;
|
||||
}
|
||||
|
||||
class ActiveBranch {
|
||||
ActiveBranch({
|
||||
this.id,
|
||||
this.name,
|
||||
});
|
||||
|
||||
ActiveBranch.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
}
|
||||
num? id;
|
||||
String? name;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['name'] = name;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class EnrolledPlan {
|
||||
EnrolledPlan({
|
||||
this.id,
|
||||
this.planId,
|
||||
this.businessId,
|
||||
this.price,
|
||||
this.duration,
|
||||
this.allowMultibranch,
|
||||
this.plan,
|
||||
});
|
||||
|
||||
EnrolledPlan.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
planId = json['plan_id'];
|
||||
businessId = json['business_id'];
|
||||
price = json['price'];
|
||||
duration = json['duration'];
|
||||
allowMultibranch = json['allow_multibranch'];
|
||||
plan = json['plan'] != null ? Plan.fromJson(json['plan']) : null;
|
||||
}
|
||||
num? id;
|
||||
num? planId;
|
||||
num? businessId;
|
||||
num? price;
|
||||
num? duration;
|
||||
num? allowMultibranch;
|
||||
Plan? plan;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['plan_id'] = planId;
|
||||
map['business_id'] = businessId;
|
||||
map['price'] = price;
|
||||
map['duration'] = duration;
|
||||
map['allow_multibranch'] = allowMultibranch;
|
||||
if (plan != null) {
|
||||
map['plan'] = plan?.toJson();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class Plan {
|
||||
Plan({
|
||||
this.id,
|
||||
this.subscriptionName,
|
||||
});
|
||||
|
||||
Plan.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
subscriptionName = json['subscriptionName'];
|
||||
}
|
||||
num? id;
|
||||
String? subscriptionName;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['subscriptionName'] = subscriptionName;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class Category {
|
||||
Category({
|
||||
this.id,
|
||||
this.name,
|
||||
});
|
||||
|
||||
Category.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
}
|
||||
num? id;
|
||||
String? name;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['name'] = name;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
329
lib/model/business_info_model_new.dart
Normal file
329
lib/model/business_info_model_new.dart
Normal file
@@ -0,0 +1,329 @@
|
||||
// class BusinessInfoModelNew {
|
||||
// BusinessInfoModelNew({
|
||||
// this.message,
|
||||
// this.data,
|
||||
// });
|
||||
//
|
||||
// BusinessInfoModelNew.fromJson(dynamic json) {
|
||||
// message = json['message'];
|
||||
// data = json['data'] != null ? BusinessInfoData.fromJson(json['data']) : null;
|
||||
// }
|
||||
// String? message;
|
||||
// BusinessInfoData? data;
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['message'] = message;
|
||||
// if (data != null) {
|
||||
// map['data'] = data?.toJson();
|
||||
// }
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class BusinessInfoData {
|
||||
// BusinessInfoData({
|
||||
// this.id,
|
||||
// this.planSubscribeId,
|
||||
// this.businessCategoryId,
|
||||
// this.affiliatorId,
|
||||
// this.companyName,
|
||||
// this.willExpire,
|
||||
// this.address,
|
||||
// this.phoneNumber,
|
||||
// this.pictureUrl,
|
||||
// this.subscriptionDate,
|
||||
// this.remainingShopBalance,
|
||||
// this.shopOpeningBalance,
|
||||
// this.vatNo,
|
||||
// this.vatName,
|
||||
// this.createdAt,
|
||||
// this.updatedAt,
|
||||
// this.category,
|
||||
// this.enrolledPlan,
|
||||
// this.user,
|
||||
// this.businessCurrency,
|
||||
// this.invoiceLogo,
|
||||
// this.saleRoundingOption,
|
||||
// this.invoiceSize,
|
||||
// this.invoiceNoteLevel,
|
||||
// this.invoiceNote,
|
||||
// this.gratitudeMessage,
|
||||
// this.developByLevel,
|
||||
// this.developBy,
|
||||
// this.developByLink,
|
||||
// });
|
||||
//
|
||||
// BusinessInfoData.fromJson(dynamic json) {
|
||||
// id = json['id'];
|
||||
// planSubscribeId = json['plan_subscribe_id'];
|
||||
// businessCategoryId = json['business_category_id'];
|
||||
// affiliatorId = json['affiliator_id'];
|
||||
// companyName = json['companyName'];
|
||||
// willExpire = json['will_expire'];
|
||||
// address = json['address'];
|
||||
// phoneNumber = json['phoneNumber'];
|
||||
// pictureUrl = json['pictureUrl'];
|
||||
// subscriptionDate = json['subscriptionDate'];
|
||||
// remainingShopBalance = json['remainingShopBalance'];
|
||||
// shopOpeningBalance = json['shopOpeningBalance'];
|
||||
// vatNo = json['vat_no'];
|
||||
// vatName = json['vat_name'];
|
||||
// createdAt = json['created_at'];
|
||||
// updatedAt = json['updated_at'];
|
||||
// category = json['category'] != null ? Category.fromJson(json['category']) : null;
|
||||
// enrolledPlan = json['enrolled_plan'] != null ? EnrolledPlan.fromJson(json['enrolled_plan']) : null;
|
||||
// user = json['user'] != null ? User.fromJson(json['user']) : null;
|
||||
// businessCurrency = json['business_currency'] != null ? BusinessCurrency.fromJson(json['business_currency']) : null;
|
||||
// invoiceLogo = json['invoice_logo'];
|
||||
// saleRoundingOption = json['sale_rounding_option'];
|
||||
// invoiceSize = json['invoice_size'];
|
||||
// invoiceNoteLevel = json['invoice_note_level'];
|
||||
// invoiceNote = json['invoice_note'];
|
||||
// gratitudeMessage = json['gratitude_message'];
|
||||
// developByLevel = json['develop_by_level'];
|
||||
// developBy = json['develop_by'];
|
||||
// developByLink = json['develop_by_link'];
|
||||
// }
|
||||
// num? id;
|
||||
// num? planSubscribeId;
|
||||
// num? businessCategoryId;
|
||||
// num? affiliatorId;
|
||||
// String? companyName;
|
||||
// String? willExpire;
|
||||
// String? address;
|
||||
// String? phoneNumber;
|
||||
// String? pictureUrl;
|
||||
// String? subscriptionDate;
|
||||
// num? remainingShopBalance;
|
||||
// num? shopOpeningBalance;
|
||||
// dynamic vatNo;
|
||||
// String? vatName;
|
||||
// String? createdAt;
|
||||
// String? updatedAt;
|
||||
// Category? category;
|
||||
// EnrolledPlan? enrolledPlan;
|
||||
// User? user;
|
||||
// BusinessCurrency? businessCurrency;
|
||||
// String? invoiceLogo;
|
||||
// String? saleRoundingOption;
|
||||
// dynamic invoiceSize;
|
||||
// String? invoiceNoteLevel;
|
||||
// String? invoiceNote;
|
||||
// String? gratitudeMessage;
|
||||
// String? developByLevel;
|
||||
// String? developBy;
|
||||
// String? developByLink;
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['id'] = id;
|
||||
// map['plan_subscribe_id'] = planSubscribeId;
|
||||
// map['business_category_id'] = businessCategoryId;
|
||||
// map['affiliator_id'] = affiliatorId;
|
||||
// map['companyName'] = companyName;
|
||||
// map['will_expire'] = willExpire;
|
||||
// map['address'] = address;
|
||||
// map['phoneNumber'] = phoneNumber;
|
||||
// map['pictureUrl'] = pictureUrl;
|
||||
// map['subscriptionDate'] = subscriptionDate;
|
||||
// map['remainingShopBalance'] = remainingShopBalance;
|
||||
// map['shopOpeningBalance'] = shopOpeningBalance;
|
||||
// map['vat_no'] = vatNo;
|
||||
// map['vat_name'] = vatName;
|
||||
// map['created_at'] = createdAt;
|
||||
// map['updated_at'] = updatedAt;
|
||||
// if (category != null) {
|
||||
// map['category'] = category?.toJson();
|
||||
// }
|
||||
// if (enrolledPlan != null) {
|
||||
// map['enrolled_plan'] = enrolledPlan?.toJson();
|
||||
// }
|
||||
// // if (user != null) {
|
||||
// // map['user'] = user?.toJson();
|
||||
// // }
|
||||
// if (businessCurrency != null) {
|
||||
// map['business_currency'] = businessCurrency?.toJson();
|
||||
// }
|
||||
// map['invoice_logo'] = invoiceLogo;
|
||||
// map['sale_rounding_option'] = saleRoundingOption;
|
||||
// map['invoice_size'] = invoiceSize;
|
||||
// map['invoice_note_level'] = invoiceNoteLevel;
|
||||
// map['invoice_note'] = invoiceNote;
|
||||
// map['gratitude_message'] = gratitudeMessage;
|
||||
// map['develop_by_level'] = developByLevel;
|
||||
// map['develop_by'] = developBy;
|
||||
// map['develop_by_link'] = developByLink;
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class BusinessCurrency {
|
||||
// BusinessCurrency({
|
||||
// this.id,
|
||||
// this.name,
|
||||
// this.code,
|
||||
// this.symbol,
|
||||
// this.position,
|
||||
// });
|
||||
//
|
||||
// BusinessCurrency.fromJson(dynamic json) {
|
||||
// id = json['id'];
|
||||
// name = json['name'];
|
||||
// code = json['code'];
|
||||
// symbol = json['symbol'];
|
||||
// position = json['position'];
|
||||
// }
|
||||
// num? id;
|
||||
// String? name;
|
||||
// String? code;
|
||||
// String? symbol;
|
||||
// String? position;
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['id'] = id;
|
||||
// map['name'] = name;
|
||||
// map['code'] = code;
|
||||
// map['symbol'] = symbol;
|
||||
// map['position'] = position;
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class User {
|
||||
// User({
|
||||
// this.id,
|
||||
// this.name,
|
||||
// this.role,
|
||||
// required this.visibility,
|
||||
// this.lang,
|
||||
// this.email,
|
||||
// });
|
||||
//
|
||||
// factory User.fromJson(Map<String, dynamic> json) {
|
||||
// final rawVisibility = json['visibility'];
|
||||
// Map<String, Map<String, String>> parsedVisibility = {};
|
||||
//
|
||||
// if (rawVisibility is Map<String, dynamic>) {
|
||||
// parsedVisibility = rawVisibility.map((moduleKey, perms) {
|
||||
// if (perms is Map<String, dynamic>) {
|
||||
// return MapEntry(
|
||||
// moduleKey,
|
||||
// perms.map((permKey, value) => MapEntry(permKey, value.toString())),
|
||||
// );
|
||||
// }
|
||||
// return MapEntry(moduleKey, <String, String>{});
|
||||
// });
|
||||
// }
|
||||
// return User(
|
||||
// id: json['id'],
|
||||
// email: json['email'],
|
||||
// name: json['name'],
|
||||
// role: json['role'],
|
||||
// lang: json['lang'],
|
||||
// visibility: parsedVisibility,
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// /// 🔍 Get all enabled permissions in format: `module.permission`
|
||||
// List<String> getAllPermissions() {
|
||||
// final List<String> permissions = [];
|
||||
// visibility.forEach((module, perms) {
|
||||
// perms.forEach((action, value) {
|
||||
// if (value == "1") {
|
||||
// permissions.add('$module.$action');
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// return permissions;
|
||||
// }
|
||||
//
|
||||
// num? id;
|
||||
// String? name;
|
||||
// String? role;
|
||||
// final Map<String, Map<String, String>> visibility;
|
||||
// dynamic lang;
|
||||
// String? email;
|
||||
// }
|
||||
//
|
||||
// class EnrolledPlan {
|
||||
// EnrolledPlan({
|
||||
// this.id,
|
||||
// this.planId,
|
||||
// this.businessId,
|
||||
// this.price,
|
||||
// this.duration,
|
||||
// this.plan,
|
||||
// });
|
||||
//
|
||||
// EnrolledPlan.fromJson(dynamic json) {
|
||||
// id = json['id'];
|
||||
// planId = json['plan_id'];
|
||||
// businessId = json['business_id'];
|
||||
// price = json['price'];
|
||||
// duration = json['duration'];
|
||||
// plan = json['plan'] != null ? Plan.fromJson(json['plan']) : null;
|
||||
// }
|
||||
// num? id;
|
||||
// num? planId;
|
||||
// num? businessId;
|
||||
// num? price;
|
||||
// num? duration;
|
||||
// Plan? plan;
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['id'] = id;
|
||||
// map['plan_id'] = planId;
|
||||
// map['business_id'] = businessId;
|
||||
// map['price'] = price;
|
||||
// map['duration'] = duration;
|
||||
// if (plan != null) {
|
||||
// map['plan'] = plan?.toJson();
|
||||
// }
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class Plan {
|
||||
// Plan({
|
||||
// this.id,
|
||||
// this.subscriptionName,
|
||||
// });
|
||||
//
|
||||
// Plan.fromJson(dynamic json) {
|
||||
// id = json['id'];
|
||||
// subscriptionName = json['subscriptionName'];
|
||||
// }
|
||||
// num? id;
|
||||
// String? subscriptionName;
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['id'] = id;
|
||||
// map['subscriptionName'] = subscriptionName;
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class Category {
|
||||
// Category({
|
||||
// this.id,
|
||||
// this.name,
|
||||
// });
|
||||
//
|
||||
// Category.fromJson(dynamic json) {
|
||||
// id = json['id'];
|
||||
// name = json['name'];
|
||||
// }
|
||||
// num? id;
|
||||
// String? name;
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['id'] = id;
|
||||
// map['name'] = name;
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
65
lib/model/cashflow_model.dart
Normal file
65
lib/model/cashflow_model.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
class CashflowModel {
|
||||
final num? cashIn;
|
||||
final num? cashOut;
|
||||
final num? runningCash;
|
||||
final num? initialRunningCash;
|
||||
final List<CashflowData>? data;
|
||||
|
||||
CashflowModel({
|
||||
this.cashIn,
|
||||
this.cashOut,
|
||||
this.runningCash,
|
||||
this.initialRunningCash,
|
||||
this.data,
|
||||
});
|
||||
|
||||
factory CashflowModel.fromJson(Map<String, dynamic> json) {
|
||||
return CashflowModel(
|
||||
cashIn: json["cash_in"],
|
||||
cashOut: json["cash_out"],
|
||||
runningCash: json["running_cash"],
|
||||
initialRunningCash: json["initial_running_cash"],
|
||||
data: json["data"] == null ? [] : List<CashflowData>.from(json["data"]!.map((x) => CashflowData.fromJson(x))),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CashflowData {
|
||||
final int? id;
|
||||
final String? platform;
|
||||
final String? transactionType;
|
||||
final String? type;
|
||||
final num? amount;
|
||||
final DateTime? date;
|
||||
final String? invoiceNo;
|
||||
final String? paymentType;
|
||||
final String? partyName;
|
||||
|
||||
CashflowData({
|
||||
this.id,
|
||||
this.platform,
|
||||
this.transactionType,
|
||||
this.type,
|
||||
this.amount,
|
||||
this.date,
|
||||
this.invoiceNo,
|
||||
this.paymentType,
|
||||
this.partyName,
|
||||
});
|
||||
|
||||
factory CashflowData.fromJson(Map<String, dynamic> json) {
|
||||
final _partyKey = (json["sale"]?["party"]) ?? (json["purchase"]?["party"]) ?? (json["due_collect"]?["party"]);
|
||||
|
||||
return CashflowData(
|
||||
id: json["id"],
|
||||
platform: json["platform"],
|
||||
transactionType: json["transaction_type"],
|
||||
type: json["type"],
|
||||
amount: json["amount"],
|
||||
date: json["date"] == null ? null : DateTime.parse(json["date"]),
|
||||
invoiceNo: json["invoice_no"],
|
||||
paymentType: json["payment_type"]?["name"],
|
||||
partyName: _partyKey?["name"],
|
||||
);
|
||||
}
|
||||
}
|
||||
25
lib/model/country_model.dart
Normal file
25
lib/model/country_model.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
class Country {
|
||||
final String name;
|
||||
final String code;
|
||||
final String emoji;
|
||||
final String unicode;
|
||||
final String image;
|
||||
|
||||
Country({
|
||||
required this.name,
|
||||
required this.code,
|
||||
required this.emoji,
|
||||
required this.unicode,
|
||||
required this.image,
|
||||
});
|
||||
|
||||
factory Country.fromJson(Map<String, dynamic> json) {
|
||||
return Country(
|
||||
name: json['name'] as String,
|
||||
code: json['code'] as String,
|
||||
emoji: json['emoji'] as String,
|
||||
unicode: json['unicode'] as String,
|
||||
image: json['image'] as String,
|
||||
);
|
||||
}
|
||||
}
|
||||
192
lib/model/dashboard_overview_model.dart
Normal file
192
lib/model/dashboard_overview_model.dart
Normal file
@@ -0,0 +1,192 @@
|
||||
class DashboardOverviewModel {
|
||||
DashboardOverviewModel({
|
||||
String? message,
|
||||
Data? data,
|
||||
}) {
|
||||
_message = message;
|
||||
_data = data;
|
||||
}
|
||||
|
||||
DashboardOverviewModel.fromJson(dynamic json) {
|
||||
_message = json['message'];
|
||||
_data = json['data'] != null ? Data.fromJson(json['data']) : null;
|
||||
}
|
||||
|
||||
String? _message;
|
||||
Data? _data;
|
||||
|
||||
String? get message => _message;
|
||||
|
||||
Data? get data => _data;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['message'] = _message;
|
||||
if (_data != null) {
|
||||
map['data'] = _data?.toJson();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
Data({
|
||||
num? totalItems,
|
||||
num? totalCategories,
|
||||
num? totalIncome,
|
||||
num? totalExpense,
|
||||
num? totalDue,
|
||||
num? stockQty,
|
||||
num? totalLoss,
|
||||
num? totalProfit,
|
||||
num? stockValue,
|
||||
List<Sales>? sales,
|
||||
List<Purchases>? purchases,
|
||||
}) {
|
||||
_totalItems = totalItems;
|
||||
_totalCategories = totalCategories;
|
||||
_totalIncome = totalIncome;
|
||||
_totalExpense = totalExpense;
|
||||
_totalDue = totalDue;
|
||||
// _stockQty = stockQty;
|
||||
_totalLoss = totalLoss;
|
||||
_totalProfit = totalProfit;
|
||||
_sales = sales;
|
||||
_purchases = purchases;
|
||||
}
|
||||
|
||||
Data.fromJson(dynamic json) {
|
||||
_totalItems = json['total_items'];
|
||||
_totalCategories = json['total_categories'];
|
||||
_totalIncome = json['total_income'];
|
||||
_totalExpense = json['total_expense'];
|
||||
_totalDue = json['total_due'];
|
||||
// _stockQty = json['stock_qty'];
|
||||
_totalLoss = json['total_loss'];
|
||||
_totalProfit = json['total_profit'];
|
||||
_stockValue = json['stock_value'];
|
||||
if (json['sales'] != null) {
|
||||
_sales = [];
|
||||
json['sales'].forEach((v) {
|
||||
_sales?.add(Sales.fromJson(v));
|
||||
});
|
||||
}
|
||||
if (json['purchases'] != null) {
|
||||
_purchases = [];
|
||||
json['purchases'].forEach((v) {
|
||||
_purchases?.add(Purchases.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
num? _totalItems;
|
||||
num? _totalCategories;
|
||||
num? _totalIncome;
|
||||
num? _totalExpense;
|
||||
num? _totalDue;
|
||||
|
||||
// num? _stockQty;
|
||||
num? _totalLoss;
|
||||
num? _totalProfit;
|
||||
num? _stockValue;
|
||||
List<Sales>? _sales;
|
||||
List<Purchases>? _purchases;
|
||||
|
||||
num? get totalItems => _totalItems;
|
||||
|
||||
num? get totalCategories => _totalCategories;
|
||||
|
||||
num? get totalIncome => _totalIncome;
|
||||
|
||||
num? get totalExpense => _totalExpense;
|
||||
|
||||
num? get totalDue => _totalDue;
|
||||
|
||||
// num? get stockQty => _stockQty;
|
||||
num? get totalLoss => _totalLoss;
|
||||
|
||||
num? get totalProfit => _totalProfit;
|
||||
|
||||
num? get stockValue => _stockValue;
|
||||
|
||||
List<Sales>? get sales => _sales;
|
||||
|
||||
List<Purchases>? get purchases => _purchases;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['total_items'] = _totalItems;
|
||||
map['total_categories'] = _totalCategories;
|
||||
map['total_income'] = _totalIncome;
|
||||
map['total_expense'] = _totalExpense;
|
||||
map['total_due'] = _totalDue;
|
||||
// map['stock_qty'] = _stockQty;
|
||||
map['total_loss'] = _totalLoss;
|
||||
map['total_profit'] = _totalProfit;
|
||||
if (_sales != null) {
|
||||
map['sales'] = _sales?.map((v) => v.toJson()).toList();
|
||||
}
|
||||
if (_purchases != null) {
|
||||
map['purchases'] = _purchases?.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class Purchases {
|
||||
Purchases({
|
||||
String? date,
|
||||
num? amount,
|
||||
}) {
|
||||
_date = date;
|
||||
_amount = amount;
|
||||
}
|
||||
|
||||
Purchases.fromJson(dynamic json) {
|
||||
_date = json['date'];
|
||||
_amount = json['amount'];
|
||||
}
|
||||
|
||||
String? _date;
|
||||
num? _amount;
|
||||
|
||||
String? get date => _date;
|
||||
|
||||
num? get amount => _amount;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['date'] = _date;
|
||||
map['amount'] = _amount;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class Sales {
|
||||
Sales({
|
||||
String? date,
|
||||
num? amount,
|
||||
}) {
|
||||
_date = date;
|
||||
_amount = amount;
|
||||
}
|
||||
|
||||
Sales.fromJson(dynamic json) {
|
||||
_date = json['date'];
|
||||
_amount = json['amount'];
|
||||
}
|
||||
|
||||
String? _date;
|
||||
num? _amount;
|
||||
|
||||
String? get date => _date;
|
||||
|
||||
num? get amount => _amount;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['date'] = _date;
|
||||
map['amount'] = _amount;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
19
lib/model/lalnguage_model.dart
Normal file
19
lib/model/lalnguage_model.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
class Language {
|
||||
final String code;
|
||||
final String name;
|
||||
final String nativeName;
|
||||
|
||||
Language({
|
||||
required this.code,
|
||||
required this.name,
|
||||
required this.nativeName,
|
||||
});
|
||||
|
||||
factory Language.fromJson(Map<String, dynamic> json) {
|
||||
return Language(
|
||||
code: json['code'] as String,
|
||||
name: json['name'] as String,
|
||||
nativeName: json['nativeName'] as String,
|
||||
);
|
||||
}
|
||||
}
|
||||
73
lib/model/loss_profit_model.dart
Normal file
73
lib/model/loss_profit_model.dart
Normal file
@@ -0,0 +1,73 @@
|
||||
class LossProfitModel {
|
||||
final List<IncomeSummaryModel>? incomeSummary;
|
||||
final List<ExpenseSummaryModel>? expenseSummary;
|
||||
final num? grossSalProfit;
|
||||
final num? grossIncomeProfit;
|
||||
final num? totalExpenses;
|
||||
final num? netProfit;
|
||||
final num? cartGrossProfit;
|
||||
final num? totalCardExpense;
|
||||
final num? cardNetProfit;
|
||||
|
||||
LossProfitModel({
|
||||
this.incomeSummary,
|
||||
this.expenseSummary,
|
||||
this.grossSalProfit,
|
||||
this.grossIncomeProfit,
|
||||
this.totalExpenses,
|
||||
this.netProfit,
|
||||
this.cartGrossProfit,
|
||||
this.totalCardExpense,
|
||||
this.cardNetProfit,
|
||||
});
|
||||
|
||||
factory LossProfitModel.fromJson(Map<String, dynamic> json) {
|
||||
return LossProfitModel(
|
||||
incomeSummary: json["mergedIncomeSaleData"] == null
|
||||
? []
|
||||
: List<IncomeSummaryModel>.from(json["mergedIncomeSaleData"]!.map((x) => IncomeSummaryModel.fromJson(x))),
|
||||
expenseSummary: json["mergedExpenseData"] == null
|
||||
? []
|
||||
: List<ExpenseSummaryModel>.from(json["mergedExpenseData"]!.map((x) => ExpenseSummaryModel.fromJson(x))),
|
||||
grossSalProfit: json["grossSaleProfit"],
|
||||
grossIncomeProfit: json['grossIncomeProfit'],
|
||||
totalExpenses: json['totalExpenses'],
|
||||
netProfit: json['netProfit'],
|
||||
cartGrossProfit: json['cardGrossProfit'],
|
||||
totalCardExpense: json['totalCardExpenses'],
|
||||
cardNetProfit: json['cardNetProfit'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class IncomeSummaryModel {
|
||||
final String? type;
|
||||
final String? date;
|
||||
final num? totalIncome;
|
||||
|
||||
IncomeSummaryModel({this.type, this.date, this.totalIncome});
|
||||
|
||||
factory IncomeSummaryModel.fromJson(Map<String, dynamic> json) {
|
||||
return IncomeSummaryModel(
|
||||
type: json["type"],
|
||||
date: json["date"],
|
||||
totalIncome: json["total_incomes"],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ExpenseSummaryModel {
|
||||
final String? type;
|
||||
final String? date;
|
||||
final num? totalExpense;
|
||||
|
||||
ExpenseSummaryModel({this.type, this.date, this.totalExpense});
|
||||
|
||||
factory ExpenseSummaryModel.fromJson(Map<String, dynamic> json) {
|
||||
return ExpenseSummaryModel(
|
||||
type: json["type"],
|
||||
date: json["date"],
|
||||
totalExpense: json["total_expenses"],
|
||||
);
|
||||
}
|
||||
}
|
||||
17
lib/model/paypal_info_model.dart
Normal file
17
lib/model/paypal_info_model.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
class PaypalInfoModel {
|
||||
PaypalInfoModel({
|
||||
required this.paypalClientId,
|
||||
required this.paypalClientSecret,
|
||||
});
|
||||
|
||||
String paypalClientId, paypalClientSecret;
|
||||
|
||||
PaypalInfoModel.fromJson(Map<dynamic, dynamic> json)
|
||||
: paypalClientId = json['paypalClientId'],
|
||||
paypalClientSecret = json['paypalClientSecret'];
|
||||
|
||||
Map<dynamic, dynamic> toJson() => <dynamic, dynamic>{
|
||||
'paypalClientId': paypalClientId,
|
||||
'paypalClientSecret': paypalClientSecret,
|
||||
};
|
||||
}
|
||||
163
lib/model/product_history_model.dart
Normal file
163
lib/model/product_history_model.dart
Normal file
@@ -0,0 +1,163 @@
|
||||
class ProductHistoryListModel {
|
||||
final int? totalPurchaseQuantity;
|
||||
final int? totalSaleQuantity;
|
||||
final List<ProductHistoryItemModel>? items;
|
||||
|
||||
int get totalRemainingQuantity {
|
||||
return items?.fold<int>(0, (p, ev) => p + (ev.remainingQuantity ?? 0)) ?? 0;
|
||||
}
|
||||
|
||||
num get totalSalePrice {
|
||||
return items?.fold<num>(0, (p, ev) => p + ((ev.salePrice ?? 0) * (ev.saleQuantity ?? 0))) ?? 0;
|
||||
}
|
||||
|
||||
num get totalPurchasePrice {
|
||||
return items?.fold<num>(0, (p, ev) => p + ((ev.purchasePrice ?? 0) * (ev.purchaseQuantity ?? 0))) ?? 0;
|
||||
}
|
||||
|
||||
ProductHistoryListModel({
|
||||
this.totalPurchaseQuantity,
|
||||
this.totalSaleQuantity,
|
||||
this.items,
|
||||
});
|
||||
|
||||
factory ProductHistoryListModel.fromJson(Map<String, dynamic> json) {
|
||||
return ProductHistoryListModel(
|
||||
totalPurchaseQuantity: json['total_purchase_qty'],
|
||||
totalSaleQuantity: json['total_sale_qty'],
|
||||
items: json['data'] == null
|
||||
? null
|
||||
: List<ProductHistoryItemModel>.from(json['data']!.map((x) => ProductHistoryItemModel.fromJson(x))),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ProductHistoryItemModel {
|
||||
final int? id;
|
||||
final String? name;
|
||||
final num? salePrice;
|
||||
final num? purchasePrice;
|
||||
final int? purchaseQuantity;
|
||||
final int? saleQuantity;
|
||||
final int? remainingQuantity;
|
||||
|
||||
ProductHistoryItemModel({
|
||||
this.id,
|
||||
this.name,
|
||||
this.salePrice,
|
||||
this.purchasePrice,
|
||||
this.purchaseQuantity,
|
||||
this.saleQuantity,
|
||||
this.remainingQuantity,
|
||||
});
|
||||
|
||||
factory ProductHistoryItemModel.fromJson(Map<String, dynamic> json) {
|
||||
final int _totalPurchaseQuantity = json["purchase_details"] == null
|
||||
? 0
|
||||
: (json["purchase_details"] as List<dynamic>).fold<int>(0, (p, ev) => p + (ev["quantities"] as int? ?? 0));
|
||||
|
||||
final int _totalSaleQuantity = json["sale_details"] == null
|
||||
? 0
|
||||
: (json["sale_details"] as List<dynamic>).fold<int>(0, (p, ev) => p + (ev["quantities"] as int? ?? 0));
|
||||
|
||||
final _remainingQuantity = switch (json["product_type"]?.trim().toLowerCase()) {
|
||||
"combo" => json["combo_products"] == null
|
||||
? 0
|
||||
: (json["combo_products"] as List<dynamic>).fold<int>(0, (p, ev) {
|
||||
return p + (ev["stock"]?["productStock"] as int? ?? 0);
|
||||
}),
|
||||
_ => json["stocks"] == null ? null : (json["stocks"] as List<dynamic>).firstOrNull?["productStock"] as int? ?? 0,
|
||||
};
|
||||
|
||||
final _salePrice = switch (json["product_type"]?.trim().toLowerCase()) {
|
||||
"combo" => json["productSalePrice"] ?? 0,
|
||||
_ =>
|
||||
json["stocks"] == null ? null : (json["stocks"] as List<dynamic>).firstOrNull?["productSalePrice"] as num? ?? 0,
|
||||
};
|
||||
|
||||
final _purchasePrice = switch (json["product_type"]?.trim().toLowerCase()) {
|
||||
"combo" => json["combo_products"] == null
|
||||
? 0
|
||||
: (json["combo_products"] as List<dynamic>).fold<num>(0, (p, ev) => p + (ev["purchase_price"] as num? ?? 0)),
|
||||
_ => json["stocks"] == null
|
||||
? null
|
||||
: (json["stocks"] as List<dynamic>).firstOrNull?["productPurchasePrice"] as num? ?? 0,
|
||||
};
|
||||
|
||||
return ProductHistoryItemModel(
|
||||
id: json['id'],
|
||||
name: json['productName'],
|
||||
salePrice: _salePrice,
|
||||
purchasePrice: _purchasePrice,
|
||||
purchaseQuantity: _totalPurchaseQuantity,
|
||||
saleQuantity: _totalSaleQuantity,
|
||||
remainingQuantity: _remainingQuantity,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ProductHistoryDetailsModel {
|
||||
final int? totalQuantities;
|
||||
final num? totalSalePrice;
|
||||
final num? totalPurchasePrice;
|
||||
final String? productName;
|
||||
final List<ProductHistoryDetailsItem>? items;
|
||||
|
||||
ProductHistoryDetailsModel({
|
||||
this.totalQuantities,
|
||||
this.totalSalePrice,
|
||||
this.totalPurchasePrice,
|
||||
this.productName,
|
||||
this.items,
|
||||
});
|
||||
|
||||
factory ProductHistoryDetailsModel.fromJson(Map<String, dynamic> j) {
|
||||
final _json = j['data'];
|
||||
final _detailsKey = _json["sale_details"] ?? _json["purchase_details"];
|
||||
|
||||
return ProductHistoryDetailsModel(
|
||||
totalQuantities: j['total_quantities'],
|
||||
totalSalePrice: j['total_sale_price'],
|
||||
totalPurchasePrice: j['total_purchase_price'],
|
||||
productName: _json?["productName"],
|
||||
items: _detailsKey == null
|
||||
? null
|
||||
: List<ProductHistoryDetailsItem>.from(_detailsKey!.map((x) => ProductHistoryDetailsItem.fromJson(x))),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ProductHistoryDetailsItem {
|
||||
final int? id;
|
||||
final String? invoiceNo;
|
||||
final String? type;
|
||||
final DateTime? transactionDate;
|
||||
final int? quantities;
|
||||
final num? salePrice;
|
||||
final num? purchasePrice;
|
||||
|
||||
ProductHistoryDetailsItem({
|
||||
this.id,
|
||||
this.invoiceNo,
|
||||
this.type,
|
||||
this.transactionDate,
|
||||
this.quantities,
|
||||
this.salePrice,
|
||||
this.purchasePrice,
|
||||
});
|
||||
|
||||
factory ProductHistoryDetailsItem.fromJson(Map<String, dynamic> json) {
|
||||
final _invoiceKey = json["sale"]?["invoiceNumber"] ?? json["purchase"]?["invoiceNumber"];
|
||||
final _transactionDate = json["sale"]?["saleDate"] ?? json["purchase"]?["purchaseDate"];
|
||||
|
||||
return ProductHistoryDetailsItem(
|
||||
id: json['id'],
|
||||
invoiceNo: _invoiceKey,
|
||||
type: 'Purchase',
|
||||
transactionDate: _transactionDate != null ? DateTime.parse(_transactionDate) : null,
|
||||
quantities: json['quantities'],
|
||||
salePrice: json['price'],
|
||||
purchasePrice: json['productPurchasePrice'],
|
||||
);
|
||||
}
|
||||
}
|
||||
651
lib/model/product_model.dart
Normal file
651
lib/model/product_model.dart
Normal file
@@ -0,0 +1,651 @@
|
||||
// class TestProductModel {
|
||||
// TestProductModel({
|
||||
// String? message,
|
||||
// num? totalStockValue,
|
||||
// List<Data>? data,
|
||||
// }) {
|
||||
// _message = message;
|
||||
// _totalStockValue = totalStockValue;
|
||||
// _data = data;
|
||||
// }
|
||||
//
|
||||
// TestProductModel.fromJson(dynamic json) {
|
||||
// _message = json['message'];
|
||||
// _totalStockValue = json['total_stock_value'];
|
||||
// if (json['data'] != null) {
|
||||
// _data = [];
|
||||
// json['data'].forEach((v) {
|
||||
// _data?.add(Data.fromJson(v));
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// String? _message;
|
||||
// num? _totalStockValue;
|
||||
// List<Data>? _data;
|
||||
// TestProductModel copyWith({
|
||||
// String? message,
|
||||
// num? totalStockValue,
|
||||
// List<Data>? data,
|
||||
// }) =>
|
||||
// TestProductModel(
|
||||
// message: message ?? _message,
|
||||
// totalStockValue: totalStockValue ?? _totalStockValue,
|
||||
// data: data ?? _data,
|
||||
// );
|
||||
// String? get message => _message;
|
||||
// num? get totalStockValue => _totalStockValue;
|
||||
// List<Data>? get data => _data;
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['message'] = _message;
|
||||
// map['total_stock_value'] = _totalStockValue;
|
||||
// if (_data != null) {
|
||||
// map['data'] = _data?.map((v) => v.toJson()).toList();
|
||||
// }
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class Data {
|
||||
// Data({
|
||||
// num? id,
|
||||
// String? productName,
|
||||
// num? businessId,
|
||||
// num? unitId,
|
||||
// num? brandId,
|
||||
// num? categoryId,
|
||||
// String? productCode,
|
||||
// dynamic productPicture,
|
||||
// String? productType,
|
||||
// num? productDealerPrice,
|
||||
// num? productPurchasePrice,
|
||||
// num? productSalePrice,
|
||||
// num? productWholeSalePrice,
|
||||
// num? productStock,
|
||||
// dynamic expireDate,
|
||||
// num? alertQty,
|
||||
// num? profitPercent,
|
||||
// num? vatAmount,
|
||||
// String? vatType,
|
||||
// String? size,
|
||||
// String? type,
|
||||
// String? color,
|
||||
// String? weight,
|
||||
// dynamic capacity,
|
||||
// String? productManufacturer,
|
||||
// dynamic meta,
|
||||
// String? createdAt,
|
||||
// String? updatedAt,
|
||||
// dynamic vatId,
|
||||
// num? modelId,
|
||||
// dynamic warehouseId,
|
||||
// num? stocksSumProductStock,
|
||||
// Unit? unit,
|
||||
// dynamic vat,
|
||||
// Brand? brand,
|
||||
// Category? category,
|
||||
// ProductModel? productModel,
|
||||
// List<Stocks>? stocks,
|
||||
// }) {
|
||||
// _id = id;
|
||||
// _productName = productName;
|
||||
// _businessId = businessId;
|
||||
// _unitId = unitId;
|
||||
// _brandId = brandId;
|
||||
// _categoryId = categoryId;
|
||||
// _productCode = productCode;
|
||||
// _productPicture = productPicture;
|
||||
// _productType = productType;
|
||||
// _productDealerPrice = productDealerPrice;
|
||||
// _productPurchasePrice = productPurchasePrice;
|
||||
// _productSalePrice = productSalePrice;
|
||||
// _productWholeSalePrice = productWholeSalePrice;
|
||||
// _productStock = productStock;
|
||||
// _expireDate = expireDate;
|
||||
// _alertQty = alertQty;
|
||||
// _profitPercent = profitPercent;
|
||||
// _vatAmount = vatAmount;
|
||||
// _vatType = vatType;
|
||||
// _size = size;
|
||||
// _type = type;
|
||||
// _color = color;
|
||||
// _weight = weight;
|
||||
// _capacity = capacity;
|
||||
// _productManufacturer = productManufacturer;
|
||||
// _meta = meta;
|
||||
// _createdAt = createdAt;
|
||||
// _updatedAt = updatedAt;
|
||||
// _vatId = vatId;
|
||||
// _modelId = modelId;
|
||||
// _warehouseId = warehouseId;
|
||||
// _stocksSumProductStock = stocksSumProductStock;
|
||||
// _unit = unit;
|
||||
// _vat = vat;
|
||||
// _brand = brand;
|
||||
// _category = category;
|
||||
// _productModel = productModel;
|
||||
// _stocks = stocks;
|
||||
// }
|
||||
//
|
||||
// Data.fromJson(dynamic json) {
|
||||
// _id = json['id'];
|
||||
// _productName = json['productName'];
|
||||
// _businessId = json['business_id'];
|
||||
// _unitId = json['unit_id'];
|
||||
// _brandId = json['brand_id'];
|
||||
// _categoryId = json['category_id'];
|
||||
// _productCode = json['productCode'];
|
||||
// _productPicture = json['productPicture'];
|
||||
// _productType = json['product_type'];
|
||||
// _productDealerPrice = json['productDealerPrice'];
|
||||
// _productPurchasePrice = json['productPurchasePrice'];
|
||||
// _productSalePrice = json['productSalePrice'];
|
||||
// _productWholeSalePrice = json['productWholeSalePrice'];
|
||||
// _productStock = json['productStock'];
|
||||
// _expireDate = json['expire_date'];
|
||||
// _alertQty = json['alert_qty'];
|
||||
// _profitPercent = json['profit_percent'];
|
||||
// _vatAmount = json['vat_amount'];
|
||||
// _vatType = json['vat_type'];
|
||||
// _size = json['size'];
|
||||
// _type = json['type'];
|
||||
// _color = json['color'];
|
||||
// _weight = json['weight'];
|
||||
// _capacity = json['capacity'];
|
||||
// _productManufacturer = json['productManufacturer'];
|
||||
// _meta = json['meta'];
|
||||
// _createdAt = json['created_at'];
|
||||
// _updatedAt = json['updated_at'];
|
||||
// _vatId = json['vat_id'];
|
||||
// _modelId = json['model_id'];
|
||||
// _warehouseId = json['warehouse_id'];
|
||||
// _stocksSumProductStock = json['stocks_sum_product_stock'];
|
||||
// _unit = json['unit'] != null ? Unit.fromJson(json['unit']) : null;
|
||||
// _vat = json['vat'];
|
||||
// _brand = json['brand'] != null ? Brand.fromJson(json['brand']) : null;
|
||||
// _category = json['category'] != null ? Category.fromJson(json['category']) : null;
|
||||
// _productModel = json['product_model'] != null ? ProductModel.fromJson(json['product_model']) : null;
|
||||
// if (json['stocks'] != null) {
|
||||
// _stocks = [];
|
||||
// json['stocks'].forEach((v) {
|
||||
// _stocks?.add(Stocks.fromJson(v));
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// num? _id;
|
||||
// String? _productName;
|
||||
// num? _businessId;
|
||||
// num? _unitId;
|
||||
// num? _brandId;
|
||||
// num? _categoryId;
|
||||
// String? _productCode;
|
||||
// dynamic _productPicture;
|
||||
// String? _productType;
|
||||
// num? _productDealerPrice;
|
||||
// num? _productPurchasePrice;
|
||||
// num? _productSalePrice;
|
||||
// num? _productWholeSalePrice;
|
||||
// num? _productStock;
|
||||
// dynamic _expireDate;
|
||||
// num? _alertQty;
|
||||
// num? _profitPercent;
|
||||
// num? _vatAmount;
|
||||
// String? _vatType;
|
||||
// String? _size;
|
||||
// String? _type;
|
||||
// String? _color;
|
||||
// String? _weight;
|
||||
// dynamic _capacity;
|
||||
// String? _productManufacturer;
|
||||
// dynamic _meta;
|
||||
// String? _createdAt;
|
||||
// String? _updatedAt;
|
||||
// dynamic _vatId;
|
||||
// num? _modelId;
|
||||
// dynamic _warehouseId;
|
||||
// num? _stocksSumProductStock;
|
||||
// Unit? _unit;
|
||||
// dynamic _vat;
|
||||
// Brand? _brand;
|
||||
// Category? _category;
|
||||
// ProductModel? _productModel;
|
||||
// List<Stocks>? _stocks;
|
||||
// Data copyWith({
|
||||
// num? id,
|
||||
// String? productName,
|
||||
// num? businessId,
|
||||
// num? unitId,
|
||||
// num? brandId,
|
||||
// num? categoryId,
|
||||
// String? productCode,
|
||||
// dynamic productPicture,
|
||||
// String? productType,
|
||||
// num? productDealerPrice,
|
||||
// num? productPurchasePrice,
|
||||
// num? productSalePrice,
|
||||
// num? productWholeSalePrice,
|
||||
// num? productStock,
|
||||
// dynamic expireDate,
|
||||
// num? alertQty,
|
||||
// num? profitPercent,
|
||||
// num? vatAmount,
|
||||
// String? vatType,
|
||||
// String? size,
|
||||
// String? type,
|
||||
// String? color,
|
||||
// String? weight,
|
||||
// dynamic capacity,
|
||||
// String? productManufacturer,
|
||||
// dynamic meta,
|
||||
// String? createdAt,
|
||||
// String? updatedAt,
|
||||
// dynamic vatId,
|
||||
// num? modelId,
|
||||
// dynamic warehouseId,
|
||||
// num? stocksSumProductStock,
|
||||
// Unit? unit,
|
||||
// dynamic vat,
|
||||
// Brand? brand,
|
||||
// Category? category,
|
||||
// ProductModel? productModel,
|
||||
// List<Stocks>? stocks,
|
||||
// }) =>
|
||||
// Data(
|
||||
// id: id ?? _id,
|
||||
// productName: productName ?? _productName,
|
||||
// businessId: businessId ?? _businessId,
|
||||
// unitId: unitId ?? _unitId,
|
||||
// brandId: brandId ?? _brandId,
|
||||
// categoryId: categoryId ?? _categoryId,
|
||||
// productCode: productCode ?? _productCode,
|
||||
// productPicture: productPicture ?? _productPicture,
|
||||
// productType: productType ?? _productType,
|
||||
// productDealerPrice: productDealerPrice ?? _productDealerPrice,
|
||||
// productPurchasePrice: productPurchasePrice ?? _productPurchasePrice,
|
||||
// productSalePrice: productSalePrice ?? _productSalePrice,
|
||||
// productWholeSalePrice: productWholeSalePrice ?? _productWholeSalePrice,
|
||||
// productStock: productStock ?? _productStock,
|
||||
// expireDate: expireDate ?? _expireDate,
|
||||
// alertQty: alertQty ?? _alertQty,
|
||||
// profitPercent: profitPercent ?? _profitPercent,
|
||||
// vatAmount: vatAmount ?? _vatAmount,
|
||||
// vatType: vatType ?? _vatType,
|
||||
// size: size ?? _size,
|
||||
// type: type ?? _type,
|
||||
// color: color ?? _color,
|
||||
// weight: weight ?? _weight,
|
||||
// capacity: capacity ?? _capacity,
|
||||
// productManufacturer: productManufacturer ?? _productManufacturer,
|
||||
// meta: meta ?? _meta,
|
||||
// createdAt: createdAt ?? _createdAt,
|
||||
// updatedAt: updatedAt ?? _updatedAt,
|
||||
// vatId: vatId ?? _vatId,
|
||||
// modelId: modelId ?? _modelId,
|
||||
// warehouseId: warehouseId ?? _warehouseId,
|
||||
// stocksSumProductStock: stocksSumProductStock ?? _stocksSumProductStock,
|
||||
// unit: unit ?? _unit,
|
||||
// vat: vat ?? _vat,
|
||||
// brand: brand ?? _brand,
|
||||
// category: category ?? _category,
|
||||
// productModel: productModel ?? _productModel,
|
||||
// stocks: stocks ?? _stocks,
|
||||
// );
|
||||
// num? get id => _id;
|
||||
// String? get productName => _productName;
|
||||
// num? get businessId => _businessId;
|
||||
// num? get unitId => _unitId;
|
||||
// num? get brandId => _brandId;
|
||||
// num? get categoryId => _categoryId;
|
||||
// String? get productCode => _productCode;
|
||||
// dynamic get productPicture => _productPicture;
|
||||
// String? get productType => _productType;
|
||||
// num? get productDealerPrice => _productDealerPrice;
|
||||
// num? get productPurchasePrice => _productPurchasePrice;
|
||||
// num? get productSalePrice => _productSalePrice;
|
||||
// num? get productWholeSalePrice => _productWholeSalePrice;
|
||||
// num? get productStock => _productStock;
|
||||
// dynamic get expireDate => _expireDate;
|
||||
// num? get alertQty => _alertQty;
|
||||
// num? get profitPercent => _profitPercent;
|
||||
// num? get vatAmount => _vatAmount;
|
||||
// String? get vatType => _vatType;
|
||||
// String? get size => _size;
|
||||
// String? get type => _type;
|
||||
// String? get color => _color;
|
||||
// String? get weight => _weight;
|
||||
// dynamic get capacity => _capacity;
|
||||
// String? get productManufacturer => _productManufacturer;
|
||||
// dynamic get meta => _meta;
|
||||
// String? get createdAt => _createdAt;
|
||||
// String? get updatedAt => _updatedAt;
|
||||
// dynamic get vatId => _vatId;
|
||||
// num? get modelId => _modelId;
|
||||
// dynamic get warehouseId => _warehouseId;
|
||||
// num? get stocksSumProductStock => _stocksSumProductStock;
|
||||
// Unit? get unit => _unit;
|
||||
// dynamic get vat => _vat;
|
||||
// Brand? get brand => _brand;
|
||||
// Category? get category => _category;
|
||||
// ProductModel? get productModel => _productModel;
|
||||
// List<Stocks>? get stocks => _stocks;
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['id'] = _id;
|
||||
// map['productName'] = _productName;
|
||||
// map['business_id'] = _businessId;
|
||||
// map['unit_id'] = _unitId;
|
||||
// map['brand_id'] = _brandId;
|
||||
// map['category_id'] = _categoryId;
|
||||
// map['productCode'] = _productCode;
|
||||
// map['productPicture'] = _productPicture;
|
||||
// map['product_type'] = _productType;
|
||||
// map['productDealerPrice'] = _productDealerPrice;
|
||||
// map['productPurchasePrice'] = _productPurchasePrice;
|
||||
// map['productSalePrice'] = _productSalePrice;
|
||||
// map['productWholeSalePrice'] = _productWholeSalePrice;
|
||||
// map['productStock'] = _productStock;
|
||||
// map['expire_date'] = _expireDate;
|
||||
// map['alert_qty'] = _alertQty;
|
||||
// map['profit_percent'] = _profitPercent;
|
||||
// map['vat_amount'] = _vatAmount;
|
||||
// map['vat_type'] = _vatType;
|
||||
// map['size'] = _size;
|
||||
// map['type'] = _type;
|
||||
// map['color'] = _color;
|
||||
// map['weight'] = _weight;
|
||||
// map['capacity'] = _capacity;
|
||||
// map['productManufacturer'] = _productManufacturer;
|
||||
// map['meta'] = _meta;
|
||||
// map['created_at'] = _createdAt;
|
||||
// map['updated_at'] = _updatedAt;
|
||||
// map['vat_id'] = _vatId;
|
||||
// map['model_id'] = _modelId;
|
||||
// map['warehouse_id'] = _warehouseId;
|
||||
// map['stocks_sum_product_stock'] = _stocksSumProductStock;
|
||||
// if (_unit != null) {
|
||||
// map['unit'] = _unit?.toJson();
|
||||
// }
|
||||
// map['vat'] = _vat;
|
||||
// if (_brand != null) {
|
||||
// map['brand'] = _brand?.toJson();
|
||||
// }
|
||||
// if (_category != null) {
|
||||
// map['category'] = _category?.toJson();
|
||||
// }
|
||||
// if (_productModel != null) {
|
||||
// map['product_model'] = _productModel?.toJson();
|
||||
// }
|
||||
// if (_stocks != null) {
|
||||
// map['stocks'] = _stocks?.map((v) => v.toJson()).toList();
|
||||
// }
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class Stocks {
|
||||
// Stocks({
|
||||
// num? id,
|
||||
// num? businessId,
|
||||
// num? productId,
|
||||
// dynamic batchNo,
|
||||
// num? productStock,
|
||||
// num? productPurchasePrice,
|
||||
// num? profitPercent,
|
||||
// num? productSalePrice,
|
||||
// num? productWholeSalePrice,
|
||||
// num? productDealerPrice,
|
||||
// String? mfgDate,
|
||||
// String? expireDate,
|
||||
// String? createdAt,
|
||||
// String? updatedAt,
|
||||
// }) {
|
||||
// _id = id;
|
||||
// _businessId = businessId;
|
||||
// _productId = productId;
|
||||
// _batchNo = batchNo;
|
||||
// _productStock = productStock;
|
||||
// _productPurchasePrice = productPurchasePrice;
|
||||
// _profitPercent = profitPercent;
|
||||
// _productSalePrice = productSalePrice;
|
||||
// _productWholeSalePrice = productWholeSalePrice;
|
||||
// _productDealerPrice = productDealerPrice;
|
||||
// _mfgDate = mfgDate;
|
||||
// _expireDate = expireDate;
|
||||
// _createdAt = createdAt;
|
||||
// _updatedAt = updatedAt;
|
||||
// }
|
||||
//
|
||||
// Stocks.fromJson(dynamic json) {
|
||||
// _id = json['id'];
|
||||
// _businessId = json['business_id'];
|
||||
// _productId = json['product_id'];
|
||||
// _batchNo = json['batch_no'];
|
||||
// _productStock = json['productStock'];
|
||||
// _productPurchasePrice = json['productPurchasePrice'];
|
||||
// _profitPercent = json['profit_percent'];
|
||||
// _productSalePrice = json['productSalePrice'];
|
||||
// _productWholeSalePrice = json['productWholeSalePrice'];
|
||||
// _productDealerPrice = json['productDealerPrice'];
|
||||
// _mfgDate = json['mfg_date'];
|
||||
// _expireDate = json['expire_date'];
|
||||
// _createdAt = json['created_at'];
|
||||
// _updatedAt = json['updated_at'];
|
||||
// }
|
||||
// num? _id;
|
||||
// num? _businessId;
|
||||
// num? _productId;
|
||||
// dynamic _batchNo;
|
||||
// num? _productStock;
|
||||
// num? _productPurchasePrice;
|
||||
// num? _profitPercent;
|
||||
// num? _productSalePrice;
|
||||
// num? _productWholeSalePrice;
|
||||
// num? _productDealerPrice;
|
||||
// String? _mfgDate;
|
||||
// String? _expireDate;
|
||||
// String? _createdAt;
|
||||
// String? _updatedAt;
|
||||
// Stocks copyWith({
|
||||
// num? id,
|
||||
// num? businessId,
|
||||
// num? productId,
|
||||
// dynamic batchNo,
|
||||
// num? productStock,
|
||||
// num? productPurchasePrice,
|
||||
// num? profitPercent,
|
||||
// num? productSalePrice,
|
||||
// num? productWholeSalePrice,
|
||||
// num? productDealerPrice,
|
||||
// String? mfgDate,
|
||||
// String? expireDate,
|
||||
// String? createdAt,
|
||||
// String? updatedAt,
|
||||
// }) =>
|
||||
// Stocks(
|
||||
// id: id ?? _id,
|
||||
// businessId: businessId ?? _businessId,
|
||||
// productId: productId ?? _productId,
|
||||
// batchNo: batchNo ?? _batchNo,
|
||||
// productStock: productStock ?? _productStock,
|
||||
// productPurchasePrice: productPurchasePrice ?? _productPurchasePrice,
|
||||
// profitPercent: profitPercent ?? _profitPercent,
|
||||
// productSalePrice: productSalePrice ?? _productSalePrice,
|
||||
// productWholeSalePrice: productWholeSalePrice ?? _productWholeSalePrice,
|
||||
// productDealerPrice: productDealerPrice ?? _productDealerPrice,
|
||||
// mfgDate: mfgDate ?? _mfgDate,
|
||||
// expireDate: expireDate ?? _expireDate,
|
||||
// createdAt: createdAt ?? _createdAt,
|
||||
// updatedAt: updatedAt ?? _updatedAt,
|
||||
// );
|
||||
// num? get id => _id;
|
||||
// num? get businessId => _businessId;
|
||||
// num? get productId => _productId;
|
||||
// dynamic get batchNo => _batchNo;
|
||||
// num? get productStock => _productStock;
|
||||
// num? get productPurchasePrice => _productPurchasePrice;
|
||||
// num? get profitPercent => _profitPercent;
|
||||
// num? get productSalePrice => _productSalePrice;
|
||||
// num? get productWholeSalePrice => _productWholeSalePrice;
|
||||
// num? get productDealerPrice => _productDealerPrice;
|
||||
// String? get mfgDate => _mfgDate;
|
||||
// String? get expireDate => _expireDate;
|
||||
// String? get createdAt => _createdAt;
|
||||
// String? get updatedAt => _updatedAt;
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['id'] = _id;
|
||||
// map['business_id'] = _businessId;
|
||||
// map['product_id'] = _productId;
|
||||
// map['batch_no'] = _batchNo;
|
||||
// map['productStock'] = _productStock;
|
||||
// map['productPurchasePrice'] = _productPurchasePrice;
|
||||
// map['profit_percent'] = _profitPercent;
|
||||
// map['productSalePrice'] = _productSalePrice;
|
||||
// map['productWholeSalePrice'] = _productWholeSalePrice;
|
||||
// map['productDealerPrice'] = _productDealerPrice;
|
||||
// map['mfg_date'] = _mfgDate;
|
||||
// map['expire_date'] = _expireDate;
|
||||
// map['created_at'] = _createdAt;
|
||||
// map['updated_at'] = _updatedAt;
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class ProductModel {
|
||||
// ProductModel({
|
||||
// num? id,
|
||||
// String? name,
|
||||
// }) {
|
||||
// _id = id;
|
||||
// _name = name;
|
||||
// }
|
||||
//
|
||||
// ProductModel.fromJson(dynamic json) {
|
||||
// _id = json['id'];
|
||||
// _name = json['name'];
|
||||
// }
|
||||
// num? _id;
|
||||
// String? _name;
|
||||
// ProductModel copyWith({
|
||||
// num? id,
|
||||
// String? name,
|
||||
// }) =>
|
||||
// ProductModel(
|
||||
// id: id ?? _id,
|
||||
// name: name ?? _name,
|
||||
// );
|
||||
// num? get id => _id;
|
||||
// String? get name => _name;
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['id'] = _id;
|
||||
// map['name'] = _name;
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class Category {
|
||||
// Category({
|
||||
// num? id,
|
||||
// String? categoryName,
|
||||
// }) {
|
||||
// _id = id;
|
||||
// _categoryName = categoryName;
|
||||
// }
|
||||
//
|
||||
// Category.fromJson(dynamic json) {
|
||||
// _id = json['id'];
|
||||
// _categoryName = json['categoryName'];
|
||||
// }
|
||||
// num? _id;
|
||||
// String? _categoryName;
|
||||
// Category copyWith({
|
||||
// num? id,
|
||||
// String? categoryName,
|
||||
// }) =>
|
||||
// Category(
|
||||
// id: id ?? _id,
|
||||
// categoryName: categoryName ?? _categoryName,
|
||||
// );
|
||||
// num? get id => _id;
|
||||
// String? get categoryName => _categoryName;
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['id'] = _id;
|
||||
// map['categoryName'] = _categoryName;
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class Brand {
|
||||
// Brand({
|
||||
// num? id,
|
||||
// String? brandName,
|
||||
// }) {
|
||||
// _id = id;
|
||||
// _brandName = brandName;
|
||||
// }
|
||||
//
|
||||
// Brand.fromJson(dynamic json) {
|
||||
// _id = json['id'];
|
||||
// _brandName = json['brandName'];
|
||||
// }
|
||||
// num? _id;
|
||||
// String? _brandName;
|
||||
// Brand copyWith({
|
||||
// num? id,
|
||||
// String? brandName,
|
||||
// }) =>
|
||||
// Brand(
|
||||
// id: id ?? _id,
|
||||
// brandName: brandName ?? _brandName,
|
||||
// );
|
||||
// num? get id => _id;
|
||||
// String? get brandName => _brandName;
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['id'] = _id;
|
||||
// map['brandName'] = _brandName;
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// class Unit {
|
||||
// Unit({
|
||||
// num? id,
|
||||
// String? unitName,
|
||||
// }) {
|
||||
// _id = id;
|
||||
// _unitName = unitName;
|
||||
// }
|
||||
//
|
||||
// Unit.fromJson(dynamic json) {
|
||||
// _id = json['id'];
|
||||
// _unitName = json['unitName'];
|
||||
// }
|
||||
// num? _id;
|
||||
// String? _unitName;
|
||||
// Unit copyWith({
|
||||
// num? id,
|
||||
// String? unitName,
|
||||
// }) =>
|
||||
// Unit(
|
||||
// id: id ?? _id,
|
||||
// unitName: unitName ?? _unitName,
|
||||
// );
|
||||
// num? get id => _id;
|
||||
// String? get unitName => _unitName;
|
||||
//
|
||||
// Map<String, dynamic> toJson() {
|
||||
// final map = <String, dynamic>{};
|
||||
// map['id'] = _id;
|
||||
// map['unitName'] = _unitName;
|
||||
// return map;
|
||||
// }
|
||||
// }
|
||||
549
lib/model/sale_transaction_model.dart
Normal file
549
lib/model/sale_transaction_model.dart
Normal file
@@ -0,0 +1,549 @@
|
||||
import '../widgets/multipal payment mathods/model/payment_transaction_model.dart';
|
||||
|
||||
class SaleModel {
|
||||
SaleModel(this.message, this.totalAmount, this.totalReturnedAmount, this.data);
|
||||
SaleModel.fromJson(dynamic json) {
|
||||
message = json['message'];
|
||||
totalAmount = json['total_amount'];
|
||||
totalReturnedAmount = json['total_return_amount'];
|
||||
data = json['data'] != null ? SalesTransactionModel.fromJson(json['data']) : null;
|
||||
}
|
||||
|
||||
String? message;
|
||||
num? totalAmount;
|
||||
num? totalReturnedAmount;
|
||||
SalesTransactionModel? data;
|
||||
}
|
||||
|
||||
class SalesTransactionModel {
|
||||
SalesTransactionModel({
|
||||
this.id,
|
||||
this.businessId,
|
||||
this.partyId,
|
||||
this.userId,
|
||||
this.discountAmount,
|
||||
this.discountPercent,
|
||||
this.shippingCharge,
|
||||
this.dueAmount,
|
||||
this.isPaid,
|
||||
this.vatAmount,
|
||||
this.vatPercent,
|
||||
this.paidAmount,
|
||||
this.changeAmount,
|
||||
this.totalAmount,
|
||||
this.paymentTypeId,
|
||||
this.paymentType,
|
||||
this.discountType,
|
||||
this.invoiceNumber,
|
||||
this.saleDate,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.detailsSumLossProfit,
|
||||
this.user,
|
||||
this.party,
|
||||
this.salesDetails,
|
||||
this.salesReturns,
|
||||
this.transactions, // NEW: List of transactions
|
||||
this.meta,
|
||||
this.vatId,
|
||||
this.vat,
|
||||
this.image,
|
||||
this.roundingAmount,
|
||||
this.actualTotalAmount,
|
||||
this.roundingOption,
|
||||
this.branch,
|
||||
});
|
||||
|
||||
SalesTransactionModel.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
businessId = json['business_id'];
|
||||
partyId = num.tryParse(json['party_id'].toString()) ?? 0;
|
||||
userId = json['user_id'];
|
||||
discountAmount = json['discountAmount'];
|
||||
discountPercent = num.tryParse(json['discount_percent'].toString()) ?? 0;
|
||||
shippingCharge = num.tryParse(json['shipping_charge'].toString()) ?? 0;
|
||||
dueAmount = json['dueAmount'];
|
||||
isPaid = json['isPaid'];
|
||||
vatAmount = json['vat_amount'];
|
||||
vatPercent = json['vat_percent'];
|
||||
vatId = json['vat_id'];
|
||||
paidAmount = json['paidAmount'];
|
||||
changeAmount = json['change_amount'];
|
||||
totalAmount = json['totalAmount'];
|
||||
paymentTypeId = int.tryParse(json['payment_type_id'].toString()) ?? 0;
|
||||
discountType = json['discount_type'];
|
||||
invoiceNumber = json['invoiceNumber'];
|
||||
saleDate = json['saleDate'];
|
||||
createdAt = json['created_at'];
|
||||
updatedAt = json['updated_at'];
|
||||
roundingOption = json['rounding_option'].toString();
|
||||
roundingAmount = num.tryParse(json['rounding_amount'].toString()) ?? 0;
|
||||
actualTotalAmount = num.tryParse(json['actual_total_amount'].toString()) ?? 0;
|
||||
detailsSumLossProfit = json['lossProfit'];
|
||||
user = json['user'] != null ? User.fromJson(json['user']) : null;
|
||||
vat = json['vat'] != null ? SalesVat.fromJson(json['vat']) : null;
|
||||
paymentType = json['payment_type'] != null ? PaymentType.fromJson(json['payment_type']) : null;
|
||||
branch = json['branch'] != null ? Branch.fromJson(json['branch']) : null;
|
||||
meta = json['meta'] != null ? Meta.fromJson(json['meta']) : null;
|
||||
party = json['party'] != null ? SalesParty.fromJson(json['party']) : SalesParty(name: 'Guest', type: 'Guest');
|
||||
|
||||
if (json['details'] != null) {
|
||||
salesDetails = [];
|
||||
json['details'].forEach((v) {
|
||||
salesDetails?.add(SalesDetails.fromJson(v));
|
||||
});
|
||||
}
|
||||
if (json['sale_returns'] != null) {
|
||||
salesReturns = [];
|
||||
json['sale_returns'].forEach((v) {
|
||||
salesReturns?.add(SalesReturn.fromJson(v));
|
||||
});
|
||||
}
|
||||
|
||||
// NEW: Parsing the transactions list
|
||||
if (json['transactions'] != null) {
|
||||
transactions = [];
|
||||
json['transactions'].forEach((v) {
|
||||
transactions?.add(PaymentsTransaction.fromJson(v));
|
||||
});
|
||||
}
|
||||
|
||||
image = json['image'];
|
||||
}
|
||||
|
||||
num? id;
|
||||
num? businessId;
|
||||
num? partyId;
|
||||
num? userId;
|
||||
num? discountAmount;
|
||||
num? discountPercent;
|
||||
num? shippingCharge;
|
||||
num? dueAmount;
|
||||
bool? isPaid;
|
||||
num? vatAmount;
|
||||
num? vatPercent;
|
||||
num? vatId;
|
||||
num? paidAmount;
|
||||
num? changeAmount;
|
||||
num? totalAmount;
|
||||
num? roundingAmount;
|
||||
num? actualTotalAmount;
|
||||
String? roundingOption;
|
||||
PaymentType? paymentType;
|
||||
Branch? branch;
|
||||
int? paymentTypeId;
|
||||
String? discountType;
|
||||
String? invoiceNumber;
|
||||
String? saleDate;
|
||||
String? createdAt;
|
||||
String? updatedAt;
|
||||
num? detailsSumLossProfit;
|
||||
User? user;
|
||||
SalesParty? party;
|
||||
Meta? meta;
|
||||
SalesVat? vat;
|
||||
List<SalesDetails>? salesDetails;
|
||||
List<SalesReturn>? salesReturns;
|
||||
List<PaymentsTransaction>? transactions; // NEW Variable
|
||||
String? image;
|
||||
}
|
||||
|
||||
// class PaymentType {
|
||||
// int? id;
|
||||
// int? name;
|
||||
// PaymentType(this.id, this.name);
|
||||
//
|
||||
// PaymentType.fromJson(dynamic json) {
|
||||
// id = json['id'];
|
||||
// name = json['name'];
|
||||
// }
|
||||
//
|
||||
// Map<String, dynamic> toJson(dynamic json) {
|
||||
// final Map<String, dynamic> data = {};
|
||||
// data['id'] = id;
|
||||
// data['name'] = name;
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
|
||||
class SalesDetails {
|
||||
SalesDetails({
|
||||
this.id,
|
||||
this.saleId,
|
||||
this.productId,
|
||||
this.price,
|
||||
this.discount, // NEW
|
||||
this.lossProfit,
|
||||
this.quantities,
|
||||
this.productPurchasePrice,
|
||||
this.mfgDate,
|
||||
this.expireDate,
|
||||
this.stockId,
|
||||
this.stock,
|
||||
this.warrantyInfo, // NEW
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.product,
|
||||
});
|
||||
|
||||
SalesDetails.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
saleId = json['sale_id'];
|
||||
productId = json['product_id'];
|
||||
price = json['price'];
|
||||
discount = json['discount']; // NEW
|
||||
lossProfit = json['lossProfit'];
|
||||
quantities = json['quantities'];
|
||||
productPurchasePrice = json['productPurchasePrice'];
|
||||
mfgDate = json['mfg_date'];
|
||||
expireDate = json['expire_date'];
|
||||
stockId = json['stock_id'];
|
||||
|
||||
// NEW: Warranty Info parsing
|
||||
warrantyInfo = json['warranty_guarantee_info'] != null
|
||||
? WarrantyGuaranteeInfo.fromJson(json['warranty_guarantee_info'])
|
||||
: null;
|
||||
|
||||
stock = json['stock'] != null ? SalesStock.fromJson(json['stock']) : null;
|
||||
createdAt = json['created_at'];
|
||||
updatedAt = json['updated_at'];
|
||||
product = json['product'] != null ? SalesProduct.fromJson(json['product']) : null;
|
||||
}
|
||||
|
||||
num? id;
|
||||
num? saleId;
|
||||
num? productId;
|
||||
num? price;
|
||||
num? discount; // NEW Variable
|
||||
num? lossProfit;
|
||||
num? quantities;
|
||||
num? productPurchasePrice;
|
||||
String? mfgDate;
|
||||
String? expireDate;
|
||||
num? stockId;
|
||||
SalesStock? stock;
|
||||
WarrantyGuaranteeInfo? warrantyInfo; // NEW Variable
|
||||
String? createdAt;
|
||||
|
||||
String? updatedAt;
|
||||
SalesProduct? product;
|
||||
}
|
||||
|
||||
// NEW CLASS: Handles Warranty and Guarantee details
|
||||
class WarrantyGuaranteeInfo {
|
||||
String? warrantyDuration;
|
||||
String? warrantyUnit;
|
||||
String? guaranteeDuration;
|
||||
String? guaranteeUnit;
|
||||
|
||||
WarrantyGuaranteeInfo({
|
||||
this.warrantyDuration,
|
||||
this.warrantyUnit,
|
||||
this.guaranteeDuration,
|
||||
this.guaranteeUnit,
|
||||
});
|
||||
|
||||
WarrantyGuaranteeInfo.fromJson(dynamic json) {
|
||||
warrantyDuration = json['warranty_duration']?.toString();
|
||||
warrantyUnit = json['warranty_unit'];
|
||||
guaranteeDuration = json['guarantee_duration']?.toString();
|
||||
guaranteeUnit = json['guarantee_unit'];
|
||||
}
|
||||
}
|
||||
|
||||
class SalesProduct {
|
||||
SalesProduct({
|
||||
this.id,
|
||||
this.productName,
|
||||
this.categoryId,
|
||||
this.category,
|
||||
this.productPurchasePrice,
|
||||
this.productCode,
|
||||
this.productType,
|
||||
});
|
||||
|
||||
SalesProduct.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
productName = json['productName'];
|
||||
productCode = json['productCode'];
|
||||
categoryId = json['category_id'];
|
||||
productType = json['product_type'];
|
||||
productPurchasePrice = json['productPurchasePrice'];
|
||||
category = json['category'] != null ? Category.fromJson(json['category']) : null;
|
||||
}
|
||||
|
||||
num? id;
|
||||
String? productName;
|
||||
String? productCode;
|
||||
num? categoryId;
|
||||
num? productPurchasePrice;
|
||||
String? productType;
|
||||
Category? category;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['productName'] = productName;
|
||||
map['category_id'] = categoryId;
|
||||
if (category != null) {
|
||||
map['category'] = category?.toJson();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class Category {
|
||||
Category({
|
||||
this.id,
|
||||
this.categoryName,
|
||||
});
|
||||
|
||||
Category.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
categoryName = json['categoryName'];
|
||||
}
|
||||
|
||||
num? id;
|
||||
String? categoryName;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['categoryName'] = categoryName;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class SalesParty {
|
||||
SalesParty({
|
||||
this.id,
|
||||
this.name,
|
||||
this.email,
|
||||
this.phone,
|
||||
this.type,
|
||||
this.address,
|
||||
});
|
||||
|
||||
SalesParty.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
email = json['email'];
|
||||
phone = json['phone'];
|
||||
type = json['type'];
|
||||
address = json['address'];
|
||||
}
|
||||
|
||||
num? id;
|
||||
String? name;
|
||||
dynamic email;
|
||||
String? phone;
|
||||
String? type;
|
||||
String? address;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['name'] = name;
|
||||
map['email'] = email;
|
||||
map['phone'] = phone;
|
||||
map['type'] = type;
|
||||
map['address'] = address;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class User {
|
||||
User({
|
||||
this.id,
|
||||
this.name,
|
||||
this.role,
|
||||
});
|
||||
|
||||
User.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
role = json['role'];
|
||||
}
|
||||
|
||||
num? id;
|
||||
String? name;
|
||||
String? role;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['name'] = name;
|
||||
map['role'] = role;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class Meta {
|
||||
Meta({
|
||||
this.customerPhone,
|
||||
this.note,
|
||||
});
|
||||
|
||||
Meta.fromJson(dynamic json) {
|
||||
customerPhone = json['customer_phone'];
|
||||
note = json['note'];
|
||||
}
|
||||
|
||||
String? customerPhone;
|
||||
String? note;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['customer_phone'] = customerPhone;
|
||||
map['note'] = note;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class SalesReturn {
|
||||
SalesReturn({
|
||||
this.id,
|
||||
this.businessId,
|
||||
this.saleId,
|
||||
this.invoiceNo,
|
||||
this.returnDate,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.salesReturnDetails,
|
||||
});
|
||||
|
||||
SalesReturn.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
businessId = json['business_id'];
|
||||
saleId = json['sale_id'];
|
||||
invoiceNo = json['invoice_no'];
|
||||
returnDate = json['return_date'];
|
||||
createdAt = json['created_at'];
|
||||
updatedAt = json['updated_at'];
|
||||
if (json['details'] != null) {
|
||||
salesReturnDetails = [];
|
||||
json['details'].forEach((v) {
|
||||
salesReturnDetails?.add(SalesReturnDetails.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
num? id;
|
||||
num? businessId;
|
||||
num? saleId;
|
||||
String? invoiceNo;
|
||||
String? returnDate;
|
||||
String? createdAt;
|
||||
String? updatedAt;
|
||||
List<SalesReturnDetails>? salesReturnDetails;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['business_id'] = businessId;
|
||||
map['sale_id'] = saleId;
|
||||
map['invoice_no'] = invoiceNo;
|
||||
map['return_date'] = returnDate;
|
||||
map['created_at'] = createdAt;
|
||||
map['updated_at'] = updatedAt;
|
||||
if (salesReturnDetails != null) {
|
||||
map['details'] = salesReturnDetails?.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class SalesReturnDetails {
|
||||
SalesReturnDetails({
|
||||
this.id,
|
||||
this.businessId,
|
||||
this.saleReturnId,
|
||||
this.saleDetailId,
|
||||
this.returnAmount,
|
||||
this.returnQty,
|
||||
});
|
||||
|
||||
SalesReturnDetails.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
businessId = json['business_id'];
|
||||
saleReturnId = json['sale_return_id'];
|
||||
saleDetailId = json['sale_detail_id'];
|
||||
returnAmount = json['return_amount'];
|
||||
returnQty = json['return_qty'];
|
||||
}
|
||||
|
||||
num? id;
|
||||
num? businessId;
|
||||
num? saleReturnId;
|
||||
num? saleDetailId;
|
||||
num? returnAmount;
|
||||
num? returnQty;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['id'] = id;
|
||||
map['business_id'] = businessId;
|
||||
map['sale_return_id'] = saleReturnId;
|
||||
map['sale_detail_id'] = saleDetailId;
|
||||
map['return_amount'] = returnAmount;
|
||||
map['return_qty'] = returnQty;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class SalesVat {
|
||||
SalesVat({
|
||||
this.id,
|
||||
this.name,
|
||||
this.rate,
|
||||
});
|
||||
|
||||
SalesVat.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
rate = json['rate'];
|
||||
}
|
||||
|
||||
num? id;
|
||||
String? name;
|
||||
num? rate;
|
||||
}
|
||||
|
||||
class Branch {
|
||||
Branch({
|
||||
this.id,
|
||||
this.name,
|
||||
this.phone,
|
||||
this.address,
|
||||
});
|
||||
|
||||
Branch.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
phone = json['phone'];
|
||||
address = json['address'];
|
||||
}
|
||||
|
||||
num? id;
|
||||
String? name;
|
||||
String? phone;
|
||||
String? address;
|
||||
}
|
||||
|
||||
class SalesStock {
|
||||
SalesStock({
|
||||
this.id,
|
||||
this.batchNo,
|
||||
this.productCurrentStock,
|
||||
});
|
||||
|
||||
SalesStock.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
batchNo = json['batch_no'] ?? 'N/A';
|
||||
productCurrentStock = json['productStock'];
|
||||
}
|
||||
|
||||
num? id;
|
||||
String? batchNo;
|
||||
num? productCurrentStock;
|
||||
}
|
||||
36
lib/model/subscription_model.dart
Normal file
36
lib/model/subscription_model.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
class SubscriptionModel {
|
||||
SubscriptionModel({
|
||||
required this.subscriptionName,
|
||||
required this.subscriptionDate,
|
||||
required this.saleNumber,
|
||||
required this.purchaseNumber,
|
||||
required this.partiesNumber,
|
||||
required this.dueNumber,
|
||||
required this.duration,
|
||||
required this.products,
|
||||
});
|
||||
|
||||
String subscriptionName, subscriptionDate;
|
||||
int saleNumber, purchaseNumber, partiesNumber, dueNumber, duration, products;
|
||||
|
||||
SubscriptionModel.fromJson(Map<dynamic, dynamic> json)
|
||||
: subscriptionName = json['subscriptionName'] as String,
|
||||
saleNumber = json['saleNumber'],
|
||||
subscriptionDate = json['subscriptionDate'],
|
||||
purchaseNumber = json['purchaseNumber'],
|
||||
partiesNumber = json['partiesNumber'],
|
||||
dueNumber = json['dueNumber'],
|
||||
duration = json['duration'],
|
||||
products = json['products'];
|
||||
|
||||
Map<dynamic, dynamic> toJson() => <dynamic, dynamic>{
|
||||
'subscriptionName': subscriptionName,
|
||||
'subscriptionDate': subscriptionDate,
|
||||
'saleNumber': saleNumber,
|
||||
'purchaseNumber': purchaseNumber,
|
||||
'partiesNumber': partiesNumber,
|
||||
'dueNumber': dueNumber,
|
||||
'duration': duration,
|
||||
'products': products,
|
||||
};
|
||||
}
|
||||
31
lib/model/subscription_report_model.dart
Normal file
31
lib/model/subscription_report_model.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
class SubscriptionReportModel {
|
||||
final int? id;
|
||||
final String? name;
|
||||
final DateTime? startDate;
|
||||
final DateTime? endDate;
|
||||
final String? paymentBy;
|
||||
final bool isPaid;
|
||||
|
||||
SubscriptionReportModel({
|
||||
this.id,
|
||||
this.name,
|
||||
this.startDate,
|
||||
this.endDate,
|
||||
this.paymentBy,
|
||||
this.isPaid = false,
|
||||
});
|
||||
|
||||
factory SubscriptionReportModel.fromJson(Map<String, dynamic> json) {
|
||||
final _startDate = json["created_at"] == null ? null : DateTime.parse(json['created_at']);
|
||||
final int _duration = json['duration'] ?? 0;
|
||||
|
||||
return SubscriptionReportModel(
|
||||
id: json['id'],
|
||||
name: json['plan']?['subscriptionName'],
|
||||
startDate: _startDate,
|
||||
endDate: _startDate?.add(Duration(days: _duration)),
|
||||
paymentBy: json['gateway']?['name'],
|
||||
isPaid: json['payment_status'] == "paid",
|
||||
);
|
||||
}
|
||||
}
|
||||
84
lib/model/tax_report_model.dart
Normal file
84
lib/model/tax_report_model.dart
Normal file
@@ -0,0 +1,84 @@
|
||||
class TaxReportModel {
|
||||
final List<InvoiceModel>? sales;
|
||||
final List<InvoiceModel>? purchases;
|
||||
final List<OverviewModel>? overviews;
|
||||
|
||||
TaxReportModel({
|
||||
this.sales,
|
||||
this.purchases,
|
||||
this.overviews,
|
||||
});
|
||||
|
||||
factory TaxReportModel.fromJson(Map<String, dynamic> json) {
|
||||
return TaxReportModel(
|
||||
sales: json['sales'] == null ? null : List<InvoiceModel>.from(json["sales"].map((x) => InvoiceModel.fromJson(x))),
|
||||
purchases: json['purchases'] == null
|
||||
? null
|
||||
: List<InvoiceModel>.from(json["purchases"].map((x) => InvoiceModel.fromJson(x))),
|
||||
overviews: [
|
||||
// Sales
|
||||
OverviewModel(
|
||||
totalAmount: json['sales_total_amount'] ?? 0,
|
||||
totalDiscount: json['sales_total_discount'] ?? 0,
|
||||
totalVat: json['sales_total_vat'] ?? 0,
|
||||
),
|
||||
|
||||
// Purchase
|
||||
OverviewModel(
|
||||
totalAmount: json['purchases_total_amount'] ?? 0,
|
||||
totalDiscount: json['purchases_total_discount'] ?? 0,
|
||||
totalVat: json['purchases_total_vat'] ?? 0,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class InvoiceModel {
|
||||
final int? id;
|
||||
final String? partyName;
|
||||
final String? invoiceNumber;
|
||||
final DateTime? transactionDate;
|
||||
final num? amount;
|
||||
final num? discountAmount;
|
||||
final String? vatName;
|
||||
final num? vatAmount;
|
||||
|
||||
InvoiceModel({
|
||||
this.id,
|
||||
this.partyName,
|
||||
this.invoiceNumber,
|
||||
this.transactionDate,
|
||||
this.amount,
|
||||
this.discountAmount,
|
||||
this.vatName,
|
||||
this.vatAmount,
|
||||
});
|
||||
|
||||
factory InvoiceModel.fromJson(Map<String, dynamic> json) {
|
||||
final _dateKey = json["saleDate"] ?? json["purchaseDate"];
|
||||
|
||||
return InvoiceModel(
|
||||
id: json['id'],
|
||||
partyName: json['party']?['name'],
|
||||
invoiceNumber: json['invoiceNumber'],
|
||||
transactionDate: _dateKey == null ? null : DateTime.parse(_dateKey),
|
||||
amount: json['totalAmount'],
|
||||
discountAmount: json['discountAmount'],
|
||||
vatName: json['vat']?['name'],
|
||||
vatAmount: json['vat_amount'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class OverviewModel {
|
||||
final num totalAmount;
|
||||
final num totalDiscount;
|
||||
final num totalVat;
|
||||
|
||||
OverviewModel({
|
||||
required this.totalAmount,
|
||||
required this.totalDiscount,
|
||||
required this.totalVat,
|
||||
});
|
||||
}
|
||||
73
lib/model/todays_summary_model.dart
Normal file
73
lib/model/todays_summary_model.dart
Normal file
@@ -0,0 +1,73 @@
|
||||
class TodaysSummaryModel {
|
||||
TodaysSummaryModel({
|
||||
String? message,
|
||||
Data? data,
|
||||
}) {
|
||||
_message = message;
|
||||
_data = data;
|
||||
}
|
||||
|
||||
TodaysSummaryModel.fromJson(dynamic json) {
|
||||
_message = json['message'];
|
||||
_data = json['data'] != null ? Data.fromJson(json['data']) : null;
|
||||
}
|
||||
|
||||
String? _message;
|
||||
Data? _data;
|
||||
|
||||
String? get message => _message;
|
||||
|
||||
Data? get data => _data;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['message'] = _message;
|
||||
if (_data != null) {
|
||||
map['data'] = _data?.toJson();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
Data({
|
||||
num? sales,
|
||||
num? income,
|
||||
num? expense,
|
||||
num? purchase,
|
||||
}) {
|
||||
_sales = sales;
|
||||
_income = income;
|
||||
_expense = expense;
|
||||
_purchase = purchase;
|
||||
}
|
||||
|
||||
Data.fromJson(dynamic json) {
|
||||
_sales = json['sales'];
|
||||
_income = json['income'];
|
||||
_expense = json['expense'];
|
||||
_purchase = json['purchase'];
|
||||
}
|
||||
|
||||
num? _sales;
|
||||
num? _income;
|
||||
num? _expense;
|
||||
num? _purchase;
|
||||
|
||||
num? get sales => _sales;
|
||||
|
||||
num? get income => _income;
|
||||
|
||||
num? get expense => _expense;
|
||||
|
||||
num? get purchase => _purchase;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final map = <String, dynamic>{};
|
||||
map['sales'] = _sales;
|
||||
map['income'] = _income;
|
||||
map['expense'] = _expense;
|
||||
map['purchase'] = _purchase;
|
||||
return map;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user