Commit 785b90b1 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_accounting: Update Printout details

   Bare minimal update to display details, and extend to support Compute Node/Project/Instance Tree Subscriptions.
   Don't display details if the lines don't aggregate subscription requests
parent 4b389d34
...@@ -155,47 +155,48 @@ ...@@ -155,47 +155,48 @@
</div> </div>
</aside--> </aside-->
<tal:block tal:define="aggregated_reference python: context.getCausalityReferenceList(portal_type='Sale Packing List', checked_permission='View'); <tal:block tal:define="invoice_line_list python: context.contentValues(portal_type='Invoice Line', checked_permission='View');
filter_portal_type python: {'portal_type': ['Instance Tree', 'Compute Node', 'Project']};
invoice_line_aggregate_list python: [i for i in invoice_line_list if i.getAggregate(portal_type='Subscription Request') and i.getAggregate(**filter_portal_type)];
item_dict python: {}"> item_dict python: {}">
<p class='line' tal:condition="python: aggregated_reference">&nbsp;</p> <tal:block tal:condition="python: invoice_line_aggregate_list">
<aside tal:condition="python: aggregated_reference"> <p class='line'>&nbsp;</p>
<h1><span>Subscription Details</span></h1> <aside>
<tal:block tal:repeat="line python: context.portal_catalog( <h1><span>Subscription Details</span></h1>
portal_type='Sale Packing List Line', <tal:block tal:repeat="line python: invoice_line_aggregate_list">
grouping_reference=aggregated_reference, <tal:block tal:define="aggregate python: line.getAggregateValue(**filter_portal_type);
default_resource_uid=context.service_module.slapos_instance_subscription.getUid(), item_uid python: aggregate.getUid();
sort_on=[('default_aggregate_uid', 'ASC'), ('movement.start_date', 'ASC')])"> item_title python: aggregate.getTitle();
<tal:block tal:define="item_uid python: line.getAggregateUid(portal_type='Instance Tree'); start_date python: line.getStartDate();
item_title python: line.getAggregateTitle(portal_type='Instance Tree'); stop_date python: line.getStopDate();
start_date python: line.getStartDate(); quantity python: line.getQuantity();
stop_date python: line.getStopDate(); dummy_init python: item_dict.setdefault(item_uid, [item_title, start_date, stop_date, 0]);
quantity python: line.getQuantity(); dummy_update python: item_dict.update({item_uid: [item_title,
dummy_init python: item_dict.setdefault(item_uid, [item_title, start_date, stop_date, 0]); min(item_dict[item_uid][1], start_date),
dummy_update python: item_dict.update({item_uid: [item_title, max(item_dict[item_uid][2], stop_date),
min(item_dict[item_uid][1], start_date), sum([item_dict[item_uid][3], quantity])]});">
max(item_dict[item_uid][2], stop_date), </tal:block>
sum([item_dict[item_uid][3], quantity])]});">
</tal:block> </tal:block>
</tal:block> <table>
<table> <thead>
<thead> <tr>
<tr> <th><span>Instance</span></th>
<th><span>Instance</span></th> <th><span>From</span></th>
<th><span>From</span></th> <th><span>To</span></th>
<th><span>To</span></th> <th><span>Quantity</span></th>
<th><span>Quantity</span></th> </tr>
</tr> </thead>
</thead> <tbody>
<tbody> <tr tal:repeat="item_tuple python: item_dict.values()">
<tr tal:repeat="item_tuple python: item_dict.values()"> <td tal:content="python: item_tuple[0]"></td>
<td tal:content="python: item_tuple[0]"></td> <td tal:content="python: item_tuple[1].strftime('%B %e, %G')"></td>
<td tal:content="python: item_tuple[1].strftime('%B %e, %G')"></td> <td tal:content="python: item_tuple[2].strftime('%B %e, %G')"></td>
<td tal:content="python: item_tuple[2].strftime('%B %e, %G')"></td> <td tal:content="python: quantity_renderer(item_tuple[3])"></td>
<td tal:content="python: quantity_renderer(item_tuple[3])"></td> </tr>
</tr> </tbody>
</tbody> </table>
</table> </aside>
</aside> </tal:block>
<p class='line page-break'>&nbsp;</p> <p class='line page-break'>&nbsp;</p>
<tal:block tal:condition="python: invoice_resource_document is not None" tal:content="structure python: invoice_resource_document.getData()"> <tal:block tal:condition="python: invoice_resource_document is not None" tal:content="structure python: invoice_resource_document.getData()">
</tal:block> </tal:block>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment