fix: Correct BMC Office router file structure
This commit is contained in:
parent
08fd2a04c7
commit
1f21ad2ec1
@ -11,6 +11,7 @@ import logging
|
|||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
from app.core.database import execute_query, execute_update
|
from app.core.database import execute_query, execute_update
|
||||||
|
from app.services.customer_activity_logger import CustomerActivityLogger
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -146,24 +147,6 @@ async def upload_bmc_office_subscriptions(file: UploadFile = File(...)):
|
|||||||
antal = parse_danish_number(row.get('Antal', 1))
|
antal = parse_danish_number(row.get('Antal', 1))
|
||||||
pris = parse_danish_number(row.get('Pris', 0))
|
pris = parse_danish_number(row.get('Pris', 0))
|
||||||
rabat = parse_danish_number(row.get('Rabat', 0))
|
rabat = parse_danish_number(row.get('Rabat', 0))
|
||||||
# Get new subscriptions per customer for activity log
|
|
||||||
new_subscriptions = execute_query("""
|
|
||||||
SELECT customer_id, COUNT(*) as count,
|
|
||||||
ROUND(SUM(total_inkl_moms)::numeric, 2) as value,
|
|
||||||
string_agg(text, ', ' ORDER BY text) as products
|
|
||||||
FROM bmc_office_subscription_totals
|
|
||||||
WHERE active = true
|
|
||||||
GROUP BY customer_id
|
|
||||||
""")
|
|
||||||
|
|
||||||
# Log import for each customer
|
|
||||||
for customer in new_subscriptions:
|
|
||||||
CustomerActivityLogger.log(
|
|
||||||
customer_id=customer['customer_id'],
|
|
||||||
activity_type='bmc_office_sync',
|
|
||||||
description=f"BMC Office abonnementer importeret: {customer['count']} abonnementer (værdi: {float(customer['value']):,.2f} DKK) - Produkter: {customer['products'][:200]}"
|
|
||||||
)
|
|
||||||
|
|
||||||
beskrivelse = str(row.get('Beskrivelse', '')).strip()
|
beskrivelse = str(row.get('Beskrivelse', '')).strip()
|
||||||
faktura_firma_id = str(row.get('FakturaFirmaID', '')).strip()
|
faktura_firma_id = str(row.get('FakturaFirmaID', '')).strip()
|
||||||
faktura_firma_name = str(row.get('FakturaFirma', '')).strip()
|
faktura_firma_name = str(row.get('FakturaFirma', '')).strip()
|
||||||
@ -194,6 +177,24 @@ async def upload_bmc_office_subscriptions(file: UploadFile = File(...)):
|
|||||||
FROM bmc_office_subscription_totals
|
FROM bmc_office_subscription_totals
|
||||||
""")[0]
|
""")[0]
|
||||||
|
|
||||||
|
# Get new subscriptions per customer for activity log
|
||||||
|
new_subscriptions = execute_query("""
|
||||||
|
SELECT customer_id, COUNT(*) as count,
|
||||||
|
ROUND(SUM(total_inkl_moms)::numeric, 2) as value,
|
||||||
|
string_agg(text, ', ' ORDER BY text) as products
|
||||||
|
FROM bmc_office_subscription_totals
|
||||||
|
WHERE active = true
|
||||||
|
GROUP BY customer_id
|
||||||
|
""")
|
||||||
|
|
||||||
|
# Log import for each customer
|
||||||
|
for customer in new_subscriptions:
|
||||||
|
CustomerActivityLogger.log(
|
||||||
|
customer_id=customer['customer_id'],
|
||||||
|
activity_type='bmc_office_sync',
|
||||||
|
description=f"BMC Office abonnementer importeret: {customer['count']} abonnementer (værdi: {float(customer['value']):,.2f} DKK) - Produkter: {customer['products'][:200]}"
|
||||||
|
)
|
||||||
|
|
||||||
logger.info(f"✅ Import færdig: {imported} importeret, {skipped} sprunget over")
|
logger.info(f"✅ Import færdig: {imported} importeret, {skipped} sprunget over")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user