Mhamdans17 commited on
Commit
c1f4954
·
1 Parent(s): 938b985

fix: select is_point_enabled in getBranches

Browse files
Files changed (2) hide show
  1. checkdb.go +19 -0
  2. controllers/company_controller.go +1 -1
checkdb.go ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package main
2
+
3
+ import (
4
+ "log"
5
+ "service-warungpos-go/config"
6
+ "service-warungpos-go/models"
7
+ "github.com/joho/godotenv"
8
+ )
9
+
10
+ func main() {
11
+ godotenv.Load()
12
+ config.ConnectDatabase()
13
+ var branch models.Branch
14
+ if err := config.DB.Where("name = ?", "CV Adi Jaya").First(&branch).Error; err != nil {
15
+ log.Println("Error:", err)
16
+ return
17
+ }
18
+ log.Printf("Branch ID: %d, Name: %s, IsPointEnabled: %v\n", branch.ID, branch.Name, branch.IsPointEnabled)
19
+ }
controllers/company_controller.go CHANGED
@@ -680,7 +680,7 @@ func ListBranches(c *gin.Context) {
680
  owner := userVal.(*models.User)
681
 
682
  branches := []models.Branch{}
683
- if err := config.DB.Select("id, company_id, name, address, phone, is_active, created_at").Where("company_id = ?", *owner.CompanyID).Find(&branches).Error; err != nil {
684
  c.JSON(http.StatusInternalServerError, gin.H{"detail": "Gagal mengambil data cabang"})
685
  return
686
  }
 
680
  owner := userVal.(*models.User)
681
 
682
  branches := []models.Branch{}
683
+ if err := config.DB.Select("id, company_id, name, address, phone, is_active, is_point_enabled, created_at").Where("company_id = ?", *owner.CompanyID).Find(&branches).Error; err != nil {
684
  c.JSON(http.StatusInternalServerError, gin.H{"detail": "Gagal mengambil data cabang"})
685
  return
686
  }