mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
Merge branch 'feat/BE/Sprint-6' of https://gitlab.com/mbugroup/lti-api into feat/BE/US-279/closing-produksi
This commit is contained in:
@@ -216,13 +216,11 @@ var TransferToLayingApprovalSteps = map[approvalutils.ApprovalStep]string{
|
||||
|
||||
const (
|
||||
ApprovalWorkflowRecording approvalutils.ApprovalWorkflowKey = approvalutils.ApprovalWorkflowKey("RECORDINGS")
|
||||
RecordingStepGradingTelur approvalutils.ApprovalStep = 1
|
||||
RecordingStepPengajuan approvalutils.ApprovalStep = 2
|
||||
RecordingStepDisetujui approvalutils.ApprovalStep = 3
|
||||
RecordingStepPengajuan approvalutils.ApprovalStep = 1
|
||||
RecordingStepDisetujui approvalutils.ApprovalStep = 2
|
||||
)
|
||||
|
||||
var RecordingApprovalSteps = map[approvalutils.ApprovalStep]string{
|
||||
RecordingStepGradingTelur: "Grading-Telur",
|
||||
RecordingStepPengajuan: "Pengajuan",
|
||||
RecordingStepDisetujui: "Disetujui",
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ func MapEggs(recordingID uint, createdBy uint, items []validation.Egg) []entity.
|
||||
RecordingId: recordingID,
|
||||
ProductWarehouseId: item.ProductWarehouseId,
|
||||
Qty: item.Qty,
|
||||
Weight: item.Weight,
|
||||
CreatedBy: createdBy,
|
||||
})
|
||||
}
|
||||
|
||||
+34
-1
@@ -1,8 +1,9 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"time"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ParseDateString mengubah string "YYYY-MM-DD" menjadi time.Time
|
||||
@@ -23,3 +24,35 @@ func ParseDateString(dateStr string) (time.Time, error) {
|
||||
func FormatDate(t time.Time) string {
|
||||
return t.Format("2006-01-02")
|
||||
}
|
||||
|
||||
// ParseDateRangeForQuery parses optional YYYY-MM-DD from/to strings for list filters.
|
||||
// It returns a start pointer (inclusive) and an end pointer advanced by one day
|
||||
// so callers can safely use "< end" to achieve an inclusive upper bound.
|
||||
func ParseDateRangeForQuery(fromStr, toStr string) (*time.Time, *time.Time, error) {
|
||||
var fromPtr *time.Time
|
||||
var toPtr *time.Time
|
||||
|
||||
if strings.TrimSpace(fromStr) != "" {
|
||||
parsed, err := ParseDateString(strings.TrimSpace(fromStr))
|
||||
if err != nil {
|
||||
return nil, nil, errors.New("created_from must use format YYYY-MM-DD")
|
||||
}
|
||||
fromValue := parsed
|
||||
fromPtr = &fromValue
|
||||
}
|
||||
|
||||
if strings.TrimSpace(toStr) != "" {
|
||||
parsed, err := ParseDateString(strings.TrimSpace(toStr))
|
||||
if err != nil {
|
||||
return nil, nil, errors.New("created_to must use format YYYY-MM-DD")
|
||||
}
|
||||
nextDay := parsed.AddDate(0, 0, 1)
|
||||
toPtr = &nextDay
|
||||
}
|
||||
|
||||
if fromPtr != nil && toPtr != nil && fromPtr.After(*toPtr) {
|
||||
return nil, nil, errors.New("created_from must be earlier than created_to")
|
||||
}
|
||||
|
||||
return fromPtr, toPtr, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user