ArticleRetailOnTicket.fromMap constructor

ArticleRetailOnTicket.fromMap(
  1. Map<String, dynamic> map
)

Implementation

factory ArticleRetailOnTicket.fromMap(Map<String, dynamic> map) {
  return ArticleRetailOnTicket(
    calibreId: map['calibreId'] != null
        ? map['calibreId'] as int
        : map['lineId'] != null
            ? map['lineId'] as int
            : map['productId'] as int,
    id: map['id']?.toInt() ?? 0,
    kind: ArticleKind.retail,
    designation: map['designation'] == null
        ? map['fullName'] as String
        : map['designation'] as String,
    unitsInOnePiece: map['unitsInOnePiece'] != null
        ? map['unitsInOnePiece']?.toDouble() ?? 1.0
        : map['weight'] != null
            ? map['weight']?.toDouble() ?? 1.0
            : 1.0,
    price: Price(map['price'] as num).price,
    cost: Cost(map['cost'] as num).cost,
  );
}