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

import Foundation
import ObjectMapper

class WSWorkOrderView: Mappable {
    var OrderId : String
    var OrderNumber : Int
    var Barcode : String?
    var CreateContactId : String?
    var CreateTime : Date
    var DeliveryDate : Date?
    var OrderTypeId : Int?
    var CertifyTime : Date?
    var Notes : String?
    var CloseTime : Date?
    var ExpireTime : Date?
    var CancelTime : Date?
    var VoucherValue : Double?
    var NetValueVatIncluded : Double = 0
    var TrackingNumber : String?
    var GrossValueVatIncluded : Double = 0
    var DiscountValue : Double?
    var AdvanceRequiredValue : Double?
    var AdvancePayedValue : Double?
    var CurrencyId : String?
    var SaleState : Int?
    var VatId : Int?
    var ContactFirstName : String?
    var ContactLastName : String?
    var ContactFiscalCode : String?
    var ContactMobile : String?
    var ContactEmail : String?
    var PurchaseState : Int?
    var WSWorkOrderDetailsView : [WSWorkOrderDetailView]?
    var paymentType: String?
    var CreateStoreId: Int?
    
    func mapping(map: Map) {
        OrderId <- map["OrderId"]
        OrderNumber <- map["OrderNumber"]
        Barcode <- map["Barcode"]
        CreateContactId <- map["CreateContactId"]
        CreateTime <- (map["CreateTime"], Util.CustomDateTransform())
        DeliveryDate <- map["DeliveryDate"]
        OrderTypeId <- map["OrderTypeId"]
        CertifyTime <- (map["CertifyTime"], Util.CustomDateTransform())
        Notes <- map["Notes"]
        CloseTime <- map["CloseTime"]
        ExpireTime <- map["ExpireTime"]
        CancelTime <- map["CancelTime"]
        VoucherValue <- map["VoucherValue"]
        NetValueVatIncluded <- (map["NetValueVatIncluded"], Util.CustomDoubleTransform())
        TrackingNumber <- map["TrackingNumber"]
        GrossValueVatIncluded <- (map["GrossValueVatIncluded"], Util.CustomDoubleTransform())
        DiscountValue <- (map["DiscountValue"], Util.CustomDoubleTransform())
        AdvanceRequiredValue <- (map["AdvanceRequiredValue"], Util.CustomDoubleTransform())
        AdvancePayedValue <- (map["AdvancePayedValue"], Util.CustomDoubleTransform())
        CurrencyId <- map["CurrencyId"]
        SaleState <- map["SaleState"]
        VatId <- map["VatId"]
        ContactFirstName <- map["ContactFirstName"]
        ContactLastName <- map["ContactLastName"]
        ContactFiscalCode <- map["ContactFiscalCode"]
        ContactMobile <- map["ContactMobile"]
        ContactEmail <- map["ContactEmail"]
        CreateStoreId <- map["CreateStoreId"]
        
    }
    
    required init?(map: Map) {
        OrderId = UUID().description
        CreateTime = Date()
        OrderNumber = 1
    }
    
    init() {
        OrderId = UUID().description
        CreateTime = Date()
        OrderNumber = 1
    }
}
