fix: synchronize document links with reconciliation items
This commit is contained in:
@@ -14,6 +14,7 @@ from sqlalchemy import text
|
||||
|
||||
from app.company_opportunity_linking import is_public_email_domain
|
||||
from app.db import engine
|
||||
from app.document_reconciliation_service import active_document_link_exclusion_sql
|
||||
from app.reconciliation_service import (
|
||||
_apply_jasmin_documents_to_opportunity, # noqa: PLC2701 - deliberate operator maintenance helper
|
||||
_jasmin_document_lines_from_item, # noqa: PLC2701
|
||||
@@ -540,6 +541,7 @@ def find_jasmin_document_candidates_for_opportunity(
|
||||
AND COALESCE(ri.customer_tax_id, '') <> ''
|
||||
AND ri.customer_tax_id <> CAST(:fiscal_tax_id AS TEXT)
|
||||
)
|
||||
AND {active_link_exclusion}
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM commercial_documents cd
|
||||
WHERE cd.opportunity_id = CAST(:opportunity_id AS UUID)
|
||||
@@ -552,7 +554,7 @@ def find_jasmin_document_candidates_for_opportunity(
|
||||
AND ri.external_id IS NOT NULL
|
||||
AND cd.external_id = ri.external_id
|
||||
)
|
||||
"""
|
||||
""".format(active_link_exclusion=active_document_link_exclusion_sql("ri"))
|
||||
params = {
|
||||
"opportunity_id": opportunity_id,
|
||||
"fiscal_customer_id": fiscal_customer_id,
|
||||
|
||||
Reference in New Issue
Block a user