52
52
'get_data':self._get_data,
53
53
'get_partner_addr': self._get_partner_addr,
54
54
'get_p_country': self._get_p_country,
55
'get_alicuota': self._get_alicuota,
56
55
'get_rif': self._get_rif,
57
56
'get_month':self._get_month,
58
'get_dates':self._get_dates,
59
57
'get_totals':self._get_totals,
60
58
'get_doc':self._get_doc,
61
59
'get_ret':self._get_ret,
118
116
if len(period_ids)>0:
119
117
fr_ids = adjust_obj.search(self.cr,self.uid,[('period_id', 'in',period_ids),('type','=',type_doc)])
120
118
if len(fr_ids)>0:
121
adj_ids = adjust_line_obj.search(self.cr,self.uid,[('adjustment_id','=',fr_ids[0])])
119
adj_ids = adjust_line_obj.search(self.cr,self.uid,[('adjustment_id','=',fr_ids[0])],order='date_admin')
122
120
#Data to review first and add more records to be printed before ordering and send to rml.
123
121
data = adjust_obj.browse(self.cr,self.uid, fr_ids)
124
122
data_line = adjust_line_obj.browse(self.cr,self.uid, adj_ids)
323
321
addr_obj = self.pool.get('res.partner.address')
324
322
addr_inv = 'NO HAY DIRECCION FISCAL DEFINIDA'
325
323
addr_ids = addr_obj.search(self.cr,self.uid,[('partner_id','=',idp), ('type','=','invoice')])
327
325
addr = addr_obj.browse(self.cr,self.uid, addr_ids[0])
328
326
addr_inv = (addr.street or '')+' '+(addr.street2 or '')+' '+(addr.zip or '')+ ' '+(addr.city or '')+ ' '+ (addr.country_id and addr.country_id.name or '')+ ', TELF.:'+(addr.phone or '')
338
336
addr_obj = self.pool.get('res.partner.address')
340
338
a_ids = addr_obj.search(self.cr,self.uid,[('partner_id','=',idp), ('type','=','invoice')])
342
340
a = addr_obj.browse(self.cr,self.uid, a_ids[0])
343
341
a_id = a.country_id.id
347
def _get_alicuota(self, tnom=None):
354
tax_obj = self.pool.get('account.tax')
355
tax_ids = tax_obj.search(self.cr,self.uid,[('name','=',tnom)])[0]
356
tax = tax_obj.browse(self.cr,self.uid, tax_ids)
358
return tax.amount*100
360
344
def _get_doc(self, inv_id=None):
362
346
Get String Document Type
418
395
res = self.cr.dictfetchone()
419
396
return res['total']
398
def _get_book_type(self,form):
400
book_type='fiscal.reports.sale'
401
if form['type']=='purchase':
402
book_type='fiscal.reports.purchase'
421
def _get_amount_untaxed_tax(self,form,percent):
406
def _get_amount_untaxed_tax(self,form,percent,nationality=''):
423
408
Return Amount Untaxed and Amount Tax, accorded percent of withholding vat
425
print 'ENTRANDOOO00000000000'
426
print 'PERCENT', percent
427
book_type='fiscal.reports.sale'
428
410
amount_untaxed=0.0
431
d1=form['date_start']
434
if form['type']=='purchase':
435
book_type='fiscal.reports.purchase'
413
book_type=self._get_book_type(form)
437
415
fr_obj = self.pool.get(book_type)
438
416
user_obj = self.pool.get('res.users')
440
418
user_ids = user_obj.search(self.cr,self.uid,[('id', '=', self.uid)])
441
fr_ids = fr_obj.search(self.cr,self.uid,[('ai_date_invoice', '<=', d2), ('ai_date_invoice', '>=', d1)])
419
fr_ids = fr_obj.search(self.cr,self.uid,[('ai_date_invoice', '<=', form['date_end']), ('ai_date_invoice', '>=', form['date_start'])])
443
421
user=user_obj.browse(self.cr,self.uid, [self.uid])
445
423
for d in fr_obj.browse(self.cr,self.uid, fr_ids):
446
print d.ai_amount_total
447
424
for tax in d.ai_id.tax_line:
449
426
if percent in tax.name:
451
#~ if self._get_p_country(user[0].company_id.partner_id.id)==self._get_p_country(d.ai_id.partner_id.id):
454
if d.ai_id.type in ['in_refund', 'out_refund']:
455
amount_untaxed+= tax.base * (-1)
456
amount_tax+= tax.amount * (-1)
427
if nationality=='nacional':
428
if self._get_p_country(user[0].company_id.partner_id.id)==self._get_p_country(d.ai_id.partner_id.id):
429
amount_untaxed+= self._get_amount_untaxed_tax2(d.ai_id.type,tax)[0]
430
amount_tax+= self._get_amount_untaxed_tax2(d.ai_id.type,tax)[1]
458
amount_untaxed+= tax.base
459
amount_tax+= tax.amount
432
if self._get_p_country(user[0].company_id.partner_id.id)!=self._get_p_country(d.ai_id.partner_id.id):
433
amount_untaxed+= self._get_amount_untaxed_tax2(d.ai_id.type,tax)[0]
434
amount_tax+= self._get_amount_untaxed_tax2(d.ai_id.type,tax)[1]
463
436
return (amount_untaxed,amount_tax)
465
#~ def _get_amount_untaxed_tax(self,type,tax):
466
#~ if d.ai_id.type in ['in_refund', 'out_refund']:
467
#~ amount_untaxed+= tax.base * (-1)
468
#~ amount_tax+= tax.amount * (-1)
470
#~ amount_untaxed+= tax.base
471
#~ amount_tax+= tax.amount
439
def _get_amount_untaxed_tax2(self,type,tax):
442
if type in ['in_refund', 'out_refund']:
443
amount_untaxed= tax.base * (-1)
444
amount_tax= tax.amount * (-1)
446
amount_untaxed= tax.base
447
amount_tax= tax.amount
448
return [amount_untaxed,amount_tax]
477
451
def _get_totals(self,form):
509
483
total=[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
512
485
for d in fr_obj.browse(self.cr,self.uid, fr_ids):
517
487
#Sum for Invoice in period
518
488
total[1]+=d.ai_amount_untaxed
519
489
total[2]+=d.ai_amount_tax