django-ledger 0.6.4__py3-none-any.whl → 0.7.1__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/__init__.py +1 -1
- django_ledger/admin/{coa.py → chart_of_accounts.py} +1 -1
- django_ledger/admin/entity.py +1 -1
- django_ledger/contrib/django_ledger_graphene/accounts/schema.py +1 -1
- django_ledger/forms/account.py +43 -38
- django_ledger/forms/bank_account.py +5 -2
- django_ledger/forms/bill.py +24 -36
- django_ledger/forms/chart_of_accounts.py +82 -0
- 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_library.py +1 -1
- django_ledger/io/io_middleware.py +5 -0
- django_ledger/migrations/0017_alter_accountmodel_unique_together_and_more.py +31 -0
- django_ledger/migrations/0018_transactionmodel_cleared_transactionmodel_reconciled_and_more.py +37 -0
- django_ledger/models/__init__.py +1 -1
- django_ledger/models/accounts.py +229 -265
- django_ledger/models/bank_account.py +6 -6
- django_ledger/models/bill.py +7 -6
- django_ledger/models/{coa.py → chart_of_accounts.py} +187 -72
- django_ledger/models/closing_entry.py +5 -10
- django_ledger/models/coa_default.py +10 -9
- django_ledger/models/customer.py +6 -6
- django_ledger/models/data_import.py +12 -8
- django_ledger/models/entity.py +96 -39
- django_ledger/models/estimate.py +6 -10
- django_ledger/models/invoice.py +14 -11
- django_ledger/models/items.py +23 -14
- django_ledger/models/journal_entry.py +73 -30
- django_ledger/models/ledger.py +8 -8
- django_ledger/models/mixins.py +0 -3
- django_ledger/models/purchase_order.py +9 -9
- django_ledger/models/signals.py +0 -3
- django_ledger/models/transactions.py +24 -7
- django_ledger/models/unit.py +4 -3
- django_ledger/models/utils.py +0 -3
- django_ledger/models/vendor.py +4 -3
- django_ledger/settings.py +28 -3
- 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 +29 -19
- django_ledger/templates/django_ledger/bills/bill_detail.html +3 -3
- django_ledger/templates/django_ledger/chart_of_accounts/coa_create.html +25 -0
- django_ledger/templates/django_ledger/chart_of_accounts/coa_list.html +25 -6
- django_ledger/templates/django_ledger/chart_of_accounts/coa_update.html +2 -2
- django_ledger/templates/django_ledger/chart_of_accounts/includes/coa_card.html +10 -4
- django_ledger/templates/django_ledger/expense/tags/expense_item_table.html +7 -0
- django_ledger/templates/django_ledger/financial_statements/tags/balance_sheet_statement.html +2 -2
- django_ledger/templates/django_ledger/includes/footer.html +2 -2
- 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/urls/chart_of_accounts.py +6 -0
- django_ledger/utils.py +9 -36
- django_ledger/views/__init__.py +2 -2
- django_ledger/views/account.py +91 -116
- 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/{coa.py → chart_of_accounts.py} +49 -44
- django_ledger/views/closing_entry.py +8 -0
- 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 +25 -13
- 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.4.dist-info → django_ledger-0.7.1.dist-info}/AUTHORS.md +8 -2
- {django_ledger-0.6.4.dist-info → django_ledger-0.7.1.dist-info}/METADATA +33 -44
- {django_ledger-0.6.4.dist-info → django_ledger-0.7.1.dist-info}/RECORD +92 -89
- {django_ledger-0.6.4.dist-info → django_ledger-0.7.1.dist-info}/WHEEL +1 -1
- django_ledger/forms/coa.py +0 -47
- {django_ledger-0.6.4.dist-info → django_ledger-0.7.1.dist-info}/LICENSE +0 -0
- {django_ledger-0.6.4.dist-info → django_ledger-0.7.1.dist-info}/top_level.txt +0 -0
django_ledger/views/__init__.py
CHANGED
|
@@ -3,14 +3,14 @@ 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_ledger.views.account import *
|
|
10
10
|
from django_ledger.views.auth import *
|
|
11
11
|
from django_ledger.views.bank_account import *
|
|
12
12
|
from django_ledger.views.bill import *
|
|
13
|
-
from django_ledger.views.
|
|
13
|
+
from django_ledger.views.chart_of_accounts import *
|
|
14
14
|
from django_ledger.views.customer import *
|
|
15
15
|
from django_ledger.views.data_import import *
|
|
16
16
|
from django_ledger.views.djl_api import *
|
django_ledger/views/account.py
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Django Ledger created by Miguel Sanda <msanda@arrobalytics.com>.
|
|
3
3
|
Copyright© EDMA Group Inc licensed under the GPLv3 Agreement.
|
|
4
|
-
|
|
5
|
-
Contributions to this module:
|
|
6
|
-
Miguel Sanda <msanda@arrobalytics.com>
|
|
7
4
|
"""
|
|
5
|
+
|
|
8
6
|
from django.contrib import messages
|
|
9
7
|
from django.core.exceptions import ImproperlyConfigured, ValidationError
|
|
10
8
|
from django.http import HttpResponseRedirect
|
|
11
|
-
from django.shortcuts import get_object_or_404
|
|
12
9
|
from django.urls import reverse
|
|
13
10
|
from django.utils.translation import gettext as _
|
|
14
11
|
from django.views.generic import ListView, UpdateView, CreateView, DetailView
|
|
@@ -17,7 +14,7 @@ from django.views.generic.detail import SingleObjectMixin
|
|
|
17
14
|
|
|
18
15
|
from django_ledger.forms.account import AccountModelUpdateForm, AccountModelCreateForm
|
|
19
16
|
from django_ledger.io.io_core import get_localdate
|
|
20
|
-
from django_ledger.models import ChartOfAccountModel
|
|
17
|
+
from django_ledger.models import EntityModel, ChartOfAccountModel
|
|
21
18
|
from django_ledger.models.accounts import AccountModel
|
|
22
19
|
from django_ledger.views.mixins import (
|
|
23
20
|
YearlyReportMixIn, MonthlyReportMixIn, QuarterlyReportMixIn, DjangoLedgerSecurityMixIn,
|
|
@@ -25,58 +22,51 @@ from django_ledger.views.mixins import (
|
|
|
25
22
|
)
|
|
26
23
|
|
|
27
24
|
|
|
28
|
-
class
|
|
25
|
+
class BaseAccountModelBaseView(DjangoLedgerSecurityMixIn):
|
|
29
26
|
queryset = None
|
|
30
27
|
coa_model = None
|
|
31
28
|
|
|
32
|
-
def
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
self.coa_model = coa_model
|
|
29
|
+
def get_authorized_entity_queryset(self):
|
|
30
|
+
qs = super().get_authorized_entity_queryset()
|
|
31
|
+
return qs.select_related('admin', 'default_coa', 'default_coa__entity')
|
|
32
|
+
|
|
33
|
+
def get_coa_model(self):
|
|
34
|
+
if not self.coa_model:
|
|
35
|
+
entity_model: EntityModel = self.get_authorized_entity_instance()
|
|
36
|
+
self.coa_model = entity_model.chartofaccountmodel_set.get(slug__exact=self.kwargs['coa_slug'])
|
|
41
37
|
return self.coa_model
|
|
42
38
|
|
|
43
39
|
def get_queryset(self):
|
|
44
40
|
if self.queryset is None:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
entity_model: EntityModel = self.get_authorized_entity_instance()
|
|
42
|
+
coa_slug = self.kwargs['coa_slug']
|
|
43
|
+
|
|
44
|
+
coa_model, account_model_qs = entity_model.get_coa_accounts(
|
|
45
|
+
coa_model=entity_model.default_coa if coa_slug == entity_model.default_coa_slug else coa_slug,
|
|
46
|
+
return_coa_model=True,
|
|
47
|
+
active=False
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
account_model_qs = account_model_qs.select_related(
|
|
49
51
|
'coa_model',
|
|
50
52
|
'coa_model__entity'
|
|
51
53
|
).order_by(
|
|
52
|
-
'coa_model', 'role', 'code'
|
|
54
|
+
'coa_model', 'role', 'code'
|
|
55
|
+
).not_coa_root()
|
|
53
56
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if coa_slug:
|
|
58
|
-
qs = qs.filter(coa_model__slug__exact=coa_slug)
|
|
59
|
-
elif account_pk:
|
|
60
|
-
qs = qs.filter(uuid__exact=account_pk)
|
|
61
|
-
else:
|
|
62
|
-
qs = qs.filter(coa_model__slug__exact=self.AUTHORIZED_ENTITY_MODEL.default_coa.slug)
|
|
57
|
+
self.coa_model = coa_model
|
|
58
|
+
self.queryset = account_model_qs
|
|
63
59
|
|
|
64
|
-
self.queryset = qs
|
|
65
60
|
return super().get_queryset()
|
|
66
61
|
|
|
67
|
-
def get_context_data(self,
|
|
68
|
-
context = super().get_context_data(
|
|
69
|
-
|
|
70
|
-
if self.kwargs.get('coa_slug'):
|
|
71
|
-
coa_model_qs = entity_model.chartofaccountmodel_set.all()
|
|
72
|
-
context['coa_model'] = get_object_or_404(coa_model_qs, slug__exact=self.kwargs['coa_slug'])
|
|
73
|
-
else:
|
|
74
|
-
context['coa_model'] = entity_model.default_coa
|
|
62
|
+
def get_context_data(self, **kwargs):
|
|
63
|
+
context = super().get_context_data(**kwargs)
|
|
64
|
+
context['coa_model'] = self.get_coa_model()
|
|
75
65
|
return context
|
|
76
66
|
|
|
77
67
|
|
|
78
68
|
# Account Views ----
|
|
79
|
-
class AccountModelListView(
|
|
69
|
+
class AccountModelListView(BaseAccountModelBaseView, ListView):
|
|
80
70
|
template_name = 'django_ledger/account/account_list.html'
|
|
81
71
|
context_object_name = 'accounts'
|
|
82
72
|
PAGE_TITLE = _('Entity Accounts')
|
|
@@ -93,40 +83,17 @@ class AccountModelListView(DjangoLedgerSecurityMixIn, BaseAccountModelViewQueryS
|
|
|
93
83
|
return qs
|
|
94
84
|
|
|
95
85
|
|
|
96
|
-
class AccountModelUpdateView(DjangoLedgerSecurityMixIn, BaseAccountModelViewQuerySetMixIn, UpdateView):
|
|
97
|
-
context_object_name = 'account'
|
|
98
|
-
template_name = 'django_ledger/account/account_update.html'
|
|
99
|
-
slug_url_kwarg = 'account_pk'
|
|
100
|
-
slug_field = 'uuid'
|
|
101
86
|
|
|
102
|
-
def
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return
|
|
108
|
-
|
|
109
|
-
def get_form(self, form_class=None):
|
|
110
|
-
account_model = self.object
|
|
111
|
-
|
|
112
|
-
# Set here because user_model is needed to instantiate an instance of MoveNodeForm (AccountModelUpdateForm)
|
|
113
|
-
account_model.USER_MODEL = self.request.user
|
|
114
|
-
return AccountModelUpdateForm(
|
|
115
|
-
entity_model=self.AUTHORIZED_ENTITY_MODEL,
|
|
116
|
-
coa_model=self.get_coa_model(),
|
|
117
|
-
user_model=self.request.user,
|
|
118
|
-
**self.get_form_kwargs()
|
|
119
|
-
)
|
|
87
|
+
def get(self, request, *args, **kwargs):
|
|
88
|
+
response = super().get(request, *args, **kwargs)
|
|
89
|
+
chart_of_accounts_model: ChartOfAccountModel = self.get_coa_model()
|
|
90
|
+
if not chart_of_accounts_model.is_active():
|
|
91
|
+
messages.error(request, _('WARNING: The chart of accounts list is inactive.'), extra_tags='is-danger')
|
|
92
|
+
return response
|
|
120
93
|
|
|
121
|
-
def get_success_url(self):
|
|
122
|
-
entity_slug = self.kwargs['entity_slug']
|
|
123
|
-
return reverse('django_ledger:account-list',
|
|
124
|
-
kwargs={
|
|
125
|
-
'entity_slug': entity_slug,
|
|
126
|
-
})
|
|
127
94
|
|
|
128
95
|
|
|
129
|
-
class AccountModelCreateView(
|
|
96
|
+
class AccountModelCreateView(BaseAccountModelBaseView, CreateView):
|
|
130
97
|
template_name = 'django_ledger/account/account_create.html'
|
|
131
98
|
PAGE_TITLE = _('Create Account')
|
|
132
99
|
extra_context = {
|
|
@@ -138,58 +105,68 @@ class AccountModelCreateView(DjangoLedgerSecurityMixIn, BaseAccountModelViewQuer
|
|
|
138
105
|
|
|
139
106
|
def get_form(self, form_class=None):
|
|
140
107
|
return AccountModelCreateForm(
|
|
141
|
-
user_model=self.request.user,
|
|
142
|
-
entity_model=self.AUTHORIZED_ENTITY_MODEL,
|
|
143
108
|
coa_model=self.get_coa_model(),
|
|
144
109
|
**self.get_form_kwargs()
|
|
145
110
|
)
|
|
146
111
|
|
|
112
|
+
def get_initial(self):
|
|
113
|
+
return {
|
|
114
|
+
'coa_model': self.get_coa_model(),
|
|
115
|
+
}
|
|
116
|
+
|
|
147
117
|
def get_context_data(self, *args, **kwargs):
|
|
148
118
|
context = super().get_context_data(*args, **kwargs)
|
|
149
|
-
|
|
119
|
+
coa_model = self.get_coa_model()
|
|
120
|
+
context['coa_model'] = coa_model
|
|
121
|
+
context['header_subtitle'] = f'CoA: {coa_model.name}'
|
|
150
122
|
return context
|
|
151
123
|
|
|
152
|
-
def form_valid(self, form):
|
|
153
|
-
entity_model = self.AUTHORIZED_ENTITY_MODEL
|
|
124
|
+
def form_valid(self, form: AccountModelCreateForm):
|
|
154
125
|
account_model: AccountModel = form.save(commit=False)
|
|
155
|
-
|
|
156
|
-
if not entity_model.has_default_coa():
|
|
157
|
-
entity_model.create_chart_of_accounts(assign_as_default=True, commit=True)
|
|
158
|
-
|
|
159
|
-
coa_model = self.get_coa_model()
|
|
126
|
+
coa_model = account_model.coa_model
|
|
160
127
|
coa_model.insert_account(account_model=account_model)
|
|
161
128
|
return HttpResponseRedirect(self.get_success_url())
|
|
162
129
|
|
|
163
130
|
def get_success_url(self):
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if coa_slug:
|
|
167
|
-
return reverse('django_ledger:account-list-coa',
|
|
168
|
-
kwargs={
|
|
169
|
-
'entity_slug': entity_slug,
|
|
170
|
-
'coa_slug': coa_slug
|
|
171
|
-
})
|
|
172
|
-
return reverse('django_ledger:account-list',
|
|
173
|
-
kwargs={
|
|
174
|
-
'entity_slug': entity_slug,
|
|
175
|
-
})
|
|
131
|
+
coa_model: ChartOfAccountModel = self.get_coa_model()
|
|
132
|
+
return coa_model.get_account_list_url()
|
|
176
133
|
|
|
177
134
|
|
|
178
|
-
class
|
|
135
|
+
class AccountModelUpdateView(BaseAccountModelBaseView, UpdateView):
|
|
136
|
+
context_object_name = 'account'
|
|
137
|
+
template_name = 'django_ledger/account/account_update.html'
|
|
138
|
+
slug_url_kwarg = 'account_pk'
|
|
139
|
+
slug_field = 'uuid'
|
|
140
|
+
form_class = AccountModelUpdateForm
|
|
141
|
+
|
|
142
|
+
def get_context_data(self, **kwargs):
|
|
143
|
+
context = super().get_context_data(**kwargs)
|
|
144
|
+
context['page_title'] = _('Update Account')
|
|
145
|
+
context['header_title'] = _(f'Update Account: {self.object.code} - {self.object.name}')
|
|
146
|
+
context['header_subtitle_icon'] = 'ic:twotone-account-tree'
|
|
147
|
+
return context
|
|
148
|
+
|
|
149
|
+
def get_success_url(self):
|
|
150
|
+
coa_model: ChartOfAccountModel = self.get_coa_model()
|
|
151
|
+
return coa_model.get_account_list_url()
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
class AccountModelDetailView(BaseAccountModelBaseView, RedirectView):
|
|
179
155
|
|
|
180
156
|
def get_redirect_url(self, *args, **kwargs):
|
|
181
157
|
loc_date = get_localdate()
|
|
158
|
+
entity_model: EntityModel = self.get_authorized_entity_instance()
|
|
182
159
|
return reverse('django_ledger:account-detail-month',
|
|
183
160
|
kwargs={
|
|
184
|
-
'entity_slug':
|
|
161
|
+
'entity_slug': entity_model.slug,
|
|
185
162
|
'account_pk': self.kwargs['account_pk'],
|
|
163
|
+
'coa_slug': self.kwargs['coa_slug'],
|
|
186
164
|
'year': loc_date.year,
|
|
187
165
|
'month': loc_date.month,
|
|
188
166
|
})
|
|
189
167
|
|
|
190
168
|
|
|
191
|
-
class AccountModelYearDetailView(
|
|
192
|
-
BaseAccountModelViewQuerySetMixIn,
|
|
169
|
+
class AccountModelYearDetailView(BaseAccountModelBaseView,
|
|
193
170
|
BaseDateNavigationUrlMixIn,
|
|
194
171
|
EntityUnitMixIn,
|
|
195
172
|
YearlyReportMixIn,
|
|
@@ -205,23 +182,23 @@ class AccountModelYearDetailView(DjangoLedgerSecurityMixIn,
|
|
|
205
182
|
}
|
|
206
183
|
|
|
207
184
|
def get_context_data(self, **kwargs):
|
|
208
|
-
account = self.object
|
|
209
185
|
context = super().get_context_data(**kwargs)
|
|
210
|
-
context['
|
|
211
|
-
context['
|
|
212
|
-
|
|
186
|
+
account_model: AccountModel = context['object']
|
|
187
|
+
context['header_title'] = f'Account {account_model.code} - {account_model.name}'
|
|
188
|
+
context['page_title'] = f'Account {account_model.code} - {account_model.name}'
|
|
213
189
|
txs_qs = account_model.transactionmodel_set.all().posted().order_by(
|
|
214
|
-
'journal_entry__timestamp'
|
|
215
|
-
|
|
190
|
+
'journal_entry__timestamp'
|
|
191
|
+
).select_related(
|
|
192
|
+
'journal_entry',
|
|
193
|
+
'journal_entry__entity_unit',
|
|
194
|
+
'journal_entry__ledger__billmodel',
|
|
195
|
+
'journal_entry__ledger__invoicemodel',
|
|
196
|
+
)
|
|
216
197
|
txs_qs = txs_qs.from_date(self.get_from_date())
|
|
217
198
|
txs_qs = txs_qs.to_date(self.get_to_date())
|
|
218
199
|
context['transactions'] = txs_qs
|
|
219
200
|
return context
|
|
220
201
|
|
|
221
|
-
def get_queryset(self):
|
|
222
|
-
qs = super().get_queryset()
|
|
223
|
-
return qs.prefetch_related('transactionmodel_set')
|
|
224
|
-
|
|
225
202
|
|
|
226
203
|
class AccountModelQuarterDetailView(QuarterlyReportMixIn, AccountModelYearDetailView):
|
|
227
204
|
"""
|
|
@@ -242,9 +219,8 @@ class AccountModelDateDetailView(DateReportMixIn, AccountModelYearDetailView):
|
|
|
242
219
|
|
|
243
220
|
|
|
244
221
|
# ACTIONS...
|
|
245
|
-
class AccountModelModelActionView(
|
|
222
|
+
class AccountModelModelActionView(BaseAccountModelBaseView,
|
|
246
223
|
RedirectView,
|
|
247
|
-
BaseAccountModelViewQuerySetMixIn,
|
|
248
224
|
SingleObjectMixin):
|
|
249
225
|
http_method_names = ['get']
|
|
250
226
|
pk_url_kwarg = 'account_pk'
|
|
@@ -252,11 +228,8 @@ class AccountModelModelActionView(DjangoLedgerSecurityMixIn,
|
|
|
252
228
|
commit = True
|
|
253
229
|
|
|
254
230
|
def get_redirect_url(self, *args, **kwargs):
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
'entity_slug': kwargs['entity_slug'],
|
|
258
|
-
# 'account_pk': kwargs['account_pk']
|
|
259
|
-
})
|
|
231
|
+
account_model: AccountModel = self.get_object()
|
|
232
|
+
return account_model.get_coa_account_list_url()
|
|
260
233
|
|
|
261
234
|
def get(self, request, *args, **kwargs):
|
|
262
235
|
kwargs['user_model'] = self.request.user
|
|
@@ -268,8 +241,10 @@ class AccountModelModelActionView(DjangoLedgerSecurityMixIn,
|
|
|
268
241
|
try:
|
|
269
242
|
getattr(account_model, self.action_name)(commit=self.commit, **kwargs)
|
|
270
243
|
except ValidationError as e:
|
|
271
|
-
messages.add_message(
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
244
|
+
messages.add_message(
|
|
245
|
+
request,
|
|
246
|
+
message=e.message,
|
|
247
|
+
level=messages.ERROR,
|
|
248
|
+
extra_tags='is-danger'
|
|
249
|
+
)
|
|
275
250
|
return response
|
django_ledger/views/auth.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.auth.views import LoginView, LogoutView
|
|
@@ -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 django.contrib import messages
|
|
9
9
|
from django.core.exceptions import ImproperlyConfigured, ValidationError
|
|
@@ -13,23 +13,22 @@ from django.views.generic import ListView, CreateView, UpdateView, RedirectView
|
|
|
13
13
|
from django.views.generic.detail import SingleObjectMixin
|
|
14
14
|
|
|
15
15
|
from django_ledger.forms.bank_account import BankAccountCreateForm, BankAccountUpdateForm
|
|
16
|
+
from django_ledger.models import EntityModel
|
|
16
17
|
from django_ledger.models.bank_account import BankAccountModel
|
|
17
18
|
from django_ledger.views.mixins import DjangoLedgerSecurityMixIn
|
|
18
19
|
|
|
19
20
|
|
|
20
|
-
class
|
|
21
|
+
class BankAccountModelModelBaseView(DjangoLedgerSecurityMixIn):
|
|
21
22
|
queryset = None
|
|
22
23
|
|
|
23
24
|
def get_queryset(self):
|
|
24
25
|
if self.queryset is None:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
user_model=self.request.user
|
|
28
|
-
).select_related('cash_account', 'entity_model')
|
|
26
|
+
entity_model: EntityModel = self.get_authorized_entity_instance()
|
|
27
|
+
self.queryset = entity_model.bankaccountmodel_set.select_related('cash_account', 'entity_model')
|
|
29
28
|
return super().get_queryset()
|
|
30
29
|
|
|
31
30
|
|
|
32
|
-
class BankAccountModelListView(
|
|
31
|
+
class BankAccountModelListView(BankAccountModelModelBaseView, ListView):
|
|
33
32
|
template_name = 'django_ledger/bank_account/bank_account_list.html'
|
|
34
33
|
PAGE_TITLE = _('Bank Accounts')
|
|
35
34
|
context_object_name = 'bank_accounts'
|
|
@@ -40,7 +39,7 @@ class BankAccountModelListView(DjangoLedgerSecurityMixIn, BankAccountModelModelV
|
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
|
|
43
|
-
class BankAccountModelCreateView(
|
|
42
|
+
class BankAccountModelCreateView(BankAccountModelModelBaseView, CreateView):
|
|
44
43
|
template_name = 'django_ledger/bank_account/bank_account_create.html'
|
|
45
44
|
PAGE_TITLE = _('Create Bank Account')
|
|
46
45
|
extra_context = {
|
|
@@ -71,7 +70,7 @@ class BankAccountModelCreateView(DjangoLedgerSecurityMixIn, BankAccountModelMode
|
|
|
71
70
|
return super(BankAccountModelCreateView, self).form_valid(form)
|
|
72
71
|
|
|
73
72
|
|
|
74
|
-
class BankAccountModelUpdateView(
|
|
73
|
+
class BankAccountModelUpdateView(BankAccountModelModelBaseView, UpdateView):
|
|
75
74
|
template_name = 'django_ledger/bank_account/bank_account_update.html'
|
|
76
75
|
pk_url_kwarg = 'bank_account_pk'
|
|
77
76
|
PAGE_TITLE = _('Update Bank Account')
|
|
@@ -97,8 +96,7 @@ class BankAccountModelUpdateView(DjangoLedgerSecurityMixIn, BankAccountModelMode
|
|
|
97
96
|
|
|
98
97
|
|
|
99
98
|
# ACTION VIEWS...
|
|
100
|
-
class BaseBankAccountModelActionView(
|
|
101
|
-
BankAccountModelModelViewQuerySetMixIn,
|
|
99
|
+
class BaseBankAccountModelActionView(BankAccountModelModelBaseView,
|
|
102
100
|
RedirectView,
|
|
103
101
|
SingleObjectMixin):
|
|
104
102
|
http_method_names = ['get']
|