修正
This commit is contained in:
@@ -60,14 +60,19 @@ def fetch_trial_balance(date_from: str, date_to: str):
|
||||
opening_balance_from_table = D(ob_row["ob"]) if ob_row else D(0)
|
||||
|
||||
# date_from より前の仕訳による増減
|
||||
# 修正された仕訳(親となった仕訳)は除外
|
||||
cur.execute("""
|
||||
SELECT COALESCE(SUM(l.debit - l.credit), 0) AS opening
|
||||
FROM journal_lines l
|
||||
JOIN journal_entries j
|
||||
ON j.journal_entry_id = l.journal_entry_id
|
||||
LEFT JOIN journal_entries child
|
||||
ON child.parent_entry_id = j.journal_entry_id
|
||||
WHERE l.account_id = %s
|
||||
AND j.entry_date < %s
|
||||
AND j.is_deleted = false
|
||||
AND j.description NOT LIKE '[逆仕訳]%%'
|
||||
AND child.journal_entry_id IS NULL
|
||||
""", (aid, date_from))
|
||||
opening_from_journals = D(cur.fetchone()["opening"])
|
||||
|
||||
@@ -75,6 +80,7 @@ def fetch_trial_balance(date_from: str, date_to: str):
|
||||
opening = opening_balance_from_table + opening_from_journals
|
||||
|
||||
# 当期増減(date_from ~ date_to)
|
||||
# 修正された仕訳(親となった仕訳)は除外
|
||||
cur.execute("""
|
||||
SELECT
|
||||
COALESCE(SUM(l.debit), 0) AS debit,
|
||||
@@ -82,9 +88,13 @@ def fetch_trial_balance(date_from: str, date_to: str):
|
||||
FROM journal_lines l
|
||||
JOIN journal_entries j
|
||||
ON j.journal_entry_id = l.journal_entry_id
|
||||
LEFT JOIN journal_entries child
|
||||
ON child.parent_entry_id = j.journal_entry_id
|
||||
WHERE l.account_id = %s
|
||||
AND j.entry_date BETWEEN %s AND %s
|
||||
AND j.is_deleted = false
|
||||
AND j.description NOT LIKE '[逆仕訳]%%'
|
||||
AND child.journal_entry_id IS NULL
|
||||
""", (aid, date_from, date_to))
|
||||
row = cur.fetchone()
|
||||
debit = D(row["debit"])
|
||||
|
||||
Reference in New Issue
Block a user