Add created_by to invoice and show it

This commit is contained in:
Patrick Gansterer 2016-02-17 16:11:01 +01:00 committed by wvengen
parent 76ea0cc411
commit 3d6f908102
10 changed files with 28 additions and 3 deletions

View file

@ -20,6 +20,7 @@ class Finance::InvoicesController < ApplicationController
def create
@invoice = Invoice.new(params[:invoice])
@invoice.created_by = current_user
if @invoice.save
flash[:notice] = I18n.t('finance.create.notice')

View file

@ -3,6 +3,7 @@ class Invoice < ActiveRecord::Base
belongs_to :supplier
belongs_to :delivery
belongs_to :order
belongs_to :created_by, :class_name => 'User', :foreign_key => 'created_by_user_id'
validates_presence_of :supplier_id
validates_numericality_of :amount, :deposit, :deposit_credit
@ -17,5 +18,3 @@ class Invoice < ActiveRecord::Base
amount - deposit + deposit_credit
end
end

View file

@ -7,6 +7,11 @@
- if @invoice.order
%p= t('finance.invoices.linked', what_link: link_to(t('finance.invoices.linked_order'), new_finance_order_path(order_id: @invoice.order.id))).html_safe
- if @invoice.created_at
= f.input :created_at do
= format_time(@invoice.created_at)
= f.input :created_by do
= show_user(@invoice.created_by)
= f.association :supplier, hint: false
= f.input :number
= f.input :date, as: :date_picker

View file

@ -1,5 +1,11 @@
- title t('.title', number: @invoice.number)
%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