~openerp-venezuela/openerp-venezuela-localization/l10n_ve_fiscal_report

« back to all changes in this revision

Viewing changes to l10n_ve_fiscal_reports/report/book.py

  • Committer: gabrielaquilarque97 at gmail
  • Date: 2011-09-09 21:55:10 UTC
  • Revision ID: gabrielaquilarque97@gmail.com-20110909215510-km98pwp183w03i1r

[IMP] Added function in the rml of table of totals.
[IMP] Added field expedient, for invoice of purchase.
[IMP] Fixed Translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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')])
326
 
        if addr_ids:                
 
324
        if addr_ids:
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 '')
329
327
        return addr_inv
338
336
        addr_obj = self.pool.get('res.partner.address')
339
337
        a_id = 1000
340
338
        a_ids = addr_obj.search(self.cr,self.uid,[('partner_id','=',idp), ('type','=','invoice')])
341
 
        if a_ids:                
 
339
        if a_ids:
342
340
            a = addr_obj.browse(self.cr,self.uid, a_ids[0])
343
341
            a_id = a.country_id.id
344
342
        return a_id 
345
343
 
346
 
 
347
 
    def _get_alicuota(self, tnom=None):
348
 
        '''
349
 
        Get Aliquot
350
 
        '''
351
 
        if not tnom:
352
 
            return []
353
 
 
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)
357
 
 
358
 
        return tax.amount*100
359
 
 
360
344
    def _get_doc(self, inv_id=None):
361
345
        '''
362
346
        Get String Document Type
367
351
        doc_type = ''
368
352
        if (inv.type=="in_invoice" or inv.type=="out_invoice") and inv.parent_id:
369
353
            doc_type = "ND"
 
354
        elif (inv.type=="in_invoice" or inv.type=="in_refund") and inv.expedient:
 
355
            doc_type="E"
370
356
        elif inv.type=='in_refund' or inv.type=='out_refund':
371
357
            doc_type = "NC"
372
358
        elif inv.type=="in_invoice" or inv.type=="out_invoice":
373
359
            doc_type = "F"
374
360
        return doc_type
375
361
 
376
 
 
377
362
    def _get_rif(self, vat=''):
378
363
        '''
379
364
        Get R.I.F.
382
367
            return []
383
368
        return vat[2:].replace(' ', '')
384
369
 
385
 
 
386
370
    def _get_month(self, form):
387
371
        '''
388
372
        return year and month
393
377
        res[1] = time.strptime(form['date_start'],"%Y-%m-%d")[0]
394
378
        return res
395
379
    
396
 
    def _get_dates(self, form):
397
 
        res=[]
398
 
        res.append(form['date_start'])
399
 
        res.append(form['date_end'])
400
 
        return res
401
 
 
402
 
 
403
380
    def _get_total_iva(self,form):
404
381
        '''
405
382
        Return Amount Total of each invoice at Withholding Vat
417
394
        
418
395
        res = self.cr.dictfetchone()
419
396
        return res['total']
 
397
 
 
398
    def _get_book_type(self,form):
 
399
        book_type=None
 
400
        book_type='fiscal.reports.sale'
 
401
        if form['type']=='purchase':
 
402
            book_type='fiscal.reports.purchase'
420
403
        
421
 
    def _get_amount_untaxed_tax(self,form,percent):
 
404
        return book_type
 
405
 
 
406
    def _get_amount_untaxed_tax(self,form,percent,nationality=''):
422
407
        '''
423
408
        Return Amount Untaxed and Amount Tax, accorded percent of withholding vat
424
409
        '''
425
 
        print 'ENTRANDOOO00000000000'
426
 
        print 'PERCENT', percent
427
 
        book_type='fiscal.reports.sale'
428
410
        amount_untaxed=0.0
429
411
        amount_tax=0.0
430
412
 
431
 
        d1=form['date_start']
432
 
        d2=form['date_end']
433
 
 
434
 
        if form['type']=='purchase':
435
 
            book_type='fiscal.reports.purchase'
436
 
        
 
413
        book_type=self._get_book_type(form)
 
414
    
437
415
        fr_obj = self.pool.get(book_type)
438
416
        user_obj = self.pool.get('res.users')
439
417
        
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'])])
442
420
 
443
421
        user=user_obj.browse(self.cr,self.uid, [self.uid])
444
422
        
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:
448
425
                
449
426
                if percent in tax.name:
450
 
                    
451
 
                    #~ if self._get_p_country(user[0].company_id.partner_id.id)==self._get_p_country(d.ai_id.partner_id.id):
452
 
                        
453
 
                    
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]
457
431
                    else:
458
 
                        amount_untaxed+= tax.base
459
 
                        amount_tax+= tax.amount
460
 
                    #~ else:
461
 
                        
462
 
        
 
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]
 
435
 
463
436
        return (amount_untaxed,amount_tax)
464
 
       
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)
469
 
        #~ else:
470
 
            #~ amount_untaxed+= tax.base
471
 
            #~ amount_tax+= tax.amount
472
 
        #~ 
473
 
    
474
 
    
475
 
 
 
437
 
 
438
 
 
439
    def _get_amount_untaxed_tax2(self,type,tax):
 
440
        amount_untaxed=0.0
 
441
        amount_tax=0.0
 
442
        if type in ['in_refund', 'out_refund']:
 
443
            amount_untaxed= tax.base * (-1)
 
444
            amount_tax= tax.amount * (-1)
 
445
        else:
 
446
            amount_untaxed= tax.base
 
447
            amount_tax= tax.amount
 
448
        return [amount_untaxed,amount_tax]
 
449
    
476
450
 
477
451
    def _get_totals(self,form):
478
452
        '''
508
482
        
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]
510
484
 
511
 
 
512
485
        for d in fr_obj.browse(self.cr,self.uid, fr_ids):
513
486
            
514
 
            
515
 
            
516
 
            
517
487
            #Sum for Invoice in period
518
488
            total[1]+=d.ai_amount_untaxed
519
489
            total[2]+=d.ai_amount_tax
531
501
                    total[7]+=d.ai_amount_untaxed
532
502
                    total[8]+=d.ai_amount_tax
533
503
 
534
 
 
535
 
 
536
 
 
537
 
 
538
504
            for tax in d.ai_id.tax_line:
539
505
                if self._get_p_country(user[0].company_id.partner_id.id)==self._get_p_country(d.ai_id.partner_id.id):
540
506
                    if '12%' in tax.name: