Items.fromJson constructor

Items.fromJson(
  1. Map<String, dynamic> json
)

Implementation

Items.fromJson(Map<String, dynamic> json) {
  id = json['id'];
  createdAt = json['createdAt'];
  status = json['status'];
  quantity = json['quantity'];
  startDate = json['startDate'];
  endDate = json['endDate'];
  basePrice = json['basePrice'] != null
      ? int.tryParse(json['basePrice'].toString())
      : null;
  discountedPrice = json['discountedPrice'] != null
      ? int.tryParse(json['discountedPrice'].toString())
      : null;
  paidPrice = json['paidPrice'] != null
      ? double.tryParse(json['paidPrice'].toString())
      : null;
  taxPercentage = json['taxPercentage'] != null
      ? int.tryParse(json['taxPercentage'].toString())
      : null;
  taxAmount = json['taxAmount'] != null
      ? double.tryParse(json['taxAmount'].toString())
      : null;
  currency = json['currency'];
  fromCurrency = json['fromCurrency'];
  currencyRate = json['currencyRate'];
  baseCurrency = json['baseCurrency'];
  baseCurrencyRate = json['baseCurrencyRate'] != null
      ? double.tryParse(json['baseCurrencyRate'].toString())
      : null;
  customerNote = json['customerNote'];
  storeNote = json['storeNote'];
  store = json['store'] != null ? StoreDTO.fromJson(json['store']) : null;
  productDetail = json['productDetail'] != null
      ? ProductDetail.fromJson(json['productDetail'])
      : null;
  campaign = json['campaign'];
  if (json['stocks'] != null) {
    stocks = <StockDTO>[];
    json['stocks'].forEach((v) {
      stocks!.add(StockDTO.fromJson(v));
    });
  }
  if (json['refunds'] != null) {
    refunds = <RefundDTO>[];
    json['refunds'].forEach((v) {
      refunds!.add(RefundDTO.fromJson(v));
    });
  }
  // if (json['sides'] != null) {
  //   sides = <Null>[];
  //   json['sides'].forEach((v) {
  //     sides!.add(void.fromJson(v));
  //   });
  // }
}