collate address: force the country to be the same when comparing postal codes

This commit is contained in:
Julien Fastré 2023-07-14 10:52:33 +02:00
parent b0fcffea2d
commit 643d8f99be
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -34,11 +34,11 @@ final readonly class CollateAddressWithReferenceOrPostalCode implements CollateA
WHERE WHERE
-- use only postal code which are reference -- use only postal code which are reference
cmpc_reference.id != cmpc.id AND cmpc_reference.origin = 0 cmpc_reference.id != cmpc.id AND cmpc_reference.origin = 0
-- only where the reference is null or the cmpc is created manually -- only where cmpc is created manually
--AND cma.addressreference_id IS NULL
AND cmpc.origin != 0 AND cmpc.origin != 0
-- only when postal code match -- only when postal code match
AND TRIM(REPLACE(LOWER(cmpc.code), ' ', '')) = LOWER(cmpc_reference.code) AND TRIM(REPLACE(LOWER(cmpc.code), ' ', '')) = LOWER(cmpc_reference.code)
AND cmpc.country_id = cmpc_reference.country_id
AND cma.id > :since_id -- to set the first id AND cma.id > :since_id -- to set the first id
) sq ) sq
WHERE ranked = 1) WHERE ranked = 1)