This commit is contained in:
2026-09-02 10:49:46 +05:30
parent 1e3fe88e87
commit c0d39e550d
8 changed files with 463 additions and 25 deletions

View File

@@ -777,6 +777,24 @@ func (r *tenantRepository) GetUserByNo(cno string) models.UserInfo {
return user
}
// GetTenantByID reads one business.
//
// Both master joins are LEFT, and that is the whole fix. They were INNER —
// `app_category` on `a.categoryid` and `app_location` on `a.applocationid` — so
// a tenant whose category or city master row is missing did not come back
// "without a category name", it did not come back AT ALL. The endpoint answered
// 200 with an all-zero record: tenantid 0, every string empty.
//
// Four of two hundred tenants have `categoryid = 0`, which matches no
// `app_category` row, and a newly onboarded shop is the likeliest to be one of
// them. The damage was silent and total: the shop-profile screen seeded an
// empty form over a business that had an address, and the setup walkthrough
// read every field as blank forever — so its first step could never complete
// however many times somebody saved it.
//
// The same INNER-JOIN-as-a-filter mistake has been fixed twice before in this
// file's neighbours, in GetStaffs and GetUserById. A master row is context; its
// absence must never delete the record it decorates.
func (r *tenantRepository) GetTenantByID(tid int, locationid int, userid int) (models.Tenantinfo, error) {
var data models.Tenantinfo
@@ -792,8 +810,8 @@ func (r *tenantRepository) GetTenantByID(tid int, locationid int, userid int) (m
SELECT a.*,b.categoryname,c.locationname AS applocation, d.allocationid AS allocationmode,e.typename AS allocationtype,e.mapid AS allocationid,f.locationid,
f.locationname, f.contactno as locationcontact
FROM tenants a
INNER JOIN app_category b ON a.categoryid = b.categoryid
INNER JOIN app_location c ON a.applocationid = c.applocationid
LEFT JOIN app_category b ON a.categoryid = b.categoryid
LEFT JOIN app_location c ON a.applocationid = c.applocationid
LEFT JOIN partnerinfo d ON a.partnerid = d.partnerid
LEFT JOIN app_types e ON d.allocationid = e.apptypeid
LEFT JOIN tenantlocations f ON a.tenantid = f.tenantid