From f24e5dc9f211c5d881e2a9cee65e2a15d2563078 Mon Sep 17 00:00:00 2001
From: Facundo Barral <facundo.barral@eynes.com.ar>
Date: Thu, 1 Feb 2024 13:03:03 -0300
Subject: [PATCH] [FIX] Normalyze symbols except dash

---
 models/hr_interbanking.py          | 8 ++++++--
 models/hr_interbanking_transfer.py | 8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/models/hr_interbanking.py b/models/hr_interbanking.py
index 93c973e..29933ed 100644
--- a/models/hr_interbanking.py
+++ b/models/hr_interbanking.py
@@ -18,12 +18,16 @@ def normalize(s):
         ("í", "i"),
         ("ó", "o"),
         ("ú", "u"),
-        ("ñ", "n")
+        ("ñ", "n"),
+        ("ü", "u")
     )
     for a, b in replacements:
         s = s.replace(a, b).replace(a.upper(), b.upper())
     return s
 
+def normalize_symbols(s):
+    return re.sub('[^a-zA-Z0-9\s-]+', ' ', normalize(s))
+
 _logger = logging.getLogger(__name__)
 
 class HRInterbankingExportAccount(models.Model):
@@ -132,7 +136,7 @@ class HRInterbankingExportAccount(models.Model):
                 "2" +
                 str(line.get("cbu", ""))[:22].zfill(22) +
                 str(line.get("cuit", ""))[:11].zfill(11) +
-                normalize(str(line.get("denomination", "")))[:40].ljust(40) +
+                normalize_symbols(str(line.get("denomination", "")))[:40].ljust(40) +
                 str(line.get("ref_use", ""))[:50].ljust(50) +
                 " " * 76
             )
diff --git a/models/hr_interbanking_transfer.py b/models/hr_interbanking_transfer.py
index 452b71b..8a8f693 100644
--- a/models/hr_interbanking_transfer.py
+++ b/models/hr_interbanking_transfer.py
@@ -20,12 +20,16 @@ def normalize(s):
         ("í", "i"),
         ("ó", "o"),
         ("ú", "u"),
-        ("ñ", "n")
+        ("ñ", "n"),
+        ("ü", "u")
     )
     for a, b in replacements:
         s = s.replace(a, b).replace(a.upper(), b.upper())
     return s
 
+def normalize_symbols(s):
+    return re.sub('[^a-zA-Z0-9\s-]+', ' ', normalize(s))
+
 _logger = logging.getLogger(__name__)
 
 class HRInterbankingExportTransfer(models.Model):
@@ -319,7 +323,7 @@ class HRInterbankingExportTransfer(models.Model):
                 "*M*" +
                 str(line.get("cbu", ""))[:22].zfill(22) +
                 str(line.get("amount", ""))[:17].zfill(17) +
-                normalize(str(line.get("denomination", "")))[:60].ljust(60) +
+                normalize_symbols(str(line.get("denomination", "")))[:60].ljust(60) +
                 "00" +
                 " " * 136
             )
-- 
GitLab