mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-12 13:46:51 +00:00
fix: booking parsing
fix: guest number fix: item name fix: parsing
This commit is contained in:
parent
677e623edf
commit
a5095963dc
1 changed files with 7 additions and 6 deletions
|
|
@ -29,7 +29,7 @@ func (bs Service) ParseFromApi(rawContent string) (*Booking, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
customerName, err := extractString(`Nom du client : \n\s+([\w\s]+)`, content)
|
||||
customerName, err := extractString(`Nom du client : \\n\s+([A-Za-z\s]+)`, content)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ func (bs Service) ParseFromApi(rawContent string) (*Booking, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
customerNumber, err := extractInt(`Nombre de personnes : \s*\n\s*(\d+)`, content)
|
||||
customerNumber, err := extractInt(`Nombre de personnes : \s*\\n\s*(\d+)`, content)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -50,17 +50,17 @@ func (bs Service) ParseFromApi(rawContent string) (*Booking, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
itemName, err := extractString(`Maison . Chambre. \((T2|T3) -`, content)
|
||||
itemName, err := extractString(`Maison . Chambre.\((T2|T3) -`, content)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
externalId, err := extractString(`Numéro de réservation : \n\s+(\d+)`, content)
|
||||
externalId, err := extractString(`Numéro de réservation : \\n\s+(\d+)`, content)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
standardRate, err := extractFloat(`Standard Rate\n\s+€ (\d+)`, content)
|
||||
standardRate, err := extractFloat(`Standard Rate\\n\s+€ (\d+)`, content)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -84,6 +84,7 @@ func extractDate(pattern, content string) (string, error) {
|
|||
// Regular expression to remove the prefix
|
||||
rePrefix := regexp.MustCompile(pattern + `\w+\.\s*`)
|
||||
dateString := rePrefix.ReplaceAllString(dateMatch, "")
|
||||
log.Println(dateString)
|
||||
return dateString, nil
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +128,7 @@ func extractString(pattern, content string) (string, error) {
|
|||
|
||||
func formatDate(date string) *time.Time {
|
||||
months := map[string]string{
|
||||
"janv.": "01", "févr.": "02", "mar": "03", "avr": "04",
|
||||
"janv.": "01", "févr.": "02", "mar.": "03", "avr.": "04",
|
||||
"mai": "05", "juin": "06", "juil.": "07", "août": "08",
|
||||
"sep.": "09", "oct.": "10", "nov.": "11", "déc.": "12",
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue