packeta final, wise edit vs
This commit is contained in:
parent
02f7bfdc9f
commit
75add99d4a
@ -1,6 +1,6 @@
|
||||
import csv
|
||||
import chardet
|
||||
from datetime import datetime
|
||||
from datetime import datetime, date
|
||||
from gpc import Data, Header, TransactionCode, CURRENCIES_GPC
|
||||
from utils import extract_order_number, extract_numbers, parse_date
|
||||
import mysql.connector
|
||||
@ -116,7 +116,7 @@ def convert_csv_to_gpc_allegro(csv_file_path, gpc_file_path, account_number, cur
|
||||
turnover_debet_sign='0',
|
||||
turnover_credit=127226,
|
||||
turnover_credit_sign='0',
|
||||
transaction_list_no=3,
|
||||
transaction_list_no=int(date.today().strftime("%j")),
|
||||
date=datetime.now()
|
||||
)
|
||||
gpc_lines["payu"].append(header.to_string())
|
||||
@ -133,7 +133,7 @@ def convert_csv_to_gpc_allegro(csv_file_path, gpc_file_path, account_number, cur
|
||||
turnover_debet_sign='0',
|
||||
turnover_credit=127226,
|
||||
turnover_credit_sign='0',
|
||||
transaction_list_no=3,
|
||||
transaction_list_no=int(date.today().strftime("%j")),
|
||||
date=datetime.now()
|
||||
)
|
||||
gpc_lines["przelewy24"].append(header.to_string())
|
||||
@ -151,7 +151,7 @@ def convert_csv_to_gpc_allegro(csv_file_path, gpc_file_path, account_number, cur
|
||||
turnover_debet_sign='0',
|
||||
turnover_credit=127226,
|
||||
turnover_credit_sign='0',
|
||||
transaction_list_no=3,
|
||||
transaction_list_no=int(date.today().strftime("%j")),
|
||||
date=datetime.now()
|
||||
)
|
||||
gpc_lines["allegro finance"].append(header.to_string())
|
||||
|
@ -5,7 +5,7 @@ import os
|
||||
import io
|
||||
import zipfile
|
||||
import shutil
|
||||
from datetime import datetime
|
||||
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
|
||||
@ -161,10 +161,10 @@ def convert_payu2comgate(csv_file_path, account_number, currency, mapping):
|
||||
payout_data = Data(
|
||||
account=account_number,
|
||||
payer_account=account_number,
|
||||
no=int(total_payout),
|
||||
no=int(rows[-1]['ID transakce']),
|
||||
balance=total_payout,
|
||||
code=TransactionCode.DEBET,
|
||||
variable=int(total_payout),
|
||||
variable=int(rows[-1]['ID transakce']),
|
||||
# variable=corresponding_transaction['Zpráva pro příjemce'].split(',')[-1].strip(),
|
||||
constant_symbol=0,
|
||||
bank_code=0,
|
||||
@ -192,7 +192,7 @@ def convert_payu2comgate(csv_file_path, account_number, currency, mapping):
|
||||
turnover_debet_sign='+',
|
||||
turnover_credit=total_payout,
|
||||
turnover_credit_sign='+',
|
||||
transaction_list_no=3,
|
||||
transaction_list_no=int(date.today().strftime("%j")),
|
||||
date=datetime.now()
|
||||
)
|
||||
gpc_lines.insert(0, header.to_string())
|
||||
|
@ -5,7 +5,7 @@ import os
|
||||
import io
|
||||
import zipfile
|
||||
import shutil
|
||||
from datetime import datetime
|
||||
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
|
||||
@ -248,7 +248,7 @@ def convert_csv_to_gpc_paynl_auto(csv_file_path, account_number, currency, mappi
|
||||
turnover_debet_sign='+',
|
||||
turnover_credit=total_payout,
|
||||
turnover_credit_sign='+',
|
||||
transaction_list_no=3,
|
||||
transaction_list_no=int(date.today().strftime("%j")),
|
||||
date=datetime.now()
|
||||
)
|
||||
gpc_lines.insert(0, header.to_string())
|
||||
|
@ -5,7 +5,7 @@ import os
|
||||
import io
|
||||
import zipfile
|
||||
import shutil
|
||||
from datetime import datetime
|
||||
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
|
||||
@ -227,7 +227,7 @@ def convert_csv_to_gpc_przelewy24_auto(csv_file_path, account_number, currency,
|
||||
turnover_debet_sign='+',
|
||||
turnover_credit=total_payout,
|
||||
turnover_credit_sign='+',
|
||||
transaction_list_no=3,
|
||||
transaction_list_no=int(date.today().strftime("%j")),
|
||||
date=datetime.now()
|
||||
)
|
||||
gpc_lines.insert(0, header.to_string())
|
||||
|
@ -5,7 +5,7 @@ import os
|
||||
import io
|
||||
import zipfile
|
||||
import shutil
|
||||
from datetime import datetime
|
||||
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
|
||||
@ -251,7 +251,7 @@ def convert_csv_to_gpc_przelewy24_transactions(rows, refunds, payout_id, account
|
||||
turnover_debet_sign='+',
|
||||
turnover_credit=total_payout,
|
||||
turnover_credit_sign='+',
|
||||
transaction_list_no=3,
|
||||
transaction_list_no=int(date.today().strftime("%j")),
|
||||
date=datetime.now()
|
||||
)
|
||||
gpc_lines.insert(0, header.to_string())
|
||||
|
30
csv2gpc.py
30
csv2gpc.py
@ -1,8 +1,10 @@
|
||||
import csv
|
||||
import chardet
|
||||
from datetime import datetime
|
||||
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
|
||||
|
||||
|
||||
def convert_csv_to_gpc(csv_file_path, gpc_file_path, account_number, currency, mapping):
|
||||
gpc_lines = []
|
||||
@ -20,7 +22,7 @@ def convert_csv_to_gpc(csv_file_path, gpc_file_path, account_number, currency, m
|
||||
turnover_debet_sign='0',
|
||||
turnover_credit=127226,
|
||||
turnover_credit_sign='0',
|
||||
transaction_list_no=3,
|
||||
transaction_list_no=int(date.today().strftime("%j")),
|
||||
date=datetime.now()
|
||||
)
|
||||
gpc_lines.append(header.to_string())
|
||||
@ -54,9 +56,31 @@ def convert_csv_to_gpc(csv_file_path, gpc_file_path, account_number, currency, m
|
||||
if payer_account != 0:
|
||||
if payer_account.strip() == "":
|
||||
payer_account = 0
|
||||
source_amount = float(row[mapping['source_amount']].replace(',', '.')) * 100 # Convert to cents
|
||||
|
||||
source_str = row[mapping['source_amount']].replace(',', '.')
|
||||
source_amount = Decimal(source_str)
|
||||
|
||||
# Quantize to 2 decimal places (rounding if necessary)
|
||||
source_amount = source_amount.quantize(Decimal('0.01'), rounding=ROUND_HALF_UP)
|
||||
|
||||
# Multiply by 100 to get cents (if that's what you need) and convert to integer
|
||||
source_amount = int(source_amount * 100)
|
||||
|
||||
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 ("GLS GENERAL" in row[mapping['source_name']]):
|
||||
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']]:
|
||||
reference = row[mapping['reference']].split("TCH ")[-1].split(" PAYPRO")[0]
|
||||
|
||||
|
||||
# Determine transaction type
|
||||
if(direction is None):
|
||||
if source_amount > 0:
|
||||
|
Loading…
Reference in New Issue
Block a user