Improve accounting ease of use

This commit is contained in:
Skia
2016-06-24 19:43:11 +02:00
parent ace58f54b5
commit 1396f2ca84
8 changed files with 79 additions and 24 deletions

View File

@ -130,7 +130,7 @@ class GeneralJournal(models.Model):
self.amount = 0
self.effective_amount = 0
for o in self.operations.all():
if o.type == "credit":
if o.accounting_type.movement_type == "credit":
if o.done:
self.effective_amount += o.amount
self.amount += o.amount
@ -154,10 +154,6 @@ class Operation(models.Model):
invoice = models.FileField(upload_to='invoices', null=True, blank=True)
done = models.BooleanField(_('is done'), default=False)
accounting_type = models.ForeignKey('AccountingType', related_name="operations")
type = models.CharField(_('operation type'), max_length=8, choices=[
('debit', _('Debit')),
('credit', _('Credit')),
])
def save(self):
super(Operation, self).save()
@ -186,8 +182,8 @@ class Operation(models.Model):
return reverse('accounting:journal_details', kwargs={'j_id': self.journal.id})
def __str__(self):
return "%d | %s | %d € | %s | %s | %s" % (
self.id, self.type, self.amount, self.date, self.accounting_type, self.done,
return "%d | %d € | %s | %s | %s" % (
self.id, self.amount, self.date, self.accounting_type, self.done,
)
class AccountingType(models.Model):