diff --git a/app/controllers/settings/menu_item_instances_controller.rb b/app/controllers/settings/menu_item_instances_controller.rb index f63c09b7..596887c3 100755 --- a/app/controllers/settings/menu_item_instances_controller.rb +++ b/app/controllers/settings/menu_item_instances_controller.rb @@ -70,7 +70,8 @@ class Settings::MenuItemInstancesController < ApplicationController format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully created.' } format.json { render :show, status: :created, location: @settings_menu_item_instances } else - format.html { render :new } + flash[:instance_code_error] = @settings_menu_item_instances.errors + format.html { redirect_to new_settings_simple_menu_item_menu_item_instance_path } format.json { render json: @settings_menu_item_instances.errors, status: :unprocessable_entity } end end diff --git a/app/models/menu_item_instance.rb b/app/models/menu_item_instance.rb index a51a94c4..baad6392 100755 --- a/app/models/menu_item_instance.rb +++ b/app/models/menu_item_instance.rb @@ -4,8 +4,9 @@ class MenuItemInstance < ApplicationRecord has_many :menu_instance_item_sets has_many :item_sets, through: :menu_instance_item_sets # before_create :generate_menu_item_instance_code - validates_presence_of :item_instance_code - # validates_uniqueness_of :item_instance_code + # validates_presence_of :item_instance_code + + validates_uniqueness_of :item_instance_code def self.findParentCategory(item) if item.menu_category_id diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index e15c4b79..0d596100 100755 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -34,7 +34,7 @@ class SaleItem < ApplicationRecord sale_item.product_alt_name = item.product_alt_name sale_item.account_id = item.account_id sale_item.remark = type - if type == "foc" || type == "promotion" || type == "void" + if type == "FOC" || type == "promotion" || type == "void" sale_item.qty = qty * (-1) else sale_item.qty = qty diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 7840817e..202108e6 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -184,7 +184,7 @@ class SalePayment < ApplicationRecord sale_items = SaleItem.where("sale_id='#{ self.sale.sale_id }'") sale_items.each do|item| - SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price) + SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "FOC", item.unit_price, item.price) end self.payment_method = "foc" diff --git a/app/views/reports/saleitem/index.html.erb b/app/views/reports/saleitem/index.html.erb index f1a775bd..2aa6762f 100644 --- a/app/views/reports/saleitem/index.html.erb +++ b/app/views/reports/saleitem/index.html.erb @@ -125,35 +125,37 @@ <% end %> - - Other Charges -   - - - <% @other_charges.each do |other| %> - <% if other.total_item > 0 - total_qty += other.total_item - end %> - <% grand_total +=other.grand_total%> - -   - Other Charges - <%= other.item_code rescue '-' %> - <%= other.product_name rescue '-' %> - <%= other.total_item rescue '-' %> - <%= other.unit_price rescue '-' %> - <%= other.grand_total rescue '-' %> + <%if @otehr_charges.present?%> + + Other Charges +   + - - - <% other_sub_total += other.grand_total %> - - <% end %> - -   - <%= t("views.right_panel.detail.sub_total") %> - <%= other_sub_total %> - + <% @other_charges.each do |other| %> + <% if other.total_item > 0 + total_qty += other.total_item + end %> + <% grand_total +=other.grand_total%> + +   + Other Charges + <%= other.item_code rescue '-' %> + <%= other.product_name rescue '-' %> + <%= other.total_item rescue '-' %> + <%= other.unit_price rescue '-' %> + <%= other.grand_total rescue '-' %> + + + + <% other_sub_total += other.grand_total %> + + <% end %> + +   + <%= t("views.right_panel.detail.sub_total") %> + <%= other_sub_total %> + + <%end%>   diff --git a/app/views/settings/menu_item_instances/_form.html.erb b/app/views/settings/menu_item_instances/_form.html.erb index 58c82852..cc478055 100755 --- a/app/views/settings/menu_item_instances/_form.html.erb +++ b/app/views/settings/menu_item_instances/_form.html.erb @@ -3,11 +3,22 @@
<%= simple_form_for([:settings,@item, @settings_menu_item_instances]) do |f| %> - <%= f.error_notification %> + <% if(flash["instance_code_error"]) %> +
Please review the problems below:
+ <% end %>
- <%= f.input :item_instance_code %> + <%= f.input :item_instance_code ,:input_html=>{:class=>""},:required=>true %> + + <% flash.each do |test, msg| %> + <% str="[\"#{msg['item_instance_code']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') + %> + <%= str %> + <% end %> + <%= f.input :item_instance_name %> <%= f.input :price %>