Minor budget edit/view cosmetic improvements
This commit is contained in:
parent
ff29819ca1
commit
2ca59c0684
@ -32,7 +32,7 @@
|
|||||||
<label class="three wide column">Name</label>
|
<label class="three wide column">Name</label>
|
||||||
<input class="eleven wide column" type="text" name="name" value="{{ revision.name }}">
|
<input class="eleven wide column" type="text" name="name" value="{{ revision.name }}">
|
||||||
</div>
|
</div>
|
||||||
<div class="ui inline grid field">
|
<div class="ui required inline grid field">
|
||||||
<label class="three wide column">Due date</label>
|
<label class="three wide column">Due date</label>
|
||||||
<div class="eleven wide column">
|
<div class="eleven wide column">
|
||||||
<div class="ui calendar" id="cal_date">
|
<div class="ui calendar" id="cal_date">
|
||||||
@ -139,11 +139,11 @@
|
|||||||
},
|
},
|
||||||
onSuccess: function(event, fields) {
|
onSuccess: function(event, fields) {
|
||||||
var revenue_data = [];
|
var revenue_data = [];
|
||||||
$('#revenue_grid .jsgrid-grid-body tr:not(.totalrow)').each(function(i, el) {
|
$('#revenue_grid .jsgrid-grid-body tr:not(.totalrow):not(.jsgrid-nodata-row)').each(function(i, el) {
|
||||||
var row = $(el).data('JSGridItem');
|
var row = $(el).data('JSGridItem');
|
||||||
revenue_data.push({
|
revenue_data.push({
|
||||||
'Description': row['Description'],
|
'Description': row['Description'],
|
||||||
'Unit cost': row['Unit cost'],
|
'Unit price': row['Unit price'],
|
||||||
'Units': row['Units'],
|
'Units': row['Units'],
|
||||||
'IWT': row['IWT'],
|
'IWT': row['IWT'],
|
||||||
});
|
});
|
||||||
@ -151,11 +151,11 @@
|
|||||||
$('#revenue_input').val(JSON.stringify(revenue_data));
|
$('#revenue_input').val(JSON.stringify(revenue_data));
|
||||||
|
|
||||||
var expense_data = [];
|
var expense_data = [];
|
||||||
$('#expense_grid .jsgrid-grid-body tr:not(.totalrow)').each(function(i, el) {
|
$('#expense_grid .jsgrid-grid-body tr:not(.totalrow):not(.jsgrid-nodata-row)').each(function(i, el) {
|
||||||
var row = $(el).data('JSGridItem');
|
var row = $(el).data('JSGridItem');
|
||||||
expense_data.push({
|
expense_data.push({
|
||||||
'Description': row['Description'],
|
'Description': row['Description'],
|
||||||
'Unit cost': row['Unit cost'],
|
'Unit price': row['Unit price'],
|
||||||
'Units': row['Units'],
|
'Units': row['Units'],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -177,9 +177,9 @@
|
|||||||
var total = 0;
|
var total = 0;
|
||||||
var totalIWT = 0;
|
var totalIWT = 0;
|
||||||
for (var row of args.grid.data) {
|
for (var row of args.grid.data) {
|
||||||
total += row['Unit cost'] * row['Units'];
|
total += row['Unit price'] * row['Units'];
|
||||||
if (row['Unit cost'] > 0 && row['IWT']) {
|
if (row['Unit price'] > 0 && row['IWT']) {
|
||||||
totalIWT += (row['Unit cost'] - (row['Unit cost'] - 0.8) / 1.019) * row['Units'];
|
totalIWT += (row['Unit price'] - (row['Unit price'] - 0.8) / 1.019) * row['Units'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +203,7 @@
|
|||||||
function recalcExpTotal(args) {
|
function recalcExpTotal(args) {
|
||||||
var total = 0;
|
var total = 0;
|
||||||
for (var row of args.grid.data) {
|
for (var row of args.grid.data) {
|
||||||
total += row['Unit cost'] * row['Units'];
|
total += row['Unit price'] * row['Units'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$(args.grid._body).find('.totalrow').remove();
|
$(args.grid._body).find('.totalrow').remove();
|
||||||
@ -244,15 +244,15 @@
|
|||||||
height: '20em',
|
height: '20em',
|
||||||
inserting: true,
|
inserting: true,
|
||||||
editing: true,
|
editing: true,
|
||||||
noDataContent: 'No entries',
|
noDataContent: 'No entries. Click the green plus icon at the top right to add a new row.',
|
||||||
data: revenue_data,
|
data: revenue_data,
|
||||||
fields: [
|
fields: [
|
||||||
{ name: 'Description', type: 'text', width: '55%', validate: 'required' },
|
{ name: 'Description', type: 'text', width: '50%', validate: 'required' },
|
||||||
{ name: 'Unit cost', type: 'float', width: '10%', validate: 'required', itemTemplate: function(value, item) { return '$' + value.toFixed(2); } },
|
{ name: 'Unit price', type: 'float', width: '12.5%', validate: 'required', itemTemplate: function(value, item) { return '$' + value.toFixed(2); } },
|
||||||
{ name: 'Units', type: 'float', width: '10%', validate: 'required' },
|
{ name: 'Units', type: 'float', width: '12.5%', validate: 'required' },
|
||||||
{ name: 'IWT', type: 'checkbox', width: '5%' },
|
{ name: 'IWT', type: 'checkbox', width: '5%', insertTemplate: function() { var result = jsGrid.fields.checkbox.prototype.insertTemplate.call(this); result.prop('checked', true); return result; } },
|
||||||
{ name: 'Total', align: 'right', width: '10%', itemTemplate: function(value, item) { return '$' + (item['Unit cost'] * item['Units']).toFixed(2); } },
|
{ name: 'Total', align: 'right', width: '10%', itemTemplate: function(value, item) { return '$' + (item['Unit price'] * item['Units']).toFixed(2); } },
|
||||||
{ type: 'control', width: '10%' },
|
{ type: 'control', width: '10%', modeSwitchButton: false },
|
||||||
],
|
],
|
||||||
onItemUpdated: recalcRevTotal,
|
onItemUpdated: recalcRevTotal,
|
||||||
onRefreshed: recalcRevTotal,
|
onRefreshed: recalcRevTotal,
|
||||||
@ -264,14 +264,14 @@
|
|||||||
height: '20em',
|
height: '20em',
|
||||||
inserting: true,
|
inserting: true,
|
||||||
editing: true,
|
editing: true,
|
||||||
noDataContent: 'No entries',
|
noDataContent: 'No entries. Click the green plus icon at the top right to add a new row.',
|
||||||
data: expense_data,
|
data: expense_data,
|
||||||
fields: [
|
fields: [
|
||||||
{ name: 'Description', type: 'text', width: '55%', validate: 'required' },
|
{ name: 'Description', type: 'text', width: '50%', validate: 'required' },
|
||||||
{ name: 'Unit cost', type: 'float', width: '10%', validate: 'required', itemTemplate: function(value, item) { return '$' + value.toFixed(2); } },
|
{ name: 'Unit price', type: 'float', width: '12.5%', validate: 'required', itemTemplate: function(value, item) { return '$' + value.toFixed(2); } },
|
||||||
{ name: 'Units', type: 'float', width: '10%', validate: 'required' },
|
{ name: 'Units', type: 'float', width: '12.5%', validate: 'required' },
|
||||||
{ name: 'Total', align: 'right', width: '10%', itemTemplate: function(value, item) { return '$' + (item['Unit cost'] * item['Units']).toFixed(2); } },
|
{ name: 'Total', align: 'right', width: '10%', itemTemplate: function(value, item) { return '$' + (item['Unit price'] * item['Units']).toFixed(2); } },
|
||||||
{ type: 'control', width: '10%' },
|
{ type: 'control', width: '10%', modeSwitchButton: false },
|
||||||
],
|
],
|
||||||
onItemUpdated: recalcExpTotal,
|
onItemUpdated: recalcExpTotal,
|
||||||
onRefreshed: recalcExpTotal,
|
onRefreshed: recalcExpTotal,
|
||||||
@ -293,5 +293,7 @@
|
|||||||
return el.classList.contains('totalrow');
|
return el.classList.contains('totalrow');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//$('.jsgrid-insert-mode-button').click();
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
{% if is_latest %}
|
{% if is_latest %}
|
||||||
<div>
|
<div>
|
||||||
<span class="ui header">Status: {{ import('sstreasury.models').BudgetState(revision.state).description }}</span>
|
<span class="ui header">Status: {{ revision.get_state_display() }}</span>
|
||||||
<a class="ui mini labeled right floated icon button" href="{{ url('budget_edit', kwargs={'id': revision.budget.id}) }}"><i class="edit icon"></i> Edit</a>
|
<a class="ui mini labeled right floated icon button" href="{{ url('budget_edit', kwargs={'id': revision.budget.id}) }}"><i class="edit icon"></i> Edit</a>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
@ -198,9 +198,9 @@
|
|||||||
var total = 0;
|
var total = 0;
|
||||||
var totalIWT = 0;
|
var totalIWT = 0;
|
||||||
for (var row of args.grid.data) {
|
for (var row of args.grid.data) {
|
||||||
total += row['Unit cost'] * row['Units'];
|
total += row['Unit price'] * row['Units'];
|
||||||
if (row['Unit cost'] > 0 && row['IWT']) {
|
if (row['Unit price'] > 0 && row['IWT']) {
|
||||||
totalIWT += (row['Unit cost'] - (row['Unit cost'] - 0.8) / 1.019) * row['Units'];
|
totalIWT += (row['Unit price'] - (row['Unit price'] - 0.8) / 1.019) * row['Units'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,7 +222,7 @@
|
|||||||
function recalcExpTotal(args) {
|
function recalcExpTotal(args) {
|
||||||
var total = 0;
|
var total = 0;
|
||||||
for (var row of args.grid.data) {
|
for (var row of args.grid.data) {
|
||||||
total += row['Unit cost'] * row['Units'];
|
total += row['Unit price'] * row['Units'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$(args.grid._body).find('.totalrow').remove();
|
$(args.grid._body).find('.totalrow').remove();
|
||||||
@ -263,10 +263,10 @@
|
|||||||
data: revenue_data,
|
data: revenue_data,
|
||||||
fields: [
|
fields: [
|
||||||
{ name: 'Description', type: 'text', width: '55%', validate: 'required' },
|
{ name: 'Description', type: 'text', width: '55%', validate: 'required' },
|
||||||
{ name: 'Unit cost', type: 'float', width: '10%', validate: 'required', itemTemplate: function(value, item) { return '$' + value.toFixed(2); } },
|
{ name: 'Unit price', type: 'float', width: '10%', validate: 'required', itemTemplate: function(value, item) { return '$' + value.toFixed(2); } },
|
||||||
{ name: 'Units', type: 'float', width: '10%', validate: 'required' },
|
{ name: 'Units', type: 'float', width: '10%', validate: 'required' },
|
||||||
{ name: 'IWT', type: 'checkbox', width: '5%' },
|
{ name: 'IWT', type: 'checkbox', width: '5%' },
|
||||||
{ name: 'Total', align: 'right', width: '10%', itemTemplate: function(value, item) { return '$' + (item['Unit cost'] * item['Units']).toFixed(2); } },
|
{ name: 'Total', align: 'right', width: '10%', itemTemplate: function(value, item) { return '$' + (item['Unit price'] * item['Units']).toFixed(2); } },
|
||||||
],
|
],
|
||||||
onRefreshed: recalcRevTotal,
|
onRefreshed: recalcRevTotal,
|
||||||
});
|
});
|
||||||
@ -279,9 +279,9 @@
|
|||||||
data: expense_data,
|
data: expense_data,
|
||||||
fields: [
|
fields: [
|
||||||
{ name: 'Description', type: 'text', width: '55%', validate: 'required' },
|
{ name: 'Description', type: 'text', width: '55%', validate: 'required' },
|
||||||
{ name: 'Unit cost', type: 'float', width: '10%', validate: 'required', itemTemplate: function(value, item) { return '$' + value.toFixed(2); } },
|
{ name: 'Unit price', type: 'float', width: '10%', validate: 'required', itemTemplate: function(value, item) { return '$' + value.toFixed(2); } },
|
||||||
{ name: 'Units', type: 'float', width: '10%', validate: 'required' },
|
{ name: 'Units', type: 'float', width: '10%', validate: 'required' },
|
||||||
{ name: 'Total', align: 'right', width: '10%', itemTemplate: function(value, item) { return '$' + (item['Unit cost'] * item['Units']).toFixed(2); } },
|
{ name: 'Total', align: 'right', width: '10%', itemTemplate: function(value, item) { return '$' + (item['Unit price'] * item['Units']).toFixed(2); } },
|
||||||
],
|
],
|
||||||
onRefreshed: recalcExpTotal,
|
onRefreshed: recalcExpTotal,
|
||||||
});
|
});
|
||||||
|
@ -50,15 +50,14 @@ class BudgetState(Enum):
|
|||||||
class BudgetRevision(models.Model):
|
class BudgetRevision(models.Model):
|
||||||
budget = models.ForeignKey(Budget, on_delete=models.CASCADE)
|
budget = models.ForeignKey(Budget, on_delete=models.CASCADE)
|
||||||
name = models.CharField(max_length=100)
|
name = models.CharField(max_length=100)
|
||||||
date = models.DateField(null=True)
|
date = models.DateField()
|
||||||
contributors = models.ManyToManyField(User, related_name='+')
|
contributors = models.ManyToManyField(User, related_name='+')
|
||||||
comments = models.TextField()
|
comments = models.TextField()
|
||||||
|
|
||||||
author = models.ForeignKey(User, on_delete=models.PROTECT, related_name='+')
|
author = models.ForeignKey(User, on_delete=models.PROTECT, related_name='+')
|
||||||
time = models.DateTimeField()
|
time = models.DateTimeField()
|
||||||
|
|
||||||
#state = models.IntegerField(choices=[(v.value, v.description) for v in BudgetState])
|
state = models.IntegerField(choices=[(v.value, v.description) for v in BudgetState])
|
||||||
state = models.IntegerField()
|
|
||||||
|
|
||||||
revenue = JSONField(default=[])
|
revenue = JSONField(default=[])
|
||||||
revenue_comments = models.TextField()
|
revenue_comments = models.TextField()
|
||||||
|
Loading…
Reference in New Issue
Block a user