Skip to content

Commit

Permalink
Added inventory to pcb_detail frontend.
Browse files Browse the repository at this point in the history
  • Loading branch information
chintal committed Jan 11, 2016
1 parent db49743 commit 87a8cd7
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def read(fname):
'pyyaml',
'progress',
'colorama',
'pcb-tools',
'python-nvd3',

# Flask Dependencies (to be pruned?)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,55 @@ <h3> Costing </h3>
{% endif %}

<!-- Inventory Information -->
<div class="small-12 medium-6 columns">
<div class="small-12 columns panel header radius">
<div class="sign small-9 medium-6 small-centered columns autoscale">
<h6>Inventory Status</h6>
</div>
<div class="small-12 columns">
<table id="inv_status_table" class="display" data-paging='false'>
<thead>
<tr>
<th class="all">Inventory Location</th>
<th class="desktop">Quantity</th>
<th class="desktop">Reserved</th>
<th class="all">Available</th>
</tr>
</thead>
<tbody>
{% for code, status in stage.inv_loc_status|dictsort %}
<tr>
<td> <a href="/inventory/location/{{ code }}">{{ status.0 }}</a> </td>
<td class="text-center"> {{ status.1 or '-' }} </td>
<td class="text-center"> {{ status.2 or '-' }} </td>
<td class="text-center"> {{ status.3 or '-' }} </td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td> <b> TOTAL </b> </td>
<td class="text-center"><b>{{ stage.inv_total_quantity }}</b></td>
<td class="text-center"><b>{{ stage.inv_total_reservations }}</b></td>
<td class="text-center"><b>{{ stage.inv_total_availability }}</b></td>
</tr>
</tfoot>
</table>
</div>
<script type="text/javascript">
$(document).ready( function () {
var table = $('#inv_status_table').DataTable({
/* Disable initial sort */
"aaSorting": [],
"info": false,
{% include 'parts/datatable_defaults.html' %}
});
table.buttons().container()
.appendTo( '#inv_status_table_wrapper .small-12.medium-6.columns:eq(0)' );
});
</script>
</div>
</div>
<!-- Product Utilization Information -->
</div>

Expand Down
28 changes: 28 additions & 0 deletions tendril/frontend/blueprints/entityhub/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from tendril.dox.gedaproject import get_pcbpricing_data
from tendril.gedaif.conffile import ConfigsFile

from tendril.inventory import electronics as invelectronics
from tendril.utils.fsutils import Crumb
from tendril.utils.types.currency import BASE_CURRENCY_SYMBOL

Expand Down Expand Up @@ -155,6 +156,7 @@ def pcbs(pcbname=None):
return render_template('entityhub_pcbs.html', stage=stage,
pagetitle="Bare PCBs")
else:

stage = {'name': pcbname,
'configdata': ConfigsFile(ehprojects.pcbs[pcbname]),
'docs': get_docs_list(ehprojects.pcbs[pcbname]),
Expand All @@ -164,6 +166,32 @@ def pcbs(pcbname=None):
'breadcrumbs': [Crumb(name="Entity Hub", path=""),
Crumb(name="Bare PCBs", path="pcbs/"),
Crumb(name=pcbname, path="pcbs/" + pcbname)]}

ident = 'PCB ' + pcbname
inv_loc_status = {}
inv_loc_transform = {}
for loc in invelectronics.inventory_locations:
qty = loc.get_ident_qty(ident) or 0
reserve = loc.get_reserve_qty(ident) or 0
inv_loc_status[loc._code] = (loc._name, qty, reserve, qty-reserve)

inv_loc_transform[loc._code] = (loc._name,
loc.tf.get_contextual_repr(ident))
inv_total_reservations = invelectronics.get_total_reservations(ident)
inv_total_quantity = invelectronics.get_total_availability(ident)
inv_total_availability = inv_total_quantity - inv_total_reservations

inv_stage = {
'inv_loc_status': inv_loc_status,
'inv_total_reservations': inv_total_reservations,
'inv_total_quantity': inv_total_quantity,
'inv_total_availability': inv_total_availability,
'inv_loc_transform': inv_loc_transform,
'inv': invelectronics,
}

stage.update(inv_stage)

return render_template('entityhub_pcb_detail.html', stage=stage,
pagetitle="PCB Details")

Expand Down

0 comments on commit 87a8cd7

Please sign in to comment.