add datefield default values max value cannot be blank
This commit is contained in:
parent
368375818e
commit
5a817a9acb
5 changed files with 7 additions and 14 deletions
|
@ -37,9 +37,9 @@ class GroupOrderInvoicesController < ApplicationController
|
||||||
goi.invoice_number = goi.generate_invoice_number(1)
|
goi.invoice_number = goi.generate_invoice_number(1)
|
||||||
goi.save!
|
goi.save!
|
||||||
end
|
end
|
||||||
redirect_back fallback_location: root_path
|
respond_to do |format|
|
||||||
rescue => error
|
format.js
|
||||||
redirect_back fallback_location: root_path, notice: 'Something went wrong', :alert => I18n.t('errors.general_msg', :msg => error)
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|
|
@ -7,14 +7,6 @@ class GroupOrderInvoice < ApplicationRecord
|
||||||
|
|
||||||
def generate_invoice_number(count)
|
def generate_invoice_number(count)
|
||||||
trailing_number = count.to_s.rjust(4, '0')
|
trailing_number = count.to_s.rjust(4, '0')
|
||||||
puts "
|
|
||||||
" + "______________" + "
|
|
||||||
" + "______________" + "
|
|
||||||
" + "______________" + "
|
|
||||||
" + "#{self.invoice_date}" + "
|
|
||||||
" + "______________"+ "
|
|
||||||
" + "______________"+ "
|
|
||||||
" + "______________"
|
|
||||||
if GroupOrderInvoice.find_by(invoice_number: self.invoice_date.strftime("%Y%m%d") + trailing_number)
|
if GroupOrderInvoice.find_by(invoice_number: self.invoice_date.strftime("%Y%m%d") + trailing_number)
|
||||||
generate_invoice_number(count.to_i + 1)
|
generate_invoice_number(count.to_i + 1)
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
- title t('.title')
|
- title t('.title')
|
||||||
|
- puts params
|
||||||
- content_for :actionbar do
|
- content_for :actionbar do
|
||||||
- if FoodsoftConfig[:charge_members_manually]
|
- if FoodsoftConfig[:charge_members_manually]
|
||||||
= link_to t('.close_all_direct_with_invoice'), close_all_direct_with_invoice_finance_order_index_path, method: :post, class: 'btn'
|
= link_to t('.close_all_direct_with_invoice'), close_all_direct_with_invoice_finance_order_index_path, method: :post, class: 'btn'
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
- if go.group_order_invoice.present?
|
- if go.group_order_invoice.present?
|
||||||
- show_generate_with_date = false
|
- show_generate_with_date = false
|
||||||
- if show_generate_with_date
|
- if show_generate_with_date
|
||||||
= form_for :group_order_invoice, url: url_for('group_order_invoice#create_multiple') do |f|
|
= form_for :group_order_invoice, url: url_for('group_order_invoice#create_multiple'), remote: true do |f|
|
||||||
= f.label :invoice_date, I18n.t('activerecord.attributes.group_order_invoice.links.invoice_date')
|
= f.label :invoice_date, I18n.t('activerecord.attributes.group_order_invoice.links.invoice_date')
|
||||||
= f.date_field :invoice_date, {}
|
= f.date_field :invoice_date, {value: Date.today, max: Date.today, required: true}
|
||||||
= f.hidden_field :order_id, value: order.id
|
= f.hidden_field :order_id, value: order.id
|
||||||
= f.submit I18n.t('activerecord.attributes.group_order_invoice.links.generate_with_date'), class: 'btn btn small'
|
= f.submit I18n.t('activerecord.attributes.group_order_invoice.links.generate_with_date'), class: 'btn btn small'
|
||||||
|
|
||||||
|
|
1
app/views/group_order_invoices/create_multiple.js.erb
Normal file
1
app/views/group_order_invoices/create_multiple.js.erb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
$("#generate-invoice<%= @order.id %>").html("<%= escape_javascript(render partial: 'links', locals: {order: @order}) %>");
|
Loading…
Reference in a new issue