Replced the SQL query with the Django model query when finding the cash account subjects in the accounting module.
This commit is contained in:
parent
a03c701a31
commit
b20b82698b
@ -73,17 +73,13 @@ def _cash_subjects():
|
|||||||
Returns:
|
Returns:
|
||||||
list[Subject]: The subjects for the cash account reports.
|
list[Subject]: The subjects for the cash account reports.
|
||||||
"""
|
"""
|
||||||
subjects = list(Subject.objects.raw("""SELECT s.*
|
subjects = list(Subject.objects.filter(
|
||||||
FROM accounting_subjects AS s
|
code__in=Record.objects.filter(
|
||||||
WHERE s.code IN (SELECT s1.code
|
Q(subject__code__startswith="11")
|
||||||
FROM accounting_subjects AS s1
|
| Q(subject__code__startswith="12")
|
||||||
INNER JOIN accounting_records AS r1 ON s1.sn=r1.subject_sn
|
| Q(subject__code__startswith="21")
|
||||||
WHERE s1.code LIKE '11%'
|
| Q(subject__code__startswith="22"))
|
||||||
OR s1.code LIKE '12%'
|
.values("subject__code")))
|
||||||
OR s1.code LIKE '21%'
|
|
||||||
OR s1.code LIKE '22%'
|
|
||||||
GROUP BY s1.code)
|
|
||||||
ORDER BY s.code"""))
|
|
||||||
subjects.insert(0, Subject(
|
subjects.insert(0, Subject(
|
||||||
code="0",
|
code="0",
|
||||||
title=pgettext(
|
title=pgettext(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user