You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.3 KiB
43 lines
1.3 KiB
# -*- coding: utf-8 -*-
|
|
from django.db import models
|
|
|
|
from .base_models import BaseInvoiceModel, BaseItemInvoiceModel
|
|
from .. import consts
|
|
|
|
|
|
class Invoice(BaseInvoiceModel):
|
|
"""Счет."""
|
|
UNPAID = 1
|
|
PARTLY_PAID = 2
|
|
PAID = 3
|
|
|
|
PAID_CHOICES = (
|
|
(UNPAID, u'Нет'),
|
|
(PARTLY_PAID, u'Частично'),
|
|
(PAID, u'Да'),
|
|
)
|
|
|
|
paid_status = models.PositiveSmallIntegerField(u'Оплачен?', choices=PAID_CHOICES, default=UNPAID)
|
|
closed_status = models.BooleanField(u'Закрыт?', choices=consts.BOOL_CHOICES, default=False)
|
|
|
|
def docs_for_invoice(self):
|
|
doc_list = ['Faktura', 'Nakladn', 'AktRabot', ]
|
|
client_docs = {}
|
|
for doc in doc_list:
|
|
docs = models.get_model('docs', doc).objects.filter(invoice=self)
|
|
if docs:
|
|
client_docs[doc] = docs
|
|
return client_docs
|
|
|
|
class Meta(BaseInvoiceModel.Meta):
|
|
verbose_name = u'Счёт'
|
|
verbose_name_plural = u'Счета'
|
|
|
|
|
|
class InvoiceItem(BaseItemInvoiceModel):
|
|
"""Табличная часть счета."""
|
|
parent = models.ForeignKey(Invoice, related_name='invoice_items')
|
|
|
|
class Meta(BaseItemInvoiceModel.Meta):
|
|
verbose_name = u'Табл. часть счета'
|
|
verbose_name_plural = u'Табл. части счетов'
|
|
|