package com.autotech.we1l.items

import com.autotech.we1l.my_classes.BaseItem
import com.autotech.we1l.tools.*
import org.json.JSONObject

class InvoiceDetail(private val currencyId: Int, val priceOnSale: Float, val qty: Int, val product: Product) : BaseItem() {

    constructor(invoiceDetailJSON: JSONObject)
            : this(invoiceDetailJSON.getInt(ATTR_CURRENCY_ID), invoiceDetailJSON.getDouble(ATTR_PRICE_ON_SALE).toFloat(),
            invoiceDetailJSON.getInt(ATTR_QTY),
            Product(invoiceDetailJSON.getJSONObject(ATTR_PRODUCT), invoiceDetailJSON.getJSONObject(ATTR_PRODUCT).getInt(ATTR_CATEGORY_ID)))
}