Fix date selection when using period in products_by_location

effective_date and planned_date could be both NULL so they must be considered
as date.max to be included.

review897003
Add test for date selection when using period in products_by_location

review897003