Update product receipe
This commit is contained in:
@@ -81,27 +81,26 @@ func (s *ReportServiceImpl) GenerateDailyTransactionPDF(ctx context.Context, org
|
||||
return "", "", fmt.Errorf("invalid outlet id: %w", err)
|
||||
}
|
||||
|
||||
// Resolve organization and outlet names
|
||||
org, err := s.organizationRepo.GetByID(ctx, orgID)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("organization not found: %w", err)
|
||||
}
|
||||
|
||||
outlet, err := s.outletRepo.GetByID(ctx, outID)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("outlet not found: %w", err)
|
||||
}
|
||||
|
||||
// Determine timezone (fallback to system local if not available)
|
||||
tzName := "Asia/Jakarta"
|
||||
if outlet.Timezone != nil && *outlet.Timezone != "" {
|
||||
tzName = *outlet.Timezone
|
||||
}
|
||||
|
||||
loc, locErr := time.LoadLocation(tzName)
|
||||
if locErr != nil || loc == nil {
|
||||
loc = time.Local
|
||||
}
|
||||
|
||||
// Compute day range in the chosen location
|
||||
var day time.Time
|
||||
if reportDate != nil {
|
||||
t := reportDate.UTC()
|
||||
@@ -113,11 +112,9 @@ func (s *ReportServiceImpl) GenerateDailyTransactionPDF(ctx context.Context, org
|
||||
start := day
|
||||
end := day.Add(24*time.Hour - time.Nanosecond)
|
||||
|
||||
// Build requests
|
||||
salesReq := &models.SalesAnalyticsRequest{OrganizationID: orgID, OutletID: &outID, DateFrom: start, DateTo: end, GroupBy: "day"}
|
||||
plReq := &models.ProfitLossAnalyticsRequest{OrganizationID: orgID, OutletID: &outID, DateFrom: start, DateTo: end, GroupBy: "day"}
|
||||
|
||||
// Call services
|
||||
sales, err := s.analyticsService.GetSalesAnalytics(ctx, salesReq)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("get sales analytics: %w", err)
|
||||
@@ -127,7 +124,6 @@ func (s *ReportServiceImpl) GenerateDailyTransactionPDF(ctx context.Context, org
|
||||
return "", "", fmt.Errorf("get profit/loss analytics: %w", err)
|
||||
}
|
||||
|
||||
// Compose template data
|
||||
data := reportTemplateData{
|
||||
OrganizationName: org.Name,
|
||||
OutletName: outlet.Name,
|
||||
@@ -149,7 +145,6 @@ func (s *ReportServiceImpl) GenerateDailyTransactionPDF(ctx context.Context, org
|
||||
},
|
||||
}
|
||||
|
||||
// Items by product
|
||||
items := make([]reportItem, 0, len(pl.ProductData))
|
||||
for _, p := range pl.ProductData {
|
||||
items = append(items, reportItem{
|
||||
@@ -164,7 +159,6 @@ func (s *ReportServiceImpl) GenerateDailyTransactionPDF(ctx context.Context, org
|
||||
}
|
||||
data.Items = items
|
||||
|
||||
// Render to PDF
|
||||
templatePath := filepath.Join("templates", "daily_transaction.html")
|
||||
pdfBytes, err := renderTemplateToPDF(templatePath, data)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user