package com.ecep.contract.vm;

import java.util.Objects;

import com.ecep.contract.model.CompanyInvoiceInfo;

import javafx.beans.property.SimpleStringProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = false)
public class CompanyInvoiceInfoViewModel extends IdentityViewModel<CompanyInvoiceInfo> {
    private SimpleStringProperty name = new SimpleStringProperty();
    private SimpleStringProperty taxId = new SimpleStringProperty();
    private SimpleStringProperty address = new SimpleStringProperty();
    private SimpleStringProperty phone = new SimpleStringProperty();
    private SimpleStringProperty bankName = new SimpleStringProperty();
    private SimpleStringProperty bankAccount = new SimpleStringProperty();

    @Override
    protected void updateFrom(CompanyInvoiceInfo v) {
        super.updateFrom(v);
        name.set(v.getName());
        taxId.set(v.getTaxId());
        address.set(v.getAddress());
        phone.set(v.getPhone());
        bankName.set(v.getBankName());
        bankAccount.set(v.getBankAccount());
    }

    @Override
    public boolean copyTo(CompanyInvoiceInfo v) {
        boolean ret = super.copyTo(v);
        if (!Objects.equals(name.get(), v.getName())) {
            v.setName(name.get());
            ret = true;
        }
        if (!Objects.equals(taxId.get(), v.getTaxId())) {
            v.setTaxId(taxId.get());
            ret = true;
        }
        if (!Objects.equals(address.get(), v.getAddress())) {
            v.setAddress(address.get());
            ret = true;
        }
        if (!Objects.equals(phone.get(), v.getPhone())) {
            v.setPhone(phone.get());
            ret = true;
        }
        if (!Objects.equals(bankName.get(), v.getBankName())) {
            v.setBankName(bankName.get());
            ret = true;
        }
        if (!Objects.equals(bankAccount.get(), v.getBankAccount())) {
            v.setBankAccount(bankAccount.get());
            ret = true;
        }
        return ret;
    }

}
