Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
fosterlynn committed Jun 28, 2016
2 parents 9bfdc6d + f2e5d43 commit e816823
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 44 deletions.
2 changes: 1 addition & 1 deletion valuenetwork/static/img/NavMapCode.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<area shape="rect" coords="30,176,140,228" alt="Create Customer and Work Orders" href="/accounting/demand/" style="outline:none;" target="_self" data-maphilight='{"stroke":false,"fillOpacity":0.05}' />
<area shape="rect" coords="31,238,140,289" alt="Create Customer Order" href="/accounting/create-order/" style="outline:none;" target="_self" data-maphilight='{"stroke":false,"fillOpacity":0.05}' />
<area shape="rect" coords="29,303,138,355" alt="Plan Work From Recipe" href="/accounting/plan-from-recipe/" style="outline:none;" target="_self" data-maphilight='{"stroke":false,"fillOpacity":0.05}' />
<area shape="rect" coords="31,370,139,423" alt="Plan Work Without Recipe" href="/accounting/plan-work/" style="outline:none;" target="_self" data-maphilight='{"stroke":false,"fillOpacity":0.05}' />
<area shape="rect" coords="31,370,139,423" alt="Plan Work Without Recipe" href="/accounting/process-selections/1/" style="outline:none;" target="_self" data-maphilight='{"stroke":false,"fillOpacity":0.05}' />
<area shape="rect" coords="191,176,304,229" alt="Log Incoming Exchange" href="/accounting/supply/" style="outline:none;" target="_self" data-maphilight='{"stroke":false,"fillOpacity":0.05}' />
<area shape="rect" coords="190,307,300,361" alt="All Work" href="/accounting/work/" style="outline:none;" target="_self" data-maphilight='{"stroke":false,"fillOpacity":0.05}' />
<area shape="rect" coords="193,366,300,422" alt="My Work" href="/accounting/start/" style="outline:none;" target="_self" data-maphilight='{"stroke":false,"fillOpacity":0.05}' />
Expand Down
8 changes: 4 additions & 4 deletions valuenetwork/templates/_work_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@
<ul>
{% for item in work_to_do %}
<li>
{% trans "Type of work" %}: <b>{{ item.resource_type.name }}:</b> {% trans "due" %} {{ item.due_date }}</br>
<b>{{ item.resource_type.name }}</b> &mdash; {% trans "updated" %} {{ item.changed_date }}</br>
{% if item.process %}
<i>{% trans "Purpose:" %} {{ item.description }}</i>
<p style="margin-left: 1em; margin-bottom: 0; font-size: 90%;">
<a href="{% url unfold_commitment commitment_id=item.id %}">Learn more...</a>
</p>

{% comment %}
<div style="display: inline;" >
<a href="" role="button" class="btn btn-info" title="This button does not work yet. It will soon.">
{% trans "do this work?" %}
</a>
</div>
</div>
<p style="margin-left: 1em; margin-bottom: 0; font-size: 90%;">
{% trans "for process" %}: <a href="{% url unfold process_id=item.process.id %}">{{ item.process.name }}</a>
</p>
{% endcomment %}
{% endif %}
</li>
{% endfor %}
</ul>
</ul>
42 changes: 23 additions & 19 deletions valuenetwork/templates/valueaccounting/resource.html
Original file line number Diff line number Diff line change
Expand Up @@ -224,26 +224,30 @@ <h3 class="hdg">{% trans "Where from" %}:</h3>

</ul>
{% endif %}
{% if event.exchange %}
<ul>
<li><b>{% trans "Exchange" %}:</b> <a href="{% url exchange_logging exchange_type_id=0 exchange_id=event.exchange.id %}">{{ event.exchange }}</a>
</li>
{% if event.exchange.payment_sources_with_contributions %}
<li><b>{% trans "Contributions to payment for " %} {{ resource.identifier }}:</b></li>
<ul>
{% for source in event.exchange.payment_sources_with_contributions %}
{% for contribution in source.cash_contribution_events %}
<li>
<b>{{ contribution.event_type }}:</b>
{{ contribution.event_date }}
{{ contribution.distribution_quantity_formatted }}
{% trans "from" %}: {{ contribution.from_agent }}
</li>
{% if event.transfer %}
{% if event.transfer.exchange %}
{% with event.transfer.exchange as exchange %}
<ul>
<li><b>{% trans "Exchange" %}:</b> <a href="{% url exchange_logging exchange_type_id=0 exchange_id=exchange.id %}">{{ exchange }}</a>
</li>
{% if exchange.payment_sources_with_contributions %}
<li><b>{% trans "Contributions to payment for " %} {{ resource.identifier }}:</b></li>
<ul>
{% for source in exchange.payment_sources_with_contributions %}
{% for contribution in source.cash_contribution_events %}
<li>
<b>{{ contribution.event_type }}:</b>
{{ contribution.event_date }}
{{ contribution.distribution_quantity_formatted }}
{% trans "from" %}: {{ contribution.from_agent }}
</li>
{% endfor %}
{% endfor %}
{% endfor %}
</ul>
{% endif %}
</ul>
</ul>
{% endif %}
</ul>
{% endwith %}
{% endif %}
{% endif %}
{% endfor %}

Expand Down
48 changes: 31 additions & 17 deletions valuenetwork/valueaccounting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6983,9 +6983,9 @@ def slots_with_detail(self):
# return ccs

#obsolete
#def payment_sources_with_contributions(self):
# resources = {p.resource for p in self.payment_events() if p.resource}
# return [r for r in resources if r.cash_contribution_events()]
def payment_sources_with_contributions(self):
resources = {p.resource for p in self.payment_events() if p.resource}
return [r for r in resources if r.cash_contribution_events()]

#obsolete
#def uncommitted_payment_events(self):
Expand Down Expand Up @@ -7211,6 +7211,7 @@ def roll_up_value(self, trigger_event, path, depth, visited, value_equation=None
values += value * trigger_fraction
evt.depth = depth
path.append(evt)
#import pdb; pdb.set_trace()
if evt.resource:
contributions = evt.resource.cash_contribution_events()
depth += 1
Expand All @@ -7219,43 +7220,56 @@ def roll_up_value(self, trigger_event, path, depth, visited, value_equation=None
c.depth = depth
path.append(c)
elif len(payments) > 1:
total = sum(p.quantity for p in payments)
#total = sum(p.quantity for p in payments)
for evt in payments:
fraction = evt.quantity / total
#depth += 1
#fraction = evt.quantity / total
evt.share = evt.quantity * trigger_fraction
evt.depth = depth
path.append(evt)
values += evt.share
depth += 1
if evt.resource:
#import pdb; pdb.set_trace()
contributions = evt.resource.cash_contribution_events()
#evt.share = evt.quantity * share * fraction * trigger_fraction
evt.share = evt.quantity * fraction * trigger_fraction
evt.depth = depth
path.append(evt)
values += evt.share
#evt.share = evt.quantity * fraction * trigger_fraction

#todo 3d: do multiple payments make sense for cash contributions?
depth += 1
for c in contributions:
c.depth = depth
path.append(c)
depth -= 1
else:
value = evt.quantity
br = evt.bucket_rule(value_equation)
if br:
#import pdb; pdb.set_trace()
value = br.compute_claim_value(evt)
evt.share = value * fraction * trigger_fraction
#evt.share = value * fraction * trigger_fraction
evt.share = evt.quantity * trigger_fraction
evt.depth = depth
path.append(evt)
values += evt.share
depth -= 1
#todo exchange redesign fallout
#import pdb; pdb.set_trace()
expenses = self.expense_events()
for ex in expenses:
ex.depth = depth
path.append(ex)
value = ex.value
values += value * trigger_fraction
#value = ex.value
#values += value * trigger_fraction
exp_payments = [evt for evt in self.payment_events() if evt.to_agent==ex.from_agent]
#exp_payments = self.payment_events().filter(to_agent=ex.from_agent)
for exp in exp_payments:
depth += 1
exp.depth = depth
path.append(exp)
depth -= 1
if exp not in payments:
depth += 1
exp.depth = depth
path.append(exp)
value = exp.quantity
values += value * trigger_fraction
depth -= 1
depth -= 1

for evt in self.work_events():
Expand Down
9 changes: 6 additions & 3 deletions valuenetwork/valueaccounting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ def home(request):
return render_to_response("homepage.html",
template_params,
context_instance=RequestContext(request))

def work_to_do(template_params):
six_months_ago = datetime.datetime.now() - datetime.timedelta(weeks=26)
template_params["work_to_do"] = Commitment.objects.unfinished().filter(
from_agent=None,
event_type__relationship="work")
from_agent=None,
event_type__relationship="work",
changed_date__gte=six_months_ago).order_by("-changed_date")

return template_params

@login_required
Expand Down

0 comments on commit e816823

Please sign in to comment.