[IMP]l10n_ch: remove res.partner.address and invoice,contact address
[odoo/odoo.git] / addons / l10n_ch / test / l10n_ch_dta.yml
1 -
2   In order to test DTA generation I make an invoice and create the DTA from it.
3 -
4   I create an invoice on 1st January for 7000 EUR 
5   ###########################
6  #   Creating 1 invoice    # 
7 ###########################
8 -
9   !record {model: account.invoice, id: dta_account_invoice, view: False}:
10     company_id: base.main_company
11     journal_id: account.bank_journal
12     currency_id: base.EUR
13     account_id: account.a_pay
14     type : in_invoice
15     partner_id: base.res_partner_agrolait
16     reference_type: bvr
17     reference: 11111111111111111111 
18     date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
19     period_id: account.period_1
20     #invoice_line: 
21     partner_bank_id: main_partner_bank
22     check_total : 7000
23 -
24   I add an invoice line
25 -
26   !record {model: account.invoice.line, id: dta_invoice_line, view: False}:
27     account_id: account.a_expense
28     name: '[PC1] Basic PC'
29     price_unit: 700.0
30     quantity: 10.0
31     product_id: product.product_product_pc1
32     uos_id: product.product_uom_unit
33     invoice_id: dta_account_invoice
34
35
36 -
37   I Validate invoice by clicking on Validate button
38 -
39   !workflow {model: account.invoice, action: invoice_open, ref: dta_account_invoice}
40
41 -
42   I create my payment order to pay my invoice
43   ###########################
44  #   Doing payment order   # 
45 ###########################
46 -
47   !record {model: payment.order, id: dta_payment_order}:
48     #date_created
49     #date_done
50     date_prefered: due
51     #date_scheduled
52     #line_ids:
53     mode: l10n_ch.payment_mode_dta
54     #reference
55     state: draft
56     total: 7000
57     #user_id
58 -
59   I add a payment line to my payment order
60 -
61   !record {model: payment.line, id: dta_pay_line}:
62     amount: 7000
63     amount_currency: 7000
64     bank_id: l10n_ch.agro_bank
65     #bank_statement_line_id
66     communication: "11111111111111111111"
67     #communication2
68     company_currency: base.EUR
69     #create_date
70     currency: base.EUR
71     #date
72     #info_owner
73     #info_partner
74     #ml_date_created
75     #ml_inv_ref
76     #ml_maturity_date
77     move_line_id: !ref {model: account.move.line, search: "[('ref','=','11111111111111111111')]"}
78     #name  (reference)
79     order_id: dta_payment_order
80     partner_id: base.res_partner_agrolait
81     state: normal
82     
83 -
84   I generate a DTA file by using the wizard "Create DTA" for my payment order
85 -
86   !python {model: create.dta.wizard}: |
87     import base64
88     wiz_id = self.create(cr,uid,[])
89     wiz = self.browse(cr, uid, wiz_id)
90     pay_order_id =  ref("dta_payment_order")
91     #set the payment order as the active id
92     context['active_ids'] = [pay_order_id]
93     context['active_id'] = pay_order_id
94     result = wiz.create_dta(context=context)
95     assert result, "No result returned"
96
97     data = wiz.read(['dta_file'])
98     dta_file = base64.decodestring(data[0]['dta_file'] or '')
99     assert dta_file, "File is empty"
100     
101     #check that file starts with 1st segment characters "01"
102     assert dta_file[:2] == "01", "File is not a DTA file"
103     
104     payment_obj = self.pool.get('payment.order')
105     payment_obj.set_done(cr, uid, [ref('dta_payment_order')], context)
106     #force state in open state (confirmed)
107     payment_obj.write(cr, uid, [ref('dta_payment_order')], {'state': 'open'})
108
109 -
110   I check the execution date is today
111 -
112   !assert {model: payment.order, id: dta_payment_order}:
113    - date_done == datetime.now().date().strftime('%Y-%m-%d')
114
115 -
116   I check my payment order state is Confirmed
117 -
118   !assert {model: payment.order, id: dta_payment_order, string: state is done}:
119     - state == 'open'
120
121 -
122   I create a Bank Statment in order to confirm the payment line
123 -
124   !record {model: account.bank.statement, id: dta_bank_statement}:
125     #account_id:
126     #balance_end:
127     #balance_end_cash:
128     #balance_end_real:
129     #balance_start:
130     #closing_date:
131     #company_id:
132     #currency:
133     date: !eval "'%s-01-01' %(datetime.now().year)"
134     #ending_details_ids:
135     journal_id: account.bank_journal
136     #line_ids:
137     #move_line_ids
138     name: "/"
139     period_id: account.period_1
140     #starting_details_ids
141     state: draft
142     #total_entry_encoding
143     #user_id
144     
145 #-
146 #  I import the payment line
147 #-
148 #  !python {model: account.payment.populate.statement}: |
149 #    wiz_id = self.create(cr,uid,[])
150 #    wiz = self.browse(cr, uid, wiz_id)
151 #    
152 #    line_obj = self.pool.get('payment.line')
153 #    pay_line_ids = line_obj.search(cr, uid, [('communication','=','11111111111111111111'),('amount','=','7000')])
154 #    
155 #    data = { 'lines': [(6, 0, [pay_line_ids[0]])],}
156 #    wiz.write(data)
157 #    
158 #    context['active_id'] = ref('dta_bank_statement')
159 #    context['active_ids'] = [ref('dta_bank_statement')]
160 #    
161 #    self.populate_statement(cr, uid, [wiz_id], context=context)
162 #
163 #
164 #-
165 #  I check the statement line is created
166 #-
167 #  !assert {model: account.bank.statement, id: dta_bank_statement, string: statement_line_ids is not empty}:
168 #    - line_ids
169 #
170 #-
171 #  I check the voucher line is created
172 #-
173 #  !python {model: account.bank.statement}: |
174 #    statement = self.browse(cr, uid, ref('dta_bank_statement'))
175 #    
176 #    assert statement.line_ids[0].voucher_id.line_ids, "Voucher line is missing"
177 #    assert len(statement.line_ids[0].voucher_id.line_ids) == 1, "There are too many voucher lines"
178 #
179 #-
180 #  In order to confirm my bank statement, I enter the closing balance and press on compute button
181 #-
182 #  !python {model: account.bank.statement}: |
183 #    statement = self.browse(cr, uid, ref('dta_bank_statement'))
184 #    statement.write({'balance_end_real': -7000.0})
185 #    self.button_dummy(cr, uid, [ref('dta_bank_statement')], context=context)
186 #    statement = self.browse(cr, uid, ref('dta_bank_statement'))
187 #
188 #-
189 #  I confirm my bank statement
190 #-
191 #  !python {model: account.bank.statement}: |
192 #    self.button_confirm_bank(cr, uid, [ref('dta_bank_statement')], context=context)
193 #
194 #
195 #-
196 #  I check the move lines have been defined
197 #-
198 #  !assert {model: account.bank.statement, id: dta_bank_statement, string: move_line_ids is not empty}:
199 #    - move_line_ids
200 #
201 #    
202 #-
203 #  I check bank statement is Closed and balance is -7000
204 #-
205 #  !assert {model: account.bank.statement, id: dta_bank_statement, string: state is Closed and balance is -7000}:
206 #    - state == 'confirm'
207 #    - balance_end == -7000.0
208 #    
209 #-
210 #  I check the residual amount of invoice, should be 0 in residual currency and 0 in amount_residual and paid
211 #-
212 #  !python {model: account.invoice}: |
213 #    invoice_id = self.browse(cr, uid, ref("dta_account_invoice"))
214 #    move_line_obj = self.pool.get('account.move.line')
215 #    move_lines = move_line_obj.search(cr, uid, [('move_id', '=', invoice_id.move_id.id), ('invoice', '=', invoice_id.id), ('account_id', '=', invoice_id.account_id.id)])
216 #    move_line = move_line_obj.browse(cr, uid, move_lines[0])
217 #    assert move_line.amount_residual_currency == 0.0, "Residual amount currency is not correct : %.2f" % move_line.amount_residual_currency
218 #    assert move_line.amount_residual == 0.0 , "Residual amount of invoice is not correct : %.2f" % move_line.amount_residual
219 #    assert invoice_id.state == 'paid', "Invoice state is not Paid"