regex edit
This commit is contained in:
parent
75add99d4a
commit
de73ddd543
11
csv2gpc.py
11
csv2gpc.py
@ -4,6 +4,7 @@ from datetime import datetime, date
|
|||||||
from gpc import Data, Header, TransactionCode, CURRENCIES_GPC
|
from gpc import Data, Header, TransactionCode, CURRENCIES_GPC
|
||||||
from utils import extract_order_number, extract_numbers, parse_date
|
from utils import extract_order_number, extract_numbers, parse_date
|
||||||
from decimal import Decimal, ROUND_HALF_UP
|
from decimal import Decimal, ROUND_HALF_UP
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
def convert_csv_to_gpc(csv_file_path, gpc_file_path, account_number, currency, mapping):
|
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']])
|
created_on = parse_date(row[mapping['created_on']])
|
||||||
|
|
||||||
if reference == '0' and row[mapping['source_name']] == "Zasilkovna SRO":
|
if reference == '0' and row[mapping['source_name']].lower() == "zasilkovna sro":
|
||||||
reference = row[mapping['reference']]
|
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)
|
reference = str(source_amount)
|
||||||
|
|
||||||
if reference == '0' and mapping['forced_encoding'] == 'iso-8859-2':
|
if reference == '0' and mapping['forced_encoding'] == 'iso-8859-2':
|
||||||
reference = extract_order_number(row[8])
|
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]
|
reference = row[mapping['reference']].split("TCH ")[-1].split(" PAYPRO")[0]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user