//
//  WSWorkOrderDetailView.swift
//  iPOS
//
//  Created by bbc on 18/11/16.
//  Copyright © 2016 BBC. All rights reserved.
//

import Foundation
import ObjectMapper

class WSWorkOrderDetailView: Mappable {
    var OrderDetailId: String
    var OrderId: String
    var ParentOrderDetailId: String?
    var OrderDetailRowNumber: Int?
    var RowType: String?
    var Barcode : String?
    var ProductCode: String?
    var ProductName: String?
    var StyleId: Int
    var OrderedQuantity: Double
    var UnitOfMeasureName: String?
    var GrossUnitValueVatIncluded : Double?
    var DiscountValue : Double?
    var NetRowValueVatIncluded: Double?
    var VatRate: Double?
    var VatValue: Double?
    var ApprovedQuantity: Double?
    var WorkApprovedQuantity: Double?
    var ApproveTime: Date?
    var ProcessTime: Date?
    var CloseTime : Date?
    var SN: String?
    var IsOriginalPriceChanged: Bool?
    var DeliveredQuantity: Double?
    var ReturnedQuantity: Double?
    var SaleState : Int?
    var PurchaseState: Int?
    var Notes : String?
    var OriginalPrice: Double?
    var FiscalPrinterDepartment: Int?
    var isChecked: Bool = false

    
    func mapping(map: Map) {
        OrderDetailId <- map["OrderDetailId"]
        OrderId <- map["OrderId"]
        ParentOrderDetailId <- map["ParentOrderDetailId"]
        OrderDetailRowNumber <- map["OrderDetailRowNumber"]
        RowType <- map["RowType"]
        Barcode <- map["Barcode"]
        ProductCode <- map["ProductCode"]
        ProductName <- map["ProductName"]
        StyleId <- map["StyleId"]
        OrderedQuantity <- (map["OrderedQuantity"], Util.CustomDoubleTransform())
        UnitOfMeasureName <- map["UnitOfMeasureName"]
        GrossUnitValueVatIncluded <- (map["GrossUnitValueVatIncluded"], Util.CustomDoubleTransform())
        DiscountValue <- (map["DiscountValue"], Util.CustomDoubleTransform())
        NetRowValueVatIncluded <- (map["NetRowValueVatIncluded"], Util.CustomDoubleTransform())
        VatRate <- (map["VatRate"], Util.CustomDoubleTransform())
        VatValue <- (map["VatValue"], Util.CustomDoubleTransform())
        ApprovedQuantity <- (map["ApprovedQuantity"], Util.CustomDoubleTransform())
        WorkApprovedQuantity <- map["WorkApprovedQuantity"]
        ApproveTime <- map["ApproveTime"]
        ProcessTime <- map["ProcessTime"]
        CloseTime <- map["CloseTime"]
        SN <- map["SN"]
        IsOriginalPriceChanged <- map["IsOriginalPriceChanged"]
        DeliveredQuantity <- (map["DeliveredQuantity"], Util.CustomDoubleTransform())
        ReturnedQuantity <- (map["ReturnedQuantity"], Util.CustomDoubleTransform())
        SaleState <- map["SaleState"]
        PurchaseState <- map["PurchaseState"]
        Notes <- map["Notes"]
        OriginalPrice <- map["OriginalPrice"]
        FiscalPrinterDepartment <- map["FiscalPrinterDepartment"]
    }
    
    required init?(map: Map) {
        OrderDetailId = UUID().description
        OrderId = UUID().description
        StyleId = 0
        OrderedQuantity = 0
    }
    
    init() {
        OrderDetailId = UUID().description
        OrderId = UUID().description
        StyleId = 0
        OrderedQuantity = 0
    }
}
