Class: ProcessDeclIva::Calculate

Inherits:
Object
  • Object
show all
Defined in:
lib/process_decl_iva/calculate.rb

Constant Summary collapse

VAT =
0.23

Instance Method Summary collapse

Constructor Details

#initialize(from_last_period:, total_vat:, other_commissions:, sales_vat:, sales_amount:) ⇒ Calculate

Returns a new instance of Calculate.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/process_decl_iva/calculate.rb', line 5

def initialize(
  from_last_period:,
  total_vat:,
  other_commissions:,
  sales_vat:,
  sales_amount:
)

  @from_last_period = from_last_period
  @total_expenses_vat = total_vat
  @other_commissions = other_commissions
  @sales_vat = sales_vat
  @sales_amount = sales_amount
end

Instance Method Details

#callObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/process_decl_iva/calculate.rb', line 61

def call
  {
    "1" => field_1,
    "2" => field_2,
    "16" => field_16,
    "17" => field_17,
    "24" => field_24,
    "61" => field_61,
    "96" => field_96,
    "97" => field_97
  }.each do |field_nr, value|
    puts ["| ", field_nr.ljust(4), "| ", value.round(2).to_s.ljust(10), "|"].join
  end
end

#field_1Object

Total serviços prestados



21
22
23
# File 'lib/process_decl_iva/calculate.rb', line 21

def field_1
  @sales_amount
end

#field_16Object

Serviços efetuados por sujeitos passivos de outros Estados membros cujo imposto foi liquidado pelo declarante Comissoes



32
33
34
# File 'lib/process_decl_iva/calculate.rb', line 32

def field_16
  (field_1 + field_2) * 0.15 + @other_commissions
end

#field_17Object

16
  • IVA



37
38
39
# File 'lib/process_decl_iva/calculate.rb', line 37

def field_17
  field_16 * VAT
end

#field_2Object

IVA liquidado serviços prestados



26
27
28
# File 'lib/process_decl_iva/calculate.rb', line 26

def field_2
  @sales_vat
end

#field_24Object

Imposto Dedutivel: Outros bens e serviços



42
43
44
# File 'lib/process_decl_iva/calculate.rb', line 42

def field_24
  @total_expenses_vat + field_17
end

#field_61Object

Excesso a reportar para o período anterior



47
48
49
# File 'lib/process_decl_iva/calculate.rb', line 47

def field_61
  @from_last_period
end

#field_96Object



51
52
53
# File 'lib/process_decl_iva/calculate.rb', line 51

def field_96
  field_61 + field_24 - field_2 - field_17
end

#field_97Object

Operações localizadas em Portugal em que, na qualidade de adquirente, liquidou o IVA devido Países comunitários



57
58
59
# File 'lib/process_decl_iva/calculate.rb', line 57

def field_97
  field_16
end