/* * [ProvincialTaxFact.java] * * Summary: facts about federal and provincial taxes in a given province on a starting on a given day and province. * * Copyright: (c) 2011-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2011-03-24 initial version */ package com.mindprod.canadiantax; import com.mindprod.common18.BigDate; import java.io.Serializable; /** * facts about federal and provincial taxes in a given province on a starting on a given day and province. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2011-03-24 initial version * @since 2011-03-24 */ class ProvincialTaxFact implements Comparable, Serializable { /** * use to track resource format versions */ static final long serialVersionUID = 1L; /** * date these tax rates came into effect. */ private final BigDate date; /** * true if pst is computed on top of gst */ private final boolean taxOnTax; /** * gst or gst portion of hst, as a percentage */ private final double gstRate; /** * hst or 0, as a percentage */ private final double hstRate; /** * pst or pst portion of hst, as a percentage */ private final double pstRate; /** * Constructor * * @param date Date these tax rates went into effect * @param gstRate gst or gst portion of hst, as a percentage. * @param hstRate hst or 0, as a percentage * @param pstRate pst or pst portion of hst, as a percentage * @param taxOnTax does province cheat and compound pst on gst? */ ProvincialTaxFact( final BigDate date, final double gstRate, final double hstRate, final double pstRate, final boolean taxOnTax ) { this.date = date; this.gstRate = gstRate; this.hstRate = hstRate; this.pstRate = pstRate; this.taxOnTax = taxOnTax; } /** * Sort most recent tax rate changes to front. * Defines default the sort order for ProvincialTaxFact Objects. * Compare this ProvincialTaxFact with another ProvincialTaxFact with JDK 1.5+ generics. * Compares descending date Comparable. * Informally, returns (this-other) or +ve if this sorts after other. * * @param other other ProvincialTaxFact to compare with this one * * @return +ve if this>other, 0 if this==other, -ve if this<other */ public final int compareTo( ProvincialTaxFact other ) { return other.date.compareTo( this.date ); } /** * date this tax rate went into effect. * * @return date this rate went into effect in this province. */ public BigDate getDate() { return date; } /** * get gst rate in effect at the time as a percentage or gst portion of hst * * @return gst as a percentage. */ public double getGstRate() { return gstRate; } /** * get hst rate in effect at the time as a percentage. * * @return hst as a percentage. */ public double getHstRate() { return hstRate; } /** * get pst rate in effect at the time as a percentage or pst portion of hst * * @return pst as a percentage */ public double getPstRate() { return pstRate; } /** * does province cheat and compound pst on gst? * * @return true if rate is compounded. */ public boolean isTaxOnTax() { return taxOnTax; } // We don't include province internally.We infer it from with Province enum this is attached to. }