cucumber-openerpscenario 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/cucumber-openerp.gemspec +1 -1
- data/cucumber-openerpscenario-0.1.0.gem +0 -0
- data/lib/cucumber/lib/ERPConnector.rb +0 -13
- data/lib/cucumber/lib/utils/sequel_utils.rb +1 -1
- data/lib/cucumber/openerp/world.rb +20 -20
- metadata +1 -16
- data/lib/cucumber/lib/Helpers/AccountBankStatement.rb +0 -156
- data/lib/cucumber/lib/Helpers/AccountInvoice.rb +0 -122
- data/lib/cucumber/lib/Helpers/AccountTax.rb +0 -85
- data/lib/cucumber/lib/Helpers/AccountVoucher.rb +0 -51
- data/lib/cucumber/lib/Helpers/IrModuleModule.rb +0 -228
- data/lib/cucumber/lib/Helpers/ModuleQualityCheck.rb +0 -93
- data/lib/cucumber/lib/Helpers/Ooor.rb +0 -41
- data/lib/cucumber/lib/Helpers/ProductProduct.rb +0 -126
- data/lib/cucumber/lib/Helpers/PurchaseOrder.rb +0 -53
- data/lib/cucumber/lib/Helpers/ResCurrency.rb +0 -49
- data/lib/cucumber/lib/Helpers/ResPartner.rb +0 -89
- data/lib/cucumber/lib/Helpers/ResUsers.rb +0 -121
- data/lib/cucumber/lib/Helpers/SaleOrder.rb +0 -76
- data/lib/cucumber/lib/Helpers/SaleOrderLine.rb +0 -72
- data/lib/cucumber/lib/Helpers/StockPicking.rb +0 -49
data/cucumber-openerp.gemspec
CHANGED
Binary file
|
@@ -59,17 +59,4 @@ class ScenarioUtils
|
|
59
59
|
:db_password => my_config.get_value('db_password')}
|
60
60
|
end
|
61
61
|
private :get_config
|
62
|
-
|
63
|
-
def helpers_absolute_path
|
64
|
-
#File.expand_path("Helpers/*", File.dirname(__FILE__))
|
65
|
-
end
|
66
|
-
private :helpers_absolute_path
|
67
|
-
|
68
|
-
def load_helpers
|
69
|
-
# TODO generic method to load each helper
|
70
|
-
# actually each ruby file contains the same
|
71
|
-
# code : test if class exists, run a class_eval
|
72
|
-
# Dir[helpers_absolute_path].each { |file| load file }
|
73
|
-
end
|
74
|
-
private :load_helpers
|
75
62
|
end
|
@@ -31,7 +31,7 @@ module SequelUtils
|
|
31
31
|
sequel_params = config.merge(params)
|
32
32
|
@sequel = SequelProxy.new(sequel_params, log)
|
33
33
|
else
|
34
|
-
msg = 'Please install the sequel and pg gems in order to use
|
34
|
+
msg = 'Please install the sequel and pg gems in order to use openerp.sequel.'
|
35
35
|
log.fatal(msg)
|
36
36
|
raise msg
|
37
37
|
end
|
@@ -1,33 +1,33 @@
|
|
1
1
|
require "cucumber/lib/ERPConnector.rb"
|
2
2
|
module CucumberOpenERP
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
3
|
+
attr_accessor :is_alive, :openerp
|
4
|
+
@@openerp_c ||= false
|
5
|
+
def am_i_alive?
|
6
|
+
@@is_alive ||= false
|
7
|
+
return @@is_alive
|
8
|
+
end
|
9
|
+
def born
|
10
|
+
@@is_alive = true
|
11
|
+
end
|
13
12
|
def openerp_ignition
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
unless am_i_alive?
|
14
|
+
openerp = ScenarioUtils.new() #$utils is deprecated please use openerp
|
15
|
+
@@openerp_c = openerp
|
16
|
+
begin
|
17
17
|
unless openerp.ready?
|
18
|
-
|
19
|
-
|
18
|
+
openerp.log.info("Attempt to connect")
|
19
|
+
openerp.create_ooor_connection
|
20
20
|
end
|
21
|
-
|
21
|
+
rescue Exception => e
|
22
22
|
openerp.log.warn("#{e.to_s}")
|
23
23
|
openerp.log.warn("Force reconnect")
|
24
24
|
openerp.create_ooor_connection
|
25
|
+
end
|
26
|
+
born
|
27
|
+
$utils = openerp #for retro-compatibility
|
25
28
|
end
|
26
|
-
|
27
|
-
$util = openerp #for retro-compat
|
29
|
+
@openerp = @@openerp_c
|
28
30
|
end
|
29
|
-
|
30
|
-
end
|
31
31
|
end
|
32
32
|
|
33
33
|
World(CucumberOpenERP)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: cucumber-openerpscenario
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nicolas Bessi - Camptocamp
|
@@ -75,21 +75,6 @@ files:
|
|
75
75
|
- lib/cucumber/.DS_Store
|
76
76
|
- lib/cucumber/lib/.DS_Store
|
77
77
|
- lib/cucumber/lib/ERPConnector.rb
|
78
|
-
- lib/cucumber/lib/Helpers/AccountBankStatement.rb
|
79
|
-
- lib/cucumber/lib/Helpers/AccountInvoice.rb
|
80
|
-
- lib/cucumber/lib/Helpers/AccountTax.rb
|
81
|
-
- lib/cucumber/lib/Helpers/AccountVoucher.rb
|
82
|
-
- lib/cucumber/lib/Helpers/IrModuleModule.rb
|
83
|
-
- lib/cucumber/lib/Helpers/ModuleQualityCheck.rb
|
84
|
-
- lib/cucumber/lib/Helpers/Ooor.rb
|
85
|
-
- lib/cucumber/lib/Helpers/ProductProduct.rb
|
86
|
-
- lib/cucumber/lib/Helpers/PurchaseOrder.rb
|
87
|
-
- lib/cucumber/lib/Helpers/ResCurrency.rb
|
88
|
-
- lib/cucumber/lib/Helpers/ResPartner.rb
|
89
|
-
- lib/cucumber/lib/Helpers/ResUsers.rb
|
90
|
-
- lib/cucumber/lib/Helpers/SaleOrder.rb
|
91
|
-
- lib/cucumber/lib/Helpers/SaleOrderLine.rb
|
92
|
-
- lib/cucumber/lib/Helpers/StockPicking.rb
|
93
78
|
- lib/cucumber/lib/core_ext/basic_object.rb
|
94
79
|
- lib/cucumber/lib/utils/memoizer_utils.rb
|
95
80
|
- lib/cucumber/lib/utils/ooor_utils.rb
|
@@ -1,156 +0,0 @@
|
|
1
|
-
###############################################################################
|
2
|
-
#
|
3
|
-
# OERPScenario, OpenERP Functional Tests
|
4
|
-
# Author Nicolas Bessi & Joel Grand-Guillaume 2009
|
5
|
-
# Copyright Camptocamp SA
|
6
|
-
#
|
7
|
-
# This program is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
9
|
-
# the Free Software Foundation, either version 3 Afero of the License, or
|
10
|
-
# (at your option) any later version.
|
11
|
-
#
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
# GNU General Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU General Public License
|
18
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
-
#
|
20
|
-
##############################################################################
|
21
|
-
require 'rubygems'
|
22
|
-
require 'ooor'
|
23
|
-
require 'pp'
|
24
|
-
|
25
|
-
|
26
|
-
begin
|
27
|
-
if Object.const_defined? 'AccountBankStatement'
|
28
|
-
|
29
|
-
# Add useful methode on bank statement handling
|
30
|
-
##############################################################################
|
31
|
-
AccountBankStatement.class_eval do
|
32
|
-
$utils.log.debug("Extending #{self.class} #{self.name}")
|
33
|
-
############################################################################
|
34
|
-
# Import invoices into the given bank statements
|
35
|
-
# Input :
|
36
|
-
# - invoices : A valid dict of AccountInvoice instance
|
37
|
-
# - statement : A valid AccountBankStatement instance
|
38
|
-
# - options {
|
39
|
-
# date (Default today) : date used into the first screen of the wizard (date
|
40
|
-
# imported in lines)
|
41
|
-
# }
|
42
|
-
# Return
|
43
|
-
# - The AccountBankStatement as a instance of the class¨
|
44
|
-
# Usage Example:
|
45
|
-
# statement = AccountBankStatement.import_invoice(invoices,statement)
|
46
|
-
#
|
47
|
-
# TODO implement journals
|
48
|
-
# TODO filter acc_move_line_ids to take the right one
|
49
|
-
# TODO Remove self to use it from an instance of the class
|
50
|
-
def import_invoice(invoices, options={}, *args)
|
51
|
-
o = {:date => false, :journals => []}.merge(options)
|
52
|
-
if o[:date]
|
53
|
-
o[:date] = Date.parse(str=o[:date]).to_s
|
54
|
-
else
|
55
|
-
o[:date] = Date.today.to_s
|
56
|
-
end
|
57
|
-
|
58
|
-
# Parse the given journal ids if provided
|
59
|
-
journal_ids=[]
|
60
|
-
o[:journals].each do |journal|
|
61
|
-
journal_ids.push journal.id
|
62
|
-
end
|
63
|
-
invoice_move_line_ids=[]
|
64
|
-
inv_total=0.0
|
65
|
-
self.balance_start=inv_total
|
66
|
-
|
67
|
-
# # For each invoices, add the right account.move.line and compute total
|
68
|
-
invoices.each do |inv|
|
69
|
-
unless inv.class == AccountInvoice
|
70
|
-
raise "!!! --- HELPER ERROR :import_invoice received a #{inv.class.to_s} instead of AccountInvoice"
|
71
|
-
end
|
72
|
-
# Take the move ids from concerned invoice
|
73
|
-
# TODO add journal support and (journal_ids.include? move_line.journal_id or journal_ids == []
|
74
|
-
# TODO : Debug the problem of undefined method `[]' for nil:NilClass (NoMethodError)
|
75
|
-
# pp inv.move_id.line_id
|
76
|
-
# inv.move_id.line_id.each do |move_line|
|
77
|
-
#
|
78
|
-
# # if move_line.reconcile_id == false
|
79
|
-
# if move_line.account_id.reconcile == true
|
80
|
-
# invoice_move_line_ids.push move_line.id
|
81
|
-
# end
|
82
|
-
# end
|
83
|
-
|
84
|
-
inv.move_id.line_id.each do |move_line|
|
85
|
-
if (not move_line.reconcile_id) && move_line.account_id.reconcile
|
86
|
-
invoice_move_line_ids.push move_line.id
|
87
|
-
inv_total = inv_total + move_line.amount_currency
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
# Save the start and end values
|
92
|
-
self.balance_end_real=inv_total
|
93
|
-
self.save
|
94
|
-
unless self.class == AccountBankStatement
|
95
|
-
raise "!!! --- HELPER ERROR :import_invoice received a #{self.class.to_s} instead of AccountBankStatement"
|
96
|
-
end
|
97
|
-
|
98
|
-
# Call the wizard
|
99
|
-
wizard = self.old_wizard_step('populate_statement_from_inv')
|
100
|
-
# Set the wizard with given values
|
101
|
-
step_dict = wizard.datas.merge({:date => o[:date]})
|
102
|
-
step_dict=step_dict.merge({:journal_id => [[[], [], journal_ids]]})
|
103
|
-
# Search the invoices and update values
|
104
|
-
res=wizard.go(step_dict)
|
105
|
-
step_dict=res.datas.merge(step_dict)
|
106
|
-
# Update the step_dict with invoice we want
|
107
|
-
step_dict=step_dict.merge({:lines => [[[], [], invoice_move_line_ids]]})
|
108
|
-
# Ask to populate the statement with given invoice linked account move
|
109
|
-
res=wizard.finish(step_dict)
|
110
|
-
# step_dict = step_dict.merge({:writeoff_acc_id => @journal.default_debit_account_id.id, :writeoff_journal_id=>@journal.id})
|
111
|
-
# return res
|
112
|
-
end
|
113
|
-
|
114
|
-
############################################################################
|
115
|
-
# Create an statement with given informations
|
116
|
-
# Input :
|
117
|
-
# - options {
|
118
|
-
# journal : A valid AccountJournal instance
|
119
|
-
# currency_code (Default : EUR) : An ISO code for currency
|
120
|
-
# name (Default : computed by OpenERP sequence) : A valid name if you wanna set it
|
121
|
-
# }
|
122
|
-
# Return
|
123
|
-
# - The created AccountBankStatement as a instance of the class¨
|
124
|
-
# Usage Example:
|
125
|
-
# statement = AccountBankStatement.create_statement_with_currency({currency_code =>'CHF'})
|
126
|
-
def self.create_statement_with_currency(options={}, *args)
|
127
|
-
o = {:currency_code => 'EUR', :journal => false, :name => false}.merge(options)
|
128
|
-
if not o[:journal]
|
129
|
-
# Take the currency
|
130
|
-
currency_id = ResCurrency.find(:first, :domain => [['name', '=', o[:currency_code]]]).id
|
131
|
-
if currency_id
|
132
|
-
# Look for the asked cash journal currency
|
133
|
-
journal = AccountJournal.find(:first, :domain => [['type', '=', 'cash'], ['currency', '=', currency_id]])
|
134
|
-
else
|
135
|
-
raise "!!! --- HELPER ERROR : create_statement_with_currency #{o[:currency_code]} currency not found"
|
136
|
-
end
|
137
|
-
else
|
138
|
-
journal = o[:journal]
|
139
|
-
end
|
140
|
-
toreturn = AccountBankStatement.new()
|
141
|
-
toreturn.journal_id = journal.id
|
142
|
-
toreturn.create
|
143
|
-
if o[:name]
|
144
|
-
toreturn.name=o[:name]
|
145
|
-
toreturn.save
|
146
|
-
end
|
147
|
-
return toreturn
|
148
|
-
end
|
149
|
-
|
150
|
-
end
|
151
|
-
else
|
152
|
-
$utils.log.debug("AccountBankStatement helper not initialized !")
|
153
|
-
end
|
154
|
-
rescue Exception => e
|
155
|
-
$utils.log.fatal("ERROR : #{e.to_s}")
|
156
|
-
end
|
@@ -1,122 +0,0 @@
|
|
1
|
-
###############################################################################
|
2
|
-
#
|
3
|
-
# OERPScenario, OpenERP Functional Tests
|
4
|
-
# Author Nicolas Bessi & Joel Grand-Guillaume 2009
|
5
|
-
# Copyright Camptocamp SA
|
6
|
-
#
|
7
|
-
# This program is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
9
|
-
# the Free Software Foundation, either version 3 Afero of the License, or
|
10
|
-
# (at your option) any later version.
|
11
|
-
#
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
# GNU General Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU General Public License
|
18
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
-
#
|
20
|
-
##############################################################################
|
21
|
-
require 'rubygems'
|
22
|
-
require 'ooor'
|
23
|
-
require 'pp'
|
24
|
-
|
25
|
-
|
26
|
-
begin
|
27
|
-
if Object.const_defined? 'AccountInvoice'
|
28
|
-
# Add useful methode on invoice handling
|
29
|
-
##############################################################################
|
30
|
-
AccountInvoice.class_eval do
|
31
|
-
$utils.log.debug("Extending #{self.class} #{self.name}")
|
32
|
-
##########################################################################
|
33
|
-
# Create an invoice with given informations
|
34
|
-
# Add a line if amount <> false, the account could be provided or not
|
35
|
-
# Input :
|
36
|
-
# - name : Name of the invoice
|
37
|
-
# - partner : A valid ResPartner instance
|
38
|
-
# - option {
|
39
|
-
# currency_code (Default : EUR) : An ISO code for currency
|
40
|
-
# date (Default : false) : A date in this text format : 1 jan 2009
|
41
|
-
# amount (Default : false) : An amount for the invoice => this will create a line
|
42
|
-
# account (Default : false) : An valide AccountAccount
|
43
|
-
# type (Default : out_invoice) : the invoice type
|
44
|
-
# }
|
45
|
-
# Return
|
46
|
-
# - The created AccountInvoice as a instance of the class¨
|
47
|
-
# Usage Example:
|
48
|
-
# part = ResPartner.find(:first)
|
49
|
-
# puts part.id
|
50
|
-
# inv = AccountInvoice.create_cust_invoice_with_currency('my name',part,{currency_code =>'CHF'})
|
51
|
-
def self.create_invoice_with_currency(name, partner, options={}, *args)
|
52
|
-
o = {:type => 'out_invoice', :currency_code => 'EUR', :date => false, :amount => false, :account => false}.merge(options)
|
53
|
-
if o[:date]
|
54
|
-
date_invoice = Date.parse(str=o[:date]).to_s
|
55
|
-
else
|
56
|
-
date_invoice = Date.today.to_s
|
57
|
-
end
|
58
|
-
toreturn = AccountInvoice.new()
|
59
|
-
|
60
|
-
unless partner.class == ResPartner
|
61
|
-
raise "!!! --- HELPER ERROR :create_cust_invoice_with_currency received a #{partner.class.to_s} instead of ResPartner"
|
62
|
-
end
|
63
|
-
# Set partner
|
64
|
-
#We use this syntax for optimisation reason, helper have to be fast
|
65
|
-
if ResPartnerAddress.find(:first, :domain => [['partner_id', '=', partner.id]], :fields => ['id'])
|
66
|
-
toreturn.partner_id = partner.id
|
67
|
-
else
|
68
|
-
raise "!!! --- HELPER ERROR :create_cust_invoice_with_currency received a partner : #{partner.name} without adresses"
|
69
|
-
end
|
70
|
-
toreturn.on_change('onchange_partner_id', :partner_id, partner.id, o[:type], partner.id, date_invoice, false, false)
|
71
|
-
toreturn.save
|
72
|
-
# Set name & date
|
73
|
-
toreturn.name = name
|
74
|
-
toreturn.date_invoice=date_invoice
|
75
|
-
|
76
|
-
# Set type of invoice
|
77
|
-
toreturn.type = o[:type]
|
78
|
-
curr = ResCurrency.find(:first, :domain => [['name', '=', o[:currency_code]]], :fields => ['id'])
|
79
|
-
# Set currency
|
80
|
-
if curr
|
81
|
-
toreturn.currency_id = curr.id
|
82
|
-
else
|
83
|
-
raise "!!! --- HELPER ERROR :#{o[:currency_code]} currency not found"
|
84
|
-
end
|
85
|
-
|
86
|
-
# Set amount and line if asked for
|
87
|
-
toreturn.save
|
88
|
-
|
89
|
-
if o[:amount]
|
90
|
-
|
91
|
-
if ['in_invoice', 'in_refund'].include? o[:type]
|
92
|
-
toreturn.check_total = o[:amount]
|
93
|
-
end
|
94
|
-
if o[:account]
|
95
|
-
unless account.class == AccountAccount
|
96
|
-
raise "!!! --- HELPER ERROR :create_cust_invoice_with_currency received a #{o[:account].class.to_s} instead of AccountAccount"
|
97
|
-
end
|
98
|
-
account_id = o[:account].id
|
99
|
-
else
|
100
|
-
# If no account, take on of type 'other' and a non-reconciliable account
|
101
|
-
account_id = AccountAccount.find(:first, :domain => [['type', '=', 'other'], ['reconcile', '=', false]], :fields => ['id']).id
|
102
|
-
# Create a line = amount for the created invoice
|
103
|
-
line=AccountInvoiceLine.new(
|
104
|
-
:account_id => account_id,
|
105
|
-
:quantity => 1,
|
106
|
-
:name => name+' line',
|
107
|
-
:price_unit => o[:amount],
|
108
|
-
:invoice_id => toreturn.id
|
109
|
-
)
|
110
|
-
line.create
|
111
|
-
end
|
112
|
-
end
|
113
|
-
toreturn.save
|
114
|
-
return toreturn
|
115
|
-
end
|
116
|
-
end
|
117
|
-
else
|
118
|
-
$utils.log.debug("AccountInvoice helper not initialized")
|
119
|
-
end
|
120
|
-
rescue Exception => e
|
121
|
-
$utils.log.fatal("ERROR : #{e.to_s}")
|
122
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
###############################################################################
|
2
|
-
#
|
3
|
-
# OERPScenario, OpenERP Functional Tests
|
4
|
-
# Author Nicolas Bessi & Joel Grand-Guillaume 2009
|
5
|
-
# Copyright Camptocamp SA
|
6
|
-
#
|
7
|
-
# This program is free software: you can redistribute it and/or modify
|
8
|
-
# it under the terms of the GNU General Public License as published by
|
9
|
-
# the Free Software Foundation, either version 3 Afero of the License, or
|
10
|
-
# (at your option) any later version.
|
11
|
-
#
|
12
|
-
# This program is distributed in the hope that it will be useful,
|
13
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
# GNU General Public License for more details.
|
16
|
-
#
|
17
|
-
# You should have received a copy of the GNU General Public License
|
18
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
-
#
|
20
|
-
##############################################################################
|
21
|
-
require 'rubygems'
|
22
|
-
require 'ooor'
|
23
|
-
require 'pp'
|
24
|
-
|
25
|
-
|
26
|
-
begin
|
27
|
-
if Object.const_defined? 'AccountTax'
|
28
|
-
# Add useful methode on taxes handling
|
29
|
-
##############################################################################
|
30
|
-
AccountTax.class_eval do
|
31
|
-
$utils.log.debug("Extending #{self.class} #{self.name}")
|
32
|
-
##########################################################################
|
33
|
-
# Create a tax and tax code with given informations
|
34
|
-
# Input :
|
35
|
-
# - name : Name of the tax
|
36
|
-
# - option {
|
37
|
-
# :type=>'percent',
|
38
|
-
# :amount=>0.196,
|
39
|
-
# :type_tax_use=>'sale',
|
40
|
-
# # For refund
|
41
|
-
# :ref_base_sign=>-1.0,
|
42
|
-
# :ref_tax_sign=>-1.0,
|
43
|
-
# # For VAT declaration
|
44
|
-
# :base_sign=>1.0,
|
45
|
-
# :tax_sign=>1.0,
|
46
|
-
# }
|
47
|
-
# Return
|
48
|
-
# - The created AccountTax as a instance of the class¨
|
49
|
-
# Usage Example:
|
50
|
-
# tax = AccountTax.create_tax_and_code('my name',{:type=>'percent',:amount=>rate,:type_tax_use=>'purchase',})
|
51
|
-
def self.create_tax_and_code(name, options={}, *args)
|
52
|
-
# debugger
|
53
|
-
# Set default values
|
54
|
-
o = {
|
55
|
-
:type => 'percent',
|
56
|
-
:amount => 0.196,
|
57
|
-
:type_tax_use => 'sale',
|
58
|
-
# For refund
|
59
|
-
:ref_base_sign => -1.0,
|
60
|
-
:ref_tax_sign => -1.0,
|
61
|
-
# For VAT declaration
|
62
|
-
:base_sign => 1.0,
|
63
|
-
:tax_sign => 1.0,
|
64
|
-
}.merge(options)
|
65
|
-
|
66
|
-
toreturn = AccountTax.new(o)
|
67
|
-
toreturn.name = name
|
68
|
-
toreturn.type = o[:type]
|
69
|
-
toreturn.amount = o[:amount]
|
70
|
-
toreturn.type_tax_use = o[:type_tax_use]
|
71
|
-
toreturn.ref_base_sign = o[:ref_base_sign]
|
72
|
-
toreturn.ref_tax_sign = o[:ref_tax_sign]
|
73
|
-
toreturn.base_sign = o[:base_sign]
|
74
|
-
toreturn.tax_sign = o[:tax_sign]
|
75
|
-
|
76
|
-
toreturn.create
|
77
|
-
return toreturn
|
78
|
-
end
|
79
|
-
end
|
80
|
-
else
|
81
|
-
$utils.log.debug("AccountTax helper not initialized")
|
82
|
-
end
|
83
|
-
rescue Exception => e
|
84
|
-
$utils.log.fatal("ERROR : #{e.to_s}")
|
85
|
-
end
|