Merge lp:~openbig/bigconsulting/account_invoice_cash_discount_milestone1 into lp:bigconsulting
- account_invoice_cash_discount_milestone1
- Merge into addons
Proposed by
gpa(OpenERP)
Status: | Merged |
---|---|
Merged at revision: | 47 |
Proposed branch: | lp:~openbig/bigconsulting/account_invoice_cash_discount_milestone1 |
Merge into: | lp:bigconsulting |
Diff against target: |
636 lines (+217/-139) 5 files modified
account_invoice_cash_discount/account_invoice_cash_discount.py (+37/-33) account_invoice_cash_discount/account_invoice_cash_discount_view.xml (+3/-1) account_invoice_cash_discount/wizard/account_pay_invoice.py (+158/-93) account_invoice_cash_discount/wizard/account_pay_invoice_view.xml (+1/-1) account_invoice_cash_discount/wizard/invoice_statement_payment.py (+18/-11) |
To merge this branch: | bzr merge lp:~openbig/bigconsulting/account_invoice_cash_discount_milestone1 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
openbig | Pending | ||
Review via email: mp+29865@code.launchpad.net |
Commit message
Description of the change
changes in the milestone1 of the account_
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'account_invoice_cash_discount/account_invoice_cash_discount.py' | |||
2 | --- account_invoice_cash_discount/account_invoice_cash_discount.py 2010-08-21 12:43:18 +0000 | |||
3 | +++ account_invoice_cash_discount/account_invoice_cash_discount.py 2010-07-14 12:24:45 +0000 | |||
4 | @@ -45,6 +45,8 @@ | |||
5 | 45 | 'credit_account_id': fields.many2one('account.account', 'Credit Account'), | 45 | 'credit_account_id': fields.many2one('account.account', 'Credit Account'), |
6 | 46 | 'debit_account_id': fields.many2one('account.account', 'Debit Account'), | 46 | 'debit_account_id': fields.many2one('account.account', 'Debit Account'), |
7 | 47 | 'payment_term_ids': fields.one2many('account.payment.term.line', 'cash_account_discount_id', 'Payment Term Lines'), | 47 | 'payment_term_ids': fields.one2many('account.payment.term.line', 'cash_account_discount_id', 'Payment Term Lines'), |
8 | 48 | 'day_tolerance': fields.integer('Days Tolerance', digits=(16,6),required=True), | ||
9 | 49 | 'sup_discount_account_id': fields.many2one('account.account', 'Supplier Discount Account',required=True), | ||
10 | 48 | } | 50 | } |
11 | 49 | account_cash_discount() | 51 | account_cash_discount() |
12 | 50 | 52 | ||
13 | @@ -61,14 +63,11 @@ | |||
14 | 61 | _inherit = "account.invoice" | 63 | _inherit = "account.invoice" |
15 | 62 | 64 | ||
16 | 63 | def _get_amount(self, cr, uid, ids, resudial_amonut, payment_term, context=None): | 65 | def _get_amount(self, cr, uid, ids, resudial_amonut, payment_term, context=None): |
17 | 64 | |||
18 | 65 | """ | 66 | """ |
19 | 66 | This function return the Amount to paid according to the payment term cash discount payment term lines | 67 | This function return the Amount to paid according to the payment term cash discount payment term lines |
20 | 67 | """ | 68 | """ |
21 | 68 | |||
22 | 69 | if context is None: | 69 | if context is None: |
23 | 70 | context = {} | 70 | context = {} |
24 | 71 | |||
25 | 72 | tax_obj = self.pool.get('account.tax') | 71 | tax_obj = self.pool.get('account.tax') |
26 | 73 | invoice = self.browse(cr, uid, ids[0], context=context) | 72 | invoice = self.browse(cr, uid, ids[0], context=context) |
27 | 74 | 73 | ||
28 | @@ -203,12 +202,14 @@ | |||
29 | 203 | dis = 0.0 | 202 | dis = 0.0 |
30 | 204 | for discount_line in payment_term_lines.cash_discount_ids: | 203 | for discount_line in payment_term_lines.cash_discount_ids: |
31 | 205 | if diff_day >= dis and diff_day <= discount_line.delay: | 204 | if diff_day >= dis and diff_day <= discount_line.delay: |
33 | 206 | account_id = discount_line.discount_account_id.id | 205 | if invoice.type in ('in_invoice', 'in_refund'): |
34 | 206 | account_id = discount_line.sup_discount_account_id.id | ||
35 | 207 | else: | ||
36 | 208 | account_id = discount_line.discount_account_id.id | ||
37 | 207 | dis = discount_line.delay | 209 | dis = discount_line.delay |
38 | 208 | return account_id | 210 | return account_id |
39 | 209 | 211 | ||
40 | 210 | def pay_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, period_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context=None, name=''): | 212 | def pay_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, period_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context=None, name=''): |
41 | 211 | |||
42 | 212 | if context is None: | 213 | if context is None: |
43 | 213 | context = {} | 214 | context = {} |
44 | 214 | #TODO check if we can use different period for payment and the writeoff line | 215 | #TODO check if we can use different period for payment and the writeoff line |
45 | @@ -220,15 +221,12 @@ | |||
46 | 220 | move_line_obj = self.pool.get('account.move.line') | 221 | move_line_obj = self.pool.get('account.move.line') |
47 | 221 | move_obj = self.pool.get('account.move') | 222 | move_obj = self.pool.get('account.move') |
48 | 222 | 223 | ||
49 | 223 | if 'amount_currency' in context and context['amount_currency']: | ||
50 | 224 | amount_currency = context['amount_currency'] | ||
51 | 225 | else: | ||
52 | 226 | amount_currency = invoice.residual | ||
53 | 227 | amount_discount = 0.0 | 224 | amount_discount = 0.0 |
54 | 228 | if invoice.payment_term: | 225 | if invoice.payment_term: |
55 | 229 | # Return the discount on for the payment term | 226 | # Return the discount on for the payment term |
58 | 230 | amount_discount = self._get_payment(cr, uid, ids, amount_currency, invoice.payment_term.id, context=context) | 227 | amount_discount = self._get_payment(cr, uid, ids, pay_amount, invoice.payment_term.id, context=context) |
59 | 231 | 228 | ||
60 | 229 | |||
61 | 232 | src_account_id = invoice.account_id.id | 230 | src_account_id = invoice.account_id.id |
62 | 233 | # Take the seq as name for move | 231 | # Take the seq as name for move |
63 | 234 | types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1} | 232 | types = {'out_invoice': -1, 'in_invoice': 1, 'out_refund': 1, 'in_refund': -1} |
64 | @@ -257,7 +255,7 @@ | |||
65 | 257 | 255 | ||
66 | 258 | if 'cash_amount' in context and context['cash_amount']: | 256 | if 'cash_amount' in context and context['cash_amount']: |
67 | 259 | discount_amount = context['cash_amount'] | 257 | discount_amount = context['cash_amount'] |
69 | 260 | 258 | ||
70 | 261 | # Pay attention to the sign for both debit/credit AND amount_currency | 259 | # Pay attention to the sign for both debit/credit AND amount_currency |
71 | 262 | l1 = { | 260 | l1 = { |
72 | 263 | 'debit': direction * (pay_amount)>0 and direction * (pay_amount), | 261 | 'debit': direction * (pay_amount)>0 and direction * (pay_amount), |
73 | @@ -270,7 +268,8 @@ | |||
74 | 270 | 'amount_currency':amount_currency and direction * amount_currency or 0.0, | 268 | 'amount_currency':amount_currency and direction * amount_currency or 0.0, |
75 | 271 | } | 269 | } |
76 | 272 | 270 | ||
78 | 273 | ### if we change the amount paid and in the disocunt then it used the changes discount | 271 | ### if we change the amount paid and in the disocunt then it used the changes discount |
79 | 272 | |||
80 | 274 | if amount_discount != discount_amount and discount_amount>0.0: | 273 | if amount_discount != discount_amount and discount_amount>0.0: |
81 | 275 | amount_discount = discount_amount | 274 | amount_discount = discount_amount |
82 | 276 | 275 | ||
83 | @@ -291,7 +290,8 @@ | |||
84 | 291 | l1['name'] = name | 290 | l1['name'] = name |
85 | 292 | l2['name'] = name | 291 | l2['name'] = name |
86 | 293 | lines = [(0, 0, l1), (0, 0, l2)] | 292 | lines = [(0, 0, l1), (0, 0, l2)] |
88 | 294 | 293 | ||
89 | 294 | ### When we make payment by pay invoice wizard and if found the taxes move then directly take the entry from the wizard | ||
90 | 295 | if 'tax_move_ids' in context and context['tax_move_ids']: | 295 | if 'tax_move_ids' in context and context['tax_move_ids']: |
91 | 296 | move_line = context['tax_move_ids'] | 296 | move_line = context['tax_move_ids'] |
92 | 297 | for move_line_id in move_line: | 297 | for move_line_id in move_line: |
93 | @@ -337,25 +337,28 @@ | |||
94 | 337 | } | 337 | } |
95 | 338 | l3['name'] = name | 338 | l3['name'] = name |
96 | 339 | lines.append((0, 0, l3)) | 339 | lines.append((0, 0, l3)) |
98 | 340 | 340 | ||
99 | 341 | ### When we make payment by pay invoice wizard and if found the discount moves in wizard discount move then directly take the entry from the wizard | ||
100 | 341 | if 'discount_move_ids' in context and context['discount_move_ids']: | 342 | if 'discount_move_ids' in context and context['discount_move_ids']: |
118 | 342 | dis_move_id = context['discount_move_ids'][0] | 343 | move_line = context['discount_move_ids'] |
119 | 343 | move_id = move_line_obj.search(cr, uid,[('move_id','=',dis_move_id)]) | 344 | for move_line_id in move_line: |
120 | 344 | move_line_data = move_line_obj.browse(cr, uid, move_id[0]) | 345 | move_line_data = move_line_obj.browse(cr, uid,move_line_id) |
121 | 345 | l4 = { | 346 | l4 = { |
122 | 346 | 'debit': move_line_data.debit, | 347 | 'debit': move_line_data.debit, |
123 | 347 | 'credit':move_line_data.credit, | 348 | 'credit':move_line_data.credit, |
124 | 348 | 'account_id': move_line_data.account_id.id, | 349 | 'account_id': move_line_data.account_id.id, |
125 | 349 | 'partner_id': move_line_data.partner_id.id, | 350 | 'partner_id': move_line_data.partner_id.id, |
126 | 350 | 'ref':move_line_data.ref, | 351 | 'ref':move_line_data.ref, |
127 | 351 | 'date': move_line_data.date, | 352 | 'date': move_line_data.date, |
128 | 352 | 'currency_id':currency_id, | 353 | 'currency_id':currency_id, |
129 | 353 | 'amount_currency':amount_currency and direction * amount_currency or 0.0, | 354 | 'amount_currency':amount_currency and direction * amount_currency or 0.0, |
130 | 354 | 'name':move_line_data.name, | 355 | 'name':move_line_data.name, |
131 | 355 | } | 356 | 'tax_code_id':move_line_data.tax_code_id.id, |
132 | 356 | lines.append((0, 0, l4)) | 357 | 'tax_amount':move_line_data.tax_amount, |
133 | 357 | 358 | } | |
134 | 358 | move_obj.unlink(cr, uid, context['discount_move_ids']) | 359 | lines.append((0, 0, l4)) |
135 | 360 | move_line_obj.unlink(cr, uid,[move_line_id]) | ||
136 | 361 | move_obj.unlink(cr, uid,[move_line_data.move_id.id]) | ||
137 | 359 | else: | 362 | else: |
138 | 360 | if amount_discount>0: | 363 | if amount_discount>0: |
139 | 361 | if 'account_id' in context and context['account_id']: | 364 | if 'account_id' in context and context['account_id']: |
140 | @@ -376,7 +379,7 @@ | |||
141 | 376 | } | 379 | } |
142 | 377 | l4['name'] = name | 380 | l4['name'] = name |
143 | 378 | lines.append((0, 0, l4)) | 381 | lines.append((0, 0, l4)) |
145 | 379 | 382 | ||
146 | 380 | move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date} | 383 | move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'date': date} |
147 | 381 | move_id = move_obj.create(cr, uid, move, context=context) | 384 | move_id = move_obj.create(cr, uid, move, context=context) |
148 | 382 | 385 | ||
149 | @@ -420,5 +423,6 @@ | |||
150 | 420 | type='many2one', relation='account.invoice', fnct_search=_invoice_search), | 423 | type='many2one', relation='account.invoice', fnct_search=_invoice_search), |
151 | 421 | } | 424 | } |
152 | 422 | account_move_line() | 425 | account_move_line() |
153 | 426 | |||
154 | 423 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 427 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
155 | 424 | 428 | ||
156 | 425 | 429 | ||
157 | === modified file 'account_invoice_cash_discount/account_invoice_cash_discount_view.xml' | |||
158 | --- account_invoice_cash_discount/account_invoice_cash_discount_view.xml 2010-08-21 12:43:18 +0000 | |||
159 | +++ account_invoice_cash_discount/account_invoice_cash_discount_view.xml 2010-07-14 12:24:45 +0000 | |||
160 | @@ -15,6 +15,8 @@ | |||
161 | 15 | <field name="delay" select="1"/> | 15 | <field name="delay" select="1"/> |
162 | 16 | <field name="discount" select="1"/> | 16 | <field name="discount" select="1"/> |
163 | 17 | <field name="discount_account_id" /> | 17 | <field name="discount_account_id" /> |
164 | 18 | <field name="day_tolerance"/> | ||
165 | 19 | <field name="sup_discount_account_id"/> | ||
166 | 18 | <group colspan="4"> | 20 | <group colspan="4"> |
167 | 19 | <separator string="Related Payment Terms Lines" colspan="4"/> | 21 | <separator string="Related Payment Terms Lines" colspan="4"/> |
168 | 20 | <field name="payment_term_ids" widget="one2many_list" nolabel="1"/> | 22 | <field name="payment_term_ids" widget="one2many_list" nolabel="1"/> |
169 | @@ -96,8 +98,8 @@ | |||
170 | 96 | <field name="inherit_id" ref="account.view_payment_term_line_form"/> | 98 | <field name="inherit_id" ref="account.view_payment_term_line_form"/> |
171 | 97 | <field name="arch" type="xml"> | 99 | <field name="arch" type="xml"> |
172 | 98 | <field name="days2" position="after"> | 100 | <field name="days2" position="after"> |
173 | 99 | <label string="" colspan="2"/> | ||
174 | 100 | <field name="compl_cash_discount"/> | 101 | <field name="compl_cash_discount"/> |
175 | 102 | <label string="" colspan="2"/> | ||
176 | 101 | </field> | 103 | </field> |
177 | 102 | </field> | 104 | </field> |
178 | 103 | </record> | 105 | </record> |
179 | 104 | 106 | ||
180 | === modified file 'account_invoice_cash_discount/wizard/account_pay_invoice.py' | |||
181 | --- account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-07-06 13:32:32 +0000 | |||
182 | +++ account_invoice_cash_discount/wizard/account_pay_invoice.py 2010-07-14 12:24:45 +0000 | |||
183 | @@ -66,7 +66,7 @@ | |||
184 | 66 | 'cal_method_selection': fields.selection([('method_gross_methodology','Calculate Discount with Net Gross Methodology'), | 66 | 'cal_method_selection': fields.selection([('method_gross_methodology','Calculate Discount with Net Gross Methodology'), |
185 | 67 | ('method_net_methodology','Calculate Discount with Net Methodology'),], | 67 | ('method_net_methodology','Calculate Discount with Net Methodology'),], |
186 | 68 | 'Method To Calculation'), | 68 | 'Method To Calculation'), |
188 | 69 | 'discount_move_ids': fields.many2many('account.move', 'account_discount_move_rel', 'discount_account_id', 'discount_move_id', 'Account Discount Moves'), | 69 | 'discount_move_ids': fields.many2many('account.move.line', 'account_discount_move_rel', 'discount_account_id', 'discount_move_id', 'Account Discount Moves'), |
189 | 70 | 'tax_move_ids': fields.many2many('account.move.line', 'account_tax_move_rel', 'tax_account_id', 'tax_move_id', 'Account Taxes Moves'), | 70 | 'tax_move_ids': fields.many2many('account.move.line', 'account_tax_move_rel', 'tax_account_id', 'tax_move_id', 'Account Taxes Moves'), |
190 | 71 | } | 71 | } |
191 | 72 | 72 | ||
192 | @@ -79,7 +79,10 @@ | |||
193 | 79 | 79 | ||
194 | 80 | def _get_amount(self, cr, uid, context=None): | 80 | def _get_amount(self, cr, uid, context=None): |
195 | 81 | obj_inv = self.pool.get('account.invoice') | 81 | obj_inv = self.pool.get('account.invoice') |
196 | 82 | tax_obj = self.pool.get('account.tax') | ||
197 | 82 | invoice = obj_inv.browse(cr, uid, context['id'], context=context) | 83 | invoice = obj_inv.browse(cr, uid, context['id'], context=context) |
198 | 84 | total_tax_amount = 0.0 | ||
199 | 85 | total_amount = 0.0 | ||
200 | 83 | amount = obj_inv._get_amount(cr, uid, [context['id']] ,invoice.residual, invoice.payment_term.id, context=context) | 86 | amount = obj_inv._get_amount(cr, uid, [context['id']] ,invoice.residual, invoice.payment_term.id, context=context) |
201 | 84 | context.update({'found':amount['found']}) | 87 | context.update({'found':amount['found']}) |
202 | 85 | amount = amount['amount'] | 88 | amount = amount['amount'] |
203 | @@ -89,6 +92,7 @@ | |||
204 | 89 | 92 | ||
205 | 90 | def _get_discount(self, cr, uid, context=None): | 93 | def _get_discount(self, cr, uid, context=None): |
206 | 91 | obj_inv = self.pool.get('account.invoice') | 94 | obj_inv = self.pool.get('account.invoice') |
207 | 95 | tax_obj = self.pool.get('account.tax') | ||
208 | 92 | invoice = obj_inv.browse(cr, uid, context['id'], context=context) | 96 | invoice = obj_inv.browse(cr, uid, context['id'], context=context) |
209 | 93 | amount = obj_inv._get_amount(cr, uid, [context['id']] ,invoice.residual, invoice.payment_term.id, context=context) | 97 | amount = obj_inv._get_amount(cr, uid, [context['id']] ,invoice.residual, invoice.payment_term.id, context=context) |
210 | 94 | amount = amount['amount'] | 98 | amount = amount['amount'] |
211 | @@ -149,6 +153,7 @@ | |||
212 | 149 | return {'value' : {'cash_amount':discount_amount,'cash_residual_amount':diff_amount}} | 153 | return {'value' : {'cash_amount':discount_amount,'cash_residual_amount':diff_amount}} |
213 | 150 | 154 | ||
214 | 151 | def _calculation(self, cr, uid, ids, context=None): | 155 | def _calculation(self, cr, uid, ids, context=None): |
215 | 156 | |||
216 | 152 | invoice_obj = self.pool.get('account.invoice') | 157 | invoice_obj = self.pool.get('account.invoice') |
217 | 153 | data = self.read(cr, uid, ids,context=context)[0] | 158 | data = self.read(cr, uid, ids,context=context)[0] |
218 | 154 | invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context) | 159 | invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context) |
219 | @@ -161,13 +166,16 @@ | |||
220 | 161 | if data['tax_move_ids']: | 166 | if data['tax_move_ids']: |
221 | 162 | move_line = data['tax_move_ids'] | 167 | move_line = data['tax_move_ids'] |
222 | 163 | for move_line_id in move_line: | 168 | for move_line_id in move_line: |
224 | 164 | move_id = move_line_data = move_line_obj.browse(cr, uid,move_line_id).move_id.id | 169 | move_id = move_line_obj.browse(cr, uid,move_line_id).move_id.id |
225 | 165 | move_line_obj.unlink(cr, uid,[move_line_id]) | 170 | move_line_obj.unlink(cr, uid,[move_line_id]) |
226 | 166 | move_obj.unlink(cr, uid,[move_id]) | 171 | move_obj.unlink(cr, uid,[move_id]) |
227 | 167 | 172 | ||
228 | 168 | if data['discount_move_ids']: | 173 | if data['discount_move_ids']: |
231 | 169 | dis_move_id = data['discount_move_ids'][0] | 174 | discount_move_line = data['discount_move_ids'] |
232 | 170 | move_obj.unlink(cr, uid, data['discount_move_ids']) | 175 | for move_line_id in discount_move_line: |
233 | 176 | move_id = move_line_obj.browse(cr, uid,move_line_id).move_id.id | ||
234 | 177 | move_line_obj.unlink(cr, uid,[move_line_id]) | ||
235 | 178 | move_obj.unlink(cr, uid,[move_id]) | ||
236 | 171 | 179 | ||
237 | 172 | ######## to get ref | 180 | ######## to get ref |
238 | 173 | if invoice.type in ('in_invoice', 'in_refund'): | 181 | if invoice.type in ('in_invoice', 'in_refund'): |
239 | @@ -182,23 +190,39 @@ | |||
240 | 182 | 190 | ||
241 | 183 | #### to get name | 191 | #### to get name |
242 | 184 | name = invoice.invoice_line and invoice.invoice_line[0].name or invoice.number | 192 | name = invoice.invoice_line and invoice.invoice_line[0].name or invoice.number |
243 | 185 | |||
244 | 186 | ##### Entry in the discount account moves and entry in the tax account moves | 193 | ##### Entry in the discount account moves and entry in the tax account moves |
246 | 187 | ### Entry for taxes in the line of wizard tax | 194 | |
247 | 188 | if data.get('cash_amount',0.0)>0.0: | 195 | if data.get('cash_amount',0.0)>0.0: |
248 | 189 | lines3 = [] | ||
249 | 190 | tax_total_amount = 0.0 | 196 | tax_total_amount = 0.0 |
251 | 191 | line_ids = [] | 197 | amount = 0.0 |
252 | 198 | discount = 0.0 | ||
253 | 199 | line_ids = [] | ||
254 | 200 | discount_line_ids = [] | ||
255 | 201 | |||
256 | 202 | discount_account_id = False | ||
257 | 203 | tax_code_id = False | ||
258 | 204 | |||
259 | 192 | for line in invoice.invoice_line: | 205 | for line in invoice.invoice_line: |
260 | 206 | tax_amount = 0.0 | ||
261 | 207 | line_tax_amount = 0.0 | ||
262 | 208 | |||
263 | 209 | #####get the ratio of the line in the total invoice amount | ||
264 | 210 | for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, line.price_subtotal, line.quantity, invoice.address_invoice_id.id, line.product_id, invoice.partner_id): | ||
265 | 211 | line_tax_amount = tax['amount'] | ||
266 | 212 | line_total = line.price_subtotal + line_tax_amount | ||
267 | 213 | invoice_res_amount = invoice.amount_total | ||
268 | 214 | line_ratio = line_total / invoice_res_amount | ||
269 | 215 | ########################### | ||
270 | 216 | |||
271 | 193 | if line.invoice_line_tax_id: | 217 | if line.invoice_line_tax_id: |
272 | 194 | for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, data['cash_amount'], line.quantity, invoice.address_invoice_id.id, line.product_id, invoice.partner_id): | 218 | for tax in tax_obj.compute(cr, uid, line.invoice_line_tax_id, data['cash_amount'], line.quantity, invoice.address_invoice_id.id, line.product_id, invoice.partner_id): |
273 | 195 | tax_amount = tax['amount'] | 219 | tax_amount = tax['amount'] |
274 | 196 | tax_total_amount += tax['amount'] | ||
275 | 197 | tax_invoice_id = invoice_tax_obj.search(cr,uid,[('invoice_id','=',invoice.id),('name','=',tax['name'])]) | 220 | tax_invoice_id = invoice_tax_obj.search(cr,uid,[('invoice_id','=',invoice.id),('name','=',tax['name'])]) |
276 | 198 | for tax_id in tax_invoice_id: | 221 | for tax_id in tax_invoice_id: |
277 | 199 | tax_value = invoice_tax_obj.browse(cr, uid, tax_id) | 222 | tax_value = invoice_tax_obj.browse(cr, uid, tax_id) |
278 | 200 | tax_account_id = tax_value.account_id.id | 223 | tax_account_id = tax_value.account_id.id |
280 | 201 | 224 | tax_code_id = tax_value.tax_code_id.id | |
281 | 225 | |||
282 | 202 | l3 = { | 226 | l3 = { |
283 | 203 | 'debit': direction * tax_amount<0 and - direction * tax_amount, | 227 | 'debit': direction * tax_amount<0 and - direction * tax_amount, |
284 | 204 | 'credit': direction * tax_amount>0 and direction * tax_amount, | 228 | 'credit': direction * tax_amount>0 and direction * tax_amount, |
285 | @@ -210,45 +234,42 @@ | |||
286 | 210 | 'period_id':data.get('period_id',False), | 234 | 'period_id':data.get('period_id',False), |
287 | 211 | 'name':name, | 235 | 'name':name, |
288 | 212 | 'tax_code_id':tax_value.tax_code_id.id, | 236 | 'tax_code_id':tax_value.tax_code_id.id, |
290 | 213 | 'tax_amount':tax_amount, | 237 | 'tax_amount':-tax_amount, |
291 | 214 | } | 238 | } |
293 | 215 | line_id = move_line_obj.create(cr,uid,l3,context=context) | 239 | line_id = move_line_obj.create(cr, uid, l3, context=context) |
294 | 216 | line_ids.append(line_id) | 240 | line_ids.append(line_id) |
295 | 241 | |||
296 | 242 | ### if calculation on the Net Methology then in discount field it will take product income account or product category income account | ||
297 | 243 | |||
298 | 244 | if data['cal_method_selection'] == 'method_net_methodology': | ||
299 | 245 | if line.product_id.property_account_income: | ||
300 | 246 | discount_account_id = line.product_id.property_account_income.id | ||
301 | 247 | else: | ||
302 | 248 | discount_account_id = line.product_id.categ_id.property_account_income_categ.id | ||
303 | 249 | else: | ||
304 | 250 | discount_account_id = data['account_id'] | ||
305 | 251 | |||
306 | 252 | discount = data['cash_amount'] * line_ratio | ||
307 | 253 | l4 = { | ||
308 | 254 | 'debit': direction * (discount - tax_amount)<0 and - direction * (discount - tax_amount), | ||
309 | 255 | 'credit': direction * (discount - tax_amount)>0 and direction * (discount - tax_amount), | ||
310 | 256 | 'account_id': discount_account_id, | ||
311 | 257 | 'partner_id': invoice.partner_id.id, | ||
312 | 258 | 'ref':ref, | ||
313 | 259 | 'date': date, | ||
314 | 260 | 'name':name, | ||
315 | 261 | 'journal_id':data.get('journal_id',False), | ||
316 | 262 | 'period_id':data.get('period_id',False), | ||
317 | 263 | 'tax_code_id':tax_code_id, | ||
318 | 264 | 'tax_amount':-tax_amount, | ||
319 | 265 | } | ||
320 | 266 | |||
321 | 267 | discount_line_id = move_line_obj.create(cr, uid, l4, context=context) | ||
322 | 268 | discount_line_ids.append(discount_line_id) | ||
323 | 269 | |||
324 | 217 | self.write(cr, uid, ids, {'tax_move_ids':[(6,0,line_ids)]}, context) | 270 | self.write(cr, uid, ids, {'tax_move_ids':[(6,0,line_ids)]}, context) |
359 | 218 | 271 | self.write(cr, uid, ids, {'discount_move_ids':[(6,0,discount_line_ids)]}, context) | |
360 | 219 | ### Entry for discount in the line of wizard discount | 272 | |
327 | 220 | lines4 = [] | ||
328 | 221 | if tax_total_amount>0: | ||
329 | 222 | data['cash_amount'] = (data['cash_amount'] - tax_total_amount) | ||
330 | 223 | |||
331 | 224 | ############################ if method type net methology than discount account journal account | ||
332 | 225 | discount_account_id = False | ||
333 | 226 | |||
334 | 227 | if data['cal_method_selection'] == 'method_net_methodology': | ||
335 | 228 | journal_id = data['journal_id'] | ||
336 | 229 | if context['type'] == 'out_invoice': | ||
337 | 230 | discount_account_id = self.pool.get('account.journal').browse(cr, uid, journal_id).default_debit_account_id.id | ||
338 | 231 | else: | ||
339 | 232 | discount_account_id = self.pool.get('account.journal').browse(cr, uid, journal_id).default_credit_account_id.id | ||
340 | 233 | else: | ||
341 | 234 | discount_account_id = data['account_id'] | ||
342 | 235 | ############################################### | ||
343 | 236 | |||
344 | 237 | l4 = { | ||
345 | 238 | 'debit': direction * data.get('cash_amount',0.0)<0 and - direction * data.get('cash_amount',0.0), | ||
346 | 239 | 'credit': direction * data.get('cash_amount',0.0)>0 and direction * data.get('cash_amount',0.0), | ||
347 | 240 | 'account_id': discount_account_id, | ||
348 | 241 | 'partner_id': invoice.partner_id.id, | ||
349 | 242 | 'ref':ref, | ||
350 | 243 | 'date': date, | ||
351 | 244 | 'name':name | ||
352 | 245 | } | ||
353 | 246 | |||
354 | 247 | lines4.append((0, 0, l4)) | ||
355 | 248 | move = {'ref': ref, 'line_id': lines4, 'journal_id': data['journal_id'], 'period_id': data['period_id'], } | ||
356 | 249 | move_id = move_obj.create(cr, uid, move, context=context) | ||
357 | 250 | self.write(cr, uid, ids, {'discount_move_ids':[(6,0,[move_id])]}, context) | ||
358 | 251 | |||
361 | 252 | return True | 273 | return True |
362 | 253 | 274 | ||
363 | 254 | def default_get(self, cr, uid, fields, context=None): | 275 | def default_get(self, cr, uid, fields, context=None): |
364 | @@ -296,7 +317,6 @@ | |||
365 | 296 | if context is None: | 317 | if context is None: |
366 | 297 | context = {} | 318 | context = {} |
367 | 298 | data = self.read(cr, uid, ids,context=context)[0] | 319 | data = self.read(cr, uid, ids,context=context)[0] |
368 | 299 | |||
369 | 300 | invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context) | 320 | invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context) |
370 | 301 | journal = self.pool.get('account.journal').browse(cr, uid, data['journal_id'], context) | 321 | journal = self.pool.get('account.journal').browse(cr, uid, data['journal_id'], context) |
371 | 302 | # Here we need that: | 322 | # Here we need that: |
372 | @@ -327,38 +347,46 @@ | |||
373 | 327 | amount_paid+=abs(debit-credit) | 347 | amount_paid+=abs(debit-credit) |
374 | 328 | 348 | ||
375 | 329 | # Test if there is a difference according to currency rouding setting | 349 | # Test if there is a difference according to currency rouding setting |
386 | 330 | amount = obj_inv._get_amount(cr, uid, [context['id']] ,invoice.residual, invoice.payment_term.id, context=context) | 350 | # amount = obj_inv._get_amount(cr, uid, [context['id']] ,invoice.residual, invoice.payment_term.id, context=context) |
387 | 331 | found_h = amount['found'] | 351 | # |
388 | 332 | 352 | # found_h = amount['found'] | |
389 | 333 | if found_h: | 353 | # |
390 | 334 | if context.get('discount_move_ids',False): | 354 | # if found_h: |
391 | 335 | context.update({'discount_move_ids':context['discount_move_ids']}) | 355 | |
392 | 336 | 356 | ####### Here when we do make full payment then to get the previous Discount and Tax Move added in context | |
393 | 337 | if context.get('tax_move_ids',False): | 357 | |
394 | 338 | context.update({'tax_move_ids':context['tax_move_ids']}) | 358 | if context.get('discount_move_ids',False): |
395 | 339 | 359 | context.update({'discount_move_ids':context['discount_move_ids']}) | |
396 | 360 | if context.get('tax_move_ids',False): | ||
397 | 361 | context.update({'tax_move_ids':context['tax_move_ids']}) | ||
398 | 362 | if context.get('amount',False): | ||
399 | 363 | context.update({'amount':context['amount']}) | ||
400 | 364 | if context.get('cash_amount',False): | ||
401 | 365 | context.update({'cash_amount':context['cash_amount']}) | ||
402 | 366 | |||
403 | 367 | # return self.pay_and_reconcile(cr, uid, ids, context=context) | ||
404 | 368 | # else: | ||
405 | 369 | |||
406 | 370 | if self.pool.get('res.currency').is_zero(cr, uid, invoice.company_id.currency_id, | ||
407 | 371 | (amount_paid - inv_amount_company_currency)) or data['cash_residual_amount'] == 0.0: | ||
408 | 340 | return self.pay_and_reconcile(cr, uid, ids, context=context) | 372 | return self.pay_and_reconcile(cr, uid, ids, context=context) |
409 | 373 | |||
410 | 341 | else: | 374 | else: |
430 | 342 | 375 | model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_account_invoice_pay_writeoff')], context=context) | |
431 | 343 | if self.pool.get('res.currency').is_zero(cr, uid, invoice.company_id.currency_id, | 376 | resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] |
432 | 344 | (amount_paid - inv_amount_company_currency)): | 377 | return { |
433 | 345 | return self.pay_and_reconcile(cr, uid, ids, context=context) | 378 | 'name': _('Information addendum'), |
434 | 346 | 379 | 'context': context, | |
435 | 347 | else: | 380 | 'view_type': 'form', |
436 | 348 | model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_account_invoice_pay_writeoff')], context=context) | 381 | 'view_mode': 'form', |
437 | 349 | resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] | 382 | 'res_model': 'account.invoice.pay.writeoff', |
438 | 350 | return { | 383 | 'views': [(resource_id,'form')], |
439 | 351 | 'name': _('Information addendum'), | 384 | 'type': 'ir.actions.act_window', |
440 | 352 | 'context': context, | 385 | 'target': 'new', |
441 | 353 | 'view_type': 'form', | 386 | } |
442 | 354 | 'view_mode': 'form', | 387 | |
424 | 355 | 'res_model': 'account.invoice.pay.writeoff', | ||
425 | 356 | 'views': [(resource_id,'form')], | ||
426 | 357 | 'type': 'ir.actions.act_window', | ||
427 | 358 | 'target': 'new', | ||
428 | 359 | } | ||
429 | 360 | |||
443 | 361 | def pay_and_reconcile(self, cr, uid, ids, context=None): | 388 | def pay_and_reconcile(self, cr, uid, ids, context=None): |
444 | 389 | |||
445 | 362 | cur_obj = self.pool.get('res.currency') | 390 | cur_obj = self.pool.get('res.currency') |
446 | 363 | if context is None: | 391 | if context is None: |
447 | 364 | context = {} | 392 | context = {} |
448 | @@ -373,8 +401,11 @@ | |||
449 | 373 | writeoff_journal_id = context['write_off']['writeoff_journal_id'] | 401 | writeoff_journal_id = context['write_off']['writeoff_journal_id'] |
450 | 374 | comment = context['write_off']['comment'] | 402 | comment = context['write_off']['comment'] |
451 | 375 | 403 | ||
454 | 376 | amount = data['amount'] + data['cash_amount'] | 404 | if context.get('amount',False): |
455 | 377 | 405 | amount = context['amount'] + context.get('cash_amount',0.0) | |
456 | 406 | else: | ||
457 | 407 | amount = data['amount'] + data['cash_amount'] | ||
458 | 408 | |||
459 | 378 | invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context) | 409 | invoice = self.pool.get('account.invoice').browse(cr, uid, context['id'], context=context) |
460 | 379 | journal = self.pool.get('account.journal').browse(cr, uid, data['journal_id'], context=context) | 410 | journal = self.pool.get('account.journal').browse(cr, uid, data['journal_id'], context=context) |
461 | 380 | # Compute the amount in company's currency, with the journal currency (which is equal to payment currency) | 411 | # Compute the amount in company's currency, with the journal currency (which is equal to payment currency) |
462 | @@ -384,39 +415,52 @@ | |||
463 | 384 | amount = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, amount, context=ctx) | 415 | amount = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, amount, context=ctx) |
464 | 385 | currency_id = journal.currency.id | 416 | currency_id = journal.currency.id |
465 | 386 | # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency | 417 | # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency |
467 | 387 | context.update({'amount_currency':data['amount'] + data['cash_amount'],'currency_id':currency_id}) | 418 | if context.get('amount',False): |
468 | 419 | context.update({'amount_currency':context['amount'] + context.get('cash_amount',0.0),'currency_id':currency_id}) | ||
469 | 420 | else: | ||
470 | 421 | context.update({'amount_currency':data['amount'] + data['cash_amount'],'currency_id':currency_id}) | ||
471 | 388 | 422 | ||
472 | 389 | if invoice.company_id.currency_id.id<>invoice.currency_id.id: | 423 | if invoice.company_id.currency_id.id<>invoice.currency_id.id: |
473 | 390 | ctx = {'date':data['date']} | 424 | ctx = {'date':data['date']} |
474 | 391 | amount = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, amount, context=ctx) | 425 | amount = cur_obj.compute(cr, uid, invoice.currency_id.id, invoice.company_id.currency_id.id, amount, context=ctx) |
475 | 392 | currency_id = invoice.currency_id.id | 426 | currency_id = invoice.currency_id.id |
476 | 393 | # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency | 427 | # Put the paid amount in currency, and the currency, in the context if currency is different from company's currency |
486 | 394 | context.update({'amount_currency':data['amount'] + data['cash_amount'],'currency_id':currency_id}) | 428 | if context.get('amount',False): |
487 | 395 | 429 | context.update({'amount_currency':context['amount'] + context.get('cash_amount',0.0),'currency_id':currency_id}) | |
488 | 396 | # Take the choosen date | 430 | else: |
489 | 397 | if comment: | 431 | context.update({'amount_currency':data['amount'] + data['cash_amount'],'currency_id':currency_id}) |
490 | 398 | context.update({'date_p':data['date'],'comment':comment}) | 432 | |
491 | 399 | else: | 433 | context.update({'account_id':data['account_id'],'date_p':data['date'],'comment':comment or False}) |
483 | 400 | context.update({'date_p':data['date'],'comment':False}) | ||
484 | 401 | |||
485 | 402 | context.update({'account_id':data['account_id'],'cash_amount':data['cash_amount'],'amount_currency':data['amount'] + data['cash_amount']}) | ||
492 | 403 | 434 | ||
493 | 404 | if context.get('discount_move_ids',False): | 435 | if context.get('discount_move_ids',False): |
495 | 405 | context = context | 436 | context.update({'discount_move_ids':context['discount_move_ids']}) |
496 | 406 | else: | 437 | else: |
497 | 407 | context.update({'discount_move_ids':data['discount_move_ids']}) | 438 | context.update({'discount_move_ids':data['discount_move_ids']}) |
498 | 408 | 439 | ||
499 | 409 | if context.get('tax_move_ids',False): | 440 | if context.get('tax_move_ids',False): |
501 | 410 | context = context | 441 | context.update({'tax_move_ids':context['tax_move_ids']}) |
502 | 411 | else: | 442 | else: |
503 | 412 | context.update({'tax_move_ids':data['tax_move_ids']}) | 443 | context.update({'tax_move_ids':data['tax_move_ids']}) |
504 | 413 | 444 | ||
506 | 414 | if data['cash_amount']: | 445 | if context.get('cash_amount',False): |
507 | 446 | cash_amount = context['cash_amount'] | ||
508 | 447 | context.update({'cash_amount':context['cash_amount']}) | ||
509 | 448 | else: | ||
510 | 449 | cash_amount = data['cash_amount'] | ||
511 | 415 | context.update({'cash_amount':data['cash_amount']}) | 450 | context.update({'cash_amount':data['cash_amount']}) |
513 | 416 | 451 | ||
514 | 452 | if journal.currency and invoice.company_id.currency_id.id<>journal.currency.id: | ||
515 | 453 | cash_amount = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, cash_amount, context=ctx) | ||
516 | 454 | context.update({'cash_amount':cash_amount}) | ||
517 | 455 | |||
518 | 456 | if invoice.company_id.currency_id.id<>invoice.currency_id.id: | ||
519 | 457 | cash_amount = cur_obj.compute(cr, uid, journal.currency.id, invoice.company_id.currency_id.id, cash_amount, context=ctx) | ||
520 | 458 | context.update({'cash_amount':cash_amount}) | ||
521 | 459 | |||
522 | 417 | acc_id = journal.default_credit_account_id and journal.default_credit_account_id.id | 460 | acc_id = journal.default_credit_account_id and journal.default_credit_account_id.id |
523 | 418 | if not acc_id: | 461 | if not acc_id: |
524 | 419 | raise osv.except_osv(_('Error !'), _('Your journal must have a default credit and debit account.')) | 462 | raise osv.except_osv(_('Error !'), _('Your journal must have a default credit and debit account.')) |
525 | 463 | |||
526 | 420 | self.pool.get('account.invoice').pay_and_reconcile(cr, uid, [context['id']], | 464 | self.pool.get('account.invoice').pay_and_reconcile(cr, uid, [context['id']], |
527 | 421 | amount, acc_id, data['period_id'], data['journal_id'], writeoff_account_id, | 465 | amount, acc_id, data['period_id'], data['journal_id'], writeoff_account_id, |
528 | 422 | data['period_id'], writeoff_journal_id, context, data['name']) | 466 | data['period_id'], writeoff_journal_id, context, data['name']) |
529 | @@ -435,7 +479,28 @@ | |||
530 | 435 | if 'Customers Cash Discount Account' in res['fields'][f]['string']: | 479 | if 'Customers Cash Discount Account' in res['fields'][f]['string']: |
531 | 436 | res['fields'][f]['string'] = res['fields'][f]['string'].replace('Customers Cash Discount Account',word) | 480 | res['fields'][f]['string'] = res['fields'][f]['string'].replace('Customers Cash Discount Account',word) |
532 | 437 | return res | 481 | return res |
534 | 438 | 482 | ||
535 | 483 | def _cancel_line(self, cr, uid, ids, context=None): | ||
536 | 484 | move_obj = self.pool.get('account.move') | ||
537 | 485 | move_line_obj = self.pool.get('account.move.line') | ||
538 | 486 | data = self.read(cr, uid, ids,context=context)[0] | ||
539 | 487 | |||
540 | 488 | if data['tax_move_ids']: | ||
541 | 489 | move_line = data['tax_move_ids'] | ||
542 | 490 | for move_line_id in move_line: | ||
543 | 491 | move_id = move_line_obj.browse(cr, uid,move_line_id).move_id.id | ||
544 | 492 | move_line_obj.unlink(cr, uid,[move_line_id]) | ||
545 | 493 | move_obj.unlink(cr, uid,[move_id]) | ||
546 | 494 | |||
547 | 495 | if data['discount_move_ids']: | ||
548 | 496 | discount_move_line = data['discount_move_ids'] | ||
549 | 497 | for move_line_id in discount_move_line: | ||
550 | 498 | move_id = move_line_obj.browse(cr, uid,move_line_id).move_id.id | ||
551 | 499 | move_line_obj.unlink(cr, uid,[move_line_id]) | ||
552 | 500 | move_obj.unlink(cr, uid,[move_id]) | ||
553 | 501 | |||
554 | 502 | return {} | ||
555 | 503 | |||
556 | 439 | account_invoice_pay() | 504 | account_invoice_pay() |
557 | 440 | 505 | ||
558 | 441 | class account_message(osv.osv_memory): | 506 | class account_message(osv.osv_memory): |
559 | 442 | 507 | ||
560 | === modified file 'account_invoice_cash_discount/wizard/account_pay_invoice_view.xml' | |||
561 | --- account_invoice_cash_discount/wizard/account_pay_invoice_view.xml 2010-08-21 12:43:18 +0000 | |||
562 | +++ account_invoice_cash_discount/wizard/account_pay_invoice_view.xml 2010-07-14 12:24:45 +0000 | |||
563 | @@ -32,7 +32,7 @@ | |||
564 | 32 | </group> | 32 | </group> |
565 | 33 | <group colspan="4" col="6"> | 33 | <group colspan="4" col="6"> |
566 | 34 | <label string ="" colspan="2"/> | 34 | <label string ="" colspan="2"/> |
568 | 35 | <button icon="gtk-cancel" special="cancel" string="Cancel"/> | 35 | <button icon="gtk-cancel" string="Cancel" name="_cancel_line" type="object"/> |
569 | 36 | <button icon="gtk-execute" string="Partial Payment" name="pay_and_reconcile" type="object"/> | 36 | <button icon="gtk-execute" string="Partial Payment" name="pay_and_reconcile" type="object"/> |
570 | 37 | <button icon="gtk-execute" string="Full-Payment" name="_message" type="object"/> | 37 | <button icon="gtk-execute" string="Full-Payment" name="_message" type="object"/> |
571 | 38 | </group> | 38 | </group> |
572 | 39 | 39 | ||
573 | === modified file 'account_invoice_cash_discount/wizard/invoice_statement_payment.py' | |||
574 | --- account_invoice_cash_discount/wizard/invoice_statement_payment.py 2010-06-30 05:22:29 +0000 | |||
575 | +++ account_invoice_cash_discount/wizard/invoice_statement_payment.py 2010-07-14 12:24:45 +0000 | |||
576 | @@ -134,7 +134,7 @@ | |||
577 | 134 | amount=line.debit | 134 | amount=line.debit |
578 | 135 | elif line.credit > 0: | 135 | elif line.credit > 0: |
579 | 136 | amount=-line.credit | 136 | amount=-line.credit |
581 | 137 | 137 | print "amount::::::",amount | |
582 | 138 | reconcile_id = statement_reconcile_obj.create(cursor, user, { | 138 | reconcile_id = statement_reconcile_obj.create(cursor, user, { |
583 | 139 | 'line_ids': [(6, 0, [line.id])] | 139 | 'line_ids': [(6, 0, [line.id])] |
584 | 140 | }, context=context) | 140 | }, context=context) |
585 | @@ -145,13 +145,17 @@ | |||
586 | 145 | discount = 0.0 | 145 | discount = 0.0 |
587 | 146 | account = False | 146 | account = False |
588 | 147 | tax_total_amount = 0.0 | 147 | tax_total_amount = 0.0 |
590 | 148 | 148 | total_discount = 0.0 | |
591 | 149 | invoice = obj_inv.browse(cursor, user, line.invoice.id, context=context) | 149 | invoice = obj_inv.browse(cursor, user, line.invoice.id, context=context) |
592 | 150 | discount = obj_inv._get_payment(cursor, user, [invoice.id] , invoice.residual, invoice.payment_term.id, context=context) | ||
593 | 151 | account = obj_inv._get_account(cursor, user, [invoice.id] , invoice.residual, invoice.payment_term.id, context=context) | ||
594 | 152 | 150 | ||
595 | 153 | for invoice_line in invoice.invoice_line: | 151 | for invoice_line in invoice.invoice_line: |
596 | 154 | if invoice_line.invoice_line_tax_id: | 152 | if invoice_line.invoice_line_tax_id: |
597 | 153 | amount_invoice_line = obj_inv._get_amount(cursor, user, [invoice.id] , invoice_line.price_subtotal, invoice.payment_term.id, context=context) | ||
598 | 154 | line_amount = amount_invoice_line['amount'] | ||
599 | 155 | discount = obj_inv._get_payment(cursor, user, [invoice.id] , line_amount, invoice.payment_term.id, context=context) | ||
600 | 156 | account = obj_inv._get_account(cursor, user, [invoice.id] , invoice.residual, invoice.payment_term.id, context=context) | ||
601 | 157 | |||
602 | 158 | tax_amount = 0.0 | ||
603 | 155 | for tax in tax_obj.compute(cursor, user, invoice_line.invoice_line_tax_id, discount, invoice_line.quantity, invoice.address_invoice_id.id, invoice_line.product_id, invoice.partner_id): | 159 | for tax in tax_obj.compute(cursor, user, invoice_line.invoice_line_tax_id, discount, invoice_line.quantity, invoice.address_invoice_id.id, invoice_line.product_id, invoice.partner_id): |
604 | 156 | tax_amount = tax['amount'] | 160 | tax_amount = tax['amount'] |
605 | 157 | tax_total_amount += tax['amount'] | 161 | tax_total_amount += tax['amount'] |
606 | @@ -167,13 +171,15 @@ | |||
607 | 167 | 'account_id': tax_account_id, | 171 | 'account_id': tax_account_id, |
608 | 168 | 'line_id': reconcile_id, | 172 | 'line_id': reconcile_id, |
609 | 169 | }, context=context) | 173 | }, context=context) |
617 | 170 | if discount>0: | 174 | |
618 | 171 | statement_reconcile_line_obj.create(cursor, user, { | 175 | if discount>0: |
619 | 172 | 'name': line.name, | 176 | total_discount += discount |
620 | 173 | 'amount': discount - tax_total_amount, | 177 | statement_reconcile_line_obj.create(cursor, user, { |
621 | 174 | 'account_id': account, | 178 | 'name': line.name, |
622 | 175 | 'line_id': reconcile_id, | 179 | 'amount': discount - tax_amount, |
623 | 176 | }, context=context) | 180 | 'account_id': account, |
624 | 181 | 'line_id': reconcile_id, | ||
625 | 182 | }, context=context) | ||
626 | 177 | ########################################################################## | 183 | ########################################################################## |
627 | 178 | 184 | ||
628 | 179 | if line.journal_id.type == 'sale': | 185 | if line.journal_id.type == 'sale': |
629 | @@ -182,6 +188,7 @@ | |||
630 | 182 | type = 'supplier' | 188 | type = 'supplier' |
631 | 183 | else: | 189 | else: |
632 | 184 | type = 'general' | 190 | type = 'general' |
633 | 191 | |||
634 | 185 | statement_line_obj.create(cursor, user, { | 192 | statement_line_obj.create(cursor, user, { |
635 | 186 | 'name': line.name or '?', | 193 | 'name': line.name or '?', |
636 | 187 | 'amount': amount, | 194 | 'amount': amount, |