update instanc code unique receipt bill and sale item
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -125,35 +125,37 @@
|
||||
<!-- end sub total -->
|
||||
<% end %>
|
||||
<!--Other Charges -->
|
||||
<tr>
|
||||
<td><b>Other Charges</b></td>
|
||||
<td colspan="4"> </td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<% @other_charges.each do |other| %>
|
||||
<% if other.total_item > 0
|
||||
total_qty += other.total_item
|
||||
end %>
|
||||
<% grand_total +=other.grand_total%>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>Other Charges</td>
|
||||
<td><%= other.item_code rescue '-' %></td>
|
||||
<td><%= other.product_name rescue '-' %></td>
|
||||
<td><%= other.total_item rescue '-' %></td>
|
||||
<td><%= other.unit_price rescue '-' %></td>
|
||||
<td><%= other.grand_total rescue '-' %></td>
|
||||
<%if @otehr_charges.present?%>
|
||||
<tr>
|
||||
<td><b>Other Charges</b></td>
|
||||
<td colspan="4"> </td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<!-- sub total -->
|
||||
|
||||
<% other_sub_total += other.grand_total %>
|
||||
<!-- end sub total -->
|
||||
<% end %>
|
||||
<tr>
|
||||
<td colspan="5"> </td>
|
||||
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||
<td ><span class="underline"><%= other_sub_total %></span></td>
|
||||
</tr>
|
||||
<% @other_charges.each do |other| %>
|
||||
<% if other.total_item > 0
|
||||
total_qty += other.total_item
|
||||
end %>
|
||||
<% grand_total +=other.grand_total%>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>Other Charges</td>
|
||||
<td><%= other.item_code rescue '-' %></td>
|
||||
<td><%= other.product_name rescue '-' %></td>
|
||||
<td><%= other.total_item rescue '-' %></td>
|
||||
<td><%= other.unit_price rescue '-' %></td>
|
||||
<td><%= other.grand_total rescue '-' %></td>
|
||||
</tr>
|
||||
<!-- sub total -->
|
||||
|
||||
<% other_sub_total += other.grand_total %>
|
||||
<!-- end sub total -->
|
||||
<% end %>
|
||||
<tr>
|
||||
<td colspan="5"> </td>
|
||||
<td><%= t("views.right_panel.detail.sub_total") %></td>
|
||||
<td ><span class="underline"><%= other_sub_total %></span></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
<!-- End Other Charges -->
|
||||
<tr style="border-top:2px solid grey;">
|
||||
<td colspan="3"> </td>
|
||||
|
||||
@@ -3,11 +3,22 @@
|
||||
<div class="card">
|
||||
<div class="body">
|
||||
<%= simple_form_for([:settings,@item, @settings_menu_item_instances]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
<% if(flash["instance_code_error"]) %>
|
||||
<div class="alert alert-danger">Please review the problems below:</div>
|
||||
<% end %>
|
||||
|
||||
<div class="col-md- panel">
|
||||
<div class="form-group p-l-15">
|
||||
<%= 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!('"]', '')
|
||||
%>
|
||||
<span class="help-block"><%= str %></span>
|
||||
<% end %>
|
||||
|
||||
<%= f.input :item_instance_name %>
|
||||
<%= f.input :price %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user