001/*
002 * Copyright 2010-2014 Ning, Inc.
003 * Copyright 2014-2015 The Billing Project, LLC
004 *
005 * The Billing Project licenses this file to you under the Apache License, version 2.0
006 * (the "License"); you may not use this file except in compliance with the
007 * License.  You may obtain a copy of the License at:
008 *
009 *    http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
014 * License for the specific language governing permissions and limitations
015 * under the License.
016 */
017
018package com.ning.billing.recurly.model;
019
020import com.fasterxml.jackson.annotation.JsonIgnore;
021import com.google.common.base.Objects;
022import org.joda.time.DateTime;
023
024import javax.xml.bind.annotation.XmlElement;
025import javax.xml.bind.annotation.XmlElementWrapper;
026import javax.xml.bind.annotation.XmlRootElement;
027import java.math.BigDecimal;
028import java.util.ArrayList;
029import java.util.List;
030
031@XmlRootElement(name = "subscription")
032public class Subscription extends AbstractSubscription {
033
034    @XmlElement(name = "account")
035    private Account account;
036
037    @XmlElement(name = "invoice")
038    private Invoice invoice;
039
040    @XmlElement(name = "plan")
041    private Plan plan;
042
043    @XmlElement(name = "uuid")
044    private String uuid;
045
046    @XmlElement(name = "state", required = false)
047    private String state;
048
049    @XmlElement(name = "tax_in_cents")
050    private Integer taxInCents;
051
052    @XmlElement(name = "tax_region")
053    private String taxRegion;
054
055    @XmlElement(name = "tax_type")
056    private String taxType;
057
058    @XmlElement(name = "tax_rate")
059    private BigDecimal taxRate;
060
061    @XmlElement(name = "currency")
062    private String currency;
063
064    @XmlElement(name = "activated_at")
065    private DateTime activatedAt;
066
067    @XmlElement(name = "canceled_at")
068    private DateTime canceledAt;
069
070    @XmlElement(name = "expires_at")
071    private DateTime expiresAt;
072
073    @XmlElement(name = "remaining_billing_cycles")
074    private Integer remainingBillingCycles;
075
076    @XmlElement(name = "current_period_started_at")
077    private DateTime currentPeriodStartedAt;
078
079    @XmlElement(name = "current_period_ends_at")
080    private DateTime currentPeriodEndsAt;
081
082    @XmlElement(name = "trial_started_at")
083    private DateTime trialStartedAt;
084
085    @XmlElement(name = "trial_ends_at")
086    private DateTime trialEndsAt;
087
088    @XmlElement(name = "pending_subscription")
089    private Subscription pendingSubscription;
090
091    @XmlElement(name = "starts_at")
092    private DateTime startsAt;
093
094    @XmlElement(name = "updated_at")
095    private DateTime updatedAt;
096
097    @XmlElement(name = "collection_method")
098    private String collectionMethod;
099
100    @XmlElement(name = "net_terms")
101    private Integer netTerms;
102
103    @JsonIgnore
104    private String couponCode;
105
106    @XmlElementWrapper(name = "coupon_codes")
107    @XmlElement(name = "coupon_code")
108    private List<String> couponCodes;
109
110    //Purchase Order Number
111    @XmlElement(name = "po_number")
112    private String poNumber;
113    
114    @XmlElement(name = "terms_and_conditions")
115    private String termsAndConditions;
116    
117    @XmlElement(name = "customer_notes")
118    private String customerNotes;
119
120    @XmlElement(name = "first_renewal_date")
121    private DateTime firstRenewalDate;
122    
123    @XmlElement(name = "bulk")
124    private Boolean bulk;
125
126    @XmlElement(name = "revenue_schedule_type")
127    private RevenueScheduleType revenueScheduleType;
128
129    @XmlElement(name = "gift_card")
130    private GiftCard giftCard;
131
132    @XmlElement(name = "started_with_gift")
133    private Boolean startedWithGift;
134
135    @XmlElement(name = "converted_at")
136    private DateTime convertedAt;
137
138    @XmlElement(name = "shipping_address")
139    private ShippingAddress shippingAddress;
140
141    @XmlElement(name = "shipping_address_id")
142    private Long shippingAddressId;
143
144    @XmlElement(name = "shipping_method_code")
145    private String shippingMethodCode;
146
147    @XmlElement(name = "shipping_amount_in_cents")
148    private Integer shippingAmountInCents;
149
150    @XmlElement(name = "no_billing_info_reason")
151    private String noBillingInfoReason;
152
153    @XmlElement(name = "imported_trial")
154    private Boolean importedTrial;
155
156    @XmlElement(name = "credit_customer_notes")
157    private String creditCustomerNotes;
158
159    @XmlElement(name = "invoice_collection")
160    private InvoiceCollection invoiceCollection;
161
162    @XmlElement(name = "remaining_pause_cycles")
163    private Integer remainingPauseCycles;
164
165    @XmlElement(name = "paused_at")
166    private DateTime pausedAt;
167
168    @XmlElement(name = "auto_renew")
169    private Boolean autoRenew;
170
171    @XmlElement(name = "renewal_billing_cycles")
172    private Integer renewalBillingCycles;
173
174    @XmlElement(name = "first_bill_date")
175    private DateTime firstBillDate;
176
177    @XmlElement(name = "next_bill_date")
178    private DateTime nextBillDate;
179
180    @XmlElement(name = "current_term_started_at")
181    private DateTime currentTermStartedAt;
182
183    @XmlElement(name = "current_term_ends_at")
184    private DateTime currentTermEndsAt;
185
186    @XmlElement(name = "transaction_type")
187    private String transactionType;
188
189    public Account getAccount() {
190        if (account != null && account.getHref() != null && !account.getHref().isEmpty()) {
191            account = fetch(account, Account.class);
192        }
193        return account;
194    }
195
196    public void setAccount(final Account account) {
197        this.account = account;
198    }
199
200    public Invoice getInvoice() {
201        if (invoice != null && invoice.getHref() != null && !invoice.getHref().isEmpty()) {
202            invoice = fetch(invoice, Invoice.class);
203        }
204        return invoice;
205    }
206
207    public Plan getPlan() {
208        return plan;
209    }
210
211    public void setPlan(final Plan plan) {
212        this.plan = plan;
213    }
214
215    public String getUuid() {
216        return uuid;
217    }
218
219    public void setUuid(final Object uuid) {
220        this.uuid = stringOrNull(uuid);
221    }
222
223    public String getState() {
224        return state;
225    }
226
227    public void setState(final Object state) {
228        this.state = stringOrNull(state);
229    }
230
231    public String getCurrency() {
232        return currency;
233    }
234
235    public void setCurrency(final Object currency) {
236        this.currency = stringOrNull(currency);
237    }
238
239    public Integer getTaxInCents() {
240        return taxInCents;
241    }
242
243    public void setTaxInCents(final Object taxInCents) {
244        this.taxInCents = integerOrNull(taxInCents);
245    }
246
247    public void setTaxRegion(final Object taxRegion) {
248        this.taxRegion = stringOrNull(taxRegion);
249    }
250
251    public String getTaxRegion() {
252        return taxRegion;
253    }
254
255    public void setTaxRate(final Object taxRate) {
256        this.taxRate = bigDecimalOrNull(taxRate);
257    }
258
259    public BigDecimal getTaxRate() {
260        return taxRate;
261    }
262
263    public void setTaxType(final Object taxType) {
264        this.taxType = stringOrNull(taxType);
265    }
266
267    public String getTaxType() {
268        return taxType;
269    }
270
271    public DateTime getActivatedAt() {
272        return activatedAt;
273    }
274
275    public void setActivatedAt(final Object activatedAt) {
276        this.activatedAt = dateTimeOrNull(activatedAt);
277    }
278
279    public DateTime getCanceledAt() {
280        return canceledAt;
281    }
282
283    public void setCanceledAt(final Object canceledAt) {
284        this.canceledAt = dateTimeOrNull(canceledAt);
285    }
286
287    public DateTime getExpiresAt() {
288        return expiresAt;
289    }
290
291    public void setExpiresAt(final Object expiresAt) {
292        this.expiresAt = dateTimeOrNull(expiresAt);
293    }
294
295    public DateTime getCurrentPeriodStartedAt() {
296        return currentPeriodStartedAt;
297    }
298
299    public Integer getRemainingBillingCycles() {
300        return remainingBillingCycles;
301    }
302
303    public void setRemainingBillingCycles(final Object remainingBillingCycles) {
304        this.remainingBillingCycles = integerOrNull(remainingBillingCycles);
305    }
306
307    public void setCurrentPeriodStartedAt(final Object currentPeriodStartedAt) {
308        this.currentPeriodStartedAt = dateTimeOrNull(currentPeriodStartedAt);
309    }
310
311    public DateTime getCurrentPeriodEndsAt() {
312        return currentPeriodEndsAt;
313    }
314
315    public void setCurrentPeriodEndsAt(final Object currentPeriodEndsAt) {
316        this.currentPeriodEndsAt = dateTimeOrNull(currentPeriodEndsAt);
317    }
318
319    public DateTime getTrialStartedAt() {
320        return trialStartedAt;
321    }
322
323    public void setTrialStartedAt(final Object trialStartedAt) {
324        this.trialStartedAt = dateTimeOrNull(trialStartedAt);
325    }
326
327    public DateTime getTrialEndsAt() {
328        return trialEndsAt;
329    }
330
331    public void setTrialEndsAt(final Object trialEndsAt) {
332        this.trialEndsAt = dateTimeOrNull(trialEndsAt);
333    }
334
335    public Subscription getPendingSubscription() {
336        return pendingSubscription;
337    }
338
339    public void setPendingSubscription(final Subscription pendingSubscription) {
340        this.pendingSubscription = pendingSubscription;
341    }
342
343    public DateTime getStartsAt() {
344        return startsAt;
345    }
346
347    public void setStartsAt(final Object startsAt) {
348        this.startsAt = dateTimeOrNull(startsAt);
349    }
350
351    public String getCollectionMethod() {
352        return collectionMethod;
353    }
354
355    public void setCollectionMethod(Object collectionMethod) {
356        this.collectionMethod = stringOrNull(collectionMethod);
357    }
358
359    public Integer getNetTerms() {
360        return netTerms;
361    }
362
363    public void setNetTerms(final Object netTerms) {
364        this.netTerms = integerOrNull(netTerms);
365    }
366
367    public String getPoNumber() {
368        return poNumber;
369    }
370
371    public void setPoNumber(Object poNumber) {
372        this.poNumber = stringOrNull(poNumber);
373    }
374
375    public DateTime getFirstRenewalDate() {
376        return firstRenewalDate;
377    }
378
379    public String getCustomerNotes() {
380        return customerNotes;
381    }
382
383    public void setCustomerNotes(Object customerNotes) {
384        this.customerNotes = stringOrNull(customerNotes);
385    }
386
387    public String getTermsAndConditions() {
388        return termsAndConditions;
389    }
390
391    public void setTermsAndConditions(Object termsAndConditions) {
392        this.termsAndConditions = stringOrNull(termsAndConditions);
393    }
394
395    public void setFirstRenewalDate(final Object firstRenewalDate) {
396        this.firstRenewalDate = dateTimeOrNull(firstRenewalDate);
397    }
398
399    public String getCouponCode() {
400        return couponCode;
401    }
402
403    public void setCouponCode(final String couponCode) {
404        this.couponCode = couponCode;
405        if (this.couponCodes == null) this.couponCodes = new ArrayList<String>();
406        this.couponCodes.add(couponCode);
407    }
408
409    public void setCouponCodes(final List<String> couponCodes) {
410        this.couponCodes = couponCodes;
411    }
412
413    public List<String> getCouponCodes() {
414        return this.couponCodes;
415    }
416
417    public void setBulk(final Object bulk) {
418        this.bulk = booleanOrNull(bulk);
419    }
420
421    public RevenueScheduleType getRevenueScheduleType() {
422        return revenueScheduleType;
423    }
424
425    public void setRevenueScheduleType(final Object revenueScheduleType) {
426        this.revenueScheduleType = enumOrNull(RevenueScheduleType.class, revenueScheduleType, true);
427    }
428
429    public GiftCard getGiftCard() {
430        return giftCard;
431    }
432
433    public void setGiftCard(final GiftCard giftCard) {
434        this.giftCard = giftCard;
435    }
436
437    public void setShippingAddress(final ShippingAddress shippingAddress) {
438        this.shippingAddress = shippingAddress;
439    }
440
441    public ShippingAddress getShippingAddress() {
442        return shippingAddress;
443    }
444
445    public void setShippingAddressId(final Object shippingAddressId) {
446        this.shippingAddressId = longOrNull(shippingAddressId);
447    }
448
449    public String getShippingMethodCode() {
450        return shippingMethodCode;
451    }
452
453    public void setShippingMethodCode(final Object shippingMethodCode) {
454        this.shippingMethodCode = stringOrNull(shippingMethodCode);
455    }
456
457    public Integer getShippingAmountInCents() {
458        return shippingAmountInCents;
459    }
460
461    public void setShippingAmountInCents(final Object shippingAmountInCents) {
462        this.shippingAmountInCents = integerOrNull(shippingAmountInCents);
463    }
464
465    public DateTime getUpdatedAt() {
466        return updatedAt;
467    }
468
469    public void setUpdatedAt(final Object updatedAt) {
470        this.updatedAt = dateTimeOrNull(updatedAt);
471    }
472
473    public Boolean getStartedWithGift() {
474        return this.startedWithGift;
475    }
476
477    public void setStartedWithGift(final Object startedWithGift) {
478        this.startedWithGift = booleanOrNull(startedWithGift);
479    }
480
481    public DateTime getConvertedAt() {
482        return this.convertedAt;
483    }
484
485    public void setConvertedAt(final Object convertedAt) {
486        this.convertedAt = dateTimeOrNull(convertedAt);
487    }
488
489    public String getNoBillingInfoReason() {
490        return this.noBillingInfoReason;
491    }
492
493    public void setNoBillingInfoReason(final Object noBillingInfoReason) {
494        this.noBillingInfoReason = stringOrNull(noBillingInfoReason);
495    }
496
497    public Boolean getImportedTrial() {
498        return this.importedTrial;
499    }
500
501    public void setImportedTrial(final Object importedTrial) {
502        this.importedTrial = booleanOrNull(importedTrial);
503    }
504
505
506    public String getCreditCustomerNotes() {
507        return creditCustomerNotes;
508    }
509
510    public void setCreditCustomerNotes(final Object creditCustomerNotes) {
511        this.creditCustomerNotes = stringOrNull(creditCustomerNotes);
512    }
513
514    public InvoiceCollection getInvoiceCollection() {
515        return invoiceCollection;
516    }
517
518    public void setInvoiceCollection(final InvoiceCollection invoiceCollection) {
519        this.invoiceCollection = invoiceCollection;
520    }
521
522    public Integer getRemainingPauseCycles() {
523        return remainingPauseCycles;
524    }
525
526    public void setRemainingPauseCycles(final Object remainingPauseCycles) {
527        this.remainingPauseCycles = integerOrNull(remainingPauseCycles);
528    }
529
530    public DateTime getPausedAt() {
531        return this.pausedAt;
532    }
533
534    public void setPausedAt(final Object pausedAt) {
535        this.pausedAt = dateTimeOrNull(pausedAt);
536    }
537
538    public Boolean getAutoRenew() {
539        return this.autoRenew;
540    }
541
542    public void setAutoRenew(final Object autoRenew) {
543        this.autoRenew = booleanOrNull(autoRenew);
544    }
545
546    public Integer getRenewalBillingCycles() {
547        return renewalBillingCycles;
548    }
549
550    public void setRenewalBillingCycles(final Object renewalBillingCycles) {
551        this.renewalBillingCycles = integerOrNull(renewalBillingCycles);
552    }
553
554    public DateTime getFirstBillDate() {
555        return firstBillDate;
556    }
557
558    protected void setFirstBillDate(final Object firstBillDate) {
559        this.firstBillDate = dateTimeOrNull(firstBillDate);
560    }
561
562    public DateTime getNextBillDate() {
563        return nextBillDate;
564    }
565
566    protected void setNextBillDate(final Object nextBillDate) {
567        this.nextBillDate = dateTimeOrNull(nextBillDate);
568    }
569
570    public DateTime getCurrentTermStartedAt() {
571        return currentTermStartedAt;
572    }
573
574    protected void setCurrentTermStartedAt(final Object currentTermStartedAt) {
575        this.currentTermStartedAt = dateTimeOrNull(currentTermStartedAt);
576    }
577
578    public DateTime getCurrentTermEndsAt() {
579        return currentTermEndsAt;
580    }
581
582    protected void setCurrentTermEndsAt(final Object currentTermEndsAt) {
583        this.currentTermEndsAt = dateTimeOrNull(currentTermEndsAt);
584    }
585
586    public String getTransactionType() {
587        return transactionType;
588    }
589
590    public void setTransactionType(final Object transactionType) {
591        this.transactionType = stringOrNull(transactionType);
592    }
593
594    @Override
595    public String toString() {
596        final StringBuilder sb = new StringBuilder();
597        sb.append("Subscription");
598        sb.append("{account=").append(account);
599        sb.append(", plan=").append(plan);
600        sb.append(", uuid='").append(uuid).append('\'');
601        sb.append(", state='").append(state).append('\'');
602        sb.append(", unitAmountInCents=").append(unitAmountInCents);
603        sb.append(", currency='").append(currency).append('\'');
604        sb.append(", quantity=").append(quantity);
605        sb.append(", couponCode=").append(couponCode);
606        sb.append(", couponCodes=").append(couponCodes);
607        sb.append(", activatedAt=").append(activatedAt);
608        sb.append(", updatedAt=").append(updatedAt);
609        sb.append(", canceledAt=").append(canceledAt);
610        sb.append(", expiresAt=").append(expiresAt);
611        sb.append(", remainingBillingCycles=").append(remainingBillingCycles);
612        sb.append(", currentPeriodStartedAt=").append(currentPeriodStartedAt);
613        sb.append(", currentPeriodEndsAt=").append(currentPeriodEndsAt);
614        sb.append(", trialStartedAt=").append(trialStartedAt);
615        sb.append(", trialEndsAt=").append(trialEndsAt);
616        sb.append(", startsAt=").append(startsAt);
617        sb.append(", addOns=").append(addOns);
618        sb.append(", pendingSubscription=").append(pendingSubscription);
619        sb.append(", firstRenewalDate=").append(firstRenewalDate);
620        sb.append(", bulk=").append(bulk);
621        sb.append(", revenueScheduleType=").append(revenueScheduleType);
622        sb.append(", giftCard=").append(giftCard);
623        sb.append(", taxInCents=").append(taxInCents);
624        sb.append(", taxRegion=").append(taxRegion);
625        sb.append(", taxType=").append(taxType);
626        sb.append(", taxRate=").append(taxRate);
627        sb.append(", shippingAddress=").append(shippingAddress);
628        sb.append(", shippingAddressId=").append(shippingAddressId);
629        sb.append(", shippingMethodCode=").append(shippingMethodCode);
630        sb.append(", shippingAmountInCents=").append(shippingAmountInCents);
631        sb.append(", startedWithGift=").append(startedWithGift);
632        sb.append(", convertedAt=").append(convertedAt);
633        sb.append(", noBillingInfoReason=").append(noBillingInfoReason);
634        sb.append(", importedTrial=").append(importedTrial);
635        sb.append(", creditCustomerNotes=").append(creditCustomerNotes);
636        sb.append(", invoiceCollection=").append(invoiceCollection);
637        sb.append(", customFields=").append(customFields);
638        sb.append(", remainingPauseCycles=").append(remainingPauseCycles);
639        sb.append(", pausedAt=").append(pausedAt);
640        sb.append(", autoRenew=").append(autoRenew);
641        sb.append(", renewalBillingCycles=").append(renewalBillingCycles);
642        sb.append(", firstBillDate=").append(firstBillDate);
643        sb.append(", nextBillDate=").append(nextBillDate);
644        sb.append(", currentPeriodStartedAt=").append(currentPeriodStartedAt);
645        sb.append(", currentPeriodEndsAt=").append(currentPeriodEndsAt);
646        sb.append(", transactionType='").append(transactionType).append('\'');
647        sb.append('}');
648        return sb.toString();
649    }
650
651    @Override
652    public boolean equals(final Object o) {
653        if (this == o) return true;
654        if (o == null || getClass() != o.getClass()) return false;
655
656        final Subscription that = (Subscription) o;
657
658        if (account != null ? !account.equals(that.account) : that.account != null) {
659            return false;
660        }
661        if (activatedAt != null ? activatedAt.compareTo(that.activatedAt) != 0 : that.activatedAt != null) {
662            return false;
663        }
664        if (addOns != null ? !addOns.equals(that.addOns) : that.addOns != null) {
665            return false;
666        }
667        if (canceledAt != null ? canceledAt.compareTo(that.canceledAt) != 0 : that.canceledAt != null) {
668            return false;
669        }
670        if (convertedAt != null ? convertedAt.compareTo(that.convertedAt) != 0 : that.convertedAt != null) {
671            return false;
672        }
673        if (currency != null ? !currency.equals(that.currency) : that.currency != null) {
674            return false;
675        }
676        if (updatedAt != null ? updatedAt.compareTo(that.updatedAt) != 0 : that.updatedAt != null) {
677            return false;
678        }
679        if (currentPeriodEndsAt != null ? currentPeriodEndsAt.compareTo(that.currentPeriodEndsAt) != 0 : that.currentPeriodEndsAt != null) {
680            return false;
681        }
682        if (currentPeriodStartedAt != null ? currentPeriodStartedAt.compareTo(that.currentPeriodStartedAt) != 0 : that.currentPeriodStartedAt != null) {
683            return false;
684        }
685        if (expiresAt != null ? expiresAt.compareTo(that.expiresAt) != 0 : that.expiresAt != null) {
686            return false;
687        }
688        if (importedTrial != null ? !importedTrial.equals(that.importedTrial) : that.importedTrial != null) {
689            return false;
690        }
691        if (remainingBillingCycles != null ? !remainingBillingCycles.equals(that.remainingBillingCycles) : that.remainingBillingCycles != null) {
692            return false;
693        }
694        if (remainingPauseCycles != null ? !remainingPauseCycles.equals(that.remainingPauseCycles) : that.remainingPauseCycles != null) {
695            return false;
696        }
697        if (plan != null ? !plan.equals(that.plan) : that.plan != null) {
698            return false;
699        }
700        if (quantity != null ? !quantity.equals(that.quantity) : that.quantity != null) {
701            return false;
702        }
703        if (startedWithGift != null ? !startedWithGift.equals(that.startedWithGift) : that.startedWithGift != null) {
704            return false;
705        }
706        if (state != null ? !state.equals(that.state) : that.state != null) {
707            return false;
708        }
709        if (trialEndsAt != null ? trialEndsAt.compareTo(that.trialEndsAt) != 0 : that.trialEndsAt != null) {
710            return false;
711        }
712        if (trialStartedAt != null ? trialStartedAt.compareTo(that.trialStartedAt) != 0 : that.trialStartedAt != null) {
713            return false;
714        }
715        if (unitAmountInCents != null ? !unitAmountInCents.equals(that.unitAmountInCents) : that.unitAmountInCents != null) {
716            return false;
717        }
718        if (uuid != null ? !uuid.equals(that.uuid) : that.uuid != null) {
719            return false;
720        }
721        if (startsAt != null ? startsAt.compareTo(that.startsAt) != 0 : that.startsAt != null) {
722            return false;
723        }
724        if (pendingSubscription != null ? !pendingSubscription.equals(that.pendingSubscription) : that.pendingSubscription != null) {
725            return false;
726        }
727        if (collectionMethod != null ? !collectionMethod.equals(that.collectionMethod) : that.collectionMethod != null) {
728            return false;
729        }
730        if (netTerms != null ? !netTerms.equals(that.netTerms) : that.netTerms != null) {
731            return false;
732        }
733        if (pausedAt != null ? pausedAt.compareTo(that.pausedAt) != 0 : that.pausedAt != null) {
734            return false;
735        }
736        if (poNumber != null ? !poNumber.equals(that.poNumber) : that.poNumber != null) {
737            return false;
738        }
739        if (firstRenewalDate != null ? firstRenewalDate.compareTo(that.firstRenewalDate) != 0 : that.firstRenewalDate != null) {
740            return false;
741        }
742        if (bulk != null ? !bulk.equals(that.bulk) : that.bulk != null) {
743            return false;
744        }
745        if (revenueScheduleType != null ? !revenueScheduleType.equals(that.revenueScheduleType) : that.revenueScheduleType != null) {
746            return false;
747        }
748        if (giftCard != null ? !giftCard.equals(that.giftCard) : that.giftCard != null) {
749            return false;
750        }
751        if (taxInCents != null ? !taxInCents.equals(that.taxInCents) : that.taxInCents != null) {
752            return false;
753        }
754        if (taxRegion != null ? !taxRegion.equals(that.taxRegion) : that.taxRegion != null) {
755            return false;
756        }
757        if (taxType != null ? !taxType.equals(that.taxType) : that.taxType != null) {
758            return false;
759        }
760        if (taxRate != null ? !taxRate.equals(that.taxRate) : that.taxRate != null) {
761            return false;
762        }
763        if (shippingAddress != null ? !shippingAddress.equals(that.shippingAddress) : that.shippingAddress != null) {
764            return false;
765        }
766        if (shippingAddressId != null ? !shippingAddressId.equals(that.shippingAddressId) : that.shippingAddressId != null) {
767            return false;
768        }
769        if (shippingMethodCode != null ? !shippingMethodCode.equals(that.shippingMethodCode) : that.shippingMethodCode != null) {
770            return false;
771        }
772        if (shippingAmountInCents != null ? !shippingAmountInCents.equals(that.shippingAmountInCents) : that.shippingAmountInCents != null) {
773            return false;
774        }
775        if (noBillingInfoReason != null ? !noBillingInfoReason.equals(that.noBillingInfoReason) : that.noBillingInfoReason != null) {
776            return false;
777        }
778        if (creditCustomerNotes != null ? !creditCustomerNotes.equals(that.creditCustomerNotes) : that.creditCustomerNotes != null) {
779            return false;
780        }
781        if (invoiceCollection != null ? !invoiceCollection.equals(that.invoiceCollection) : that.invoiceCollection != null) {
782            return false;
783        }
784        if (customFields != null ? !customFields.equals(that.customFields) : that.customFields != null) {
785            return false;
786        }
787        if (renewalBillingCycles != null ? !renewalBillingCycles.equals(that.renewalBillingCycles) : that.renewalBillingCycles != null) {
788            return false;
789        }
790        if (autoRenew != null ? !autoRenew.equals(that.autoRenew) : that.autoRenew != null) {
791            return false;
792        }
793        if (firstBillDate != null ? firstBillDate.compareTo(that.firstBillDate) != 0 : that.firstBillDate != null) {
794            return false;
795        }
796        if (nextBillDate != null ? nextBillDate.compareTo(that.nextBillDate) != 0 : that.nextBillDate != null) {
797            return false;
798        }
799        if (currentPeriodStartedAt != null ? currentPeriodStartedAt.compareTo(that.currentPeriodStartedAt) != 0 : that.currentPeriodStartedAt != null) {
800            return false;
801        }
802        if (currentPeriodEndsAt != null ? currentPeriodEndsAt.compareTo(that.currentPeriodEndsAt) != 0 : that.currentPeriodEndsAt != null) {
803            return false;
804        }
805        if (transactionType != null ? !transactionType.equals(that.transactionType) : that.transactionType != null) {
806            return false;
807        }
808
809        return true;
810    }
811
812    @Override
813    public int hashCode() {
814        return Objects.hashCode(
815                account,
816                plan,
817                uuid,
818                state,
819                unitAmountInCents,
820                currency,
821                quantity,
822                activatedAt,
823                updatedAt,
824                canceledAt,
825                expiresAt,
826                remainingBillingCycles,
827                currentPeriodStartedAt,
828                currentPeriodEndsAt,
829                trialStartedAt,
830                trialEndsAt,
831                addOns,
832                pendingSubscription,
833                startsAt,
834                collectionMethod,
835                netTerms,
836                poNumber,
837                revenueScheduleType,
838                giftCard,
839                taxInCents,
840                taxRegion,
841                taxType,
842                taxRate,
843                shippingAddress,
844                shippingAddressId,
845                shippingMethodCode,
846                shippingAmountInCents,
847                couponCode,
848                couponCodes,
849                convertedAt,
850                startedWithGift,
851                noBillingInfoReason,
852                importedTrial,
853                invoiceCollection,
854                customFields,
855                remainingPauseCycles,
856                pausedAt,
857                autoRenew,
858                renewalBillingCycles,
859                firstBillDate,
860                nextBillDate,
861                currentPeriodStartedAt,
862                currentPeriodEndsAt,
863                transactionType
864        );
865    }
866
867}