Revised the code according to the PyCharm and PEP8 inspection.
This commit is contained in:
parent
dc14f2e27a
commit
0243289946
@ -80,8 +80,8 @@ class Transaction(models.Model):
|
||||
|
||||
@property
|
||||
def is_balanced(self):
|
||||
"""Whether the sum of the amounts of the debit records is the same as the sum of the amounts of the credit
|
||||
records. """
|
||||
"""Whether the sum of the amounts of the debit records is the
|
||||
same as the sum of the amounts of the credit records. """
|
||||
debit_sum = sum([x.amount for x in self.debit_records])
|
||||
credit_sum = sum([x.amount for x in self.credit_records])
|
||||
return debit_sum == credit_sum
|
||||
@ -105,11 +105,14 @@ class Transaction(models.Model):
|
||||
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))
|
||||
return reverse(
|
||||
"accounting:transaction", args=("expense", self.sn))
|
||||
elif self.is_cash_income:
|
||||
return reverse("accounting:transaction", args=("income", self.sn))
|
||||
return reverse(
|
||||
"accounting:transaction", args=("income", self.sn))
|
||||
else:
|
||||
return reverse("accounting:transaction", args=("transfer", self.sn))
|
||||
return reverse(
|
||||
"accounting:transaction", args=("transfer", self.sn))
|
||||
|
||||
def __str__(self):
|
||||
"""Returns the string representation of this accounting
|
||||
@ -163,10 +166,11 @@ class Record(models.Model):
|
||||
def __str__(self):
|
||||
"""Returns the string representation of this accounting
|
||||
record."""
|
||||
return self.transaction.date.__str__() + " " \
|
||||
+ self.subject.title_zhtw.__str__() \
|
||||
+ " " + self.summary.__str__() \
|
||||
+ " " + self.amount.__str__()
|
||||
return "%s %s %s %s" % (
|
||||
self.transaction.date,
|
||||
self.subject.title_zhtw,
|
||||
self.summary,
|
||||
self.amount)
|
||||
|
||||
class Meta:
|
||||
db_table = "accounting_records"
|
||||
|
@ -41,7 +41,10 @@ app_name = "accounting"
|
||||
urlpatterns = [
|
||||
path("", views.home, name="home"),
|
||||
path("cash", views.cash_home, name="cash.home"),
|
||||
path("cash/<str:subject_code>/<str:period_spec>", views.CashReportView.as_view(), name="cash"),
|
||||
path("transactions/<txn-type:type>/<int:pk>", views.CashReportView.as_view(), name="transaction"),
|
||||
path("transactions/<txn-type:type>/<int:pk>/edit", views.CashReportView.as_view(), name="transaction.edit"),
|
||||
path("cash/<str:subject_code>/<str:period_spec>",
|
||||
views.CashReportView.as_view(), name="cash"),
|
||||
path("transactions/<txn-type:type>/<int:pk>",
|
||||
views.CashReportView.as_view(), name="transaction"),
|
||||
path("transactions/<txn-type:type>/<int:pk>/edit",
|
||||
views.CashReportView.as_view(), name="transaction.edit"),
|
||||
]
|
||||
|
@ -61,7 +61,7 @@ class Pagination:
|
||||
|
||||
DEFAULT_PAGE_SIZE = 10
|
||||
|
||||
def __init__(self, count, page_no, page_size, is_reverse = False):
|
||||
def __init__(self, count, page_no, page_size, is_reverse=False):
|
||||
self.page_size = page_size \
|
||||
if page_size is not None \
|
||||
else self.DEFAULT_PAGE_SIZE
|
||||
|
@ -104,7 +104,8 @@ class BaseReportView(generic.ListView):
|
||||
str(UrlBuilder(request.get_full_path())
|
||||
.del_param("page")))
|
||||
try:
|
||||
r = super(BaseReportView, self).get(request, *args, **kwargs)
|
||||
r = super(BaseReportView, self) \
|
||||
.get(request, *args, **kwargs)
|
||||
except PageNoOutOfRangeError:
|
||||
return HttpResponseRedirect(
|
||||
str(UrlBuilder(request.get_full_path())
|
||||
@ -143,7 +144,7 @@ FROM accounting_records AS r
|
||||
OR s1.code LIKE '21%%'
|
||||
OR s1.code LIKE '22%%')
|
||||
AND t1.date >= %s
|
||||
AND t1.date <= %s
|
||||
AND t1.date <= %s
|
||||
GROUP BY t1.sn) AS t
|
||||
ON r.transaction_sn=t.sn
|
||||
LEFT JOIN accounting_subjects AS s ON r.subject_sn = s.sn
|
||||
@ -171,7 +172,7 @@ FROM accounting_records AS r
|
||||
LEFT JOIN accounting_subjects AS s1
|
||||
ON r1.subject_sn = s1.sn
|
||||
WHERE t1.date >= %s
|
||||
AND t1.date <= %s
|
||||
AND t1.date <= %s
|
||||
AND s1.code LIKE %s
|
||||
GROUP BY t1.sn) AS t
|
||||
ON r.transaction_sn=t.sn
|
||||
|
@ -14,7 +14,6 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import locale
|
||||
from datetime import date
|
||||
|
||||
from django import template
|
||||
|
Loading…
Reference in New Issue
Block a user