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



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

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



44
45
46
# File 'lib/magelex/lexware_account.rb', line 44

def self.for_0 bill
  '8120'
end

.for_19(bill) ⇒ Object



40
41
42
# File 'lib/magelex/lexware_account.rb', line 40

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

.for_7(bill) ⇒ Object



36
37
38
# File 'lib/magelex/lexware_account.rb', line 36

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

.for_customer(bill) ⇒ Object



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

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



56
57
58
# File 'lib/magelex/lexware_account.rb', line 56

def self.for_discount_19 bill
  '8790'
end

.for_discount_7(bill) ⇒ Object



52
53
54
# File 'lib/magelex/lexware_account.rb', line 52

def self.for_discount_7 bill
  '8780'
end

.for_incorrect_tax(bill) ⇒ Object



48
49
50
# File 'lib/magelex/lexware_account.rb', line 48

def self.for_incorrect_tax bill
  '1783'
end