2 In order to test DTA generation I make an invoice and create the DTA from it.
4 I create an invoice on 1st January for 7000 EUR
5 ###########################
7 ###########################
9 !record {model: account.invoice, id: dta_account_invoice, view: False}:
10 company_id: base.main_company
11 journal_id: account.bank_journal
13 account_id: account.a_pay
15 partner_id: base.res_partner_agrolait
17 reference: 11111111111111111111
18 date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
19 period_id: account.period_1
21 partner_bank_id: main_partner_bank
26 !record {model: account.invoice.line, id: dta_invoice_line, view: False}:
27 account_id: account.a_expense
28 name: '[PC1] Basic PC'
31 product_id: product.product_product_pc1
32 uos_id: product.product_uom_unit
33 invoice_id: dta_account_invoice
37 I Validate invoice by clicking on Validate button
39 !workflow {model: account.invoice, action: invoice_open, ref: dta_account_invoice}
42 I create my payment order to pay my invoice
43 ###########################
44 # Doing payment order #
45 ###########################
47 !record {model: payment.order, id: dta_payment_order}:
53 mode: l10n_ch.payment_mode_dta
59 I add a payment line to my payment order
61 !record {model: payment.line, id: dta_pay_line}:
64 bank_id: l10n_ch.agro_bank
65 #bank_statement_line_id
66 communication: "11111111111111111111"
68 company_currency: base.EUR
77 move_line_id: !ref {model: account.move.line, search: "[('ref','=','11111111111111111111')]"}
79 order_id: dta_payment_order
80 partner_id: base.res_partner_agrolait
84 I generate a DTA file by using the wizard "Create DTA" for my payment order
86 !python {model: create.dta.wizard}: |
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"
97 data = wiz.read(['dta_file'])
98 dta_file = base64.decodestring(data[0]['dta_file'] or '')
99 assert dta_file, "File is empty"
101 #check that file starts with 1st segment characters "01"
102 assert dta_file[:2] == "01", "File is not a DTA file"
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'})
110 I check the execution date is today
112 !assert {model: payment.order, id: dta_payment_order}:
113 - date_done == datetime.now().date().strftime('%Y-%m-%d')
116 I check my payment order state is Confirmed
118 !assert {model: payment.order, id: dta_payment_order, string: state is done}:
122 I create a Bank Statment in order to confirm the payment line
124 !record {model: account.bank.statement, id: dta_bank_statement}:
133 date: !eval "'%s-01-01' %(datetime.now().year)"
135 journal_id: account.bank_journal
139 period_id: account.period_1
140 #starting_details_ids
142 #total_entry_encoding
146 # I import the payment line
148 # !python {model: account.payment.populate.statement}: |
149 # wiz_id = self.create(cr,uid,[])
150 # wiz = self.browse(cr, uid, wiz_id)
152 # line_obj = self.pool.get('payment.line')
153 # pay_line_ids = line_obj.search(cr, uid, [('communication','=','11111111111111111111'),('amount','=','7000')])
155 # data = { 'lines': [(6, 0, [pay_line_ids[0]])],}
158 # context['active_id'] = ref('dta_bank_statement')
159 # context['active_ids'] = [ref('dta_bank_statement')]
161 # self.populate_statement(cr, uid, [wiz_id], context=context)
165 # I check the statement line is created
167 # !assert {model: account.bank.statement, id: dta_bank_statement, string: statement_line_ids is not empty}:
171 # I check the voucher line is created
173 # !python {model: account.bank.statement}: |
174 # statement = self.browse(cr, uid, ref('dta_bank_statement'))
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"
180 # In order to confirm my bank statement, I enter the closing balance and press on compute button
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'))
189 # I confirm my bank statement
191 # !python {model: account.bank.statement}: |
192 # self.button_confirm_bank(cr, uid, [ref('dta_bank_statement')], context=context)
196 # I check the move lines have been defined
198 # !assert {model: account.bank.statement, id: dta_bank_statement, string: move_line_ids is not empty}:
203 # I check bank statement is Closed and balance is -7000
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
210 # I check the residual amount of invoice, should be 0 in residual currency and 0 in amount_residual and paid
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"