- HUD now displays "Payfrit Tasks - <BusinessName>" by fetching from getBusiness API - Fixed portal Task HUD button to link to /hud/index.html instead of /hud/ Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
68 lines
1.9 KiB
Text
68 lines
1.9 KiB
Text
<cfsetting showdebugoutput="false">
|
|
<cfsetting enablecfoutputonly="true">
|
|
|
|
<cfcontent type="application/json; charset=utf-8" reset="true">
|
|
<cfheader name="Cache-Control" value="no-store">
|
|
|
|
<cfscript>
|
|
/**
|
|
* Get Business Settings
|
|
* Returns settings for the currently selected business
|
|
*
|
|
* Requires: request.BusinessID (set by auth middleware)
|
|
*/
|
|
|
|
function apiAbort(obj) {
|
|
writeOutput(serializeJSON(obj));
|
|
abort;
|
|
}
|
|
|
|
if (!structKeyExists(request, "BusinessID") || !isNumeric(request.BusinessID) || request.BusinessID LTE 0) {
|
|
apiAbort({ OK: false, ERROR: "no_business_selected" });
|
|
}
|
|
|
|
try {
|
|
q = queryExecute("
|
|
SELECT
|
|
BusinessID,
|
|
BusinessName,
|
|
BusinessTaxRate,
|
|
BusinessAddress,
|
|
BusinessCity,
|
|
BusinessState,
|
|
BusinessZip,
|
|
BusinessContactNumber,
|
|
BusinessEmailAddress
|
|
FROM Businesses
|
|
WHERE BusinessID = :businessId
|
|
LIMIT 1
|
|
", { businessId: request.BusinessID }, { datasource: "payfrit" });
|
|
|
|
if (q.recordCount == 0) {
|
|
apiAbort({ OK: false, ERROR: "business_not_found" });
|
|
}
|
|
|
|
// Format tax rate as percentage for display (0.0825 -> 8.25)
|
|
taxRateRaw = isNumeric(q.BusinessTaxRate) ? q.BusinessTaxRate : 0;
|
|
taxRatePercent = taxRateRaw * 100;
|
|
|
|
writeOutput(serializeJSON({
|
|
"OK": true,
|
|
"SETTINGS": {
|
|
"BusinessID": q.BusinessID,
|
|
"BusinessName": q.BusinessName,
|
|
"TaxRate": taxRateRaw,
|
|
"TaxRatePercent": taxRatePercent,
|
|
"Address": q.BusinessAddress ?: "",
|
|
"City": q.BusinessCity ?: "",
|
|
"State": q.BusinessState ?: "",
|
|
"Zip": q.BusinessZip ?: "",
|
|
"Phone": q.BusinessContactNumber ?: "",
|
|
"Email": q.BusinessEmailAddress ?: ""
|
|
}
|
|
}));
|
|
|
|
} catch (any e) {
|
|
apiAbort({ OK: false, ERROR: "server_error", MESSAGE: e.message });
|
|
}
|
|
</cfscript>
|