package com.uas.platform.b2b.mobile.model;

import java.util.Date;
import java.util.Objects;

import com.uas.platform.b2b.model.PurchaseInquiryItem;
import com.uas.platform.b2b.support.SystemSession;

/**
 * 平台里面，以供应商的角度来查看采购询价单明细
 * 
 * @author yingp
 *
 */
public class InquiryItem {

	private Long id;
	/**
	 * 询价单Id
	 */
	private Long inquiryId;
	/**
	 * 询价单号
	 */
	private String inquiryCode;
	/**
	 * 询价单日期
	 */
	private Date inquiryDate;
	/**
	 * 客户UU
	 */
	private Long customerUu;
	/**
	 * 客户名称
	 */
	private String customerName;
	/**
	 * 客户地址
	 */
	private String customerAddress;
	/**
	 * 客户电话
	 */
	private String customerTel;
	/**
	 * 供应商企业名称
	 */
	private String vendName;
	/**
	 * 物料id
	 */
	private Long productId;
	/**
	 * 物料标题
	 */
	private String productTitle;
	/**
	 * 物料规格
	 */
	private String productSpec;
	/**
	 * 物料单位
	 */
	private String productUnit;
	/**
	 * 币种
	 */
	private String currency;
	/**
	 * 税率
	 */
	private Float taxrate;
	/**
	 * 备注
	 */
	private String remark;
	/**
	 * {未回复、已回复}
	 */
	private Short status;
	/**
	 * 是否采纳
	 */
	private Short agreed;
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public Long getInquiryId() {
		return inquiryId;
	}
	public void setInquiryId(Long inquiryId) {
		this.inquiryId = inquiryId;
	}
	public String getInquiryCode() {
		return inquiryCode;
	}
	public void setInquiryCode(String inquiryCode) {
		this.inquiryCode = inquiryCode;
	}
	public Date getInquiryDate() {
		return inquiryDate;
	}
	public void setInquiryDate(Date inquiryDate) {
		this.inquiryDate = inquiryDate;
	}
	public Long getCustomerUu() {
		return customerUu;
	}
	public void setCustomerUu(Long customerUu) {
		this.customerUu = customerUu;
	}
	public String getCustomerName() {
		return customerName;
	}
	public void setCustomerName(String customerName) {
		this.customerName = customerName;
	}
	public String getCustomerAddress() {
		return customerAddress;
	}
	public void setCustomerAddress(String customerAddress) {
		this.customerAddress = customerAddress;
	}
	public String getCustomerTel() {
		return customerTel;
	}
	public void setCustomerTel(String customerTel) {
		this.customerTel = customerTel;
	}
	public Long getProductId() {
		return productId;
	}
	public void setProductId(Long productId) {
		this.productId = productId;
	}
	public String getProductTitle() {
		return productTitle;
	}
	public void setProductTitle(String productTitle) {
		this.productTitle = productTitle;
	}
	public String getProductSpec() {
		return productSpec;
	}
	public void setProductSpec(String productSpec) {
		this.productSpec = productSpec;
	}
	public String getProductUnit() {
		return productUnit;
	}
	public void setProductUnit(String productUnit) {
		this.productUnit = productUnit;
	}
	public String getCurrency() {
		return currency;
	}
	public void setCurrency(String currency) {
		this.currency = currency;
	}
	public Float getTaxrate() {
		return taxrate;
	}
	public void setTaxrate(Float taxrate) {
		this.taxrate = taxrate;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public Short getStatus() {
		return status;
	}
	public void setStatus(Short status) {
		this.status = status;
	}
	public Short getAgreed() {
		return agreed;
	}
	public void setAgreed(Short agreed) {
		this.agreed = agreed;
	}

	public String getVendName() {
		return vendName;
	}
	public void setVendName(String vendName) {
		this.vendName = vendName;
	}
	
	public InquiryItem(){};
	/**
	 * 转化构造函数
	 * @param purchaseInquiryItem
	 */
	public InquiryItem(PurchaseInquiryItem purchaseInquiryItem) {
		this.id = purchaseInquiryItem.getId();
		this.inquiryId = purchaseInquiryItem.getInquiry().getId();
		this.inquiryCode = purchaseInquiryItem.getInquiry().getCode();
		this.inquiryDate = purchaseInquiryItem.getInquiry().getDate();
		this.customerUu = purchaseInquiryItem.getInquiry().getEnterprise().getUu();
		this.customerName = purchaseInquiryItem.getInquiry().getEnterprise().getEnName();
		this.customerAddress = purchaseInquiryItem.getInquiry().getEnterprise().getEnAddress();
		this.customerTel = purchaseInquiryItem.getInquiry().getEnterprise().getEnTel();
		this.productId = purchaseInquiryItem.getProduct().getId();
		this.productTitle = purchaseInquiryItem.getProduct().getTitle();
		this.productSpec = purchaseInquiryItem.getProduct().getSpec();
		this.productUnit = purchaseInquiryItem.getProduct().getUnit();
		this.currency = purchaseInquiryItem.getCurrency();
		this.agreed = purchaseInquiryItem.getAgreed();
		this.taxrate = purchaseInquiryItem.getTaxrate();
		this.remark = purchaseInquiryItem.getRemark();
		this.status = purchaseInquiryItem.getStatus();
		// 取到多个企业的单据，需要切换供应商名字
		if (!Objects.equals(purchaseInquiryItem.getVendUU(), SystemSession.getUser().getEnterprise().getUu())) {
			SystemSession.getUser().setCurrentEnterprise(purchaseInquiryItem.getVendUU());
		}
		this.vendName = SystemSession.getUser().getEnterprise().getEnName();
	}
	
}
