package api.unicore.component;
 
import static api.util.ComponentConstants.BOOLEAN_NULL;
import static api.util.ComponentConstants.BOOLEAN_NULL_CODE;
import static api.util.ComponentConstants.INTEGER_NULL;
import static api.util.ComponentConstants.INTEGER_NULL_CODE;
import static api.util.ComponentConstants.STRING_NULL;
import static api.util.ComponentConstants.STRING_NULL_CODE;
import static org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion.NON_NULL;
 
import api.UnoComponent;
import api.unicore.component_manual.BillingSettings;
import api.util.BooleanFormat;
import api.util.IntegerFormat;
import api.util.StringFormat;
import iapp.services.ServerObject;
import iapp.util.audit.AuditHelper;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.FormParam;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.codehaus.jackson.annotate.JsonPropertyOrder;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import unipay.fields_manual.Fields;
import unipay.validator.EnumValidator;
 
/**
 * @author CodeGen [Liza Zhydok]
 * @company UnitedThinkers
 * @since 2015/11/16
 */
 
@JsonSerialize(include=NON_NULL)
@XmlType(propOrder={"balancingAlgorithmType", "codeUniqenessScopeMode", "forecastingPeriod", "isMultiplePaymentPlanModeEnabled", "isChargebackFeeReversalEnabled", "isSchedulePaymentDeclinesEnabled", "isPaymentOptionDeclineDeactivationEnabled", "creditBureauReportingStatus", "invoiceWriteoffAge", "customAccountWriteoffAge", "isSkipTracingEnabled", "skipTracingPeriod", "letterMailMode", "isBadPhoneRetentionEnabled", "collectionsPeriod"})
@JsonPropertyOrder({"balancingAlgorithmType", "codeUniqenessScopeMode", "forecastingPeriod", "isMultiplePaymentPlanModeEnabled", "isChargebackFeeReversalEnabled", "isSchedulePaymentDeclinesEnabled", "isPaymentOptionDeclineDeactivationEnabled", "creditBureauReportingStatus", "invoiceWriteoffAge", "customAccountWriteoffAge", "isSkipTracingEnabled", "skipTracingPeriod", "letterMailMode", "isBadPhoneRetentionEnabled", "collectionsPeriod"})
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso(BillingSettings.class)
public abstract class AbstractBillingSettings extends UnoComponent<unicore.model.Merchant> {
 
    @FormParam("balancingAlgorithmType")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String balancingAlgorithmType;
 
    @FormParam("codeUniqenessScopeMode")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String codeUniqenessScopeMode;
 
    @FormParam("forecastingPeriod")
    @IntegerFormat
    @DefaultValue(INTEGER_NULL_CODE)
    protected Integer forecastingPeriod;
 
    @FormParam("isMultiplePaymentPlanModeEnabled")
    @BooleanFormat
    @DefaultValue(BOOLEAN_NULL_CODE)
    protected Boolean isMultiplePaymentPlanModeEnabled;
 
    @FormParam("isChargebackFeeReversalEnabled")
    @BooleanFormat
    @DefaultValue(BOOLEAN_NULL_CODE)
    protected Boolean isChargebackFeeReversalEnabled;
 
    @FormParam("isSchedulePaymentDeclinesEnabled")
    @BooleanFormat
    @DefaultValue(BOOLEAN_NULL_CODE)
    protected Boolean isSchedulePaymentDeclinesEnabled;
 
    @FormParam("isPaymentOptionDeclineDeactivationEnabled")
    @BooleanFormat
    @DefaultValue(BOOLEAN_NULL_CODE)
    protected Boolean isPaymentOptionDeclineDeactivationEnabled;
 
    @FormParam("creditBureauReportingStatus")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String creditBureauReportingStatus;
 
    @FormParam("invoiceWriteoffAge")
    @IntegerFormat
    @DefaultValue(INTEGER_NULL_CODE)
    protected Integer invoiceWriteoffAge;
 
    @FormParam("customAccountWriteoffAge")
    @IntegerFormat
    @DefaultValue(INTEGER_NULL_CODE)
    protected Integer customAccountWriteoffAge;
 
    @FormParam("isSkipTracingEnabled")
    @BooleanFormat
    @DefaultValue(BOOLEAN_NULL_CODE)
    protected Boolean isSkipTracingEnabled;
 
    @FormParam("skipTracingPeriod")
    @IntegerFormat
    @DefaultValue(INTEGER_NULL_CODE)
    protected Integer skipTracingPeriod;
 
    @FormParam("letterMailMode")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String letterMailMode;
 
    @FormParam("isBadPhoneRetentionEnabled")
    @BooleanFormat
    @DefaultValue(BOOLEAN_NULL_CODE)
    protected Boolean isBadPhoneRetentionEnabled;
 
    @FormParam("collectionsPeriod")
    @IntegerFormat
    @DefaultValue(INTEGER_NULL_CODE)
    protected Integer collectionsPeriod;
 
 
    public AbstractBillingSettings(){
        super();
        applyDefaults();
    }
 
    public AbstractBillingSettings(unicore.model.Merchant object){
        super(object);
    }
 
 
    private void applyDefaults() {
        if (!isProxyObject()) {
            balancingAlgorithmType = STRING_NULL;
            codeUniqenessScopeMode = STRING_NULL;
            forecastingPeriod = INTEGER_NULL;
            isMultiplePaymentPlanModeEnabled = BOOLEAN_NULL;
            isChargebackFeeReversalEnabled = BOOLEAN_NULL;
            isSchedulePaymentDeclinesEnabled = BOOLEAN_NULL;
            isPaymentOptionDeclineDeactivationEnabled = BOOLEAN_NULL;
            creditBureauReportingStatus = STRING_NULL;
            invoiceWriteoffAge = INTEGER_NULL;
            customAccountWriteoffAge = INTEGER_NULL;
            isSkipTracingEnabled = BOOLEAN_NULL;
            skipTracingPeriod = INTEGER_NULL;
            letterMailMode = STRING_NULL;
            isBadPhoneRetentionEnabled = BOOLEAN_NULL;
            collectionsPeriod = INTEGER_NULL;
        }
    }
 
    @Override
    public void from() {
        fromInternal();
        super.from();
    }
 
    protected abstract void fromInternal();
    @Override
    public abstract void to();
    @Override
    public abstract void initializeNew();
 
    @Override
    public String toString(){
        StringBuilder sb = new StringBuilder();
        sb.append("billing-settings: {");
        sb.append("balancingAlgorithmType: ");
        sb.append(balancingAlgorithmType);
        sb.append(',').append(' ');
        sb.append("codeUniqenessScopeMode: ");
        sb.append(codeUniqenessScopeMode);
        sb.append(',').append(' ');
        sb.append("forecastingPeriod: ");
        sb.append(forecastingPeriod);
        sb.append(',').append(' ');
        sb.append("isMultiplePaymentPlanModeEnabled: ");
        sb.append(isMultiplePaymentPlanModeEnabled);
        sb.append(',').append(' ');
        sb.append("isChargebackFeeReversalEnabled: ");
        sb.append(isChargebackFeeReversalEnabled);
        sb.append(',').append(' ');
        sb.append("isSchedulePaymentDeclinesEnabled: ");
        sb.append(isSchedulePaymentDeclinesEnabled);
        sb.append(',').append(' ');
        sb.append("isPaymentOptionDeclineDeactivationEnabled: ");
        sb.append(isPaymentOptionDeclineDeactivationEnabled);
        sb.append(',').append(' ');
        sb.append("creditBureauReportingStatus: ");
        sb.append(creditBureauReportingStatus);
        sb.append(',').append(' ');
        sb.append("invoiceWriteoffAge: ");
        sb.append(invoiceWriteoffAge);
        sb.append(',').append(' ');
        sb.append("customAccountWriteoffAge: ");
        sb.append(customAccountWriteoffAge);
        sb.append(',').append(' ');
        sb.append("isSkipTracingEnabled: ");
        sb.append(isSkipTracingEnabled);
        sb.append(',').append(' ');
        sb.append("skipTracingPeriod: ");
        sb.append(skipTracingPeriod);
        sb.append(',').append(' ');
        sb.append("letterMailMode: ");
        sb.append(letterMailMode);
        sb.append(',').append(' ');
        sb.append("isBadPhoneRetentionEnabled: ");
        sb.append(isBadPhoneRetentionEnabled);
        sb.append(',').append(' ');
        sb.append("collectionsPeriod: ");
        sb.append(collectionsPeriod);
        sb.append('}');
        return sb.toString();
    }
 
 
    @XmlAttribute(name="balancingAlgorithmType")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("balancingAlgorithmType")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @EnumValidator(unicore.model.AccountBalanceAlgorithmClassifier.class)
    public String getBalancingAlgorithmType(){
        return balancingAlgorithmType;
    }
 
    public void setBalancingAlgorithmType(String value){
        this.balancingAlgorithmType = value;
    }
 
    @XmlAttribute(name="codeUniqenessScopeMode")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("codeUniqenessScopeMode")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @EnumValidator(unicore.model.CodeUniquenessScopeClassifier.class)
    public String getCodeUniqenessScopeMode(){
        return codeUniqenessScopeMode;
    }
 
    public void setCodeUniqenessScopeMode(String value){
        this.codeUniqenessScopeMode = value;
    }
 
    @XmlAttribute(name="forecastingPeriod")
    @XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
    @FormParam("forecastingPeriod")
    @IntegerFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    @Min(0)
    public Integer getForecastingPeriod(){
        return forecastingPeriod;
    }
 
    public void setForecastingPeriod(Integer value){
        this.forecastingPeriod = value;
    }
 
    @XmlAttribute(name="isMultiplePaymentPlanModeEnabled")
    @FormParam("isMultiplePaymentPlanModeEnabled")
    @BooleanFormat
    public Boolean getIsMultiplePaymentPlanModeEnabled(){
        return isMultiplePaymentPlanModeEnabled;
    }
 
    public void setIsMultiplePaymentPlanModeEnabled(Boolean value){
        this.isMultiplePaymentPlanModeEnabled = value;
    }
 
    @XmlAttribute(name="isChargebackFeeReversalEnabled")
    @FormParam("isChargebackFeeReversalEnabled")
    @BooleanFormat
    public Boolean getIsChargebackFeeReversalEnabled(){
        return isChargebackFeeReversalEnabled;
    }
 
    public void setIsChargebackFeeReversalEnabled(Boolean value){
        this.isChargebackFeeReversalEnabled = value;
    }
 
    @XmlAttribute(name="isSchedulePaymentDeclinesEnabled")
    @FormParam("isSchedulePaymentDeclinesEnabled")
    @BooleanFormat
    public Boolean getIsSchedulePaymentDeclinesEnabled(){
        return isSchedulePaymentDeclinesEnabled;
    }
 
    public void setIsSchedulePaymentDeclinesEnabled(Boolean value){
        this.isSchedulePaymentDeclinesEnabled = value;
    }
 
    @XmlAttribute(name="isPaymentOptionDeclineDeactivationEnabled")
    @FormParam("isPaymentOptionDeclineDeactivationEnabled")
    @BooleanFormat
    public Boolean getIsPaymentOptionDeclineDeactivationEnabled(){
        return isPaymentOptionDeclineDeactivationEnabled;
    }
 
    public void setIsPaymentOptionDeclineDeactivationEnabled(Boolean value){
        this.isPaymentOptionDeclineDeactivationEnabled = value;
    }
 
    @XmlAttribute(name="creditBureauReportingStatus")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("creditBureauReportingStatus")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @EnumValidator(unicore.model.CreditAgencyStatusClassifier.class)
    public String getCreditBureauReportingStatus(){
        return creditBureauReportingStatus;
    }
 
    public void setCreditBureauReportingStatus(String value){
        this.creditBureauReportingStatus = value;
    }
 
    @XmlAttribute(name="invoiceWriteoffAge")
    @XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
    @FormParam("invoiceWriteoffAge")
    @IntegerFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    @Min(0)
    public Integer getInvoiceWriteoffAge(){
        return invoiceWriteoffAge;
    }
 
    public void setInvoiceWriteoffAge(Integer value){
        this.invoiceWriteoffAge = value;
    }
 
    @XmlAttribute(name="customAccountWriteoffAge")
    @XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
    @FormParam("customAccountWriteoffAge")
    @IntegerFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    @Min(0)
    public Integer getCustomAccountWriteoffAge(){
        return customAccountWriteoffAge;
    }
 
    public void setCustomAccountWriteoffAge(Integer value){
        this.customAccountWriteoffAge = value;
    }
 
    @XmlAttribute(name="isSkipTracingEnabled")
    @FormParam("isSkipTracingEnabled")
    @BooleanFormat
    public Boolean getIsSkipTracingEnabled(){
        return isSkipTracingEnabled;
    }
 
    public void setIsSkipTracingEnabled(Boolean value){
        this.isSkipTracingEnabled = value;
    }
 
    @XmlAttribute(name="skipTracingPeriod")
    @XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
    @FormParam("skipTracingPeriod")
    @IntegerFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    @Min(0)
    public Integer getSkipTracingPeriod(){
        return skipTracingPeriod;
    }
 
    public void setSkipTracingPeriod(Integer value){
        this.skipTracingPeriod = value;
    }
 
    @XmlAttribute(name="letterMailMode")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("letterMailMode")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @EnumValidator(unicore.model.MailModeClassifier.class)
    public String getLetterMailMode(){
        return letterMailMode;
    }
 
    public void setLetterMailMode(String value){
        this.letterMailMode = value;
    }
 
    @XmlAttribute(name="isBadPhoneRetentionEnabled")
    @FormParam("isBadPhoneRetentionEnabled")
    @BooleanFormat
    public Boolean getIsBadPhoneRetentionEnabled(){
        return isBadPhoneRetentionEnabled;
    }
 
    public void setIsBadPhoneRetentionEnabled(Boolean value){
        this.isBadPhoneRetentionEnabled = value;
    }
 
    @XmlAttribute(name="collectionsPeriod")
    @XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
    @FormParam("collectionsPeriod")
    @IntegerFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    @Min(0)
    @Max(366)
    public Integer getCollectionsPeriod(){
        return collectionsPeriod;
    }
 
    public void setCollectionsPeriod(Integer value){
        this.collectionsPeriod = value;
    }
 
 
    public void audit(AuditHelper helper, ServerObject object) {
        unicore.model.Merchant s_object = (unicore.model.Merchant) object;
        helper.audit("balancingAlgorithmType", STRING_NULL.equals(balancingAlgorithmType) ? null : unicore.model.AccountBalanceAlgorithmClassifier.fromString(Fields.Management.BillingSettings.BalancingAlgorithmType, balancingAlgorithmType), s_object.getAccountBalanceAlgorithmCl() == null ? null : s_object.getAccountBalanceAlgorithmCl().getValue());
        helper.audit("codeUniqenessScopeMode", STRING_NULL.equals(codeUniqenessScopeMode) ? null : unicore.model.CodeUniquenessScopeClassifier.fromString(Fields.Management.BillingSettings.CodeUniqenessScopeMode, codeUniqenessScopeMode), s_object.getCodeUniquenessScopeCl() == null ? null : s_object.getCodeUniquenessScopeCl().getValue());
        helper.audit("forecastingPeriod", forecastingPeriod, s_object.getIbillingForecastingPeriod());
        helper.audit("isMultiplePaymentPlanModeEnabled", isMultiplePaymentPlanModeEnabled, s_object.getIsDisallowMultiplePaymentPlans());
        helper.audit("isChargebackFeeReversalEnabled", isChargebackFeeReversalEnabled, s_object.getIsReverseChargebackFee());
        helper.audit("isSchedulePaymentDeclinesEnabled", isSchedulePaymentDeclinesEnabled, s_object.getIsProcessScheduledPaymentDecline());
        helper.audit("isPaymentOptionDeclineDeactivationEnabled", isPaymentOptionDeclineDeactivationEnabled, s_object.getIsPaymentOptionDisabledOnDecline());
        helper.audit("creditBureauReportingStatus", STRING_NULL.equals(creditBureauReportingStatus) ? null : unicore.model.CreditAgencyStatusClassifier.fromString(Fields.Management.BillingSettings.CreditBureauReportingStatus, creditBureauReportingStatus), s_object.getCreditAgencyStatusCl() == null ? null : s_object.getCreditAgencyStatusCl().getValue());
        helper.audit("invoiceWriteoffAge", invoiceWriteoffAge, s_object.getTerminalInvoiceAge());
        helper.audit("customAccountWriteoffAge", customAccountWriteoffAge, s_object.getTerminalCustomerAccountAge());
        helper.audit("isSkipTracingEnabled", isSkipTracingEnabled, s_object.getIsSkipTraceEnabled());
        helper.audit("skipTracingPeriod", skipTracingPeriod, s_object.getSkipTracePeriod());
        helper.audit("letterMailMode", STRING_NULL.equals(letterMailMode) ? null : unicore.model.MailModeClassifier.fromString(Fields.Management.BillingSettings.LetterMailMode, letterMailMode), s_object.getMailModeCl() == null ? null : s_object.getMailModeCl().getValue());
        helper.audit("isBadPhoneRetentionEnabled", isBadPhoneRetentionEnabled, s_object.getIsKeepBadPhones());
        helper.audit("collectionsPeriod", collectionsPeriod, s_object.getCollectionsPeriod());
 
    }
 
    public static String objectTypeCode(){
        return "billing-settings";
    }
 
}