MMS43 changes

This commit is contained in:
Arnaud Delcasse
2025-12-29 10:50:58 +01:00
parent 52de8d363e
commit 6cda7509c1
6 changed files with 126 additions and 79 deletions

View File

@@ -31,8 +31,8 @@ type VehiclesSearchResult struct {
BeneficiaryDocuments []filestorage.FileInfo
Groups map[string]any
Searched bool
StartDate string
EndDate string
StartDate time.Time
EndDate time.Time
VehicleType string
Automatic bool
MandatoryDocuments []string
@@ -41,22 +41,13 @@ type VehiclesSearchResult struct {
Beneficiaries []mobilityaccountsstorage.Account
}
func (h *ApplicationHandler) SearchVehicles(ctx context.Context, beneficiaryID, startDateStr, endDateStr, vehicleType string, automatic bool) (*VehiclesSearchResult, error) {
func (h *ApplicationHandler) SearchVehicles(ctx context.Context, beneficiaryID string, startdate, enddate time.Time, vehicleType string, automatic bool) (*VehiclesSearchResult, error) {
var beneficiary mobilityaccountsstorage.Account
beneficiarydocuments := []filestorage.FileInfo{}
vehicles := []storage.Vehicle{}
searched := false
administrators := []string{}
startdate, err := time.Parse("2006-01-02", startDateStr)
if err != nil {
startdate = time.Time{}
}
enddate, err := time.Parse("2006-01-02", endDateStr)
if err != nil {
enddate = time.Time{}
}
if beneficiaryID != "" && startdate.After(time.Now().Add(-24*time.Hour)) && enddate.After(startdate) {
// Handler form
searched = true
@@ -165,8 +156,8 @@ func (h *ApplicationHandler) SearchVehicles(ctx context.Context, beneficiaryID,
BeneficiaryDocuments: beneficiarydocuments,
Groups: groups,
Searched: searched,
StartDate: startDateStr,
EndDate: endDateStr,
StartDate: startdate,
EndDate: enddate,
VehicleType: vehicleType,
Automatic: automatic,
MandatoryDocuments: mandatoryDocuments,
@@ -180,7 +171,7 @@ type BookVehicleResult struct {
BookingID string
}
func (h *ApplicationHandler) BookVehicle(ctx context.Context, vehicleID, beneficiaryID, startDateStr, endDateStr string, documents map[string]io.Reader, documentHeaders map[string]string, existingDocs map[string]string, currentUserID string, currentUserClaims map[string]any, currentGroup any) (*BookVehicleResult, error) {
func (h *ApplicationHandler) BookVehicle(ctx context.Context, vehicleID, beneficiaryID string, startdate, enddate time.Time, documents map[string]io.Reader, documentHeaders map[string]string, existingDocs map[string]string, currentUserID string, currentUserClaims map[string]any, currentGroup any) (*BookVehicleResult, error) {
group := currentGroup.(groupsmanagementstorage.Group)
vehicle, err := h.services.GRPC.Fleets.GetVehicle(ctx, &fleets.GetVehicleRequest{
@@ -190,15 +181,6 @@ func (h *ApplicationHandler) BookVehicle(ctx context.Context, vehicleID, benefic
return nil, fmt.Errorf("vehicle not found: %w", err)
}
startdate, err := time.Parse("2006-01-02", startDateStr)
if err != nil {
return nil, fmt.Errorf("invalid start date: %w", err)
}
enddate, err := time.Parse("2006-01-02", endDateStr)
if err != nil {
return nil, fmt.Errorf("invalid end date: %w", err)
}
data := map[string]any{
"booked_by": map[string]any{
"user": map[string]any{