This commit is contained in:
admin
2026-01-16 09:50:21 +09:00
parent 24c04e0d29
commit d8ec60629e
18 changed files with 941 additions and 22 deletions

View File

@@ -23,6 +23,7 @@ class JournalEntryRequest(BaseModel):
tax_paid_account_id: Optional[int] = None # 仮払消費税等 勘定
tax_received_account_id: Optional[int] = None # 仮受消費税等 勘定
rounding_mode: str = "round" # "round", "floor", or "ceil"
parent_entry_id: Optional[int] = None # 修正元の仕訳ID
class JournalEntryUpdateRequest(BaseModel):
description: str
@@ -58,7 +59,8 @@ def get_journal_entries(
je.fiscal_year,
je.version,
COALESCE(SUM(jl.debit), 0) as debit_total,
COALESCE(SUM(jl.credit), 0) as credit_total
COALESCE(SUM(jl.credit), 0) as credit_total,
STRING_AGG(DISTINCT CASE WHEN jl.tax_rate IS NOT NULL THEN jl.tax_rate::text END, ', ' ORDER BY CASE WHEN jl.tax_rate IS NOT NULL THEN jl.tax_rate::text END) as tax_rates
FROM journal_entries je
LEFT JOIN journal_lines jl ON je.journal_entry_id = jl.journal_entry_id
WHERE je.is_deleted = false
@@ -74,7 +76,8 @@ def get_journal_entries(
je.fiscal_year,
je.version,
COALESCE(SUM(jl.debit), 0) as debit_total,
COALESCE(SUM(jl.credit), 0) as credit_total
COALESCE(SUM(jl.credit), 0) as credit_total,
STRING_AGG(DISTINCT CASE WHEN jl.tax_rate IS NOT NULL THEN jl.tax_rate::text END, ', ' ORDER BY CASE WHEN jl.tax_rate IS NOT NULL THEN jl.tax_rate::text END) as tax_rates
FROM journal_entries je
LEFT JOIN journal_lines jl ON je.journal_entry_id = jl.journal_entry_id
WHERE je.is_deleted = false
@@ -202,15 +205,17 @@ def create_reverse_entry(journal_id: int):
fiscal_year,
version,
is_deleted,
created_by
created_by,
parent_entry_id
)
VALUES (%s, %s, %s, 1, false, %s)
VALUES (%s, %s, %s, 1, false, %s, %s)
RETURNING journal_entry_id
""", (
header["entry_date"],
f"[逆仕訳] {header['description']}",
header["fiscal_year"],
"system"
"system",
journal_id # 逆仕訳の元となる仕訳ID
))
new_entry_id = cur.fetchone()["journal_entry_id"]
@@ -322,15 +327,17 @@ def create_journal_entry(req: JournalEntryRequest):
fiscal_year,
version,
is_deleted,
created_by
created_by,
parent_entry_id
)
VALUES (%s, %s, %s, 1, false, %s)
VALUES (%s, %s, %s, 1, false, %s, %s)
RETURNING journal_entry_id
""", (
req.entry_date,
req.description,
fiscal_year,
"system"
"system",
req.parent_entry_id
))
entry_id = cur.fetchone()["journal_entry_id"]