Add created_by to invoice and show it
This commit is contained in:
parent
76ea0cc411
commit
3d6f908102
10 changed files with 28 additions and 3 deletions
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -54,6 +54,8 @@ de:
|
|||
total_price: Summe
|
||||
invoice:
|
||||
amount: Betrag
|
||||
created_at: Erstellt am
|
||||
created_by: Erstellt von
|
||||
date: Rechnungsdatum
|
||||
delivery: Lieferung
|
||||
deposit: Pfand berechnet
|
||||
|
|
|
@ -54,6 +54,8 @@ en:
|
|||
total_price: Sum
|
||||
invoice:
|
||||
amount: Amount
|
||||
created_at: Created at
|
||||
created_by: Created by
|
||||
date: Billing date
|
||||
delivery: Delivery
|
||||
deposit: Deposit charged
|
||||
|
|
|
@ -54,6 +54,8 @@ fr:
|
|||
total_price: Total
|
||||
invoice:
|
||||
amount: Montant
|
||||
created_at: Créé le
|
||||
created_by: "Établi par"
|
||||
date: Date de facturation
|
||||
delivery: Réapprovisionnement
|
||||
deposit: Consigne facturée
|
||||
|
|
|
@ -54,6 +54,8 @@ nl:
|
|||
total_price: Som
|
||||
invoice:
|
||||
amount: Bedrag
|
||||
created_at: Gemaakt op
|
||||
created_by: Gemaakt door
|
||||
date: Factuurdatum
|
||||
delivery: Levering
|
||||
deposit: Statiegeld in rekening gebracht
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddCreatedByUserIdToInvoice < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :invoices, :created_by_user_id, :integer
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150923190747) do
|
||||
ActiveRecord::Schema.define(version: 20160217124256) do
|
||||
|
||||
create_table "article_categories", force: :cascade do |t|
|
||||
t.string "name", limit: 255, default: "", null: false
|
||||
|
@ -166,6 +166,7 @@ ActiveRecord::Schema.define(version: 20150923190747) do
|
|||
t.decimal "deposit_credit", precision: 8, scale: 2, default: 0, null: false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.integer "created_by_user_id"
|
||||
end
|
||||
|
||||
add_index "invoices", ["delivery_id"], name: "index_invoices_on_delivery_id", using: :btree
|
||||
|
|
Loading…
Reference in a new issue