commission update

This commit is contained in:
Zin Lin Phyo
2017-08-23 11:14:24 +06:30
parent b53db9b08b
commit 3132bc7c34
13 changed files with 204 additions and 166 deletions

View File

@@ -20,6 +20,8 @@
//= require settings/processing_items
//= require jquery-ui
//= require bootstrap-datepicker
//= require select2
//= require select2-full
$(document).on('turbolinks:load', function() {
$('.datepicker').datepicker({

View File

@@ -4,7 +4,8 @@
@import "theme";
@import "jquery-ui";
@import "bootstrap-datepicker3";
@import "select2";
@import "select2-bootstrap";
/* Show it is fixed to the top */
// body {

View File

@@ -15,10 +15,12 @@ class Origami::CommissionsController < BaseOrigamiController
# GET /commissions/new
def new
@commission = Commission.new
@products = MenuItem.all
end
# GET /commissions/1/edit
def edit
@products = MenuItem.all
end
# POST /commissions

View File

@@ -1,4 +1,4 @@
class Commission < ApplicationRecord
belongs_to :product, foreign_key: 'product_id'
belongs_to :menu_item, foreign_key: 'product_id'
has_many :commissioners
end

View File

@@ -3,6 +3,8 @@ class MenuItem < ApplicationRecord
belongs_to :menu_category, :optional => true
has_many :menu_item_instances
has_many :commissions
# belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
# has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
belongs_to :account

View File

@@ -1,6 +1,5 @@
class Product < ApplicationRecord
validates_presence_of :name
has_many :commissions
# Product Image Uploader
mount_uploader :image_path, ProductImageUploader

View File

@@ -4,11 +4,11 @@
<div class="form-inputs">
<%= f.label :product_id %>
<%= f.collection_select :product_id, Product.all.order('name asc'), :id, :name, {prompt: "Select a Product"}, {class: "form-control"} %><br/>
<%= f.collection_select :product_id, @products, :id, :name, {prompt: 'Select a Product'}, {class: 'form-control'} %><br/>
<%= f.input :amount %>
<%= f.input :commission_type, :collection => [:percentage, :net_amount] %>
<%= f.input :commission_type, :collection => ['Percentage','Net Amount'], prompt: 'Select Commission Type', class: 'form-control' %>
<label><%= f.check_box :is_active %> Active </label>
</div>
</div><br>
<div class="form-actions">
<%= link_to 'Back', origami_commissions_path, class: 'btn btn-success' %>
<%= f.button :submit, class: 'btn btn-info' %>

View File

@@ -1,11 +1,11 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li>Commissions</li>
<span style="float: right">
<%= link_to t('.new', :default => t("helpers.links.new")), new_origami_commission_path ,:class => 'btn btn-primary btn-sm' %>
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li>Commissions</li>
<span style="float: right">
<%= link_to t('.new', :default => t("helpers.links.new")), new_origami_commission_path, :class => 'btn btn-primary btn-sm' %>
</span>
</ul>
</ul>
</div>
<br>
@@ -23,22 +23,16 @@
<tbody>
<% @commissions.each do |commission| %>
<tr>
<td>
<% if Product.exists? %>
<% product = Product.find(commission.product_id) %>
<%= product.name %>
<% end %>
</td>
<td><%= commission.amount %></td>
<td><%= commission.commission_type %></td>
<td><%= commission.is_active %></td>
<td><%= link_to 'Show', origami_commission_path(commission) %></td>
<td><%= link_to 'Edit', edit_origami_commission_path(commission) %></td>
<td><%= link_to 'Destroy', origami_commission_path(commission), method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<tr>
<td><%= commission.menu_item.name rescue '-' %></td>
<td><%= commission.amount rescue '-' %></td>
<td><%= commission.commission_type rescue '-' %></td>
<td><%= commission.is_active rescue '-' %></td>
<td><%= link_to 'Show', origami_commission_path(commission) %></td>
<td><%= link_to 'Edit', edit_origami_commission_path(commission) %></td>
<td><%= link_to 'Destroy', origami_commission_path(commission), method: :delete, data: {confirm: 'Are you sure?'} %></td>
</tr>
<% end %>
</tbody>
</tbody>
</table>
</div>

View File

@@ -16,12 +16,7 @@
<tbody>
<tr>
<td style="width:20%">Product Name</td>
<td>
<% if Product.exists? %>
<% product = Product.find(@commission.product_id) %>
<%= product.name %>
<% end %>
</td>
<td><%= @commission.menu_item.name rescue '-' %></td>
</tr>
<tr>
<td style="width:20%">Amount</td>