account.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. 'expiredDays' : interest.expired_days if(interest) else 0,
  30. 'amountInterest' : interest.amount_interest if(interest and interest.state == 'open') else 0,
  31. 'amountTotal' : (moveLine.amount_residual + interest.amount_interest) if(interest and interest.state == 'open') else moveLine.amount_residual,
  32. 'state' : state,
  33. 'value': moveLine.debit - moveLine.amount_residual,
  34. })
  35. return values
  36. @api.model
  37. def getInvoiceAccountStatemnete(self, invoiceId):
  38. return [{
  39. 'id': invoice.id,
  40. 'number': invoice.number,
  41. 'partner': {
  42. 'id' : invoice.partner_id.id,
  43. 'name' : invoice.partner_id.name,
  44. 'ruc' : invoice.partner_id.ruc or '',
  45. },
  46. 'amountTotal': invoice.amount_total,
  47. 'amountResidual': invoice.residual,
  48. 'currency': {
  49. 'thousandsSeparator': invoice.currency_id.thousands_separator,
  50. 'decimalPlaces': invoice.currency_id.decimal_places,
  51. 'decimalSeparator': invoice.currency_id.decimal_separator,
  52. 'name': invoice.currency_id.local_name,
  53. 'symbol ':invoice.currency_id.symbol,
  54. },
  55. 'company':{
  56. 'id': invoice.company_id.id,
  57. 'name': invoice.company_id.name,
  58. 'currencyCompany':{
  59. 'thousandsSeparator': invoice.company_id.currency_id.thousands_separator,
  60. 'decimalPlaces': invoice.company_id.currency_id.decimal_places,
  61. 'decimalSeparator': invoice.company_id.currency_id.decimal_separator,
  62. 'name': invoice.company_id.currency_id.local_name,
  63. 'symbol ':invoice.company_id.currency_id.symbol,
  64. },
  65. 'logo': invoice.company_id.logo,
  66. },
  67. } for invoice in self.env['account.invoice'].browse(invoiceId)]
  68. class ResCurrrency(models.Model):
  69. _inherit = 'res.currency'
  70. @api.model
  71. def getResCurrencyQuoteAnalysis(self,domain):
  72. AccountInvoice = self.env['account.invoice'].search(domain)
  73. ResCurrency = self.env['res.currency'].search([('id','=',AccountInvoice.currency_id.id)])
  74. values = []
  75. for currency in ResCurrency:
  76. values.append({
  77. 'symbol': currency.symbol,
  78. 'decimal_separator': currency.decimal_separator,
  79. 'decimal_places': currency.decimal_places,
  80. 'thousands_separator': currency.thousands_separator,
  81. 'symbol_position': currency.symbol_position,
  82. })
  83. return values