account_reconcile_model_strict_match_amount: Fix _get_select_communication_flag and _get_select_payment_reference_flag

This commit is contained in:
nguyenhk
2021-11-01 17:19:48 +07:00
parent 0a5792ecf9
commit 5582ee3dc8

View File

@@ -14,36 +14,17 @@ class AccountReconcileModel(models.Model):
) )
# flake8: noqa # flake8: noqa
def _get_select_communication_flag(self): def _get_select_communication_flag(self):
comm_flag = super()._get_select_communication_flag()
if not self.match_total_amount or not self.strict_match_total_amount: if not self.match_total_amount or not self.strict_match_total_amount:
return super()._get_select_communication_flag() return comm_flag
else: # comm_flag.replace is for 13.0
return r""" comm_flag = (
-- Determine a matching or not with the statement line communication using the aml.name, move.name or move.ref. r"""
COALESCE( COALESCE(
( """
aml.name IS NOT NULL + comm_flag.replace("AS communication_flag", "")
AND + r"""
substring(REGEXP_REPLACE(aml.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*') != ''
AND
regexp_split_to_array(substring(REGEXP_REPLACE(aml.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'),'\s+')
&& regexp_split_to_array(substring(REGEXP_REPLACE(st_line.payment_ref, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'), '\s+')
)
OR
regexp_split_to_array(substring(REGEXP_REPLACE(move.name, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'),'\s+')
&&
regexp_split_to_array(substring(REGEXP_REPLACE(st_line.payment_ref, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'), '\s+')
OR
(
move.ref IS NOT NULL
AND
substring(REGEXP_REPLACE(move.ref, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*') != ''
AND
regexp_split_to_array(substring(REGEXP_REPLACE(move.ref, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'),'\s+')
&&
regexp_split_to_array(substring(REGEXP_REPLACE(st_line.payment_ref, '[^0-9|^\s]', '', 'g'), '\S(?:.*\S)*'), '\s+')
)
, FALSE) , FALSE)
AND AND
CASE CASE
@@ -54,19 +35,20 @@ class AccountReconcileModel(models.Model):
""".format( """.format(
match_total_amount_param=self.match_total_amount_param match_total_amount_param=self.match_total_amount_param
) )
)
return comm_flag
def _get_select_payment_reference_flag(self): def _get_select_payment_reference_flag(self):
ref_flag = super()._get_select_payment_reference_flag()
if not self.match_total_amount or not self.strict_match_total_amount: if not self.match_total_amount or not self.strict_match_total_amount:
return super()._get_select_payment_reference_flag() return ref_flag
else: # ref_flag.replace is for 13.0
return r""" ref_flag = (
-- Determine a matching or not with the statement line communication using the move.payment_reference. r"""
COALESCE COALESCE(
( """
move.payment_reference IS NOT NULL + ref_flag.replace("AS reference_flag", "")
AND + r"""
regexp_replace(move.payment_reference, '\s+', '', 'g') =
regexp_replace(st_line.payment_ref, '\s+', '', 'g')
, FALSE) , FALSE)
AND AND
CASE CASE
@@ -77,3 +59,5 @@ class AccountReconcileModel(models.Model):
""".format( """.format(
match_total_amount_param=self.match_total_amount_param match_total_amount_param=self.match_total_amount_param
) )
)
return ref_flag