regex edit

This commit is contained in:
t0is 2025-03-12 08:16:14 +01:00
parent 75add99d4a
commit de73ddd543

View File

@ -4,6 +4,7 @@ from datetime import datetime, date
from gpc import Data, Header, TransactionCode, CURRENCIES_GPC
from utils import extract_order_number, extract_numbers, parse_date
from decimal import Decimal, ROUND_HALF_UP
import re
def convert_csv_to_gpc(csv_file_path, gpc_file_path, account_number, currency, mapping):
@ -68,16 +69,18 @@ def convert_csv_to_gpc(csv_file_path, gpc_file_path, account_number, currency, m
created_on = parse_date(row[mapping['created_on']])
if reference == '0' and row[mapping['source_name']] == "Zasilkovna SRO":
reference = row[mapping['reference']]
if reference == '0' and row[mapping['source_name']].lower() == "zasilkovna sro":
match = re.compile(r'\b\d{10}\b').search(row[mapping['reference']])
if match:
reference = match.group(0)
if reference == '0' and ("GLS GENERAL" in row[mapping['source_name']]):
if reference == '0' and ("gls general" in row[mapping['source_name']].lower()):
reference = str(source_amount)
if reference == '0' and mapping['forced_encoding'] == 'iso-8859-2':
reference = extract_order_number(row[8])
if "p24w-" in row[mapping['reference']]:
if "p24w-" in row[mapping['reference']].lower():
reference = row[mapping['reference']].split("TCH ")[-1].split(" PAYPRO")[0]