django-ledger 0.6.3__py3-none-any.whl → 0.7.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of django-ledger might be problematic. Click here for more details.
- django_ledger/__init__.py +1 -4
- django_ledger/admin/coa.py +1 -2
- django_ledger/contrib/django_ledger_graphene/accounts/schema.py +1 -1
- django_ledger/forms/account.py +60 -44
- django_ledger/forms/bank_account.py +3 -2
- django_ledger/forms/bill.py +24 -36
- django_ledger/forms/customer.py +1 -1
- django_ledger/forms/data_import.py +3 -3
- django_ledger/forms/estimate.py +1 -1
- django_ledger/forms/invoice.py +5 -7
- django_ledger/forms/item.py +24 -15
- django_ledger/forms/transactions.py +3 -3
- django_ledger/io/io_core.py +4 -2
- django_ledger/io/io_middleware.py +5 -0
- django_ledger/io/roles.py +6 -0
- django_ledger/migrations/0017_alter_accountmodel_unique_together_and_more.py +31 -0
- django_ledger/models/accounts.py +629 -342
- django_ledger/models/bank_account.py +0 -4
- django_ledger/models/bill.py +0 -3
- django_ledger/models/closing_entry.py +0 -3
- django_ledger/models/coa.py +59 -48
- django_ledger/models/coa_default.py +9 -8
- django_ledger/models/customer.py +0 -4
- django_ledger/models/data_import.py +0 -3
- django_ledger/models/entity.py +80 -40
- django_ledger/models/estimate.py +0 -9
- django_ledger/models/invoice.py +0 -3
- django_ledger/models/items.py +4 -6
- django_ledger/models/journal_entry.py +2 -5
- django_ledger/models/ledger.py +0 -3
- django_ledger/models/mixins.py +0 -3
- django_ledger/models/purchase_order.py +0 -4
- django_ledger/models/signals.py +0 -3
- django_ledger/models/transactions.py +2 -5
- django_ledger/models/unit.py +0 -3
- django_ledger/models/utils.py +0 -3
- django_ledger/models/vendor.py +0 -3
- django_ledger/report/cash_flow_statement.py +1 -1
- django_ledger/static/.DS_Store +0 -0
- django_ledger/static/django_ledger/.DS_Store +0 -0
- django_ledger/static/django_ledger/logo_2/.DS_Store +0 -0
- django_ledger/static/django_ledger/logo_2/django_ledger_logo_dark.png +0 -0
- django_ledger/static/django_ledger/logo_2/django_ledger_logo_dark@0.5x.png +0 -0
- django_ledger/static/django_ledger/logo_2/django_ledger_logo_dark@2x.png +0 -0
- django_ledger/static/django_ledger/logo_2/django_ledger_logo_dark@3x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-full-vert.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-full-vert@0.5x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-full-vert@2x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-full-vert@3x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-logo-full-horiz.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-logo-full-horiz@0.5x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-logo-full-horiz@2x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-logo-full-horiz@3x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-logo-full-vert.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-logo-full-vert@0.5x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-logo-full-vert@2x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-logo-full-vert@3x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-logo.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-logo@0.5x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-logo@2x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-logo@3x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-txt-full-horiz.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-txt-full-horiz@0.5x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-txt-full-horiz@2x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-txt-full-horiz@3x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-txt-full-vert.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-txt-full-vert@0.5x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-txt-full-vert@2x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-txt-full-vert@3x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-txt-horiz.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-txt-horiz@0.5x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-txt-horiz@2x.png +0 -0
- django_ledger/static/django_ledger/logo_2/djl-txt-horiz@3x.png +0 -0
- django_ledger/templates/django_ledger/account/account_create.html +2 -2
- django_ledger/templates/django_ledger/account/account_update.html +1 -1
- django_ledger/templates/django_ledger/account/tags/account_txs_table.html +1 -0
- django_ledger/templates/django_ledger/account/tags/accounts_table.html +27 -18
- django_ledger/templates/django_ledger/bills/bill_detail.html +3 -3
- django_ledger/templates/django_ledger/expense/tags/expense_item_table.html +7 -0
- django_ledger/templates/django_ledger/invoice/invoice_detail.html +3 -3
- django_ledger/templatetags/django_ledger.py +7 -1
- django_ledger/tests/base.py +23 -7
- django_ledger/tests/test_accounts.py +145 -9
- django_ledger/urls/account.py +17 -24
- django_ledger/utils.py +8 -0
- django_ledger/views/__init__.py +1 -1
- django_ledger/views/account.py +80 -118
- django_ledger/views/auth.py +1 -1
- django_ledger/views/bank_account.py +9 -11
- django_ledger/views/bill.py +91 -80
- django_ledger/views/closing_entry.py +8 -0
- django_ledger/views/coa.py +2 -1
- django_ledger/views/customer.py +1 -1
- django_ledger/views/data_import.py +1 -1
- django_ledger/views/entity.py +1 -1
- django_ledger/views/estimate.py +13 -8
- django_ledger/views/feedback.py +1 -1
- django_ledger/views/financial_statement.py +1 -1
- django_ledger/views/home.py +1 -1
- django_ledger/views/inventory.py +9 -0
- django_ledger/views/invoice.py +5 -2
- django_ledger/views/item.py +58 -68
- django_ledger/views/journal_entry.py +1 -1
- django_ledger/views/ledger.py +3 -1
- django_ledger/views/mixins.py +9 -8
- django_ledger/views/purchase_order.py +1 -1
- django_ledger/views/transactions.py +1 -1
- django_ledger/views/unit.py +9 -0
- django_ledger/views/vendor.py +1 -1
- {django_ledger-0.6.3.dist-info → django_ledger-0.7.0.dist-info}/AUTHORS.md +8 -2
- {django_ledger-0.6.3.dist-info → django_ledger-0.7.0.dist-info}/METADATA +34 -43
- {django_ledger-0.6.3.dist-info → django_ledger-0.7.0.dist-info}/RECORD +115 -79
- {django_ledger-0.6.3.dist-info → django_ledger-0.7.0.dist-info}/WHEEL +1 -1
- {django_ledger-0.6.3.dist-info → django_ledger-0.7.0.dist-info}/top_level.txt +0 -1
- {django_ledger-0.6.3.dist-info → django_ledger-0.7.0.dist-info}/LICENSE +0 -0
django_ledger/views/bill.py
CHANGED
|
@@ -13,34 +13,41 @@ from django.shortcuts import get_object_or_404
|
|
|
13
13
|
from django.urls import reverse
|
|
14
14
|
from django.utils.html import format_html
|
|
15
15
|
from django.utils.translation import gettext_lazy as _
|
|
16
|
-
from django.views.generic import (
|
|
17
|
-
|
|
16
|
+
from django.views.generic import (
|
|
17
|
+
UpdateView, CreateView, ArchiveIndexView, MonthArchiveView, YearArchiveView,
|
|
18
|
+
DetailView, RedirectView
|
|
19
|
+
)
|
|
18
20
|
from django.views.generic.detail import SingleObjectMixin
|
|
19
21
|
|
|
20
|
-
from django_ledger.forms.bill import (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
from django_ledger.forms.bill import (
|
|
23
|
+
BillModelCreateForm,
|
|
24
|
+
BaseBillModelUpdateForm,
|
|
25
|
+
DraftBillModelUpdateForm,
|
|
26
|
+
get_bill_itemtxs_formset_class,
|
|
27
|
+
BillModelConfigureForm,
|
|
28
|
+
InReviewBillModelUpdateForm,
|
|
29
|
+
ApprovedBillModelUpdateForm,
|
|
30
|
+
AccruedAndApprovedBillModelUpdateForm,
|
|
31
|
+
PaidBillModelUpdateForm
|
|
32
|
+
)
|
|
25
33
|
from django_ledger.io.io_core import get_localdate
|
|
26
|
-
from django_ledger.models import EntityModel, PurchaseOrderModel, EstimateModel
|
|
34
|
+
from django_ledger.models import EntityModel, PurchaseOrderModel, EstimateModel, BillModelQuerySet
|
|
27
35
|
from django_ledger.models.bill import BillModel
|
|
28
36
|
from django_ledger.views.mixins import DjangoLedgerSecurityMixIn
|
|
29
37
|
|
|
30
38
|
|
|
31
|
-
class
|
|
39
|
+
class BillModelModelBaseView(DjangoLedgerSecurityMixIn):
|
|
32
40
|
queryset = None
|
|
33
41
|
|
|
34
42
|
def get_queryset(self):
|
|
35
43
|
if self.queryset is None:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
).select_related('vendor', 'ledger', 'ledger__entity').order_by('-updated')
|
|
44
|
+
entity_model: EntityModel = self.get_authorized_entity_instance()
|
|
45
|
+
qs: BillModelQuerySet = entity_model.get_bills()
|
|
46
|
+
self.queryset = qs
|
|
40
47
|
return super().get_queryset()
|
|
41
48
|
|
|
42
49
|
|
|
43
|
-
class BillModelCreateView(
|
|
50
|
+
class BillModelCreateView(BillModelModelBaseView, CreateView):
|
|
44
51
|
template_name = 'django_ledger/bills/bill_create.html'
|
|
45
52
|
PAGE_TITLE = _('Create Bill')
|
|
46
53
|
extra_context = {
|
|
@@ -51,19 +58,19 @@ class BillModelCreateView(DjangoLedgerSecurityMixIn, CreateView):
|
|
|
51
58
|
for_purchase_order = False
|
|
52
59
|
for_estimate = False
|
|
53
60
|
|
|
54
|
-
def get(self, request,
|
|
61
|
+
def get(self, request, **kwargs):
|
|
55
62
|
if not request.user.is_authenticated:
|
|
56
63
|
return HttpResponseForbidden()
|
|
57
64
|
|
|
58
65
|
if self.for_estimate and 'ce_pk' in self.kwargs:
|
|
59
66
|
estimate_qs = EstimateModel.objects.for_entity(
|
|
60
|
-
entity_slug=entity_slug,
|
|
67
|
+
entity_slug=self.kwargs['entity_slug'],
|
|
61
68
|
user_model=self.request.user
|
|
62
69
|
)
|
|
63
70
|
estimate_model: EstimateModel = get_object_or_404(estimate_qs, uuid__exact=self.kwargs['ce_pk'])
|
|
64
71
|
if not estimate_model.can_bind():
|
|
65
72
|
return HttpResponseNotFound('404 Not Found')
|
|
66
|
-
return super(BillModelCreateView, self).get(request,
|
|
73
|
+
return super(BillModelCreateView, self).get(request, **kwargs)
|
|
67
74
|
|
|
68
75
|
def get_context_data(self, **kwargs):
|
|
69
76
|
context = super(BillModelCreateView, self).get_context_data(**kwargs)
|
|
@@ -121,10 +128,11 @@ class BillModelCreateView(DjangoLedgerSecurityMixIn, CreateView):
|
|
|
121
128
|
}
|
|
122
129
|
|
|
123
130
|
def get_form(self, form_class=None):
|
|
124
|
-
|
|
125
|
-
return BillModelCreateForm(
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
entity_model: EntityModel = self.get_authorized_entity_instance()
|
|
132
|
+
return BillModelCreateForm(
|
|
133
|
+
entity_model=entity_model,
|
|
134
|
+
**self.get_form_kwargs()
|
|
135
|
+
)
|
|
128
136
|
|
|
129
137
|
def form_valid(self, form):
|
|
130
138
|
bill_model: BillModel = form.save(commit=False)
|
|
@@ -200,14 +208,17 @@ class BillModelCreateView(DjangoLedgerSecurityMixIn, CreateView):
|
|
|
200
208
|
})
|
|
201
209
|
|
|
202
210
|
|
|
203
|
-
class BillModelListView(
|
|
211
|
+
class BillModelListView(BillModelModelBaseView, ArchiveIndexView):
|
|
204
212
|
template_name = 'django_ledger/bills/bill_list.html'
|
|
205
213
|
context_object_name = 'bills'
|
|
206
214
|
PAGE_TITLE = _('Bill List')
|
|
215
|
+
|
|
216
|
+
# todo: can this be status date?...
|
|
207
217
|
date_field = 'date_draft'
|
|
208
218
|
paginate_by = 20
|
|
209
219
|
paginate_orphans = 2
|
|
210
220
|
allow_empty = True
|
|
221
|
+
ordering = '-updated'
|
|
211
222
|
extra_context = {
|
|
212
223
|
'page_title': PAGE_TITLE,
|
|
213
224
|
'header_title': PAGE_TITLE,
|
|
@@ -226,7 +237,7 @@ class BillModelMonthListView(MonthArchiveView, BillModelListView):
|
|
|
226
237
|
date_list_period = 'year'
|
|
227
238
|
|
|
228
239
|
|
|
229
|
-
class BillModelDetailView(
|
|
240
|
+
class BillModelDetailView(BillModelModelBaseView, DetailView):
|
|
230
241
|
slug_url_kwarg = 'bill_pk'
|
|
231
242
|
slug_field = 'uuid'
|
|
232
243
|
context_object_name = 'bill'
|
|
@@ -264,20 +275,21 @@ class BillModelDetailView(DjangoLedgerSecurityMixIn, DetailView):
|
|
|
264
275
|
return context
|
|
265
276
|
|
|
266
277
|
def get_queryset(self):
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
user_model=self.request.user
|
|
270
|
-
).select_related(
|
|
278
|
+
qs = super().get_queryset()
|
|
279
|
+
return qs.select_related(
|
|
271
280
|
'ledger',
|
|
272
281
|
'ledger__entity',
|
|
273
282
|
'vendor',
|
|
274
283
|
'cash_account',
|
|
275
284
|
'prepaid_account',
|
|
276
|
-
'unearned_account'
|
|
285
|
+
'unearned_account',
|
|
286
|
+
'cash_account__coa_model',
|
|
287
|
+
'prepaid_account__coa_model',
|
|
288
|
+
'unearned_account__coa_model'
|
|
277
289
|
)
|
|
278
290
|
|
|
279
291
|
|
|
280
|
-
class BillModelUpdateView(
|
|
292
|
+
class BillModelUpdateView(BillModelModelBaseView, UpdateView):
|
|
281
293
|
slug_url_kwarg = 'bill_pk'
|
|
282
294
|
slug_field = 'uuid'
|
|
283
295
|
context_object_name = 'bill_model'
|
|
@@ -288,22 +300,17 @@ class BillModelUpdateView(DjangoLedgerSecurityMixIn, UpdateView):
|
|
|
288
300
|
http_method_names = ['get', 'post']
|
|
289
301
|
action_update_items = False
|
|
290
302
|
|
|
291
|
-
def get_itemtxs_qs(self):
|
|
292
|
-
bill_model: BillModel = self.object
|
|
293
|
-
return bill_model.itemtransactionmodel_set.select_related(
|
|
294
|
-
'item_model', 'po_model', 'bill_model').order_by(
|
|
295
|
-
'-total_amount')
|
|
296
|
-
|
|
297
303
|
def get_form(self, form_class=None):
|
|
298
304
|
form_class = self.get_form_class()
|
|
305
|
+
entity_model: EntityModel = self.get_authorized_entity_instance()
|
|
299
306
|
if self.request.method == 'POST' and self.action_update_items:
|
|
300
307
|
return form_class(
|
|
301
|
-
|
|
308
|
+
entity_model=entity_model,
|
|
302
309
|
user_model=self.request.user,
|
|
303
310
|
instance=self.object
|
|
304
311
|
)
|
|
305
312
|
return form_class(
|
|
306
|
-
|
|
313
|
+
entity_model=entity_model,
|
|
307
314
|
user_model=self.request.user,
|
|
308
315
|
**self.get_form_kwargs()
|
|
309
316
|
)
|
|
@@ -324,10 +331,14 @@ class BillModelUpdateView(DjangoLedgerSecurityMixIn, UpdateView):
|
|
|
324
331
|
return PaidBillModelUpdateForm
|
|
325
332
|
return BaseBillModelUpdateForm
|
|
326
333
|
|
|
327
|
-
def get_context_data(self,
|
|
334
|
+
def get_context_data(self,
|
|
335
|
+
*,
|
|
336
|
+
object_list=None,
|
|
328
337
|
itemtxs_formset=None,
|
|
329
338
|
**kwargs):
|
|
339
|
+
|
|
330
340
|
context = super().get_context_data(object_list=object_list, **kwargs)
|
|
341
|
+
entity_model: EntityModel = self.get_authorized_entity_instance()
|
|
331
342
|
bill_model: BillModel = self.object
|
|
332
343
|
ledger_model = bill_model.ledger
|
|
333
344
|
|
|
@@ -363,20 +374,14 @@ class BillModelUpdateView(DjangoLedgerSecurityMixIn, UpdateView):
|
|
|
363
374
|
f'This bill has not been posted. Must post to see ledger changes.',
|
|
364
375
|
extra_tags='is-info')
|
|
365
376
|
|
|
377
|
+
itemtxs_qs = itemtxs_formset.get_queryset() if itemtxs_formset else None
|
|
366
378
|
if not itemtxs_formset:
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
itemtxs_formset = invoice_itemtxs_formset_class(
|
|
371
|
-
entity_slug=self.kwargs['entity_slug'],
|
|
372
|
-
user_model=self.request.user,
|
|
373
|
-
bill_model=bill_model,
|
|
374
|
-
queryset=itemtxs_qs
|
|
375
|
-
)
|
|
376
|
-
else:
|
|
377
|
-
itemtxs_qs, itemtxs_agg = bill_model.get_itemtxs_data(queryset=itemtxs_formset.queryset)
|
|
379
|
+
itemtxs_formset_class = get_bill_itemtxs_formset_class(bill_model)
|
|
380
|
+
itemtxs_formset = itemtxs_formset_class(entity_model=entity_model, bill_model=bill_model)
|
|
381
|
+
itemtxs_qs, itemtxs_agg = bill_model.get_itemtxs_data(queryset=itemtxs_qs)
|
|
378
382
|
|
|
379
383
|
has_po = any(i.po_model_id for i in itemtxs_qs)
|
|
384
|
+
|
|
380
385
|
if has_po:
|
|
381
386
|
itemtxs_formset.can_delete = False
|
|
382
387
|
itemtxs_formset.has_po = has_po
|
|
@@ -396,12 +401,18 @@ class BillModelUpdateView(DjangoLedgerSecurityMixIn, UpdateView):
|
|
|
396
401
|
})
|
|
397
402
|
|
|
398
403
|
def get_queryset(self):
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
'
|
|
404
|
-
'
|
|
404
|
+
qs = super().get_queryset()
|
|
405
|
+
return qs.select_related(
|
|
406
|
+
'ledger',
|
|
407
|
+
'ledger__entity',
|
|
408
|
+
'vendor',
|
|
409
|
+
'cash_account',
|
|
410
|
+
'prepaid_account',
|
|
411
|
+
'unearned_account',
|
|
412
|
+
'cash_account__coa_model',
|
|
413
|
+
'prepaid_account__coa_model',
|
|
414
|
+
'unearned_account__coa_model'
|
|
415
|
+
)
|
|
405
416
|
|
|
406
417
|
def form_valid(self, form):
|
|
407
418
|
form.save(commit=False)
|
|
@@ -411,37 +422,40 @@ class BillModelUpdateView(DjangoLedgerSecurityMixIn, UpdateView):
|
|
|
411
422
|
extra_tags='is-success')
|
|
412
423
|
return super().form_valid(form)
|
|
413
424
|
|
|
414
|
-
def get(self, request,
|
|
425
|
+
def get(self, request, *args, **kwargs):
|
|
415
426
|
if self.action_update_items:
|
|
416
427
|
return HttpResponseRedirect(
|
|
417
428
|
redirect_to=reverse('django_ledger:bill-update',
|
|
418
429
|
kwargs={
|
|
419
|
-
'entity_slug': entity_slug,
|
|
420
|
-
'bill_pk': bill_pk
|
|
430
|
+
'entity_slug': self.kwargs['entity_slug'],
|
|
431
|
+
'bill_pk': self.kwargs['bill_pk']
|
|
421
432
|
})
|
|
422
433
|
)
|
|
423
|
-
return super(BillModelUpdateView, self).get(request,
|
|
434
|
+
return super(BillModelUpdateView, self).get(request, *args, **kwargs)
|
|
424
435
|
|
|
425
|
-
def post(self, request,
|
|
436
|
+
def post(self, request, *args, **kwargs):
|
|
426
437
|
if self.action_update_items:
|
|
427
438
|
|
|
428
439
|
if not request.user.is_authenticated:
|
|
429
440
|
return HttpResponseForbidden()
|
|
430
441
|
|
|
431
442
|
queryset = self.get_queryset()
|
|
443
|
+
entity_model: EntityModel = self.get_authorized_entity_instance()
|
|
432
444
|
bill_model: BillModel = self.get_object(queryset=queryset)
|
|
445
|
+
bill_pk = bill_model.uuid
|
|
446
|
+
|
|
433
447
|
self.object = bill_model
|
|
448
|
+
|
|
434
449
|
bill_itemtxs_formset_class = get_bill_itemtxs_formset_class(bill_model)
|
|
435
|
-
itemtxs_formset = bill_itemtxs_formset_class(
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
450
|
+
itemtxs_formset = bill_itemtxs_formset_class(
|
|
451
|
+
request.POST,
|
|
452
|
+
bill_model=bill_model,
|
|
453
|
+
entity_model=entity_model
|
|
454
|
+
)
|
|
439
455
|
|
|
440
456
|
if itemtxs_formset.has_changed():
|
|
441
457
|
if itemtxs_formset.is_valid():
|
|
442
458
|
itemtxs_list = itemtxs_formset.save(commit=False)
|
|
443
|
-
entity_qs = EntityModel.objects.for_user(user_model=self.request.user)
|
|
444
|
-
entity_model: EntityModel = get_object_or_404(entity_qs, slug__exact=entity_slug)
|
|
445
459
|
|
|
446
460
|
for itemtxs in itemtxs_list:
|
|
447
461
|
itemtxs.bill_model_id = bill_model.uuid
|
|
@@ -451,14 +465,17 @@ class BillModelUpdateView(DjangoLedgerSecurityMixIn, UpdateView):
|
|
|
451
465
|
itemtxs_qs = bill_model.update_amount_due()
|
|
452
466
|
bill_model.get_state(commit=True)
|
|
453
467
|
bill_model.clean()
|
|
454
|
-
bill_model.save(
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
468
|
+
bill_model.save(
|
|
469
|
+
update_fields=[
|
|
470
|
+
'amount_due',
|
|
471
|
+
'amount_receivable',
|
|
472
|
+
'amount_unearned',
|
|
473
|
+
'amount_earned',
|
|
474
|
+
'updated'
|
|
475
|
+
])
|
|
459
476
|
|
|
460
477
|
bill_model.migrate_state(
|
|
461
|
-
entity_slug=entity_slug,
|
|
478
|
+
entity_slug=self.kwargs['entity_slug'],
|
|
462
479
|
user_model=self.request.user,
|
|
463
480
|
itemtxs_qs=itemtxs_qs,
|
|
464
481
|
raise_exception=False
|
|
@@ -473,7 +490,7 @@ class BillModelUpdateView(DjangoLedgerSecurityMixIn, UpdateView):
|
|
|
473
490
|
return HttpResponseRedirect(
|
|
474
491
|
redirect_to=reverse('django_ledger:bill-update',
|
|
475
492
|
kwargs={
|
|
476
|
-
'entity_slug':
|
|
493
|
+
'entity_slug': entity_model.slug,
|
|
477
494
|
'bill_pk': bill_pk
|
|
478
495
|
})
|
|
479
496
|
)
|
|
@@ -483,18 +500,12 @@ class BillModelUpdateView(DjangoLedgerSecurityMixIn, UpdateView):
|
|
|
483
500
|
|
|
484
501
|
|
|
485
502
|
# ACTION VIEWS...
|
|
486
|
-
class BaseBillActionView(
|
|
503
|
+
class BaseBillActionView(BillModelModelBaseView, RedirectView, SingleObjectMixin):
|
|
487
504
|
http_method_names = ['get']
|
|
488
505
|
pk_url_kwarg = 'bill_pk'
|
|
489
506
|
action_name = None
|
|
490
507
|
commit = True
|
|
491
508
|
|
|
492
|
-
def get_queryset(self):
|
|
493
|
-
return BillModel.objects.for_entity(
|
|
494
|
-
entity_slug=self.kwargs['entity_slug'],
|
|
495
|
-
user_model=self.request.user
|
|
496
|
-
).select_related('ledger', 'ledger__entity')
|
|
497
|
-
|
|
498
509
|
def get_redirect_url(self, *args, **kwargs):
|
|
499
510
|
return reverse('django_ledger:bill-update',
|
|
500
511
|
kwargs={
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Django Ledger created by Miguel Sanda <msanda@arrobalytics.com>.
|
|
3
|
+
Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
|
|
4
|
+
|
|
5
|
+
Contributions to this module:
|
|
6
|
+
* Miguel Sanda <msanda@arrobalytics.com>
|
|
7
|
+
"""
|
|
8
|
+
|
|
1
9
|
from django.contrib import messages
|
|
2
10
|
from django.core.exceptions import ValidationError, ImproperlyConfigured
|
|
3
11
|
from django.db.models import Count
|
django_ledger/views/coa.py
CHANGED
|
@@ -3,8 +3,9 @@ Django Ledger created by Miguel Sanda <msanda@arrobalytics.com>.
|
|
|
3
3
|
Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
|
|
4
4
|
|
|
5
5
|
Contributions to this module:
|
|
6
|
-
Miguel Sanda <msanda@arrobalytics.com>
|
|
6
|
+
* Miguel Sanda <msanda@arrobalytics.com>
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
from django.contrib import messages
|
|
9
10
|
from django.core.exceptions import ImproperlyConfigured, ValidationError
|
|
10
11
|
from django.db.models import Count, Q
|
django_ledger/views/customer.py
CHANGED
|
@@ -3,7 +3,7 @@ Django Ledger created by Miguel Sanda <msanda@arrobalytics.com>.
|
|
|
3
3
|
Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
|
|
4
4
|
|
|
5
5
|
Contributions to this module:
|
|
6
|
-
Miguel Sanda <msanda@arrobalytics.com>
|
|
6
|
+
* Miguel Sanda <msanda@arrobalytics.com>
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
from django.urls import reverse
|
|
@@ -3,7 +3,7 @@ Django Ledger created by Miguel Sanda <msanda@arrobalytics.com>.
|
|
|
3
3
|
Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
|
|
4
4
|
|
|
5
5
|
Contributions to this module:
|
|
6
|
-
Miguel Sanda <msanda@arrobalytics.com>
|
|
6
|
+
* Miguel Sanda <msanda@arrobalytics.com>
|
|
7
7
|
"""
|
|
8
8
|
from datetime import datetime, time
|
|
9
9
|
|
django_ledger/views/entity.py
CHANGED
|
@@ -3,7 +3,7 @@ Django Ledger created by Miguel Sanda <msanda@arrobalytics.com>.
|
|
|
3
3
|
Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
|
|
4
4
|
|
|
5
5
|
Contributions to this module:
|
|
6
|
-
Miguel Sanda <msanda@arrobalytics.com>
|
|
6
|
+
* Miguel Sanda <msanda@arrobalytics.com>
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
from datetime import timedelta
|
django_ledger/views/estimate.py
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Django Ledger created by Miguel Sanda <msanda@arrobalytics.com>.
|
|
3
|
+
Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
|
|
4
|
+
|
|
5
|
+
Contributions to this module:
|
|
6
|
+
* Miguel Sanda <msanda@arrobalytics.com>
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
|
|
1
10
|
from django.contrib import messages
|
|
2
11
|
from django.core.exceptions import ValidationError, ImproperlyConfigured
|
|
3
12
|
from django.http import HttpResponseRedirect, HttpResponseForbidden
|
|
@@ -10,7 +19,7 @@ from django.views.generic.detail import SingleObjectMixin
|
|
|
10
19
|
from django_ledger.forms.estimate import (EstimateModelCreateForm, BaseEstimateModelUpdateForm,
|
|
11
20
|
CanEditEstimateItemModelFormset, ReadOnlyEstimateItemModelFormset,
|
|
12
21
|
DraftEstimateModelUpdateForm)
|
|
13
|
-
from django_ledger.models import EntityModel
|
|
22
|
+
from django_ledger.models import EntityModel
|
|
14
23
|
from django_ledger.models.estimate import EstimateModel
|
|
15
24
|
from django_ledger.views import DjangoLedgerSecurityMixIn
|
|
16
25
|
|
|
@@ -20,10 +29,8 @@ class EstimateModelModelViewQuerySetMixIn:
|
|
|
20
29
|
|
|
21
30
|
def get_queryset(self):
|
|
22
31
|
if self.queryset is None:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
user_model=self.request.user
|
|
26
|
-
).select_related('customer', 'entity')
|
|
32
|
+
entity_model: EntityModel = getattr(self, 'AUTHORIZED_ENTITY_MODEL')
|
|
33
|
+
self.queryset = entity_model.estimatemodel_set.select_related('customer', 'entity')
|
|
27
34
|
return super().get_queryset()
|
|
28
35
|
|
|
29
36
|
|
|
@@ -70,9 +77,7 @@ class EstimateModelCreateView(DjangoLedgerSecurityMixIn, EstimateModelModelViewQ
|
|
|
70
77
|
|
|
71
78
|
def form_valid(self, form):
|
|
72
79
|
estimate_model: EstimateModel = form.save(commit=False)
|
|
73
|
-
|
|
74
|
-
entity_model: EntityModel = get_object_or_404(entity_model_qs, slug=self.kwargs['entity_slug'])
|
|
75
|
-
estimate_model.entity = entity_model
|
|
80
|
+
estimate_model.entity = self.AUTHORIZED_ENTITY_MODEL
|
|
76
81
|
return super(EstimateModelCreateView, self).form_valid(form)
|
|
77
82
|
|
|
78
83
|
|
django_ledger/views/feedback.py
CHANGED
|
@@ -3,7 +3,7 @@ Django Ledger created by Miguel Sanda <msanda@arrobalytics.com>.
|
|
|
3
3
|
Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
|
|
4
4
|
|
|
5
5
|
Contributions to this module:
|
|
6
|
-
Miguel Sanda <msanda@arrobalytics.com>
|
|
6
|
+
* Miguel Sanda <msanda@arrobalytics.com>
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
from django.core.mail import send_mail
|
|
@@ -3,7 +3,7 @@ Django Ledger created by Miguel Sanda <msanda@arrobalytics.com>.
|
|
|
3
3
|
Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
|
|
4
4
|
|
|
5
5
|
Contributions to this module:
|
|
6
|
-
Miguel Sanda <msanda@arrobalytics.com>
|
|
6
|
+
* Miguel Sanda <msanda@arrobalytics.com>
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
from django.shortcuts import get_object_or_404
|
django_ledger/views/home.py
CHANGED
|
@@ -3,7 +3,7 @@ Django Ledger created by Miguel Sanda <msanda@arrobalytics.com>.
|
|
|
3
3
|
Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
|
|
4
4
|
|
|
5
5
|
Contributions to this module:
|
|
6
|
-
Miguel Sanda <msanda@arrobalytics.com>
|
|
6
|
+
* Miguel Sanda <msanda@arrobalytics.com>
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
from django.urls import reverse
|
django_ledger/views/inventory.py
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Django Ledger created by Miguel Sanda <msanda@arrobalytics.com>.
|
|
3
|
+
Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
|
|
4
|
+
|
|
5
|
+
Contributions to this module:
|
|
6
|
+
* Miguel Sanda <msanda@arrobalytics.com>
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
|
|
1
10
|
from django.contrib import messages
|
|
2
11
|
from django.http import HttpResponseBadRequest, HttpResponseNotFound, HttpResponseRedirect
|
|
3
12
|
from django.urls import reverse
|
django_ledger/views/invoice.py
CHANGED
|
@@ -3,7 +3,7 @@ Django Ledger created by Miguel Sanda <msanda@arrobalytics.com>.
|
|
|
3
3
|
Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
|
|
4
4
|
|
|
5
5
|
Contributions to this module:
|
|
6
|
-
Miguel Sanda <msanda@arrobalytics.com>
|
|
6
|
+
* Miguel Sanda <msanda@arrobalytics.com>
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
from django.contrib import messages
|
|
@@ -391,7 +391,10 @@ class InvoiceModelDetailView(DjangoLedgerSecurityMixIn, InvoiceModelModelViewQue
|
|
|
391
391
|
'customer',
|
|
392
392
|
'cash_account',
|
|
393
393
|
'prepaid_account',
|
|
394
|
-
'unearned_account'
|
|
394
|
+
'unearned_account',
|
|
395
|
+
'cash_account__coa_model',
|
|
396
|
+
'prepaid_account__coa_model',
|
|
397
|
+
'unearned_account__coa_model'
|
|
395
398
|
)
|
|
396
399
|
|
|
397
400
|
|