From 6c0c663206b5e5af94ad7cb03c6ee5473eca944b Mon Sep 17 00:00:00 2001
From: "Alfino.Fr" <alfino@kanosolution.com>
Date: Thu, 9 Nov 2023 17:57:22 +0700
Subject: [PATCH] add compensation for timezone difference

---
 engine/ingest.go | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/engine/ingest.go b/engine/ingest.go
index fb2799a..b0a3151 100644
--- a/engine/ingest.go
+++ b/engine/ingest.go
@@ -129,8 +129,7 @@ func (r *Cita) IngestCitaOrder() error {
 func (r *Cita) readTheCSV(path fs.DirEntry) error {
 	layoutDD := "02-01-2006"
 	layout := "02-01-2006 15:04:05"
-	//var nilDate time.Time
-
+	location, _ := time.LoadLocation("Asia/Jakarta")
 	file, err := os.Open(filepath.Join(r.Config.FileParams.Path, path.Name()))
 	if err != nil {
 		log.Println("Error opening CSV file:", err)
@@ -166,6 +165,9 @@ func (r *Cita) readTheCSV(path fs.DirEntry) error {
 	}
 
 	for i := 0; i < len(records); i++ {
+
+		Orderdate, _ := time.Parse(layout, dataMap["Inserted_Date"][i])
+
 		a := model.ExtractorCita{}
 		a.File_name = path.Name()
 		a.Order_cita_id, _ = strconv.ParseInt(dataMap["Order_Id"][i], 10, 64)
@@ -177,7 +179,7 @@ func (r *Cita) readTheCSV(path fs.DirEntry) error {
 		a.Customer_code = dataMap["Store_Code"][i]
 		a.Customer_name = dataMap["Store_Name"][i]
 		a.Distributor_code = mapCustomer_Code[a.Customer_code]
-		a.Order_date, _ = time.Parse(layout, dataMap["Inserted_Date"][i])
+		a.Order_date = Orderdate.Add(-7 * time.Hour).In(location)
 		a.Delivery_date, _ = time.Parse(layoutDD, dataMap["Delivery_Date"][i])
 		//a.Actual_date = a.Delivery_date
 		a.Nomor_nota = ""
-- 
GitLab