Added CNB rate count and SN from BIS
This commit is contained in:
45
main.py
45
main.py
@@ -14,12 +14,23 @@ import time
|
||||
import configparser
|
||||
from pandastable import Table
|
||||
import pathlib
|
||||
import cnb_exchange_rate
|
||||
|
||||
ver = "0.4.5"
|
||||
|
||||
ver = "0.4.6"
|
||||
|
||||
outvar = {}
|
||||
|
||||
|
||||
def getCNBRates():
|
||||
current_month = datetime.now().strftime('%m')
|
||||
current_year_full = datetime.now().strftime('%Y')
|
||||
rate = cnb_exchange_rate.daily_rate('EUR', datetime(2022, 12, 1))
|
||||
return rate
|
||||
|
||||
getCNBRates()
|
||||
|
||||
|
||||
def updateapp():
|
||||
print("Updating app")
|
||||
ret = sp.call(["python", "update.py"])
|
||||
@@ -143,15 +154,19 @@ def pairBis():
|
||||
iccid = row['ICCID']
|
||||
print("iccid: ",iccid)
|
||||
print("phoneno: ", phoneno)
|
||||
MU_ID = row['MU ID']
|
||||
if phoneno == 882390031032318:
|
||||
print("found")
|
||||
sys.exit()
|
||||
|
||||
|
||||
bisbyphoneno[phoneno] = {'amount': amount, 'currency': currency, 'code': code, 'textid': textid}
|
||||
bisbyphoneno[phoneno] = {'amount': amount, 'currency': currency, 'code': code, 'textid': textid, 'mu_id': MU_ID}
|
||||
|
||||
# We don't have valid Phone number, so we use ICCID if possible
|
||||
elif row['ICCID'] != '' and row['ICCID'] != 'True' and row['ICCID'] != 'False':
|
||||
|
||||
print("We have no Phone number, trying to pair by iccid")
|
||||
iccid = row['ICCID']
|
||||
MU_ID = row['MU ID']
|
||||
phoneno = 0
|
||||
amount = row['Amount']
|
||||
currency = row['Currency']
|
||||
@@ -159,7 +174,7 @@ def pairBis():
|
||||
textid = row['Text ID']
|
||||
print("iccid: ", iccid)
|
||||
print("phoneno: ", phoneno)
|
||||
bisbyiccid[iccid] = {'amount': amount, 'currency': currency, 'code': code, 'textid': textid}
|
||||
bisbyiccid[iccid] = {'amount': amount, 'currency': currency, 'code': code, 'textid': textid, 'mu_id': MU_ID}
|
||||
|
||||
else:
|
||||
print("skipping record, no valid Phone No. or ICCID")
|
||||
@@ -199,6 +214,7 @@ def pairBis():
|
||||
currency = bisbyphoneno[MSISDN]['currency']
|
||||
code = bisbyphoneno[MSISDN]['code']
|
||||
textid = bisbyphoneno[MSISDN]['textid']
|
||||
mu_id = bisbyphoneno[MSISDN]['mu_id']
|
||||
|
||||
|
||||
elif ICCID in bisbyiccid:
|
||||
@@ -206,6 +222,8 @@ def pairBis():
|
||||
currency = bisbyiccid[ICCID]['currency']
|
||||
code = bisbyiccid[ICCID]['code']
|
||||
textid = bisbyiccid[ICCID]['textid']
|
||||
print("iccid: ", ICCID)
|
||||
mu_id = bisbyiccid[ICCID]['mu_id']
|
||||
|
||||
|
||||
else:
|
||||
@@ -215,6 +233,7 @@ def pairBis():
|
||||
currency = "N/A"
|
||||
code = "N/A"
|
||||
textid = "N/A"
|
||||
mu_id = "N/A"
|
||||
testcounter += 1
|
||||
print("testcounter: ", testcounter)
|
||||
|
||||
@@ -227,7 +246,7 @@ def pairBis():
|
||||
'DATA-AMOUNT': DATAAMOUNT, 'SMS-PRICE': SMSPRICE, 'SMS-COUNT': SMSCOUNT,
|
||||
'OTHER-PRICE': OTHERPRICE, 'SIM-STATUS': SIMSTATUS, 'SN': SN,
|
||||
'SN-DEC': SNDEC, 'UNIT': UNIT, 'LAST-DATA': LASTDATA, 'OPERATOR': OPERATOR,
|
||||
'amount': amount, 'currency': currency, 'code': code, 'textid': textid}
|
||||
'amount': amount, 'currency': currency, 'code': code, 'textid': textid, 'mu_id': mu_id}
|
||||
# this still works...
|
||||
|
||||
|
||||
@@ -240,9 +259,12 @@ def pairBis():
|
||||
writer = csv.writer(f)
|
||||
writer.writerow(
|
||||
["MSISDN", "ICCID", "IMSI", "DATA-PRICE", "DATA-AMOUNT", "SMS-PRICE", "SMS-COUNT", "OTHER-PRICE",
|
||||
"SIM-STATUS", "SN", "SN-DEC", "UNIT", "LAST-DATA", "OPERATOR", "AMOUNT", "CURRENCY", "CODE", "TEXTID"])
|
||||
"SIM-STATUS", "SN", "SN-DEC", "UNIT", "LAST-DATA", "OPERATOR", "AMOUNT", "CURRENCY","AMOUNT-CZK", "CODE", "TEXTID", "SN-BIS"])
|
||||
|
||||
print("how many: ", len(completepairing.keys()))
|
||||
rate = getCNBRates()
|
||||
rate = str(rate).replace(",", "." )
|
||||
|
||||
|
||||
for MSISDN in completepairing:
|
||||
|
||||
@@ -264,8 +286,17 @@ def pairBis():
|
||||
code = completepairing[MSISDN]['code']
|
||||
textid = completepairing[MSISDN]['textid']
|
||||
UNIT = completepairing[MSISDN]['UNIT']
|
||||
mu_id = completepairing[MSISDN]['mu_id']
|
||||
|
||||
print(amount)
|
||||
writer.writerow([MSISDN, ICCID, IMSI, DATAPRICE, DATAAMOUNT, SMSPRICE, SMSCOUNT, OTHERPRICE, SIMSTATUS, SN, SNDEC, UNIT, LASTDATA, OPERATOR, amount, currency, code, textid])
|
||||
if currency == "EUR":
|
||||
amount = float(amount.replace(",", "." ))
|
||||
amountczk = float(amount) * float(rate)
|
||||
amountczk = round(amountczk, 2)
|
||||
else:
|
||||
amountczk = amount
|
||||
|
||||
writer.writerow([MSISDN, ICCID, IMSI, DATAPRICE, DATAAMOUNT, SMSPRICE, SMSCOUNT, OTHERPRICE, SIMSTATUS, SN, SNDEC, UNIT, LASTDATA, OPERATOR, amount, currency, amountczk, code, textid, mu_id])
|
||||
print("Pairing BIS file with merged output file done")
|
||||
|
||||
def merge():
|
||||
|
||||
Reference in New Issue
Block a user