Skip to content

Commit

Permalink
Pre-populated "date issued" and "date due" on edit invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
TreyWW committed Dec 13, 2023
1 parent dccc610 commit bcd0673
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion backend/views/core/invoices/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ def invoice_get_existing_data(invoice_obj):
"og_cilent_city": invoice_obj.client_city,
"og_cilent_county": invoice_obj.client_county,
"og_cilent_country": invoice_obj.client_country,
"og_date_issued": invoice_obj.date_issued,
"og_date_due": invoice_obj.date_due,
}
return stored_data


# gets invoice object from invoice id, convert obj to dict, and renders edit.html while passing the stored invoice values to frontend
def invoice_edit_page_get(request, invoice_id):
context = {"type": "edit"}
try:
invoice = Invoice.objects.get(id=invoice_id)
except:
Expand Down
5 changes: 3 additions & 2 deletions frontend/templates/pages/invoices/edit/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ <h3 class="text-sm text-natural font-semibold hidden lg:block text-end me-6">To<
Issue date
<span class="required_star">*</span>
</label>
<input required id="dateIssued" name="date_issued" placeholder="" type="date"
<input required id="dateIssued" name="date_issued" placeholder=""
value="{{ og_date_issued|date:"Y-m-d" }}" type="date"
class="peer input input-bordered input-block">
<label class="label peer-[&amp;:not(:placeholder-shown):not(:focus):invalid]:block hidden ">
<span class="label-text-alt text-error">Please enter a valid date.</span>
Expand All @@ -42,7 +43,7 @@ <h3 class="text-sm text-natural font-semibold hidden lg:block text-end me-6">To<
<span class="required_star">*</span>
</label>
<input required name="date_due" id="dueDate" placeholder="" type="date"
class="peer input-bordered input input-block">
class="peer input-bordered input input-block" value="{{ og_date_due|date:"Y-m-d" }}">
<label class="label peer-[&amp;:not(:placeholder-shown):not(:focus):invalid]:block hidden ">
<span class="label-text-alt text-error">Please enter a valid date.</span>
</label>
Expand Down

0 comments on commit bcd0673

Please sign in to comment.