Adds background task for invoice processing
Implements a background task that listens for paid invoices and automatically records them in the accounting system. This ensures payments are captured even if the user closes their browser before the client-side polling detects the payment. Introduces a new `get_journal_entry_by_reference` function to improve idempotency when recording payments.
This commit is contained in:
parent
4957826c49
commit
cfa25cc61b
4 changed files with 142 additions and 2 deletions
13
__init__.py
13
__init__.py
|
|
@ -1,6 +1,10 @@
|
|||
import asyncio
|
||||
|
||||
from fastapi import APIRouter
|
||||
from loguru import logger
|
||||
|
||||
from .crud import db
|
||||
from .tasks import wait_for_paid_invoices
|
||||
from .views import castle_generic_router
|
||||
from .views_api import castle_api_router
|
||||
|
||||
|
|
@ -15,4 +19,11 @@ castle_static_files = [
|
|||
}
|
||||
]
|
||||
|
||||
__all__ = ["castle_ext", "castle_static_files", "db"]
|
||||
|
||||
def castle_start():
|
||||
"""Initialize Castle extension background tasks"""
|
||||
logger.info("Starting Castle accounting extension background tasks")
|
||||
asyncio.create_task(wait_for_paid_invoices())
|
||||
|
||||
|
||||
__all__ = ["castle_ext", "castle_static_files", "db", "castle_start"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue