//
//  Movements.swift
//  iPOS
//
//  Created by bbc on 14.02.2017.
//  Copyright © 2017 BBC. All rights reserved.
//

import Foundation
import ObjectMapper

class Movement: Mappable{
    var movementId: UUID
    var movementTime:Date!
    var movementNumber: Int?
    var storeId: Int!
    var cashRegister: Int?
    var styleId: Int!
    var grossUnitValueVatIncluded: Double?
    var netRowValueVatIncluded: Double?
    var netUnitValueVatIncluded: Double?
    var netRowValueVatExcluded: Double?
    var quantity: Double?
    var totalDiscountValue: Double?
    var receiptId: UUID
    var receiptNumber: Int!
    var barcodeInfo: WSBarcodeInfo
    var contactId: String?
    var productFamilyId: String?
    var vatId: Int?
    var vatRate: Double?
    var fiscalExpenseTypeId: Int?
    var medicalDevice: Bool?
    
    func mapping(map: Map) {
        movementId <- (map["ReceiptId"], Util.CustomUuidTransform())
        movementTime <- map["MovementTime"]
        movementNumber <- map["MovementNumber"]
        storeId <- map["StoreId"]
        cashRegister <- map["CashRegister"]
        styleId <- map["StyleId"]
        grossUnitValueVatIncluded <- (map["GrossUnitValueVatIncluded"],Util.CustomDoubleTransform())
        netRowValueVatIncluded <- (map["NetRowValueVatIncluded"],Util.CustomDoubleTransform())
        netUnitValueVatIncluded <- (map["NetUnitValueVatIncluded"],Util.CustomDoubleTransform())
        netRowValueVatExcluded <- (map["NetRowValueVatExcluded"],Util.CustomDoubleTransform())
        quantity <- (map["Quantity"],Util.CustomDoubleTransformQuantities())
        totalDiscountValue <- (map["TotalDiscountValue"],Util.CustomDoubleTransform())
        receiptNumber <- map["ReceiptNumber"]
        receiptId <- (map["ReceiptId"],Util.CustomUuidTransform())
        barcodeInfo <- map["WSStyleInfo"]
        contactId <- map["ContactId"]
        productFamilyId <- map["ProductFamilyId"]
        vatId <- map["VatId"]
        vatRate <- map["VatRate"]
        fiscalExpenseTypeId <- map["FiscalExpenseTypeId"]
        medicalDevice <- map["MedicalDevice"]
    }
    
    required init?(map: Map) {
        barcodeInfo = WSBarcodeInfo()
        movementId = UUID.init()
        receiptId = UUID.init()
    }
    
    init() {
        barcodeInfo = WSBarcodeInfo()
        movementId = UUID.init()
        receiptId = UUID.init()
    }
}
