feat: ajout pricing vosges (0.30€/km conducteur, 0.20€/km passager)
This commit is contained in:
@@ -16,6 +16,8 @@ func NewPricingService(implementation string) (PricingService, error) {
|
||||
return NewMMS43PricingService()
|
||||
case "pfm63":
|
||||
return NewPFM63PricingService()
|
||||
case "vosges":
|
||||
return NewVosgesPricingService()
|
||||
default:
|
||||
return nil, fmt.Errorf("pricing implementation %v is not supported", implementation)
|
||||
|
||||
|
||||
30
pricing/pricing_vosges.go
Normal file
30
pricing/pricing_vosges.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package pricing
|
||||
|
||||
type VosgesPricingService struct{}
|
||||
|
||||
func NewVosgesPricingService() (*VosgesPricingService, error) {
|
||||
return &VosgesPricingService{}, nil
|
||||
}
|
||||
|
||||
func (s *VosgesPricingService) Prices(params PricingParams) (map[string]Price, error) {
|
||||
var distanceForPricing int64
|
||||
if params.MobilityType == "solidarity_transport" {
|
||||
distanceForPricing = params.SharedMobility.DriverDistance
|
||||
} else {
|
||||
distanceForPricing = params.SharedMobility.PassengerDistance
|
||||
}
|
||||
|
||||
passengerAmount := 0.20 * float64(distanceForPricing)
|
||||
driverAmount := 0.30 * float64(distanceForPricing)
|
||||
|
||||
return map[string]Price{
|
||||
"passenger": {
|
||||
Amount: passengerAmount,
|
||||
Currency: "EUR",
|
||||
},
|
||||
"driver": {
|
||||
Amount: driverAmount,
|
||||
Currency: "EUR",
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user