123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- # -*- coding: utf-8 -*-
- from openerp import models, fields, api
- class AccountInvoice(models.Model):
- _inherit = 'account.invoice'
- @api.model
- def getAccountInvoiceQuoteAnalysis(self,idInvoice):
- values = []
- ''' Account Invoice '''
- invoice = self.env['account.invoice'].browse(idInvoice)
- if (not invoice):
- return False
- ''' Move line'''
- moveLines = self.env['account.move.line'].search([('invoice','=',invoice.id),('debit','>',0),('date_maturity','!=', False)], order='date_maturity')
- quotaCont = 0
- for moveLine in moveLines:
- quotaCont += 1
- state = 'No pagado'
- if(moveLine.reconcile_ref and moveLine.amount_residual == 0):
- state = 'Pagado'
- elif (moveLine.reconcile_ref and moveLine.amount_residual > 0):
- state = 'Amortizado'
- interestIDS = map(lambda x: x.id, moveLine.interest_line_ids)
- interest = self.env['account.interest.line'].search([('id','in',interestIDS ),('state', '=', 'open')])
- values.append({
- 'dateMaturity' : moveLine.date_maturity,
- 'quotaNumber' : "%s/%s" %(quotaCont, len(moveLines)),
- 'amountQuota' : moveLine.debit,
- 'amountResidual' : moveLine.amount_residual,
- 'expiredDays' : interest.expired_days if(interest) else 0,
- 'amountInterest' : interest.amount_interest if(interest and interest.state == 'open') else 0,
- 'amountTotal' : (moveLine.amount_residual + interest.amount_interest) if(interest and interest.state == 'open') else moveLine.amount_residual,
- 'state' : state,
- 'value': moveLine.debit - moveLine.amount_residual,
- })
- return values
- @api.model
- def getInvoiceAccountStatemnete(self, invoiceId):
- return [{
- 'id': invoice.id,
- 'number': invoice.number,
- 'partner': {
- 'id' : invoice.partner_id.id,
- 'name' : invoice.partner_id.name,
- 'ruc' : invoice.partner_id.ruc or '',
- },
- 'amountTotal': invoice.amount_total,
- 'amountResidual': invoice.residual,
- 'currency': {
- 'thousandsSeparator': invoice.currency_id.thousands_separator,
- 'decimalPlaces': invoice.currency_id.decimal_places,
- 'decimalSeparator': invoice.currency_id.decimal_separator,
- 'name': invoice.currency_id.local_name,
- 'symbol ':invoice.currency_id.symbol,
- },
- 'company':{
- 'id': invoice.company_id.id,
- 'name': invoice.company_id.name,
- 'currencyCompany':{
- 'thousandsSeparator': invoice.company_id.currency_id.thousands_separator,
- 'decimalPlaces': invoice.company_id.currency_id.decimal_places,
- 'decimalSeparator': invoice.company_id.currency_id.decimal_separator,
- 'name': invoice.company_id.currency_id.local_name,
- 'symbol ':invoice.company_id.currency_id.symbol,
- },
- 'logo': invoice.company_id.logo,
- },
- } for invoice in self.env['account.invoice'].browse(invoiceId)]
- class ResCurrrency(models.Model):
- _inherit = 'res.currency'
- @api.model
- def getResCurrencyQuoteAnalysis(self,domain):
- AccountInvoice = self.env['account.invoice'].search(domain)
- ResCurrency = self.env['res.currency'].search([('id','=',AccountInvoice.currency_id.id)])
- values = []
- for currency in ResCurrency:
- values.append({
- 'symbol': currency.symbol,
- 'decimal_separator': currency.decimal_separator,
- 'decimal_places': currency.decimal_places,
- 'thousands_separator': currency.thousands_separator,
- 'symbol_position': currency.symbol_position,
- })
- return values
|