Module: PaperlessToXero::DecimalHelpers
- Included in:
- Invoice, InvoiceItem
- Defined in:
- lib/paperless_to_xero/decimal_helpers.rb
Instance Method Summary collapse
- #amounts_when_vat_exclusive(decimal_ex_vat_amount, decimal_vat_amount) ⇒ Object
- #amounts_when_vat_inclusive(decimal_inc_vat_amount, decimal_vat_amount) ⇒ Object
- #formatted_decimal(value) ⇒ Object
Instance Method Details
#amounts_when_vat_exclusive(decimal_ex_vat_amount, decimal_vat_amount) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/paperless_to_xero/decimal_helpers.rb', line 11 def amounts_when_vat_exclusive(decimal_ex_vat_amount, decimal_vat_amount) vat_exclusive_amount = formatted_decimal(decimal_ex_vat_amount) vat_amount = formatted_decimal(decimal_vat_amount) decimal_inc_vat_amount = decimal_ex_vat_amount + decimal_vat_amount vat_inclusive_amount = formatted_decimal(decimal_inc_vat_amount) [vat_exclusive_amount, vat_amount, vat_inclusive_amount] end |
#amounts_when_vat_inclusive(decimal_inc_vat_amount, decimal_vat_amount) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/paperless_to_xero/decimal_helpers.rb', line 3 def amounts_when_vat_inclusive(decimal_inc_vat_amount, decimal_vat_amount) vat_inclusive_amount = formatted_decimal(decimal_inc_vat_amount) vat_amount = formatted_decimal(decimal_vat_amount) decimal_ex_vat_amount = decimal_inc_vat_amount - decimal_vat_amount vat_exclusive_amount = formatted_decimal(decimal_ex_vat_amount) [vat_exclusive_amount, vat_amount, vat_inclusive_amount] end |
#formatted_decimal(value) ⇒ Object
19 20 21 22 23 |
# File 'lib/paperless_to_xero/decimal_helpers.rb', line 19 def formatted_decimal(value) value = value.to_s('F') value = value + '0' unless value.index('.') < value.size - 2 value end |