Class: Google4R::Checkout::TaxTable
- Inherits:
-
Object
- Object
- Google4R::Checkout::TaxTable
- Defined in:
- lib/google4r/checkout/shared.rb
Overview
A TaxTable is an ordered array of TaxRule objects. You should create the TaxRule instances using #create_rule
You must set up a tax table factory and should only create tax tables from within its temporal factory method as described in the class documentation of Frontend.
Each tax table must have one or more tax rules.
Example
include Google4R::Checkout
tax_free_table = TaxTable.new(false)
tax_free_table.name = "default table"
tax_free_table.create_rule do |rule|
rule.area = UsCountryArea.new(UsCountryArea::ALL)
rule.rate = 0.0
end
Instance Attribute Summary collapse
-
#merchant_calculated ⇒ Object
indicates whether tax for the order is calculated using a special process.
-
#name ⇒ Object
The name of this tax table (string, required).
-
#rules ⇒ Object
readonly
An Array of the TaxRule objects that this TaxTable contains.
-
#standalone ⇒ Object
readonly
Boolean, true iff the table’s standalone attribute is to be set to “true”.
Instance Method Summary collapse
-
#create_rule {|rule| ... } ⇒ Object
Use this method to add a new TaxRule to the table.
-
#initialize(standalone) ⇒ TaxTable
constructor
A new instance of TaxTable.
Constructor Details
#initialize(standalone) ⇒ TaxTable
Returns a new instance of TaxTable.
602 603 604 605 606 607 |
# File 'lib/google4r/checkout/shared.rb', line 602 def initialize(standalone) @rules = Array.new @standalone = standalone @merchant_calculated = false end |
Instance Attribute Details
#merchant_calculated ⇒ Object
indicates whether tax for the order is calculated using a special process. default “false”
600 601 602 |
# File 'lib/google4r/checkout/shared.rb', line 600 def merchant_calculated @merchant_calculated end |
#name ⇒ Object
The name of this tax table (string, required).
590 591 592 |
# File 'lib/google4r/checkout/shared.rb', line 590 def name @name end |
#rules ⇒ Object (readonly)
An Array of the TaxRule objects that this TaxTable contains. Use #create_rule do add to this Array but do not change it directly.
594 595 596 |
# File 'lib/google4r/checkout/shared.rb', line 594 def rules @rules end |
#standalone ⇒ Object (readonly)
Boolean, true iff the table’s standalone attribute is to be set to “true”.
597 598 599 |
# File 'lib/google4r/checkout/shared.rb', line 597 def standalone @standalone end |
Instance Method Details
#create_rule {|rule| ... } ⇒ Object
Use this method to add a new TaxRule to the table. If you use a block with this method then the block will called with the newly created rule for the parameter. The method will return the new rule in any case.
612 613 614 615 616 617 618 619 620 |
# File 'lib/google4r/checkout/shared.rb', line 612 def create_rule(&block) rule = TaxRule.new(self) @rules << rule # Pass the newly generated rule to the given block to set its attributes. yield(rule) if block_given? return rule end |