Module: XeroGateway::LineItemCalculations
- Included in:
- BankTransaction, CreditNote, Invoice
- Defined in:
- lib/xero_gateway/line_item_calculations.rb
Instance Method Summary collapse
- #add_line_item(params = {}) ⇒ Object
-
#sub_total ⇒ Object
Calculate the sub_total as the SUM(line_item.line_amount).
-
#total ⇒ Object
Calculate the toal as sub_total + total_tax.
-
#total_tax ⇒ Object
Calculate the total_tax as the SUM(line_item.tax_amount).
Instance Method Details
#add_line_item(params = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/xero_gateway/line_item_calculations.rb', line 4 def add_line_item(params = {}) line_item = nil case params when Hash then line_item = LineItem.new(params) when LineItem then line_item = params else raise InvalidLineItemError end @line_items << line_item line_item end |
#sub_total ⇒ Object
Calculate the sub_total as the SUM(line_item.line_amount).
22 23 24 |
# File 'lib/xero_gateway/line_item_calculations.rb', line 22 def sub_total total_cache(:sub_total) || sum_line_items(line_items, :line_amount) end |
#total ⇒ Object
Calculate the toal as sub_total + total_tax.
32 33 34 |
# File 'lib/xero_gateway/line_item_calculations.rb', line 32 def total total_cache(:total) || (sub_total + total_tax) end |
#total_tax ⇒ Object
Calculate the total_tax as the SUM(line_item.tax_amount).
27 28 29 |
# File 'lib/xero_gateway/line_item_calculations.rb', line 27 def total_tax total_cache(:total_tax) || sum_line_items(line_items, :tax_amount) end |