Add POI feature and imporve the overall backend implementation
This commit is contained in:
@@ -80,3 +80,40 @@ class POSConfigurationRepository(BaseRepository[POSConfiguration, dict, dict]):
|
||||
except Exception as e:
|
||||
logger.error("Failed to count configurations by tenant", error=str(e), tenant_id=tenant_id)
|
||||
raise
|
||||
|
||||
async def get_by_pos_identifier(
|
||||
self,
|
||||
pos_system: str,
|
||||
identifier: str
|
||||
) -> Optional[POSConfiguration]:
|
||||
"""
|
||||
Get POS configuration by POS-specific identifier
|
||||
|
||||
Args:
|
||||
pos_system: POS system name (square, toast, lightspeed)
|
||||
identifier: merchant_id, location_id, or other POS-specific ID
|
||||
|
||||
Returns:
|
||||
POSConfiguration if found, None otherwise
|
||||
"""
|
||||
try:
|
||||
query = select(self.model).where(
|
||||
and_(
|
||||
self.model.pos_system == pos_system,
|
||||
or_(
|
||||
self.model.merchant_id == identifier,
|
||||
self.model.location_id == identifier
|
||||
),
|
||||
self.model.is_active == True
|
||||
)
|
||||
).order_by(self.model.created_at.desc())
|
||||
|
||||
result = await self.session.execute(query)
|
||||
return result.scalars().first()
|
||||
|
||||
except Exception as e:
|
||||
logger.error("Failed to get config by POS identifier",
|
||||
error=str(e),
|
||||
pos_system=pos_system,
|
||||
identifier=identifier)
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user