diff --git a/TODO.md b/TODO.md
index 951032e7..740223b6 100644
--- a/TODO.md
+++ b/TODO.md
@@ -434,3 +434,20 @@ serailzer self.instance on create.
* backendLog store method and language... and use it for display_script with correct lexer
# process monitor data to represent state, or maybe create new resource datas when period expires?
+
+
+# Automatically mark as paid transactions with 0 or prevent its creation?
+
+# Confirmation steps on amend and other billing actions
+
+
+@register.filter
+def comma(value):
+ value = str(value)
+ if '.' in value:
+ left, right = str(value).split('.')
+ return ','.join((left, right))
+ return value
+
+
+# Close, send + download admin action for bills (with confirmation)
diff --git a/orchestra/contrib/bills/admin.py b/orchestra/contrib/bills/admin.py
index 10301e09..67d10c02 100644
--- a/orchestra/contrib/bills/admin.py
+++ b/orchestra/contrib/bills/admin.py
@@ -195,8 +195,8 @@ class BillAdmin(AccountAdminMixin, ExtendedModelAdmin):
change_list_template = 'admin/bills/change_list.html'
fieldsets = (
(None, {
- 'fields': ('number', 'type', 'amend_of_link', 'account_link', 'display_total',
- 'display_payment_state', 'is_sent', 'due_on', 'comments'),
+ 'fields': ['number', 'type', 'amend_of_link', 'account_link', 'display_total',
+ 'display_payment_state', 'is_sent', 'due_on', 'comments'],
}),
(_("Raw"), {
'classes': ('collapse',),
@@ -213,13 +213,23 @@ class BillAdmin(AccountAdminMixin, ExtendedModelAdmin):
actions.manage_lines, actions.download_bills, actions.close_bills, actions.send_bills,
actions.amend_bills, actions.report
]
- change_readonly_fields = ('account_link', 'type', 'is_open', 'amend_of_link')
+ change_readonly_fields = ('account_link', 'type', 'is_open', 'amend_of_link', 'amend_links')
readonly_fields = ('number', 'display_total', 'is_sent', 'display_payment_state')
inlines = [BillLineInline, ClosedBillLineInline]
+ date_hierarchy = 'closed_on'
created_on_display = admin_date('created_on', short_description=_("Created"))
amend_of_link = admin_link('amend_of')
+ def amend_links(self, bill):
+ links = []
+ for amend in bill.amends.all():
+ url = reverse('admin:bills_bill_change', args=(amend.id,))
+ links.append('{num}'.format(url=url, num=amend.number))
+ return '
'.join(links)
+ amend_links.short_description = _("Amends")
+ amend_links.allow_tags = True
+
def num_lines(self, bill):
return bill.lines__count
num_lines.admin_order_field = 'lines__count'
@@ -279,9 +289,11 @@ class BillAdmin(AccountAdminMixin, ExtendedModelAdmin):
def get_fieldsets(self, request, obj=None):
fieldsets = super(BillAdmin, self).get_fieldsets(request, obj)
if obj:
-# if obj.amend_of_id:
-# fieldsets = list(fieldsets)
-# fieldsets[0][1]['fields'] = fieldsets[0][1]['fields'] + ('amend_of_link',)
+ # Switches between amend_of_link and amend_links fields
+ if obj.amend_of_id:
+ fieldsets[0][1]['fields'][2] = 'amend_of_link'
+ else:
+ fieldsets[0][1]['fields'][2] = 'amend_links'
if obj.is_open:
fieldsets = (fieldsets[0],)
return fieldsets
diff --git a/orchestra/contrib/bills/filters.py b/orchestra/contrib/bills/filters.py
index dae95794..cd706656 100644
--- a/orchestra/contrib/bills/filters.py
+++ b/orchestra/contrib/bills/filters.py
@@ -20,10 +20,10 @@ class BillTypeListFilter(SimpleListFilter):
return (
('bill', _("All")),
('invoice', _("Invoice")),
- ('amendmentinvoice', _("Amendment invoice")),
('fee', _("Fee")),
- ('amendmentfee', _("Amendment fee")),
('proforma', _("Pro-forma")),
+ ('amendmentfee', _("Amendment fee")),
+ ('amendmentinvoice', _("Amendment invoice")),
)
def queryset(self, request, queryset):
@@ -152,4 +152,3 @@ class AmendedListFilter(SimpleListFilter):
return queryset.filter(id__in=amended_ids)
else:
return queryset.exclude(id__in=amended_ids)
-
diff --git a/orchestra/contrib/bills/templates/admin/bills/report.html b/orchestra/contrib/bills/templates/admin/bills/report.html
index 7cb63a83..61d74426 100644
--- a/orchestra/contrib/bills/templates/admin/bills/report.html
+++ b/orchestra/contrib/bills/templates/admin/bills/report.html
@@ -49,9 +49,9 @@