Fix: Remove hourly_rate query from customers table (kolonne eksisterer ikke)
BUG FIX:
- _get_hourly_rate() tried to query hourly_rate from customers table
- customers table har ikke hourly_rate kolonne
- Forårsagede '500: no results to fetch' fejl ved order oprettelse
- Changed execute_query_single → execute_query for tmodule_customers check
- Removed hub customer rate check (ikke relevant)
- Falls back til default rate fra settings
ERROR: SELECT hourly_rate FROM customers WHERE id = 512
→ column 'hourly_rate' does not exist
This commit is contained in:
parent
152670b4b2
commit
718de1a6bd
@ -42,22 +42,15 @@ class OrderService:
|
|||||||
try:
|
try:
|
||||||
# Check module customer
|
# Check module customer
|
||||||
query = "SELECT hourly_rate FROM tmodule_customers WHERE id = %s"
|
query = "SELECT hourly_rate FROM tmodule_customers WHERE id = %s"
|
||||||
result = execute_query_single(query, (customer_id,))
|
result = execute_query(query, (customer_id,))
|
||||||
|
|
||||||
if result and result.get('hourly_rate'):
|
if result and result[0].get('hourly_rate'):
|
||||||
rate = result['hourly_rate']
|
rate = result[0]['hourly_rate']
|
||||||
logger.info(f"✅ Using tmodule customer rate: {rate} DKK")
|
logger.info(f"✅ Using tmodule customer rate: {rate} DKK")
|
||||||
return Decimal(str(rate))
|
return Decimal(str(rate))
|
||||||
|
|
||||||
# Check Hub customer if linked
|
# Hub customers table doesn't have hourly_rate column
|
||||||
if hub_customer_id:
|
# Skip that check and go straight to default
|
||||||
query = "SELECT hourly_rate FROM customers WHERE id = %s"
|
|
||||||
result = execute_query_single(query, (hub_customer_id,))
|
|
||||||
|
|
||||||
if result and result.get('hourly_rate'):
|
|
||||||
rate = result['hourly_rate']
|
|
||||||
logger.info(f"✅ Using Hub customer rate: {rate} DKK")
|
|
||||||
return Decimal(str(rate))
|
|
||||||
|
|
||||||
# Fallback to default
|
# Fallback to default
|
||||||
default_rate = Decimal(str(settings.TIMETRACKING_DEFAULT_HOURLY_RATE))
|
default_rate = Decimal(str(settings.TIMETRACKING_DEFAULT_HOURLY_RATE))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user