PFM63 pricing
This commit is contained in:
@@ -1,34 +1,19 @@
|
||||
package pricing
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/manterfield/go-mapreader"
|
||||
)
|
||||
|
||||
type MMS43PricingService struct{}
|
||||
|
||||
func NewMMS43PricingService() (*MMS43PricingService, error) {
|
||||
return &MMS43PricingService{}, nil
|
||||
}
|
||||
|
||||
func (s *MMS43PricingService) Prices(vars map[string]any) (map[string]Price, error) {
|
||||
driver_distance, err := mapreader.IntErr(vars, "journey.driver_distance")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parameter not found : %v", err)
|
||||
}
|
||||
passenger_distance, err := mapreader.IntErr(vars, "journey.passenger_distance")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parameter not found : %v", err)
|
||||
}
|
||||
|
||||
func (s *MMS43PricingService) Prices(params PricingParams) (map[string]Price, error) {
|
||||
return map[string]Price{
|
||||
"passenger": {
|
||||
Amount: 0.32 * float64(passenger_distance),
|
||||
Amount: 0.32 * float64(params.SharedMobility.PassengerDistance),
|
||||
Currency: "EUR/2",
|
||||
},
|
||||
"driver": {
|
||||
Amount: 0.32 * float64(driver_distance),
|
||||
Amount: 0.32 * float64(params.SharedMobility.DriverDistance),
|
||||
Currency: "EUR/2",
|
||||
},
|
||||
}, nil
|
||||
|
||||
Reference in New Issue
Block a user