perbaikan data report
This commit is contained in:
@@ -25,16 +25,16 @@ class DueCollection {
|
||||
this.branch});
|
||||
|
||||
DueCollection.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
businessId = json['business_id'];
|
||||
partyId = json['party_id'];
|
||||
userId = json['user_id'];
|
||||
saleId = json['sale_id'];
|
||||
purchaseId = json['purchase_id'];
|
||||
totalDue = json['totalDue'];
|
||||
dueAmountAfterPay = json['dueAmountAfterPay'];
|
||||
payDueAmount = json['payDueAmount'];
|
||||
paymentTypeId = int.tryParse(json["payment_type_id"].toString());
|
||||
id = num.tryParse(json['id']?.toString() ?? '');
|
||||
businessId = num.tryParse(json['business_id']?.toString() ?? '');
|
||||
partyId = num.tryParse(json['party_id']?.toString() ?? '');
|
||||
userId = num.tryParse(json['user_id']?.toString() ?? '');
|
||||
saleId = num.tryParse(json['sale_id']?.toString() ?? '');
|
||||
purchaseId = num.tryParse(json['purchase_id']?.toString() ?? '');
|
||||
totalDue = num.tryParse(json['totalDue']?.toString() ?? '');
|
||||
dueAmountAfterPay = num.tryParse(json['dueAmountAfterPay']?.toString() ?? '');
|
||||
payDueAmount = num.tryParse(json['payDueAmount']?.toString() ?? '');
|
||||
paymentTypeId = int.tryParse(json["payment_type_id"]?.toString() ?? '');
|
||||
// paymentType = json['paymentType'];
|
||||
paymentDate = json['paymentDate'];
|
||||
invoiceNumber = json['invoiceNumber'];
|
||||
@@ -131,7 +131,7 @@ class Branch {
|
||||
});
|
||||
|
||||
Branch.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
id = num.tryParse(json['id']?.toString() ?? '');
|
||||
name = json['name'];
|
||||
phone = json['phone'];
|
||||
address = json['address'];
|
||||
|
||||
@@ -35,24 +35,24 @@ class PurchaseTransaction {
|
||||
});
|
||||
|
||||
PurchaseTransaction.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
partyId = json['party_id'];
|
||||
businessId = json['business_id'];
|
||||
userId = json['user_id'];
|
||||
discountAmount = json['discountAmount'];
|
||||
discountPercent = json['discount_percent'];
|
||||
shippingCharge = json['shipping_charge'];
|
||||
id = num.tryParse(json['id']?.toString() ?? '');
|
||||
partyId = num.tryParse(json['party_id']?.toString() ?? '');
|
||||
businessId = num.tryParse(json['business_id']?.toString() ?? '');
|
||||
userId = num.tryParse(json['user_id']?.toString() ?? '');
|
||||
discountAmount = num.tryParse(json['discountAmount']?.toString() ?? '');
|
||||
discountPercent = num.tryParse(json['discount_percent']?.toString() ?? '');
|
||||
shippingCharge = num.tryParse(json['shipping_charge']?.toString() ?? '');
|
||||
discountType = json['discount_type'];
|
||||
dueAmount = json['dueAmount'];
|
||||
changeAmount = json['change_amount'];
|
||||
vatAmount = json['vat_amount'];
|
||||
vatPercent = json['vat_percent'];
|
||||
vatId = json['vat_id'];
|
||||
paidAmount = json['paidAmount'];
|
||||
totalAmount = json['totalAmount'];
|
||||
dueAmount = num.tryParse(json['dueAmount']?.toString() ?? '');
|
||||
changeAmount = num.tryParse(json['change_amount']?.toString() ?? '');
|
||||
vatAmount = num.tryParse(json['vat_amount']?.toString() ?? '');
|
||||
vatPercent = num.tryParse(json['vat_percent']?.toString() ?? '');
|
||||
vatId = num.tryParse(json['vat_id']?.toString() ?? '');
|
||||
paidAmount = num.tryParse(json['paidAmount']?.toString() ?? '');
|
||||
totalAmount = num.tryParse(json['totalAmount']?.toString() ?? '');
|
||||
invoiceNumber = json['invoiceNumber'];
|
||||
isPaid = json['isPaid'];
|
||||
paymentTypeId = int.tryParse(json["payment_type_id"].toString());
|
||||
paymentTypeId = int.tryParse(json["payment_type_id"]?.toString() ?? '');
|
||||
|
||||
vat = json['vat'] != null ? PurchaseVat.fromJson(json['vat']) : null;
|
||||
purchaseDate = json['purchaseDate'];
|
||||
@@ -137,19 +137,19 @@ class PurchaseDetails {
|
||||
});
|
||||
|
||||
PurchaseDetails.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
purchaseId = json['purchase_id'];
|
||||
productId = json['product_id'];
|
||||
productPurchasePrice = json['productPurchasePrice'];
|
||||
quantities = json['quantities'];
|
||||
productDealerPrice = json['productDealerPrice'];
|
||||
productSalePrice = json['productSalePrice'];
|
||||
productStock = json['productStock'];
|
||||
profitPercent = json['profit_percent'];
|
||||
id = num.tryParse(json['id']?.toString() ?? '');
|
||||
purchaseId = num.tryParse(json['purchase_id']?.toString() ?? '');
|
||||
productId = num.tryParse(json['product_id']?.toString() ?? '');
|
||||
productPurchasePrice = num.tryParse(json['productPurchasePrice']?.toString() ?? '');
|
||||
quantities = num.tryParse(json['quantities']?.toString() ?? '');
|
||||
productDealerPrice = num.tryParse(json['productDealerPrice']?.toString() ?? '');
|
||||
productSalePrice = num.tryParse(json['productSalePrice']?.toString() ?? '');
|
||||
productStock = num.tryParse(json['productStock']?.toString() ?? '');
|
||||
profitPercent = num.tryParse(json['profit_percent']?.toString() ?? '');
|
||||
mfgDate = json['mfg_date'];
|
||||
expireDate = json['expire_date'];
|
||||
stockId = json['stock_id']; // Added
|
||||
productWholeSalePrice = json['productWholeSalePrice'];
|
||||
stockId = num.tryParse(json['stock_id']?.toString() ?? ''); // Added
|
||||
productWholeSalePrice = num.tryParse(json['productWholeSalePrice']?.toString() ?? '');
|
||||
product = json['product'] != null ? Product.fromJson(json['product']) : null;
|
||||
stock = json['stock'] != null ? PurchaseStock.fromJson(json['stock']) : null;
|
||||
}
|
||||
@@ -198,11 +198,11 @@ class Product {
|
||||
});
|
||||
|
||||
Product.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
id = num.tryParse(json['id']?.toString() ?? '');
|
||||
productName = json['productName'];
|
||||
productType = json['product_type'];
|
||||
categoryId = json['category_id'];
|
||||
vatAmount = json['vat_amount'];
|
||||
categoryId = num.tryParse(json['category_id']?.toString() ?? '');
|
||||
vatAmount = num.tryParse(json['vat_amount']?.toString() ?? '');
|
||||
vatType = json['vat_type'];
|
||||
|
||||
category = json['category'] != null ? Category.fromJson(json['category']) : null;
|
||||
@@ -238,7 +238,7 @@ class Category {
|
||||
});
|
||||
|
||||
Category.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
id = num.tryParse(json['id']?.toString() ?? '');
|
||||
categoryName = json['categoryName'];
|
||||
}
|
||||
|
||||
@@ -262,10 +262,10 @@ class PurchaseStock {
|
||||
});
|
||||
|
||||
PurchaseStock.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
id = num.tryParse(json['id']?.toString() ?? '');
|
||||
batchNo = json['batch_no'] ?? 'N/A';
|
||||
variantName = json['variant_name']; // Added
|
||||
warehouseId = json['warehouse_id']; // Added
|
||||
warehouseId = num.tryParse(json['warehouse_id']?.toString() ?? ''); // Added
|
||||
}
|
||||
|
||||
num? id;
|
||||
@@ -285,7 +285,7 @@ class Party {
|
||||
});
|
||||
|
||||
Party.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
id = num.tryParse(json['id']?.toString() ?? '');
|
||||
name = json['name'];
|
||||
email = json['email'];
|
||||
phone = json['phone'];
|
||||
@@ -320,7 +320,7 @@ class User {
|
||||
});
|
||||
|
||||
User.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
id = num.tryParse(json['id']?.toString() ?? '');
|
||||
name = json['name'];
|
||||
role = json['role'];
|
||||
}
|
||||
@@ -347,7 +347,7 @@ class Branch {
|
||||
});
|
||||
|
||||
Branch.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
id = num.tryParse(json['id']?.toString() ?? '');
|
||||
name = json['name'];
|
||||
phone = json['phone'];
|
||||
address = json['address'];
|
||||
@@ -372,9 +372,9 @@ class PurchaseReturn {
|
||||
});
|
||||
|
||||
PurchaseReturn.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
businessId = json['business_id'];
|
||||
purchaseId = json['purchase_id'];
|
||||
id = num.tryParse(json['id']?.toString() ?? '');
|
||||
businessId = num.tryParse(json['business_id']?.toString() ?? '');
|
||||
purchaseId = num.tryParse(json['purchase_id']?.toString() ?? '');
|
||||
invoiceNo = json['invoice_no'];
|
||||
returnDate = json['return_date'];
|
||||
createdAt = json['created_at'];
|
||||
@@ -423,12 +423,12 @@ class PurchaseReturnDetails {
|
||||
});
|
||||
|
||||
PurchaseReturnDetails.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
businessId = json['business_id'];
|
||||
purchaseReturnId = json['purchase_return_id'];
|
||||
purchaseDetailId = json['purchase_detail_id'];
|
||||
returnAmount = json['return_amount'];
|
||||
returnQty = json['return_qty'];
|
||||
id = num.tryParse(json['id']?.toString() ?? '');
|
||||
businessId = num.tryParse(json['business_id']?.toString() ?? '');
|
||||
purchaseReturnId = num.tryParse(json['purchase_return_id']?.toString() ?? '');
|
||||
purchaseDetailId = num.tryParse(json['purchase_detail_id']?.toString() ?? '');
|
||||
returnAmount = num.tryParse(json['return_amount']?.toString() ?? '');
|
||||
returnQty = num.tryParse(json['return_qty']?.toString() ?? '');
|
||||
}
|
||||
|
||||
num? id;
|
||||
@@ -458,9 +458,9 @@ class PurchaseVat {
|
||||
});
|
||||
|
||||
PurchaseVat.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
id = num.tryParse(json['id']?.toString() ?? '');
|
||||
name = json['name'];
|
||||
rate = json['rate'];
|
||||
rate = num.tryParse(json['rate']?.toString() ?? '');
|
||||
}
|
||||
|
||||
num? id;
|
||||
@@ -475,7 +475,7 @@ class PaymentType {
|
||||
});
|
||||
|
||||
PaymentType.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
id = num.tryParse(json['id']?.toString() ?? '');
|
||||
name = json['name'];
|
||||
}
|
||||
|
||||
@@ -491,9 +491,9 @@ class PurchaseProductVat {
|
||||
});
|
||||
|
||||
PurchaseProductVat.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
id = num.tryParse(json['id']?.toString() ?? '');
|
||||
name = json['name'];
|
||||
rate = json['rate'];
|
||||
rate = num.tryParse(json['rate']?.toString() ?? '');
|
||||
}
|
||||
|
||||
num? id;
|
||||
|
||||
@@ -21,9 +21,9 @@ class TransactionModel {
|
||||
factory TransactionModel.fromJson(Map<String, dynamic> json) {
|
||||
return TransactionModel(
|
||||
message: json['message'],
|
||||
totalAmount: json['total_amount'],
|
||||
moneyIn: json['money_in'],
|
||||
moneyOut: json['money_out'],
|
||||
totalAmount: num.tryParse(json['total_amount']?.toString() ?? ''),
|
||||
moneyIn: num.tryParse(json['money_in']?.toString() ?? ''),
|
||||
moneyOut: num.tryParse(json['money_out']?.toString() ?? ''),
|
||||
data: json['data'] != null
|
||||
? List<TransactionModelData>.from(
|
||||
json['data'].map((v) => TransactionModelData.fromJson(v)),
|
||||
@@ -105,20 +105,20 @@ class TransactionModelData {
|
||||
final _partyKey = json['sale']?['party'] ?? json['purchase']?['party'] ?? json['due_collect']?['party'];
|
||||
|
||||
return TransactionModelData(
|
||||
id: json['id'],
|
||||
id: num.tryParse(json['id']?.toString() ?? ''),
|
||||
platform: json['platform'],
|
||||
transactionType: json['transaction_type'],
|
||||
type: json['type'],
|
||||
amount: json['amount'],
|
||||
totalAmount: json['total_amount'],
|
||||
amount: num.tryParse(json['amount']?.toString() ?? ''),
|
||||
totalAmount: num.tryParse(json['total_amount']?.toString() ?? ''),
|
||||
date: json['date'],
|
||||
businessId: json['business_id'],
|
||||
branchId: json['branch_id'],
|
||||
paymentTypeId: json['payment_type_id'],
|
||||
userId: json['user_id'],
|
||||
businessId: num.tryParse(json['business_id']?.toString() ?? ''),
|
||||
branchId: num.tryParse(json['branch_id']?.toString() ?? ''),
|
||||
paymentTypeId: num.tryParse(json['payment_type_id']?.toString() ?? ''),
|
||||
userId: num.tryParse(json['user_id']?.toString() ?? ''),
|
||||
fromBank: json['from_bank'],
|
||||
toBank: json['to_bank'],
|
||||
referenceId: json['reference_id'],
|
||||
toBank: int.tryParse(json['to_bank']?.toString() ?? ''),
|
||||
referenceId: num.tryParse(json['reference_id']?.toString() ?? ''),
|
||||
invoiceNo: json['invoice_no'],
|
||||
image: json['image'],
|
||||
note: json['note'],
|
||||
|
||||
@@ -6,7 +6,7 @@ class BalanceSheetModel {
|
||||
|
||||
factory BalanceSheetModel.fromJson(Map<String, dynamic> json) {
|
||||
return BalanceSheetModel(
|
||||
totalAsset: json["total_asset"],
|
||||
totalAsset: num.tryParse(json["total_asset"].toString()),
|
||||
data: json["asset_datas"] == null
|
||||
? []
|
||||
: List<AssetData>.from(json["asset_datas"]!.map((x) => AssetData.fromJson(x))),
|
||||
@@ -40,8 +40,8 @@ class AssetData {
|
||||
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;
|
||||
final _purchasePrice = num.tryParse(_firstStock["productPurchasePrice"].toString()) ?? 0;
|
||||
final _stockQty = num.tryParse(_firstStock["productStock"].toString()) ?? 0;
|
||||
|
||||
_amount = _purchasePrice * _stockQty;
|
||||
}
|
||||
@@ -51,8 +51,8 @@ class AssetData {
|
||||
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;
|
||||
final _price = num.tryParse(item["purchase_price"].toString()) ?? 0;
|
||||
final _qty = num.tryParse(item["quantity"].toString()) ?? 0;
|
||||
return sum + (_price * _qty);
|
||||
}
|
||||
return sum;
|
||||
@@ -60,7 +60,7 @@ class AssetData {
|
||||
}
|
||||
}
|
||||
} else if (_source == "bank") {
|
||||
_amount = (json["balance"] as num?) ?? 0;
|
||||
_amount = num.tryParse(json["balance"].toString()) ?? 0;
|
||||
}
|
||||
|
||||
return AssetData(
|
||||
|
||||
@@ -13,9 +13,9 @@ class BillWiseLossProfitReportModel {
|
||||
|
||||
factory BillWiseLossProfitReportModel.fromJson(Map<String, dynamic> json) {
|
||||
return BillWiseLossProfitReportModel(
|
||||
totalSaleAmount: json["total_amount"],
|
||||
totalProfit: json['total_bill_profit'],
|
||||
totalLoss: json['total_bill_loss'],
|
||||
totalSaleAmount: num.tryParse(json["total_amount"].toString()),
|
||||
totalProfit: num.tryParse(json['total_bill_profit'].toString()),
|
||||
totalLoss: num.tryParse(json['total_bill_loss'].toString()),
|
||||
transactions: json['data'] == null
|
||||
? null
|
||||
: List<TransactionModel>.from(json['data'].map((x) => TransactionModel.fromJson(x))),
|
||||
@@ -50,8 +50,8 @@ class TransactionModel {
|
||||
partyName: json['party']?['name'],
|
||||
invoiceNumber: json['invoiceNumber'],
|
||||
transactionDate: json["saleDate"] == null ? null : DateTime.parse(json['saleDate']),
|
||||
totalAmount: json['totalAmount'],
|
||||
lossProfit: json['lossProfit'],
|
||||
totalAmount: num.tryParse(json['totalAmount'].toString()),
|
||||
lossProfit: num.tryParse(json['lossProfit'].toString()),
|
||||
items: json['details'] == null
|
||||
? null
|
||||
: List<TransactionItem>.from(json['details'].map((x) => TransactionItem.fromJson(x))),
|
||||
@@ -82,10 +82,10 @@ class TransactionItem {
|
||||
return TransactionItem(
|
||||
id: json['id'],
|
||||
name: json['product']?['productName'],
|
||||
quantity: json['quantities'],
|
||||
purchasePrice: json['productPurchasePrice'],
|
||||
salesPrice: json['price'],
|
||||
lossProfit: json['lossProfit'],
|
||||
quantity: int.tryParse(json['quantities'].toString()),
|
||||
purchasePrice: num.tryParse(json['productPurchasePrice'].toString()),
|
||||
salesPrice: num.tryParse(json['price'].toString()),
|
||||
lossProfit: num.tryParse(json['lossProfit'].toString()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ class CashflowModel {
|
||||
|
||||
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"],
|
||||
cashIn: num.tryParse(json["cash_in"].toString()),
|
||||
cashOut: num.tryParse(json["cash_out"].toString()),
|
||||
runningCash: num.tryParse(json["running_cash"].toString()),
|
||||
initialRunningCash: num.tryParse(json["initial_running_cash"].toString()),
|
||||
data: json["data"] == null ? [] : List<CashflowData>.from(json["data"]!.map((x) => CashflowData.fromJson(x))),
|
||||
);
|
||||
}
|
||||
@@ -55,7 +55,7 @@ class CashflowData {
|
||||
platform: json["platform"],
|
||||
transactionType: json["transaction_type"],
|
||||
type: json["type"],
|
||||
amount: json["amount"],
|
||||
amount: num.tryParse(json["amount"].toString()),
|
||||
date: json["date"] == null ? null : DateTime.parse(json["date"]),
|
||||
invoiceNo: json["invoice_no"],
|
||||
paymentType: json["payment_type"]?["name"],
|
||||
|
||||
@@ -29,13 +29,13 @@ class LossProfitModel {
|
||||
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'],
|
||||
grossSalProfit: num.tryParse(json["grossSaleProfit"].toString()),
|
||||
grossIncomeProfit: num.tryParse(json['grossIncomeProfit'].toString()),
|
||||
totalExpenses: num.tryParse(json['totalExpenses'].toString()),
|
||||
netProfit: num.tryParse(json['netProfit'].toString()),
|
||||
cartGrossProfit: num.tryParse(json['cardGrossProfit'].toString()),
|
||||
totalCardExpense: num.tryParse(json['totalCardExpenses'].toString()),
|
||||
cardNetProfit: num.tryParse(json['cardNetProfit'].toString()),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ class IncomeSummaryModel {
|
||||
return IncomeSummaryModel(
|
||||
type: json["type"],
|
||||
date: json["date"],
|
||||
totalIncome: json["total_incomes"],
|
||||
totalIncome: num.tryParse(json["total_incomes"].toString()),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class ExpenseSummaryModel {
|
||||
return ExpenseSummaryModel(
|
||||
type: json["type"],
|
||||
date: json["date"],
|
||||
totalExpense: json["total_expenses"],
|
||||
totalExpense: num.tryParse(json["total_expenses"].toString()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ class ProductHistoryListModel {
|
||||
|
||||
factory ProductHistoryListModel.fromJson(Map<String, dynamic> json) {
|
||||
return ProductHistoryListModel(
|
||||
totalPurchaseQuantity: json['total_purchase_qty'],
|
||||
totalSaleQuantity: json['total_sale_qty'],
|
||||
totalPurchaseQuantity: int.tryParse(json['total_purchase_qty']?.toString() ?? ''),
|
||||
totalSaleQuantity: int.tryParse(json['total_sale_qty']?.toString() ?? ''),
|
||||
items: json['data'] == null
|
||||
? null
|
||||
: List<ProductHistoryItemModel>.from(json['data']!.map((x) => ProductHistoryItemModel.fromJson(x))),
|
||||
@@ -54,34 +54,40 @@ class ProductHistoryItemModel {
|
||||
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));
|
||||
: (json["purchase_details"] as List<dynamic>)
|
||||
.fold<int>(0, (p, ev) => p + (int.tryParse(ev["quantities"]?.toString() ?? '') ?? 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));
|
||||
: (json["sale_details"] as List<dynamic>)
|
||||
.fold<int>(0, (p, ev) => p + (int.tryParse(ev["quantities"]?.toString() ?? '') ?? 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);
|
||||
return p + (int.tryParse(ev["stock"]?["productStock"]?.toString() ?? '') ?? 0);
|
||||
}),
|
||||
_ => json["stocks"] == null ? null : (json["stocks"] as List<dynamic>).firstOrNull?["productStock"] as int? ?? 0,
|
||||
_ => json["stocks"] == null
|
||||
? null
|
||||
: int.tryParse((json["stocks"] as List<dynamic>).firstOrNull?["productStock"]?.toString() ?? '') ?? 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,
|
||||
"combo" => num.tryParse(json["productSalePrice"]?.toString() ?? '') ?? 0,
|
||||
_ => json["stocks"] == null
|
||||
? null
|
||||
: num.tryParse((json["stocks"] as List<dynamic>).firstOrNull?["productSalePrice"]?.toString() ?? '') ?? 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["combo_products"] as List<dynamic>)
|
||||
.fold<num>(0, (p, ev) => p + (num.tryParse(ev["purchase_price"]?.toString() ?? '') ?? 0)),
|
||||
_ => json["stocks"] == null
|
||||
? null
|
||||
: (json["stocks"] as List<dynamic>).firstOrNull?["productPurchasePrice"] as num? ?? 0,
|
||||
: num.tryParse((json["stocks"] as List<dynamic>).firstOrNull?["productPurchasePrice"]?.toString() ?? '') ?? 0,
|
||||
};
|
||||
|
||||
return ProductHistoryItemModel(
|
||||
@@ -116,9 +122,9 @@ class ProductHistoryDetailsModel {
|
||||
final _detailsKey = _json["sale_details"] ?? _json["purchase_details"];
|
||||
|
||||
return ProductHistoryDetailsModel(
|
||||
totalQuantities: j['total_quantities'],
|
||||
totalSalePrice: j['total_sale_price'],
|
||||
totalPurchasePrice: j['total_purchase_price'],
|
||||
totalQuantities: int.tryParse(j['total_quantities']?.toString() ?? ''),
|
||||
totalSalePrice: num.tryParse(j['total_sale_price']?.toString() ?? ''),
|
||||
totalPurchasePrice: num.tryParse(j['total_purchase_price']?.toString() ?? ''),
|
||||
productName: _json?["productName"],
|
||||
items: _detailsKey == null
|
||||
? null
|
||||
@@ -155,9 +161,9 @@ class ProductHistoryDetailsItem {
|
||||
invoiceNo: _invoiceKey,
|
||||
type: 'Purchase',
|
||||
transactionDate: _transactionDate != null ? DateTime.parse(_transactionDate) : null,
|
||||
quantities: json['quantities'],
|
||||
salePrice: json['price'],
|
||||
purchasePrice: json['productPurchasePrice'],
|
||||
quantities: int.tryParse(json['quantities']?.toString() ?? ''),
|
||||
salePrice: num.tryParse(json['price']?.toString() ?? ''),
|
||||
purchasePrice: num.tryParse(json['productPurchasePrice']?.toString() ?? ''),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class SubscriptionReportModel {
|
||||
|
||||
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;
|
||||
final int _duration = int.tryParse(json['duration']?.toString() ?? '') ?? 0;
|
||||
|
||||
return SubscriptionReportModel(
|
||||
id: json['id'],
|
||||
|
||||
@@ -18,16 +18,16 @@ class TaxReportModel {
|
||||
overviews: [
|
||||
// Sales
|
||||
OverviewModel(
|
||||
totalAmount: json['sales_total_amount'] ?? 0,
|
||||
totalDiscount: json['sales_total_discount'] ?? 0,
|
||||
totalVat: json['sales_total_vat'] ?? 0,
|
||||
totalAmount: num.tryParse(json['sales_total_amount'].toString()) ?? 0,
|
||||
totalDiscount: num.tryParse(json['sales_total_discount'].toString()) ?? 0,
|
||||
totalVat: num.tryParse(json['sales_total_vat'].toString()) ?? 0,
|
||||
),
|
||||
|
||||
// Purchase
|
||||
OverviewModel(
|
||||
totalAmount: json['purchases_total_amount'] ?? 0,
|
||||
totalDiscount: json['purchases_total_discount'] ?? 0,
|
||||
totalVat: json['purchases_total_vat'] ?? 0,
|
||||
totalAmount: num.tryParse(json['purchases_total_amount'].toString()) ?? 0,
|
||||
totalDiscount: num.tryParse(json['purchases_total_discount'].toString()) ?? 0,
|
||||
totalVat: num.tryParse(json['purchases_total_vat'].toString()) ?? 0,
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -63,10 +63,10 @@ class InvoiceModel {
|
||||
partyName: json['party']?['name'],
|
||||
invoiceNumber: json['invoiceNumber'],
|
||||
transactionDate: _dateKey == null ? null : DateTime.parse(_dateKey),
|
||||
amount: json['totalAmount'],
|
||||
discountAmount: json['discountAmount'],
|
||||
amount: num.tryParse(json['totalAmount'].toString()),
|
||||
discountAmount: num.tryParse(json['discountAmount'].toString()),
|
||||
vatName: json['vat']?['name'],
|
||||
vatAmount: json['vat_amount'],
|
||||
vatAmount: num.tryParse(json['vat_amount'].toString()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,14 +24,14 @@ class PaymentsTransaction {
|
||||
});
|
||||
|
||||
PaymentsTransaction.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
id = num.tryParse(json['id']?.toString() ?? '');
|
||||
platform = json['platform'];
|
||||
transactionType = json['transaction_type'];
|
||||
amount = num.tryParse(json['amount'].toString());
|
||||
amount = num.tryParse(json['amount']?.toString() ?? '');
|
||||
date = json['date'];
|
||||
invoiceNo = json['invoice_no'];
|
||||
referenceId = json['reference_id'];
|
||||
paymentTypeId = json['payment_type_id'];
|
||||
referenceId = num.tryParse(json['reference_id']?.toString() ?? '');
|
||||
paymentTypeId = num.tryParse(json['payment_type_id']?.toString() ?? '');
|
||||
meta = json['meta'] != null ? TransactionMeta.fromJson(json['meta']) : null;
|
||||
paymentType = json['payment_type'] != null ? PaymentType.fromJson(json['payment_type']) : null;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class PaymentType {
|
||||
});
|
||||
|
||||
PaymentType.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
id = num.tryParse(json['id']?.toString() ?? '');
|
||||
name = json['name'];
|
||||
paymentTypeMeta = json['meta'] != null ? PaymentTypeMeta.fromJson(json['meta']) : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user