mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-12 13:46:51 +00:00
better date formatting
This commit is contained in:
parent
6bff5ccc18
commit
ee3674e12f
2 changed files with 7 additions and 3 deletions
|
|
@ -51,7 +51,10 @@ func (bs Service) Create(From time.Time, To time.Time, Name string, PhoneNumber
|
||||||
PlatformFees: PlatformFees,
|
PlatformFees: PlatformFees,
|
||||||
ExternalId: externalId,
|
ExternalId: externalId,
|
||||||
}
|
}
|
||||||
_ = bs.db.Create(b)
|
err := bs.db.Create(b)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,7 +251,6 @@ func (bs Service) ParseFromApi(rawContent string) (*Booking, error) {
|
||||||
item := extractString(`Maison 1 Chambre \((T2|T3) -`, content)
|
item := extractString(`Maison 1 Chambre \((T2|T3) -`, content)
|
||||||
externalId := extractString(`Numéro de réservation : \n\s+(\d+)`, content)
|
externalId := extractString(`Numéro de réservation : \n\s+(\d+)`, content)
|
||||||
standardRate := extractFloat(`Standard Rate\n\s+€ (\d+)`, content)
|
standardRate := extractFloat(`Standard Rate\n\s+€ (\d+)`, content)
|
||||||
|
|
||||||
taxQty := (totalAmount - standardRate*float64(stayLength)) / 1.5
|
taxQty := (totalAmount - standardRate*float64(stayLength)) / 1.5
|
||||||
|
|
||||||
b := bs.Create(*formatDate(arrivalDate), *formatDate(departureDate), customerName, "", customerEmail, "Booking", customerNumber, commissionAmount, externalId)
|
b := bs.Create(*formatDate(arrivalDate), *formatDate(departureDate), customerName, "", customerEmail, "Booking", customerNumber, commissionAmount, externalId)
|
||||||
|
|
@ -313,10 +315,11 @@ func formatDate(date string) *time.Time {
|
||||||
"sep": "09", "oct": "10", "nov": "11", "déc": "12",
|
"sep": "09", "oct": "10", "nov": "11", "déc": "12",
|
||||||
}
|
}
|
||||||
parts := strings.Split(date, " ")
|
parts := strings.Split(date, " ")
|
||||||
dateString := fmt.Sprintf("%s-%s-%s", parts[2], months[parts[1]], parts[0])
|
dateString := fmt.Sprintf("%s-%02s-%02s", parts[2], months[parts[1]], parts[0])
|
||||||
|
|
||||||
t, err := time.Parse(time.DateOnly, dateString)
|
t, err := time.Parse(time.DateOnly, dateString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &t
|
return &t
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import (
|
||||||
|
|
||||||
func handleSync(bs *booking.Service) echo.HandlerFunc {
|
func handleSync(bs *booking.Service) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
log.Info("received booking sync request from booking")
|
||||||
x := c.Request().Body
|
x := c.Request().Body
|
||||||
body, err := io.ReadAll(x)
|
body, err := io.ReadAll(x)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue