Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
32 changes: 19 additions & 13 deletions code/bookkeepingScripts/Python/splitmaker_PPDonation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@
import csv
import sys
import random
import datetime

#convert dates from PP format of dd/mm/yyyy to standard yyyy-mm-dd
def convertDate(inDate):
if len(inDate) < 10:
today = date.today()
inDate = inDate.strip()

if not inDate:
today = datetime.date.today()
return today.strftime("%Y-%m-%d")

try:
dt = datetime.datetime.strptime(inDate, "%d/%m/%Y")
return dt.strftime("%Y-%m-%d")
except ValueError:
today = datetime.date.today()
return today.strftime("%Y-%m-%d")
year = inDate[6 : 10]
month = inDate[3 : 5]
day = inDate[0 : 2]
newDate = year + '-' + month + '-' + day
return newDate

#convert values from ',' decimal separator to '.'.
def commaToPoint(inValue):
Expand Down Expand Up @@ -67,20 +72,21 @@ def commaToPoint(inValue):
reverseValue = -1.0
txCounterStart = random.randint(15000, 16000)

donatOut = open(donatFileName, 'w', newline='')
donatWriter = csv.writer(donatOut, delimiter=',')
with open(inputFileName) as csvIn:
donatOut = open(donatFileName, 'w', newline='', encoding='utf-8-sig')
donatWriter = csv.writer(donatOut, delimiter=',', quoting=csv.QUOTE_MINIMAL)

with open(inputFileName, encoding='utf-8-sig', newline='') as csvIn:
csvReader = csv.reader(csvIn, delimiter=',')
for line in csvReader:
recordsIn += 1
date = convertDate(line[iDate])
tx_date = convertDate(line[iDate])
baseAmount = float(commaToPoint(line[iGross]))

if paymentToken in line[iType] and refundToken not in line[iType]:
# this is (probably) a normal donat transaction
#line 1 - basic donation transaction
reversedValue = baseAmount * reverseValue
row = [date] + [commodityStringUSD] + [line[iDesc]]+ [inAccount] + [reversedValue] + [txCounterStart + recordsIn]
row = [tx_date] + [commodityStringUSD] + [line[iDesc]] + [inAccount] + [reversedValue] + [txCounterStart + recordsIn]
donatWriter.writerow(row)

#line 2 - fee deduction USD
Expand All @@ -100,4 +106,4 @@ def commaToPoint(inValue):
print("splitmaker_PPDonat records in: {0}".format(recordsIn))
print("splitmaker_PPDonat donation splits out: {0}".format(donatsOut))



6 changes: 3 additions & 3 deletions code/bookkeepingScripts/Python/streamsplitter_PP.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ def commaToPoint(inValue):
refundToken = "Refund"
AcceptedCurrencies = ["EUR", "USD"]

donationOut = open(donationFileName, 'w', newline='')
donationOut = open(donationFileName, 'w', encoding='utf-8-sig', newline='')
donationWriter = csv.writer(donationOut, delimiter=',')
manualOut = open(manualFileName, 'w', newline='')
manualOut = open(manualFileName, 'w', encoding='utf-8-sig', newline='')
manualWriter = csv.writer(manualOut, delimiter=',')
with open(inputFileName) as csvIn:
with open(inputFileName, encoding='utf-8-sig', newline='') as csvIn:
csvReader = csv.reader(csvIn, delimiter=',')
for line in csvReader:
if recordsIn == 0:
Expand Down
Binary file modified code/bookkeepingScripts/Spreadsheets/2025RevenueTrackingSheet.ods
Binary file not shown.
Binary file modified code/bookkeepingScripts/Spreadsheets/BurnPlan.ods
Binary file not shown.
Binary file modified code/bookkeepingScripts/Spreadsheets/MonthlyPaymentWorksheet.ods
Binary file not shown.
Binary file modified code/bookkeepingScripts/Spreadsheets/WeeklyTransferWorksheet.ods
Binary file not shown.