Sha256: ead52a1e2b75ed258d98a674e1b7a5474478f784f4aa71d68335b6078c8a96a3
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
require 'xeroizer/models/account' require 'xeroizer/models/line_amount_type' module Xeroizer module Record class LineItemModel < BaseModel end class LineItem < Base TAX_TYPE = Account::TAX_TYPE unless defined?(TAX_TYPE) string :item_code string :description decimal :quantity decimal :unit_amount string :account_code string :tax_type decimal :tax_amount decimal :line_amount, :calculated => true decimal :discount_rate string :line_item_id has_many :tracking, :model_name => 'TrackingCategoryChild' def initialize(parent) super(parent) @line_amount_set = false end def line_amount=(line_amount) @line_amount_set = true attributes[:line_amount] = line_amount end # Calculate the line_total (if there is a quantity and unit_amount). # Description-only lines have been allowed since Xero V2.09. def line_amount(summary_only = false) return attributes[:line_amount] if summary_only || @line_amount_set if quantity && unit_amount total = quantity * unit_amount if discount_rate BigDecimal((total * ((100 - discount_rate) / 100)).to_s).round(2) else BigDecimal(total.to_s).round(2) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
xeroizer-2.18.1 | lib/xeroizer/models/line_item.rb |
xeroizer-2.17.1 | lib/xeroizer/models/line_item.rb |