Changeset 18ad664 in tailbone


Ignore:
Timestamp:
03/27/19 21:06:23 (6 months ago)
Author:
Lance Edgar <ledgar@…>
Branches:
master
Children:
24547b4
Parents:
d60679a
Message:

Add validation when "declaring credit" for receiving batch row

i.e. don't just blindly attempt, when it isn't supported

Location:
tailbone
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tailbone/templates/receiving/declare_credit.mako

    rd60679a r18ad664  
    4040
    4141  <div class="form-wrapper">
     42
     43    <p style="padding: 1em;">
     44      Please select the "state" of the product, and enter the appropriate
     45      quantity.
     46    </p>
     47
     48    <p style="padding: 1em;">
     49      Note that this tool will <strong>deduct</strong> from the "received"
     50      quantity, and <strong>add</strong> to the corresponding credit quantity.
     51    </p>
     52
     53    <p style="padding: 1em;">
     54      Please see ${h.link_to("Receive Row", url('{}.receive_row'.format(route_prefix), uuid=batch.uuid, row_uuid=row.uuid))}
     55      if you need to "receive" instead of "convert" the product.
     56    </p>
     57
    4258    ${form.render()|n}
    4359  </div><!-- form-wrapper -->
  • tailbone/templates/receiving/receive_row.mako

    rd60679a r18ad664  
    4040
    4141  <div class="form-wrapper">
     42
     43    <p style="padding: 1em;">
     44      Please select the "state" of the product, and enter the appropriate
     45      quantity.
     46    </p>
     47
     48    <p style="padding: 1em;">
     49      Note that this tool will <strong>add</strong> the corresponding
     50      quantities for the row.
     51    </p>
     52
     53    <p style="padding: 1em;">
     54      Please see ${h.link_to("Declare Credit", url('{}.declare_credit'.format(route_prefix), uuid=batch.uuid, row_uuid=row.uuid))}
     55      if you need to "convert" some already-received amount, into a credit.
     56    </p>
     57
    4258    ${form.render()|n}
    4359  </div><!-- form-wrapper -->
  • tailbone/views/purchasing/receiving.py

    rd60679a r18ad664  
    862862        schema = ReceiveRowForm().bind(session=self.Session())
    863863        form = forms.Form(schema=schema, request=self.request)
     864        form.cancel_url = self.get_row_action_url('view', row, mobile=mobile)
    864865        form.set_widget('mode', forms.widgets.JQuerySelectWidget(values=[(m, m) for m in possible_modes]))
    865866        form.set_widget('quantity', forms.widgets.CasesUnitsWidget(amount_required=True,
     
    997998        }
    998999
    999         schema = DeclareCreditForm().bind(session=self.Session())
     1000        schema = DeclareCreditForm()
    10001001        form = forms.Form(schema=schema, request=self.request)
    10011002        form.set_widget('credit_type', forms.widgets.JQuerySelectWidget(
     
    10121013            kwargs['units'] = kwargs['quantity']['units']
    10131014            del kwargs['quantity']
    1014             self.handler.declare_credit(row, **kwargs)
    1015 
    1016             return self.redirect(self.get_row_action_url('view', row))
     1015            try:
     1016                result = self.handler.can_declare_credit(row, **kwargs)
     1017            except Exception as error:
     1018                self.request.session.flash("Handler says you can't declare that credit: {}".format(error), 'error')
     1019            else:
     1020                if result:
     1021                    self.handler.declare_credit(row, **kwargs)
     1022                    return self.redirect(self.get_row_action_url('view', row))
     1023
     1024                self.request.session.flash("Handler says you can't declare that credit; not sure why", 'error')
    10171025
    10181026        context['form'] = form
Note: See TracChangeset for help on using the changeset viewer.