Advertisement
Guest User

Untitled

a guest
Aug 15th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. trasaction.py
  2.  
  3. from django.db import models
  4. from bee.models import ModelMixin
  5. from .extract import Extract
  6.  
  7.  
  8. class Transaction(ModelMixin):
  9. paying = models.OneToOneField(
  10. Extract,
  11. on_delete=models.CASCADE,
  12. related_name='paying',
  13. verbose_name='extrato pagamento'
  14. )
  15. receiver = models.OneToOneField(
  16. Extract,
  17. on_delete=models.CASCADE,
  18. related_name='receiver',
  19. verbose_name='extrato recebimento'
  20. )
  21. proof = models.CharField(
  22. max_length=19,
  23. unique=True,
  24. verbose_name='comprovante'
  25. )
  26. amount = models.DecimalField(
  27. max_digits=18,
  28. decimal_places=8,
  29. verbose_name='valor'
  30. )
  31. fee = models.DecimalField(
  32. max_digits=18,
  33. decimal_places=8,
  34. verbose_name='taxa'
  35. )
  36.  
  37. class Meta():
  38. verbose_name = "Transação"
  39. verbose_name_plural = 'Transações'
  40.  
  41. def invoice():
  42. return self.invoice
  43.  
  44. -----------------------------------------------------------------
  45.  
  46. payment.py
  47.  
  48. from django.db import models
  49. from bee.models import ModelMixin
  50. from .invoice import Invoice
  51. from wallet.models import Transaction
  52.  
  53.  
  54. class Payment(ModelMixin):
  55. invoice = models.ForeignKey(
  56. Invoice,
  57. on_delete=models.CASCADE,
  58. verbose_name='fatura'
  59. )
  60. transaction = models.OneToOneField(
  61. Transaction,
  62. on_delete=models.CASCADE,
  63. related_name='transaction',
  64. verbose_name='transação'
  65. )
  66.  
  67. class Meta:
  68. verbose_name = "Pagamento"
  69. verbose_name_plural = 'Pagamentos'
  70.  
  71. def __str__(self):
  72. return f'''
  73. {self.transaction.payment.user.username.lower()} > {self.transaction.receipt.user.username.lower()} |
  74. {self.transaction.payment.coin.code.upper()} {self.transaction.amount} | {self.transaction.proof}
  75. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement