AmountTotals

public class AmountTotals

A container for the various totals.

Methods

addAmounts

public void addAmounts(Decimal subtotal, Decimal tax, Decimal gratuity, Decimal fees, Decimal cashback, Decimal donation, Decimal total)

Adds the specified values to the existing values.

addTaxWithCode

public void addTaxWithCode(String taxCode, Decimal taxAmount)

Inserts this amount for this code if it is not already present, or replaces it if the tax code is already present. If the amount is null, removes the tax code from the map if it exists, otherwise it does nothing. If the tax code is null, the amount is considered to be the total tax being applied.

create

public static AmountTotals create(boolean unset)

Create an amount totals object. If unset is true, then none of the amounts default to 0, otherwise the total and possibly other values will be set to 0.

getCashback

public Decimal getCashback()

Returns the amount that is being returned as cashback if set, otherwise returns null.

getDonation

public Decimal getDonation()

Returns the amount that is being paid as donation if set, otherwise returns null.

getFees

public Decimal getFees()

Returns the amount that is being paid as fees if set, otherwise returns null.

getGratuity

public Decimal getGratuity()

Returns the amount that is being paid as a tip or gratuity if set, otherwise returns null.

getSubtotal

public Decimal getSubtotal()

Returns the subtotal if set, otherwise returns null.

getTax

public Decimal getTax()

Returns the general tax if set, otherwise returns null.

getTaxesWithCodes

public HashMap<String, Decimal> getTaxesWithCodes()

Returns the actual instance for the map that stores the taxes and codes. This object is not thread-safe.

getTotal

public Decimal getTotal()

Returns the grand total, which is (subtotal + tax(es) + gratuity + any other amounts) if set, otherwise returns null.

isUnset

public boolean isUnset()

Returns true if all of getTotal(), getSubtotal(), getTax(), getGratuity(), and getTaxesWithCodes() are null.

setCashback

public void setCashback(Decimal cashback)

Set the amount of cashback as a GAAP-standard BigDecimal. This may also refer to a cash advance amount, based on the payment type.

setDonation

public void setDonation(Decimal donation)

Set the amount of donations as a GAAP-standard BigDecimal.

setFees

public void setFees(Decimal fees)

Set the amount of fees as a GAAP-standard BigDecimal.

setGratuity

public void setGratuity(Decimal gratuity)

Sets the amount that is being paid as a tip or gratuity.

setSubtotal

public void setSubtotal(Decimal subtotal)

Sets the subtotal, which normally does not include taxes and gratuity depending on the region. This is optional but highly recommended.

setTax

public void setTax(Decimal tax)

Sets the general tax amount. Acts as a wrapper for calling addTaxWithCode(String,BigDecimal) with a null tax code. This should not be used in conjunction with setTaxesWithCodes(HashMap).

setTaxesWithCodes

public void setTaxesWithCodes(HashMap<String, Decimal> taxesWithCodes)

Sets the taxes with codes all at once. Use either this or addTaxWithCode(String,BigDecimal).

setTotal

public void setTotal(Decimal total)

Sets the grand total, which is (subtotal + tax(es) + gratuity + any other amounts).

setWithAmounts

public void setWithAmounts(Decimal subtotal, Decimal tax, Decimal gratuity, Decimal fees, Decimal cashback, Decimal donation, Decimal total)

Set all of the amounts at once, overriding any previous setting.

subtractAmounts

public void subtractAmounts(Decimal subtotal, Decimal tax, Decimal gratuity, Decimal fees, Decimal cashback, Decimal donation, Decimal total)

Subtracts the specified values from the existing values.