Module: Magelex::AccountNumber

Defined in:
lib/magelex/lexware_account.rb

Class Method Summary collapse

Class Method Details

.for(bill, tax_kind) ⇒ Object

Get account number for :incorrect_tax, :total_0, :total_7 or :total_19



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/magelex/lexware_account.rb', line 19

def self.for(bill, tax_kind)
  if tax_kind == :total_0
    return for_0 bill
  elsif tax_kind == :total_7
    return for_7 bill
  elsif tax_kind == :total_19
    return for_19 bill
  elsif tax_kind == :incorrect_tax
    return for_incorrect_tax bill
  elsif tax_kind == :discount_7
    return for_discount_7 bill
  elsif tax_kind == :discount_19
    return for_discount_19 bill
  else
    # its not a tax kind anymore, its a posten type
    raise "unknown tax_kind (#{tax_kind})"
  end
end

.for_0(bill) ⇒ Object



46
47
48
# File 'lib/magelex/lexware_account.rb', line 46

def self.for_0 bill
  '8120'
end

.for_19(bill) ⇒ Object



42
43
44
# File 'lib/magelex/lexware_account.rb', line 42

def self.for_19 bill
  bill.in_eu? ? '8315' : '8400'
end

.for_7(bill) ⇒ Object



38
39
40
# File 'lib/magelex/lexware_account.rb', line 38

def self.for_7 bill
  bill.in_eu? ? '8310' : '8300'
end

.for_customer(bill) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/magelex/lexware_account.rb', line 5

def self.for_customer bill
  first_letter = bill.customer_lastname[0].upcase
  first_letter.gsub!(/[ÖÜÄ]/, 'Ä' => 'A', 'Ö' => 'O', 'Ü' => 'U')

  return 12300 if first_letter == "Y"
  return 12300 if first_letter == "Z"

  # A is 0
  ord = first_letter.ord - "A".ord# + 1
  10000 + ord * 100
end

.for_discount_19(bill) ⇒ Object



58
59
60
# File 'lib/magelex/lexware_account.rb', line 58

def self.for_discount_19 bill
  '8790'
end

.for_discount_7(bill) ⇒ Object



54
55
56
# File 'lib/magelex/lexware_account.rb', line 54

def self.for_discount_7 bill
  '8780'
end

.for_incorrect_tax(bill) ⇒ Object



50
51
52
# File 'lib/magelex/lexware_account.rb', line 50

def self.for_incorrect_tax bill
  '1783'
end