Rename Delivery.delivered_on to date
This aligns it with column names of StockTaking and us to use inheritance in a next step to share common code between the entities.
This commit is contained in:
parent
7b2072251e
commit
a5582e9542
18 changed files with 35 additions and 30 deletions
|
@ -4,7 +4,7 @@ class DeliveriesController < ApplicationController
|
||||||
before_action :find_supplier, :exclude => :fill_new_stock_article_form
|
before_action :find_supplier, :exclude => :fill_new_stock_article_form
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@deliveries = @supplier.deliveries.order('delivered_on DESC')
|
@deliveries = @supplier.deliveries.order('date DESC')
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@ -13,12 +13,12 @@ class DeliveriesController < ApplicationController
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@delivery = @supplier.deliveries.build
|
@delivery = @supplier.deliveries.build
|
||||||
@delivery.delivered_on = Date.today #TODO: move to model/database
|
@delivery.date = Date.today #TODO: move to model/database
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@delivery = Delivery.new(params[:delivery])
|
@delivery = Delivery.new(params[:delivery])
|
||||||
|
|
||||||
if @delivery.save
|
if @delivery.save
|
||||||
flash[:notice] = I18n.t('deliveries.create.notice')
|
flash[:notice] = I18n.t('deliveries.create.notice')
|
||||||
redirect_to [@supplier, @delivery]
|
redirect_to [@supplier, @delivery]
|
||||||
|
@ -30,7 +30,7 @@ class DeliveriesController < ApplicationController
|
||||||
def edit
|
def edit
|
||||||
@delivery = Delivery.find(params[:id])
|
@delivery = Delivery.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@delivery = Delivery.find(params[:id])
|
@delivery = Delivery.find(params[:id])
|
||||||
|
|
||||||
|
@ -49,22 +49,22 @@ class DeliveriesController < ApplicationController
|
||||||
flash[:notice] = I18n.t('deliveries.destroy.notice')
|
flash[:notice] = I18n.t('deliveries.destroy.notice')
|
||||||
redirect_to supplier_deliveries_url(@supplier)
|
redirect_to supplier_deliveries_url(@supplier)
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_stock_change
|
def add_stock_change
|
||||||
@stock_change = StockChange.new
|
@stock_change = StockChange.new
|
||||||
@stock_change.stock_article = StockArticle.find(params[:stock_article_id])
|
@stock_change.stock_article = StockArticle.find(params[:stock_article_id])
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
def form_on_stock_article_create # See publish/subscribe design pattern in /doc.
|
def form_on_stock_article_create # See publish/subscribe design pattern in /doc.
|
||||||
@stock_article = StockArticle.find(params[:id])
|
@stock_article = StockArticle.find(params[:id])
|
||||||
|
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
def form_on_stock_article_update # See publish/subscribe design pattern in /doc.
|
def form_on_stock_article_update # See publish/subscribe design pattern in /doc.
|
||||||
@stock_article = StockArticle.find(params[:id])
|
@stock_article = StockArticle.find(params[:id])
|
||||||
|
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ class Finance::InvoicesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def fill_deliveries_and_orders_collection(invoice_id, supplier_id)
|
def fill_deliveries_and_orders_collection(invoice_id, supplier_id)
|
||||||
@deliveries_collection = Delivery.where('invoice_id = ? OR (invoice_id IS NULL AND supplier_id = ?)', invoice_id, supplier_id).order(:delivered_on)
|
@deliveries_collection = Delivery.where('invoice_id = ? OR (invoice_id IS NULL AND supplier_id = ?)', invoice_id, supplier_id).order(:date)
|
||||||
@orders_collection = Order.where('invoice_id = ? OR (invoice_id IS NULL AND supplier_id = ? AND state = ?)', invoice_id, supplier_id, 'finished').order(:ends)
|
@orders_collection = Order.where('invoice_id = ? OR (invoice_id IS NULL AND supplier_id = ? AND state = ?)', invoice_id, supplier_id, 'finished').order(:ends)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ class OrderFax < OrderPdf
|
||||||
text Date.today.strftime(I18n.t('date.formats.default')), align: :right
|
text Date.today.strftime(I18n.t('date.formats.default')), align: :right
|
||||||
|
|
||||||
move_down 10
|
move_down 10
|
||||||
text "#{Delivery.human_attribute_name :delivered_on}:"
|
text "#{Delivery.human_attribute_name :date}:"
|
||||||
move_down 10
|
move_down 10
|
||||||
unless order.supplier.try(:contact_person).blank?
|
unless order.supplier.try(:contact_person).blank?
|
||||||
text "#{Supplier.human_attribute_name :contact_person}: #{order.supplier[:contact_person]}"
|
text "#{Supplier.human_attribute_name :contact_person}: #{order.supplier[:contact_person]}"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module Finance::InvoicesHelper
|
module Finance::InvoicesHelper
|
||||||
def format_delivery_item delivery
|
def format_delivery_item delivery
|
||||||
format_date(delivery.delivered_on)
|
format_date(delivery.date)
|
||||||
end
|
end
|
||||||
def format_order_item order
|
def format_order_item order
|
||||||
"#{format_date(order.ends)} (#{number_to_currency(order.sum)})"
|
"#{format_date(order.ends)} (#{number_to_currency(order.sum)})"
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Delivery < ApplicationRecord
|
||||||
|
|
||||||
scope :recent, -> { order('created_at DESC').limit(10) }
|
scope :recent, -> { order('created_at DESC').limit(10) }
|
||||||
|
|
||||||
validates_presence_of :supplier_id, :delivered_on
|
validates_presence_of :supplier_id, :date
|
||||||
validate :stock_articles_must_be_unique
|
validate :stock_articles_must_be_unique
|
||||||
|
|
||||||
accepts_nested_attributes_for :stock_changes, :allow_destroy => :true
|
accepts_nested_attributes_for :stock_changes, :allow_destroy => :true
|
||||||
|
|
|
@ -131,7 +131,7 @@
|
||||||
= render :partial => 'stock_change_fields', :locals => {:f => stock_change_form}
|
= render :partial => 'stock_change_fields', :locals => {:f => stock_change_form}
|
||||||
|
|
||||||
%h2= t '.title_finish_delivery'
|
%h2= t '.title_finish_delivery'
|
||||||
= f.input :delivered_on, as: :date_picker
|
= f.input :date, as: :date_picker
|
||||||
= f.input :note, input_html: {size: '35x4'}
|
= f.input :note, input_html: {size: '35x4'}
|
||||||
.form-actions
|
.form-actions
|
||||||
= f.submit class: 'btn btn-primary'
|
= f.submit class: 'btn btn-primary'
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
%table.table.table-striped
|
%table.table.table-striped
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th= heading_helper Delivery, :delivered_on
|
%th= heading_helper Delivery, :date
|
||||||
%th.numeric= t 'deliveries.invoice_amount'
|
%th.numeric= t 'deliveries.invoice_amount'
|
||||||
%th= heading_helper Delivery, :note
|
%th= heading_helper Delivery, :note
|
||||||
%tbody
|
%tbody
|
||||||
- for delivery in @deliveries
|
- for delivery in @deliveries
|
||||||
%tr
|
%tr
|
||||||
%td=h delivery.delivered_on
|
%td=h delivery.date
|
||||||
%td.numeric= link_to_invoice(delivery)
|
%td.numeric= link_to_invoice(delivery)
|
||||||
%td= truncate delivery.note
|
%td= truncate delivery.note
|
||||||
%td
|
%td
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
%dl
|
%dl
|
||||||
%dt= heading_helper Delivery, :supplier
|
%dt= heading_helper Delivery, :supplier
|
||||||
%dd= @delivery.supplier.name
|
%dd= @delivery.supplier.name
|
||||||
%dt= heading_helper Delivery, :delivered_on
|
%dt= heading_helper Delivery, :date
|
||||||
%dd= @delivery.delivered_on
|
%dd= @delivery.date
|
||||||
%dt= t 'deliveries.invoice_amount'
|
%dt= t 'deliveries.invoice_amount'
|
||||||
%dd= link_to_invoice(@delivery)
|
%dd= link_to_invoice(@delivery)
|
||||||
- if @delivery.invoice
|
- if @delivery.invoice
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
%td><
|
%td><
|
||||||
- invoice.deliveries.each_with_index do |delivery, index|
|
- invoice.deliveries.each_with_index do |delivery, index|
|
||||||
= ', ' if index > 0
|
= ', ' if index > 0
|
||||||
= link_to format_date(delivery.delivered_on), [delivery.supplier,delivery]
|
= link_to format_date(delivery.date), [delivery.supplier,delivery]
|
||||||
%td><
|
%td><
|
||||||
- invoice.orders.each_with_index do |order, index|
|
- invoice.orders.each_with_index do |order, index|
|
||||||
= ', ' if index > 0
|
= ', ' if index > 0
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
%p
|
%p
|
||||||
%b= heading_helper(Invoice, :deliveries) + ':'
|
%b= heading_helper(Invoice, :deliveries) + ':'
|
||||||
%span><
|
%span><
|
||||||
- @invoice.deliveries.order(:delivered_on).each_with_index do |delivery, index|
|
- @invoice.deliveries.order(:date).each_with_index do |delivery, index|
|
||||||
- sum = delivery.sum
|
- sum = delivery.sum
|
||||||
- total += sum
|
- total += sum
|
||||||
= ', ' if index > 0
|
= ', ' if index > 0
|
||||||
= link_to format_date(delivery.delivered_on), [delivery.supplier,delivery]
|
= link_to format_date(delivery.date), [delivery.supplier, delivery]
|
||||||
= ' (' + number_to_currency(sum) + ')'
|
= ' (' + number_to_currency(sum) + ')'
|
||||||
- if @invoice.orders.any?
|
- if @invoice.orders.any?
|
||||||
%p
|
%p
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
%tbody
|
%tbody
|
||||||
- for delivery in @deliveries
|
- for delivery in @deliveries
|
||||||
%tr
|
%tr
|
||||||
%td= link_to delivery.delivered_on, [@supplier, delivery]
|
%td= link_to delivery.date, [@supplier, delivery]
|
||||||
%td= link_to_invoice(delivery)
|
%td= link_to_invoice(delivery)
|
||||||
|
|
||||||
- if @orders.any?
|
- if @orders.any?
|
||||||
|
|
|
@ -47,7 +47,7 @@ de:
|
||||||
reference: Zahlungsreferenz
|
reference: Zahlungsreferenz
|
||||||
text: Beschreibung
|
text: Beschreibung
|
||||||
delivery:
|
delivery:
|
||||||
delivered_on: Lieferdatum
|
date: Lieferdatum
|
||||||
note: Notiz
|
note: Notiz
|
||||||
supplier: Lieferantin
|
supplier: Lieferantin
|
||||||
document:
|
document:
|
||||||
|
|
|
@ -47,7 +47,7 @@ en:
|
||||||
reference: Referenz
|
reference: Referenz
|
||||||
text: Description
|
text: Description
|
||||||
delivery:
|
delivery:
|
||||||
delivered_on: Delivery date
|
date: Delivery date
|
||||||
note: Note
|
note: Note
|
||||||
supplier: Supplier
|
supplier: Supplier
|
||||||
document:
|
document:
|
||||||
|
|
|
@ -47,7 +47,7 @@ es:
|
||||||
reference: Referencia
|
reference: Referencia
|
||||||
text: Descripción
|
text: Descripción
|
||||||
delivery:
|
delivery:
|
||||||
delivered_on: Fecha entrega
|
date: Fecha entrega
|
||||||
note: Nota
|
note: Nota
|
||||||
supplier: Proveedor
|
supplier: Proveedor
|
||||||
document:
|
document:
|
||||||
|
|
|
@ -33,7 +33,7 @@ fr:
|
||||||
tax: TVA
|
tax: TVA
|
||||||
unit_quantity: Unités par lot
|
unit_quantity: Unités par lot
|
||||||
delivery:
|
delivery:
|
||||||
delivered_on: Date de réapprovisionnement
|
date: Date de réapprovisionnement
|
||||||
supplier: Fournisseur-e
|
supplier: Fournisseur-e
|
||||||
document:
|
document:
|
||||||
created_at: Créé le
|
created_at: Créé le
|
||||||
|
|
|
@ -47,7 +47,7 @@ nl:
|
||||||
reference: Referentie
|
reference: Referentie
|
||||||
text: Omschrijving
|
text: Omschrijving
|
||||||
delivery:
|
delivery:
|
||||||
delivered_on: Leverdatum
|
date: Leverdatum
|
||||||
note: Notitie
|
note: Notitie
|
||||||
supplier: Leverancier
|
supplier: Leverancier
|
||||||
document:
|
document:
|
||||||
|
|
5
db/migrate/20181204060000_change_delivered_on_to_date.rb
Normal file
5
db/migrate/20181204060000_change_delivered_on_to_date.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class ChangeDeliveredOnToDate < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
rename_column :deliveries, :delivered_on, :date
|
||||||
|
end
|
||||||
|
end
|
|
@ -91,11 +91,11 @@ ActiveRecord::Schema.define(version: 20181205010000) do
|
||||||
add_index "bank_transactions", ["financial_link_id"], name: "index_bank_transactions_on_financial_link_id", using: :btree
|
add_index "bank_transactions", ["financial_link_id"], name: "index_bank_transactions_on_financial_link_id", using: :btree
|
||||||
|
|
||||||
create_table "deliveries", force: :cascade do |t|
|
create_table "deliveries", force: :cascade do |t|
|
||||||
t.integer "supplier_id", limit: 4
|
t.integer "supplier_id", limit: 4
|
||||||
t.date "delivered_on"
|
t.date "date"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.text "note", limit: 65535
|
t.text "note", limit: 65535
|
||||||
t.integer "invoice_id", limit: 4
|
t.integer "invoice_id", limit: 4
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "deliveries", ["supplier_id"], name: "index_deliveries_on_supplier_id", using: :btree
|
add_index "deliveries", ["supplier_id"], name: "index_deliveries_on_supplier_id", using: :btree
|
||||||
|
|
Loading…
Reference in a new issue