diff --git a/models/common.go b/models/common.go index 0c5e460..7e51c2e 100644 --- a/models/common.go +++ b/models/common.go @@ -22,9 +22,10 @@ type Material struct { DestinationPlanned Station `json:"destination_planned"` Accessible bool `json:"accessible"` - Closed bool `json:"closed"` - RemainsBehind bool `json:"remains_behind"` - Added bool `json:"added"` + Closed bool `json:"closed"` + RemainsBehind bool `json:"remains_behind"` + Added bool `json:"added"` + AlreadyRemoved bool `json:"already_removed"` Modifications []Modification } diff --git a/models/departure.go b/models/departure.go index 839764c..911bdb2 100644 --- a/models/departure.go +++ b/models/departure.go @@ -231,7 +231,7 @@ func (departure Departure) GetRemarksTips(language string) (remarks, tips []stri if material.Closed { closedMaterialUnits = append(closedMaterialUnits, *material.NormalizedNumber()) } - if material.RemainsBehind { + if material.RemainsBehind && !material.AlreadyRemoved { leftBehindMaterialUnits = append(leftBehindMaterialUnits, *material.NormalizedNumber()) } if material.Added { diff --git a/models/departure_test.go b/models/departure_test.go index 4dba2e9..6dc929b 100644 --- a/models/departure_test.go +++ b/models/departure_test.go @@ -355,3 +355,65 @@ func TestDepartureMaterialRemarksClosed(t *testing.T) { t.Errorf("Remarks: expected %s, got %s", "Treinstellen 1234, 2345: niet instappen", remarks[0]) } } + +func TestDepartureMaterialRemarksRemainsBehindAlreadyRemoved(t *testing.T) { + var departure Departure = Departure{ + Station: Station{ + Code: "RTD", + NameMedium: "Rotterdam C.", + }, + TrainWings: []TrainWing{ + { + Material: []Material{ + { + NaterialType: "ICM", + Number: "1234", + RemainsBehind: true, + AlreadyRemoved: true, + }, + }, + }, + }, + } + + remarks, _ := departure.GetRemarksTips("nl") + + if len(remarks) > 0 { + t.Errorf("Remarks: expected no remarks, got %d", len(remarks)) + } + + departure = Departure{ + Station: Station{ + Code: "RTD", + NameMedium: "Rotterdam C.", + }, + TrainWings: []TrainWing{ + { + Material: []Material{ + { + NaterialType: "ICM", + Number: "1234", + RemainsBehind: true, + AlreadyRemoved: true, + }, + { + NaterialType: "ICM", + Number: "4321", + RemainsBehind: false, + }, + { + NaterialType: "ICM", + Number: "2345", + RemainsBehind: true, + }, + }, + }, + }, + } + + remarks, _ = departure.GetRemarksTips("nl") + + if remarks[0] != "Treinstel 2345 blijft achter in Rotterdam C." { + t.Errorf("Remarks: expected %s, got %s", "Treinstel 2345 blijft achter in Rotterdam C.", remarks[0]) + } +} diff --git a/models/modification.go b/models/modification.go index 016fd05..9b08587 100644 --- a/models/modification.go +++ b/models/modification.go @@ -98,6 +98,9 @@ const ModificationMaterialAdded = 83 // ModificationMaterialLeftBehind when material is left behind on a station const ModificationMaterialLeftBehind = 84 +// ModificationMaterialAlreadyRemoved when the material that was left behind has already been removed (driven away) +const ModificationMaterialAlreadyRemoved = 85 + // Modification is a change (to the schedule) which is communicated to travellers type Modification struct { ModificationType int `json:"type"` diff --git a/parsers/dvsparser.go b/parsers/dvsparser.go index 829eff7..3b52c8d 100644 --- a/parsers/dvsparser.go +++ b/parsers/dvsparser.go @@ -178,6 +178,8 @@ func ParseDvsMessage(reader io.Reader) (departure models.Departure, err error) { material.Added = true case models.ModificationMaterialLeftBehind: material.RemainsBehind = true + case models.ModificationMaterialAlreadyRemoved: + material.AlreadyRemoved = true } }