Skip to content

Commit

Permalink
Refactoring to get pilot and club data into the invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
joeeltgroth committed Jul 16, 2019
1 parent 3bf7180 commit e299b09
Show file tree
Hide file tree
Showing 5 changed files with 339 additions and 287 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,19 @@ Purpose of each:

## Run it
```
$ python build_invoices.py
$ python main.py
```

## What to expect
A pdf file will be created for each pilot in data/pilot.csv.
A pdf invoice file will be created (in the output directory) for
each pilot in data/pilot.csv.


### References
- FPDF Library: http://fpdf.org/
- Python environment manager: https://github.com/pyenv/pyenv
- Virtual Environments: https://virtualenv.pypa.io/en/latest/
- Pip Requirements: https://pip.pypa.io/en/stable/user_guide/
- Various techniques: https://stackoverflow.com


283 changes: 0 additions & 283 deletions build_invoices.py

This file was deleted.

52 changes: 52 additions & 0 deletions club.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import csv


def read_csv(filename):
rows = []
with open(filename, 'r') as csvfile:
for row in csv.reader(csvfile):
rows.append(row)
# Ignore the 2 header rows.
return rows[2:len(rows)]


class Club:

def __init__(self, club_name, club_addr1, club_addr2, club_city, club_state, club_zip,
bill_name, bill_addr1, bill_addr2, bill_city, bill_state, bill_zip):
self.club_name = club_name
self.club_addr1 = club_addr1
self.club_addr2 = club_addr2
self.club_city = club_city
self.club_state = club_state
self.club_zip = club_zip

self.bill_name = bill_name
self.bill_addr1 = bill_addr1
self.bill_addr2 = bill_addr2
self.bill_city = bill_city
self.bill_state = bill_state
self.bill_zip = bill_zip


def load(rows):
row = rows[0]
club = Club(row[0], row[1], row[2], row[3], row[4], row[5],
row[6], row[7], row[8], row[9], row[10], row[11])
return club


def get_club_info(filename):
data_rows = read_csv(filename)
club = load(data_rows)
return club


def main():
club = get_club_info("data/club.csv")

print(club.club_name, club.club_addr1, club.bill_addr1)


if __name__ == "__main__":
main()
Loading

0 comments on commit e299b09

Please sign in to comment.