aboutsummaryrefslogtreecommitdiff
path: root/app/dispatch
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2018-01-08 11:27:19 -0500
committerMitch Riedstra <mitch@riedstra.us>2018-01-08 11:27:19 -0500
commit25520245c37b0df8bd86ac4901c18146f84525ee (patch)
tree3c9ed4a60adfae1394651571a8fb4d7dc5d5bf5c /app/dispatch
parenta7966a6ab6ed824613f1e22b568a1eba56e8369f (diff)
downloaddispatch-tracker-25520245c37b0df8bd86ac4901c18146f84525ee.tar.gz
dispatch-tracker-25520245c37b0df8bd86ac4901c18146f84525ee.tar.xz
Final touches on fake invoice generation
Diffstat (limited to 'app/dispatch')
-rw-r--r--app/dispatch/management/commands/insert_fake_data.py54
1 files changed, 12 insertions, 42 deletions
diff --git a/app/dispatch/management/commands/insert_fake_data.py b/app/dispatch/management/commands/insert_fake_data.py
index 0ceac6e..f9e2348 100644
--- a/app/dispatch/management/commands/insert_fake_data.py
+++ b/app/dispatch/management/commands/insert_fake_data.py
@@ -19,7 +19,7 @@ class Command(BaseCommand):
help = """Generate fake data.\n
Example usage: \n
./manage.py insert_fake_data --companies 4 --users 3 --loads 800
- --start-date='-16w' --end-date '+16w' --attachments=True"""
+ --start-date='-16w' --end-date '+16w' --attachments=True --invoices=True"""
fake = Faker()
end_date = ""
@@ -78,66 +78,36 @@ class Command(BaseCommand):
# and can/should be fixed later
start_load = Load.objects.order_by('date')[0]
end_load = Load.objects.order_by('-date')[0]
- # print("Start Load: {} PK: {} user: {}".format(start_load, start_load.pk, start_load.user))
- # print("End Load: {} PK: {} user: {}".format(end_load, end_load.pk, end_load.user))
+
+ generated_invoices = []
# Use the date of the first load to the date of the last load, and
# iterate over all of the weeks in between
for dt in rrule.rrule(rrule.WEEKLY, dtstart=start_load.date, until=end_load.date):
- print(dt)
-
- # This will hold all of the users for the week
users = []
-
- # Let's get a listing of loads for the week
wk = get_week_dates_datetime(dt)
loads = Load.objects.filter(date__range=[wk['start_date'], wk['end_date']])
for l in loads:
if l.user not in users:
users.append(l.user)
- print(l.user)
-
+ # print(l.user)
for u in users:
due_date = wk['start_date'] + datetime.timedelta(days=30)
inv = Invoice(user=u, invoice_date=wk['start_date'], due_date=due_date)
-
inv.setup()
-
inv.save()
-
+ generated_invoices.append(inv.pk)
inv.populate_items(start_date=wk['start_date'], end_date=wk['end_date'])
- print(inv)
-
-
- # wk = get_week_dates_datetime(dt)
- # loads = Load.objects.filter(date__range=[wk['start_date'], wk['end_date']])
- # loads = loads.order_by('user')
-
- # uniqe_users
-
- # print("################################################################################")
- # print("MUH LOADS")
- # print("FOR: {}".format(dt))
- # for l in loads:
- # print("PK: {}, Date: {}, User: {}".format(l.pk, l.date, l.user))
- # print(loads)
- # print("################################################################################")
-
-
- # break
-
-
-
-
- # users = User.objects.all()
- # for u in users:
- # inv = Invoice(user=u, invoice_date=start_date, due_date=due_date)
- # inv.setup()
- # inv.save()
+ # Pay for half of the invoices we've generated
+ generated_invoices = generated_invoices[0:int(len(generated_invoices)/2)]
+ for pk in generated_invoices:
+ inv = Invoice.objects.get(pk=pk)
+ inv.paid = True
+ inv.payment_identifier = "Check #{}".format(random.randint(1050,10000))
+ inv.save()
- # inv.populate_items_default_date
def fake_customer(self):
new_customer = Customer(