Skip to content

Commit

Permalink
Fix morning/evening deactivated autopilot bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalloor, Eric Abraham committed Sep 25, 2023
1 parent 4494739 commit ae7e21c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions register/templates/register/react_register.html
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ <h3> to </h3>
<div className="col-6">
<h5 className="mb-4">Morning Register</h5>
{this.state.data.m_register.map((entry, index) => {
return entry.status && (
return entry.status && entry.m_quantity && (
<label key={index}
className="container-register autopilot-modal-content-mobile">{entry.name} | {entry.m_quantity} ML
<input name={`${entry.id}-morning`}
Expand Down Expand Up @@ -585,7 +585,7 @@ <h5 className="mb-4 text-success">Add Customer to
<div className="col-6">
<h5 className="mb-4">Evening Register</h5>
{this.state.data.e_register.map((entry, index) => {
return entry.status && (
return entry.status && entry.e_quantity && (
<label key={index}
className="container-register autopilot-modal-content-mobile">{entry.name} | {entry.e_quantity} ML
<input name={`${entry.id}-evening`}
Expand Down
17 changes: 8 additions & 9 deletions register/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,15 +475,14 @@ def autopilot(request, year=None, month=None):
e.log_date == current_date and e.schedule.startswith(
cust['schedule']))
except StopIteration:
register_entries.append(Register(tenant=tenant,
customer_id=customer.id,
log_date=current_date,
schedule=f'{cust["schedule"]}-yes',
quantity=getattr(customer,
schedule_to_attr.get(
cust['schedule'],
'm_quantity')),
current_price=current_price))
quantity = getattr(customer,schedule_to_attr[cust['schedule']])
if quantity is not None:
register_entries.append(Register(tenant=tenant,
customer_id=customer.id,
log_date=current_date,
schedule=f'{cust["schedule"]}-yes',
quantity=quantity,
current_price=current_price))

Register.objects.bulk_create(register_entries) # Create bulk Register entry
response = {
Expand Down

0 comments on commit ae7e21c

Please sign in to comment.