示例#1
0
 def testCriandoPagamento(self):
     iIDProjeto= 1
     iTipo1= constantes.cntTipoPagamento_CreditoOfertante
     self.oControle.criaPagamento(iIDProjeto, iTipo1)
     
     iTipo2= constantes.cntTipoPagamento_DebitoFreelancer
     iPagamento2= Pagamentos()
     iPagamento2.id_projeto= Projetos.objects.filter(id_projeto= iIDProjeto)[0]
     iPagamento2.id_estado_pagamento= Estado_do_Pagamento.objects.filter(id_estado= 2)[0]
     iPagamento2.id_tipo_pagamento= Tipo_de_Pagamento.objects.filter(id_tipo= iTipo2)[0]
     iPagamento2.id_usuario= Usuario.objects.all()[0]
     iPagamento2.valor= 850.00
     iPagamento2.desconto= 0.00
     iPagamento2.data= datetime.datetime.today()
     iPagamento2.save()
     
     self.assertEquals(iIDProjeto, Pagamentos.objects.filter(id_projeto= iIDProjeto)[0].id_projeto.id_projeto)
     self.assertEquals(iIDProjeto, Pagamentos.objects.filter(id_projeto= iIDProjeto)[1].id_projeto.id_projeto)
示例#2
0
 def criaPagamento(self, vIDProjeto, vTipo):
     try:
         iProjeto= self.oProjetoControle.obtemProjetoReal(vIDProjeto)
         if self.obtemPagamento(iProjeto, None, constantes.cntTipoPagamento_CreditoOfertante) != False:
             return True
         if vTipo == constantes.cntTipoPagamento_CreditoOfertante:
             iPagamento= Pagamentos()
             iPagamento.id_projeto= iProjeto
             iPagamento.id_usuario= iProjeto.id_proprietario
             iPagamento.id_tipo_pagamento= Tipo_de_Pagamento.objects.filter(id_tipo= constantes.cntTipoPagamento_CreditoOfertante)[0] 
             iPagamento.id_estado_pagamento= Estado_do_Pagamento.objects.filter(id_estado= constantes.cntEstadoPagamento_Pendente)[0]
             iPagamento.valor= self.oProjetoControle.obtemPropostaVencedora(vIDProjeto).valor
             iPagamento.data= str(datetime.datetime.today())[:19]
             iPagamento.desconto= '0.00'
             iPagamento.save()
         return True
     except Exception, e:
         self.getLogger().error('Nao foi possivel criar o pagamento: ' + str(e))
         return False