account.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class AccountInvoice(models.Model):
  4. _inherit = 'account.invoice'
  5. @api.model
  6. def getAccountInvoiceQuoteAnalysis(self,idInvoice):
  7. values = []
  8. ''' Account Invoice '''
  9. invoice = self.env['account.invoice'].browse(idInvoice)
  10. if (not invoice):
  11. return False
  12. ''' Move line'''
  13. moveLines = self.env['account.move.line'].search([('invoice','=',invoice.id),('debit','>',0),('date_maturity','!=', False)], order='date_maturity')
  14. quotaCont = 0
  15. for moveLine in moveLines:
  16. quotaCont += 1
  17. state = 'No pagado'
  18. if(moveLine.reconcile_ref and moveLine.amount_residual == 0):
  19. state = 'Pagado'
  20. elif (moveLine.reconcile_ref and moveLine.amount_residual > 0):
  21. state = 'Amortizado'
  22. interestIDS = map(lambda x: x.id, moveLine.interest_line_ids)
  23. interest = self.env['account.interest.line'].search([('id','in',interestIDS ),('state', '=', 'open')])
  24. values.append({
  25. 'dateMaturity' : moveLine.date_maturity,
  26. 'quotaNumber' : "%s/%s" %(quotaCont, len(moveLines)),
  27. 'amountQuota' : moveLine.debit,
  28. 'amountResidual' : moveLine.amount_residual,
  29. 'expiredDaystot' : interest.expired_daystot if(interest) else 0,
  30. 'expiredDays' : interest.expired_days if(interest) else 0,
  31. 'amountInterest' : interest.amount_interest if(interest and interest.state == 'open') else 0,
  32. 'amountTotal' : (moveLine.amount_residual + interest.amount_interest) if(interest and interest.state == 'open') else moveLine.amount_residual,
  33. 'state' : state,
  34. 'value': moveLine.debit - moveLine.amount_residual,
  35. })
  36. return values
  37. @api.model
  38. def getInvoiceAccountStatemnete(self, invoiceId):
  39. return [{
  40. 'id': invoice.id,
  41. 'number': invoice.number,
  42. 'partner': {
  43. 'id' : invoice.partner_id.id,
  44. 'name' : invoice.partner_id.name,
  45. 'ruc' : invoice.partner_id.ruc or '',
  46. },
  47. 'amountTotal': invoice.amount_total,
  48. 'amountResidual': invoice.residual,
  49. 'currency': {
  50. 'thousandsSeparator': invoice.currency_id.thousands_separator,
  51. 'decimalPlaces': invoice.currency_id.decimal_places,
  52. 'decimalSeparator': invoice.currency_id.decimal_separator,
  53. 'name': invoice.currency_id.local_name,
  54. 'symbol ':invoice.currency_id.symbol,
  55. },
  56. 'company':{
  57. 'id': invoice.company_id.id,
  58. 'name': invoice.company_id.name,
  59. 'currencyCompany':{
  60. 'thousandsSeparator': invoice.company_id.currency_id.thousands_separator,
  61. 'decimalPlaces': invoice.company_id.currency_id.decimal_places,
  62. 'decimalSeparator': invoice.company_id.currency_id.decimal_separator,
  63. 'name': invoice.company_id.currency_id.local_name,
  64. 'symbol ':invoice.company_id.currency_id.symbol,
  65. },
  66. 'logo': invoice.company_id.logo,
  67. },
  68. } for invoice in self.env['account.invoice'].browse(invoiceId)]
  69. class ResCurrrency(models.Model):
  70. _inherit = 'res.currency'
  71. @api.model
  72. def getResCurrencyQuoteAnalysis(self,domain):
  73. AccountInvoice = self.env['account.invoice'].search(domain)
  74. ResCurrency = self.env['res.currency'].search([('id','=',AccountInvoice.currency_id.id)])
  75. values = []
  76. for currency in ResCurrency:
  77. values.append({
  78. 'symbol': currency.symbol,
  79. 'decimal_separator': currency.decimal_separator,
  80. 'decimal_places': currency.decimal_places,
  81. 'thousands_separator': currency.thousands_separator,
  82. 'symbol_position': currency.symbol_position,
  83. })
  84. return values