Added the get_absolute_url() method to the accounting transactions.
This commit is contained in:
parent
42fe685d53
commit
a48a885ed6
@ -20,6 +20,7 @@
|
||||
"""
|
||||
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
|
||||
|
||||
class Subject(models.Model):
|
||||
@ -101,6 +102,15 @@ class Transaction(models.Model):
|
||||
and credit_records[0].subject.code == "1111"
|
||||
and credit_records[0].summary is None)
|
||||
|
||||
def get_absolute_url(self):
|
||||
"""Returns the URL to view this transaction."""
|
||||
if self.is_cash_expense:
|
||||
return reverse("accounting:transaction", args=("expense", self.sn))
|
||||
elif self.is_cash_income:
|
||||
return reverse("accounting:transaction", args=("income", self.sn))
|
||||
else:
|
||||
return reverse("accounting:transaction", args=("transfer", self.sn))
|
||||
|
||||
def __str__(self):
|
||||
"""Returns the string representation of this accounting
|
||||
transaction."""
|
||||
|
@ -22,7 +22,7 @@
|
||||
<td>{{ record.debit_amount }}</td>
|
||||
<td>{{ record.credit_amount }}</td>
|
||||
<td>{{ record.amount }}</td>
|
||||
<td><a href="{% url "accounting:transaction" "transfer" record.transaction.sn %}">View</a></td>
|
||||
<td><a href="{{ record.transaction.get_absolute_url }}">View</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
Loading…
Reference in New Issue
Block a user