From b2a6c198ac67a3503345ad612c292af4071b1427 Mon Sep 17 00:00:00 2001 From: twothreenine Date: Wed, 24 Mar 2021 21:29:44 +0100 Subject: [PATCH] Improve invoice and supplier show views (#840) --- .../bootstrap_and_overrides.css.less | 5 +- app/views/finance/invoices/show.html.haml | 138 +++++++++--------- app/views/suppliers/show.html.haml | 4 +- 3 files changed, 74 insertions(+), 73 deletions(-) diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/assets/stylesheets/bootstrap_and_overrides.css.less index cad8d6d3..971308c9 100644 --- a/app/assets/stylesheets/bootstrap_and_overrides.css.less +++ b/app/assets/stylesheets/bootstrap_and_overrides.css.less @@ -335,10 +335,9 @@ td.symbol, th.symbol { // https://github.com/twbs/bootstrap/issues/4550#issuecomment-31916049 .dropdown-backdrop { position: static; } -// need more space for supplier&order information (in German, at least) .dl-horizontal { - dt { width: 160px; } - dd { margin-left: 170px; } + dt { width: 200px; margin-bottom: 0.2em; } + dd { margin-left: 210px; } } // get rid of extra bottom margin inside well diff --git a/app/views/finance/invoices/show.html.haml b/app/views/finance/invoices/show.html.haml index 03857183..b285798c 100644 --- a/app/views/finance/invoices/show.html.haml +++ b/app/views/finance/invoices/show.html.haml @@ -2,74 +2,76 @@ - total = 0 -%p - %b= heading_helper(Invoice, :created_at) + ':' - = format_time(@invoice.created_at) -%p - %b= heading_helper(Invoice, :created_by) + ':' - = show_user(@invoice.created_by) -%p - %b= heading_helper(Invoice, :supplier) + ':' - = @invoice.supplier.name +.row-fluid + .span6 + %dl.dl-horizontal + %dt= heading_helper(Invoice, :created_at) + ':' + %dd= format_time(@invoice.created_at) -- if @invoice.deliveries.any? - %p - %b= heading_helper(Invoice, :deliveries) + ':' - %span>< - - @invoice.deliveries.order(:date).each_with_index do |delivery, index| - - sum = delivery.sum - - total += sum - = ', ' if index > 0 - = link_to format_date(delivery.date), [delivery.supplier, delivery] - = ' (' + number_to_currency(sum) + ')' -- if @invoice.orders.any? - %p - %b= heading_helper(Invoice, :orders) + ':' - %span>< - - @invoice.orders.order(:ends).each_with_index do |order, index| - - sum = order.sum - - total += sum - = ', ' if index > 0 - = link_to format_date(order.ends), new_finance_order_path(order_id: order) - = ' (' + number_to_currency(sum) + ')' + %dt= heading_helper(Invoice, :created_by) + ':' + %dd= show_user(@invoice.created_by) -%p - %b= heading_helper(Invoice, :number) + ':' - = @invoice.number -%p - %b= heading_helper(Invoice, :date) + ':' - = @invoice.date -%p - %b= heading_helper(Invoice, :paid_on) + ':' - = @invoice.paid_on -%p - %b= heading_helper(Invoice, :amount) + ':' - = number_to_currency @invoice.amount -%p - %b= heading_helper(Invoice, :deposit) + ':' - = number_to_currency @invoice.deposit -%p - %b= heading_helper(Invoice, :deposit_credit) + ':' - = number_to_currency @invoice.deposit_credit -%p - %b= heading_helper(Invoice, :net_amount) + ':' - = number_to_currency @invoice.net_amount -- if @invoice.deliveries.any? || @invoice.orders.any? - %p - %b= heading_helper(Invoice, :total) + ':' - = number_to_currency total -%p - %b= heading_helper(Invoice, :attachment) + ':' - - if @invoice.attachment_data - = link_to t('ui.download'), finance_invoice_attachment_path(@invoice) -%p - %b= heading_helper(Invoice, :note) + ':' - =h @invoice.note -- if @invoice.financial_link - %p - %b= heading_helper(Invoice, :financial_link) + ':' - = link_to t('ui.show'), finance_link_path(@invoice.financial_link) + %dt= heading_helper(Invoice, :supplier) + ':' + %dd= @invoice.supplier.name -- if @invoice.user_can_edit?(current_user) - = link_to t('ui.edit'), edit_finance_invoice_path(@invoice), class: 'btn' -= link_to t('ui.or_cancel'), finance_invoices_path + - if @invoice.deliveries.any? + %dt= heading_helper(Invoice, :deliveries) + ':' + %dd>< + - @invoice.deliveries.order(:date).each_with_index do |delivery, index| + - sum = delivery.sum + - total += sum + = ', ' if index > 0 + = link_to format_date(delivery.date), [delivery.supplier, delivery] + = ' (' + number_to_currency(sum) + ')' + + - if @invoice.orders.any? + %dt= heading_helper(Invoice, :orders) + ':' + %dd>< + - @invoice.orders.order(:ends).each_with_index do |order, index| + - sum = order.sum + - total += sum + = ', ' if index > 0 + = link_to format_date(order.ends), new_finance_order_path(order_id: order) + = ' (' + number_to_currency(sum) + ')' + + %dt= heading_helper(Invoice, :number) + ':' + %dd= @invoice.number + + %dt= heading_helper(Invoice, :date) + ':' + %dd= format_date(@invoice.date) + + %dt= heading_helper(Invoice, :paid_on) + ':' + %dd= format_date(@invoice.paid_on) + + %dt= heading_helper(Invoice, :amount) + ':' + %dd= number_to_currency @invoice.amount + + %dt= heading_helper(Invoice, :deposit) + ':' + %dd= number_to_currency @invoice.deposit + + %dt= heading_helper(Invoice, :deposit_credit) + ':' + %dd= number_to_currency @invoice.deposit_credit + + %dt= heading_helper(Invoice, :net_amount) + ':' + %dd= number_to_currency @invoice.net_amount + + - if @invoice.deliveries.any? || @invoice.orders.any? + %dt= heading_helper(Invoice, :total) + ':' + %dd= number_to_currency total + + - if @invoice.attachment_data + %dt= heading_helper(Invoice, :attachment) + ':' + %dd= link_to t('ui.download'), finance_invoice_attachment_path(@invoice) + + %dt= heading_helper(Invoice, :note) + ':' + %dd= simple_format(@invoice.note) + + - if @invoice.financial_link + %dt= heading_helper(Invoice, :financial_link) + ':' + %dd= link_to t('ui.show'), finance_link_path(@invoice.financial_link) + + .clearfix + .form-actions + - if @invoice.user_can_edit?(current_user) + = link_to t('ui.edit'), edit_finance_invoice_path(@invoice), class: 'btn' + = link_to t('ui.or_cancel'), finance_invoices_path diff --git a/app/views/suppliers/show.html.haml b/app/views/suppliers/show.html.haml index 3296d7cc..c3fbe4c4 100644 --- a/app/views/suppliers/show.html.haml +++ b/app/views/suppliers/show.html.haml @@ -38,9 +38,9 @@ %dt= heading_helper(Supplier, :delivery_days) + ':' %dd= @supplier.delivery_days %dt= heading_helper(Supplier, :order_howto) + ':' - %dd= @supplier.order_howto + %dd= simple_format(@supplier.order_howto) %dt= heading_helper(Supplier, :note) + ':' - %dd= @supplier.note + %dd= simple_format(@supplier.note) %dt= heading_helper(Supplier, :min_order_quantity) + ':' %dd= @supplier.min_order_quantity