/*
 * Copyright 2010-2014 Ning, Inc.
 *
 * Ning licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package org.killbill.billing.client.model;

import java.math.BigDecimal;
import java.util.List;
import java.util.UUID;

import javax.annotation.Nullable;

import org.joda.time.LocalDate;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

public class Credit extends KillBillObject {

    private BigDecimal creditAmount;
    private UUID invoiceId;
    private String invoiceNumber;
    private LocalDate effectiveDate;
    private UUID accountId;

    public Credit() {}

    @JsonCreator
    public Credit(@JsonProperty("creditAmount") final BigDecimal creditAmount,
                  @JsonProperty("invoiceId") final UUID invoiceId,
                  @JsonProperty("invoiceNumber") final String invoiceNumber,
                  @JsonProperty("effectiveDate") final LocalDate effectiveDate,
                  @JsonProperty("accountId") final UUID accountId,
                  @JsonProperty("auditLogs") @Nullable final List<AuditLog> auditLogs) {
        super(auditLogs);
        this.creditAmount = creditAmount;
        this.invoiceId = invoiceId;
        this.invoiceNumber = invoiceNumber;
        this.effectiveDate = effectiveDate;
        this.accountId = accountId;
    }

    public BigDecimal getCreditAmount() {
        return creditAmount;
    }

    public void setCreditAmount(final BigDecimal creditAmount) {
        this.creditAmount = creditAmount;
    }

    public UUID getInvoiceId() {
        return invoiceId;
    }

    public void setInvoiceId(final UUID invoiceId) {
        this.invoiceId = invoiceId;
    }

    public String getInvoiceNumber() {
        return invoiceNumber;
    }

    public void setInvoiceNumber(final String invoiceNumber) {
        this.invoiceNumber = invoiceNumber;
    }

    public LocalDate getEffectiveDate() {
        return effectiveDate;
    }

    public void setEffectiveDate(final LocalDate effectiveDate) {
        this.effectiveDate = effectiveDate;
    }

    public UUID getAccountId() {
        return accountId;
    }

    public void setAccountId(final UUID accountId) {
        this.accountId = accountId;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Credit{");
        sb.append("creditAmount=").append(creditAmount);
        sb.append(", invoiceId='").append(invoiceId).append('\'');
        sb.append(", invoiceNumber='").append(invoiceNumber).append('\'');
        sb.append(", effectiveDate=").append(effectiveDate);
        sb.append(", accountId='").append(accountId).append('\'');
        sb.append('}');
        return sb.toString();
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        final Credit credit = (Credit) o;

        if (accountId != null ? !accountId.equals(credit.accountId) : credit.accountId != null) {
            return false;
        }
        if (creditAmount != null ? creditAmount.compareTo(credit.creditAmount) != 0 : credit.creditAmount != null) {
            return false;
        }
        if (effectiveDate != null ? effectiveDate.compareTo(credit.effectiveDate) != 0 : credit.effectiveDate != null) {
            return false;
        }
        if (invoiceId != null ? !invoiceId.equals(credit.invoiceId) : credit.invoiceId != null) {
            return false;
        }
        if (invoiceNumber != null ? !invoiceNumber.equals(credit.invoiceNumber) : credit.invoiceNumber != null) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        int result = creditAmount != null ? creditAmount.hashCode() : 0;
        result = 31 * result + (invoiceId != null ? invoiceId.hashCode() : 0);
        result = 31 * result + (invoiceNumber != null ? invoiceNumber.hashCode() : 0);
        result = 31 * result + (effectiveDate != null ? effectiveDate.hashCode() : 0);
        result = 31 * result + (accountId != null ? accountId.hashCode() : 0);
        return result;
    }
}

@@ -1122,16 +1122,48 @@
 countId;
+%0A    private String description;
 %0A%0A    pu
@@ -1563,24 +1563,97 @@
  accountId,%0A
+                  @JsonProperty(%22description%22) final String description,%0A
             
@@ -1917,24 +1917,64 @@
 ectiveDate;%0A
+        this.description = description;%0A
         this
@@ -2898,32 +2898,210 @@
 countId;%0A    %7D%0A%0A
+    public String getDescription() %7B%0A        return description;%0A    %7D%0A%0A    public void setDescription(final String description) %7B%0A        this.description = description;%0A    %7D%0A%0A
     @Override%0A  
@@ -3452,16 +3452,73 @@
 eDate);%0A
+        sb.append(%22, description=%22).append(description);%0A
         
@@ -4609,32 +4609,174 @@
 false;%0A        %7D
+%0A        if (description != null ? !description.equals(credit.description) : credit.description != null) %7B%0A            return false;%0A        %7D
 %0A%0A        return
@@ -4975,32 +4975,32 @@
 ashCode() : 0);%0A
-
         result =
@@ -5062,32 +5062,115 @@
 ashCode() : 0);%0A
+        result = 31 * result + (description != null ? description.hashCode() : 0);%0A
         result =

Add description for Credit model