'
+'
'
+''+ menu_items[field].name +' '
@@ -73,7 +66,7 @@ $(function(){
+ price +"' data-instance-code = '"+ code +"' data-instance = '"
+ name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '"
+ JSON.stringify(item_attributes) +"' data-options = '"
- + options +"'>"
+ + options +"' data-image='"+image_path+"'>"
+"'
+'
'
@@ -88,7 +81,7 @@ $(function(){
+JSON.stringify(menu_items[field].item_sets)+"' data-toggle='modal' data-target='."+data_target+"'>"
+"
"
- +"
"
+ +"
"
+"
"
@@ -105,10 +98,10 @@ $(function(){
}
//end show list function
//click item row for item set
- $(document).on('click', '.set_item_box', function(event){
- $(".instance-list").empty();
- $(".options-list").empty();
-
+ $(document).on('click', '.set_item_box', function(event){
+ $(".instance-list").empty();
+ $(".options-list").empty();
+ change_qty_plus_minus("set_count","set_plus","set_minus");
data = $(this).parent().children().children('.add_icon');
instances = $(this).data('instance');
@@ -153,8 +146,10 @@ $(function(){
$('#set_item_instances').text(instances);
$('#set_name').text(data.attr('data-name'));
$('#set_item_code').text(data.attr('data-item-code'));
- $('#set_total_price').text(data.attr('data-price'));
+ // $('#set_total_price').text(data.attr('data-price'));
+ $('#set_total_price').text(0);
$('#set_unit_price').text(data.attr('data-price'));
+ // $('#set_unit_price').text(0);
});
// click instance for add item set
$(document).on('click', '.instance_box', function(event){
@@ -180,7 +175,8 @@ $(function(){
sub_total = $('#set_total_price').text();
name = $(this).data('name');
price = $(this).data('price');
- qty = $('#set_change_qty').val();
+ // qty = $('#set_change_qty').val();
+ qty = document.getElementById("set_count").value;
total = qty*price;
var total_price = +sub_total - +total;
$(this).removeClass('selected-instance');
@@ -188,21 +184,24 @@ $(function(){
$(this).removeAttr('data-options');
$('#instance_option').text('')
}else {
+
sub_total = $('#set_total_price').text();
name = $(this).data('name');
price = $(this).data('price');
- qty = $('#set_change_qty').val();
+ // qty = $('#set_change_qty').val();
+ qty = document.getElementById("set_count").value;
total = qty*price;
var total_price = +sub_total + +total;
$(this).addClass('selected-instance');
}
+ $('#set_unit_price').text(price);
$('#set_total_price').text(total_price);
}); //End selecct attribute buttom
// click add order
$(document).on('click', '.set_order', function(event){
total_price = $('#set_total_price').text();
- qty = parseInt($('#set_change_qty').val());
+ qty = parseInt($('#set_count').val());
item_code = $('#set_item_code').text();
item_name = $('#set_name').text();
@@ -242,6 +241,7 @@ $(function(){
$(document).on('click', '.menu_item_box', function(event){
$('.attributes-list').empty();
$('.options-list').empty();
+ $('#modal_box_img').empty();
$('.attr-alert').addClass('hide');
$('.add_to_order').removeAttr('data-instance-code');
$('.add_to_order').removeAttr('data-instance');
@@ -253,30 +253,66 @@ $(function(){
$('.add_to_order').removeAttr('data-attributes');
$('.add_to_order').removeAttr('data-options');
+ change_qty_plus_minus("count","plus","minus");
+
data = $(this).parent().children().children('.add_icon');
+
+ $('#total_price').text(data.attr('data-price'));
attributes = $(this).data('id');
selected_item = $(this).data('item');
instances = $(this).data('instance');
item_options = $(this).data('option');
+ if (data.attr('data-image')) {
+ image = "
";
+ }else{
+ image = "
";
+ }
+
+ $('#modal_box_img').append(image);
+
instance_attributes = []
for(var field in instances) {
value = instances[field].values;
$(value).each(function(i){
- options = value[i];
- instance_attributes.push(options);
+ options = value[i];
+ instance_attributes.push(options);
+ // $.ajax({
+ // type: "GET",
+ // url: '../../api/restaurant/menu_item_attributes/'+value[i],
+ // data: {id:value[i]},
+ // success:function(result){
+
+ // options = result["name"];
+ // instance_attributes.push(options);
+ // }
+ // });
});
}
+ // selected_arr = []
+ // $(selected_item).each(function(i){
+ // $.ajax({
+ // type: "GET",
+ // url: '../../api/restaurant/menu_item_attributes/'+selected_item[i],
+ // data: {id:selected_item[i]},
+ // success:function(result){
+ // name = result["name"];
+ // selected_arr.push(name);
+ // }
+ // });
+ // });
+
+
for(var field in attributes) {
value = attributes[field]["values"];
type = attributes[field]["type"]
- row = "
"+attributes[field]["type"]+" "
+ row = "
"+attributes[field]["type"]+" ";
+
$(value).each(function(i){
disabled = ""
status ="";
-
- if(parseInt(jQuery.inArray(value[i], selected_item))!== -1){
+ if(parseInt(jQuery.inArray(value[i], selected_item)) !== -1){
status = "selected-attribute";
}
if(parseInt(jQuery.inArray(value[i], instance_attributes)) == -1){
@@ -302,16 +338,21 @@ $(function(){
$(".options-list").append(row);
}
- $('#change_qty').val(1);
+ $('#count').val(1);
$('#item_instances').text(instances);
$('#title_name').text(data.attr('data-name'));
$('#item_code').text(data.attr('data-item-code'));
+ $('#instance_name').text(data.attr('data-instance'));
+ $('#instance_code').text(data.attr('data-instance-code'));
+ $('#promotion_price').text(data.attr('data-promotion-price'));
$('#total_price').text(data.attr('data-price'));
$('#unit_price').text(data.attr('data-price'));
});
// click select option icon for add
$(document).on('click', '.attribute_btn', function(event){
+
+ $('.change_qty').val(1);
value = $(this).data('value');
type = $(this).data('type');
instances = $(this).data('instances');
@@ -331,7 +372,7 @@ $(function(){
var selected_attr = get_selected_attributes('selected-attribute');
- qty = $('#change_qty').val();
+ qty = $('.change_qty').val();
for(var field in instances) {
item_attr = instances[field].values;
@@ -381,23 +422,30 @@ $(function(){
// click add order
$(document).on('click', '.add_to_order', function(event){
total_price = $('#total_price').text();
- qty = parseInt($('#change_qty').val());
+ qty = parseInt($('#count').val());
var item_row = $('.selected-attribute');
- var instances = jQuery.parseJSON(item_row.attr('data-instances'));
-
+
attribute_arr = get_selected_attributes('selected-attribute');
option_arr = get_selected_attributes('selected-option');
- for(var field in instances) {
- if (JSON.stringify(attribute_arr) === JSON.stringify(instances[field].values)) {
-
- $('.add_to_order').attr('data-instance-code',instances[field].code);
- $('.add_to_order').attr('data-instance',instances[field].name);
- $('.add_to_order').attr('data-price',instances[field].price);
- $('.add_to_order').attr('data-promotion-price',instances[field].promotion_price);
+ if (item_row.length>0) {
+ var instances = jQuery.parseJSON(item_row.attr('data-instances'));
+ for(var field in instances) {
+ if (JSON.stringify(attribute_arr) === JSON.stringify(instances[field].values)) {
+ $('.add_to_order').attr('data-instance-code',instances[field].code);
+ $('.add_to_order').attr('data-instance',instances[field].name);
+ $('.add_to_order').attr('data-price',instances[field].price);
+ $('.add_to_order').attr('data-promotion-price',instances[field].promotion_price);
+ }
}
+ }else{
+ $('.add_to_order').attr('data-instance-code',$('#instance_code').text());
+ $('.add_to_order').attr('data-instance',$('#instance_name').text());
+ $('.add_to_order').attr('data-price',$('#unit_price').text());
+ $('.add_to_order').attr('data-promotion-price',$('#promotion_price').text());
}
+
$('.add_to_order').attr('data-item-code',$('#item_code').text());
$('.add_to_order').attr('data-qty',qty);
$('.add_to_order').attr('data-name',$('#title_name').text());
@@ -417,7 +465,7 @@ $(function(){
}); //End Add Icon Click
function show_item_detail(data){
- console.log(data)
+
qty = parseInt(data.attr('data-qty'));
append = 0;
price = parseFloat(data.attr('data-price')).toFixed(2);
@@ -599,7 +647,7 @@ $(function(){
var item_row = $('.summary-items tbody tr');
$(item_row).each(function(i){
var order_item = {};
- console.log($(item_row[i]).attr('data-options'));
+
order_item.order_item_id = $(item_row[i]).attr('data-row');
order_item.item_instance_code = $(item_row[i]).attr('data-instance-code');
order_item.quantity = $(item_row[i]).children('#item_qty').text();
@@ -620,4 +668,88 @@ $(function(){
return attribute_arr;
}
+ //click menu sidebar menu category
+ $("#back").on("click", function(){
+ var table_id = $('#table_id').text();
+ var table_type = $('#table_type').text();
+ if(table_type == "Table"){
+ window.location.href = "/origami/table/" + table_id
+ }else {
+ window.location.href = "/origami/room/" + table_id
+ }
+ });
+
+ // Get Selected Class
+ function change_qty_plus_minus(id,plus,minus) {
+
+ var count = 1;
+ var countEl = document.getElementById(id);
+
+ $('#'+plus).on("click", function(){
+
+ count++;
+ countEl.value = count;
+
+
+ if (id == "count") {
+ price = $("#unit_price").text();
+ $("#total_price").text(count*price);
+ }else{
+ var item_row = $('.selected-instance');
+ price = $("#set_unit_price").text();
+ set_total_price = $("#set_total_price").text();
+
+ if (item_row.length > 1) {
+ total = 0 ;
+ $(item_row).each(function(i){
+ total += count * $(item_row[i]).attr('data-price');
+ total_price = total;
+ });
+ }else{
+ total_price = count*price;
+ }
+
+ $("#set_total_price").text(total_price);
+ }
+ });
+
+ $('#'+minus).on("click", function(){
+ if (count > 1) {
+ count--;
+ countEl.value = count;
+
+ if (id=="count") {
+ price = $("#unit_price").text();
+ $("#total_price").text(count*price);
+ }else{
+ var item_row = $('.selected-instance');
+ price = $("#set_unit_price").text();
+ set_total_price = $("#set_total_price").text();
+
+ if (item_row.length > 1) {
+ total = 0 ;
+ $(item_row).each(function(i){
+ total += count * $(item_row[i]).attr('data-price');
+ total_price = total;
+ });
+ }else{
+ total_price = count*price;
+ }
+ $("#set_total_price").text(total_price);
+ }
+ }
+ })
+ }
+ // $("#set_change_qty").change(function(){
+ // qty = $(this).val();
+ // price = $("#set_total_price").text();
+ // $("#set_total_price").text(qty*price);
+ // });
+
+ // $(".change_qty").change(function(){
+ // qty = $(this).val();
+ // price = $("#unit_price").text();
+ // $("#total_price").text(qty*price);
+ // });
+
});
\ No newline at end of file
diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js
index ce5ac871..55bfd46b 100644
--- a/app/assets/javascripts/cable.js
+++ b/app/assets/javascripts/cable.js
@@ -1,14 +1,14 @@
// Action Cable provides the framework to deal with WebSockets in Rails.
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
-//
+
//= require action_cable
//= require_self
//= require_tree ./channels
// Temp Disable
-// (function() {
-// this.App || (this.App = {});
+(function() {
+ this.App || (this.App = {});
-// App.cable = ActionCable.createConsumer();
+ App.cable = ActionCable.createConsumer();
-// }).call(this);
+}).call(this);
diff --git a/app/assets/javascripts/channels/bill.js b/app/assets/javascripts/channels/bill.js
new file mode 100644
index 00000000..ab8e0898
--- /dev/null
+++ b/app/assets/javascripts/channels/bill.js
@@ -0,0 +1,14 @@
+App.order = App.cable.subscriptions.create('BillChannel', {
+// App.messages = App.cable.subscriptions.create('MessagesChannel', {
+
+ connected: function() {},
+
+ disconnected: function() {},
+
+ received: function(data) {
+ $('.table_'+data.table.id).removeClass('blue');
+ $('.table_'+data.table.id).addClass('red');
+ $('.new_text_'+data.table.id).removeClass('hide')
+ }
+});
+
diff --git a/app/assets/javascripts/channels/order.js b/app/assets/javascripts/channels/order.js
new file mode 100644
index 00000000..dccb86d7
--- /dev/null
+++ b/app/assets/javascripts/channels/order.js
@@ -0,0 +1,14 @@
+App.order = App.cable.subscriptions.create('OrderChannel', {
+// App.messages = App.cable.subscriptions.create('MessagesChannel', {
+
+ connected: function() {},
+
+ disconnected: function() {},
+
+ received: function(data) {
+ $('.table_'+data.table.id).removeClass('green');
+ $('.table_'+data.table.id).addClass('blue');
+ $('.new_text_'+data.table.id).removeClass('hide')
+ }
+});
+
diff --git a/app/assets/javascripts/channels/order_queue_station.js b/app/assets/javascripts/channels/order_queue_station.js
index 85706bb5..1b9351cf 100644
--- a/app/assets/javascripts/channels/order_queue_station.js
+++ b/app/assets/javascripts/channels/order_queue_station.js
@@ -1,24 +1,83 @@
-// App.order_queue_station = App.cable.subscriptions.create("OrderQueueStationChannel", {
-// connected: function() {},
+App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChannel', {
+// App.messages = App.cable.subscriptions.create('MessagesChannel', {
-// disconnected: function() {},
+ connected: function() {},
-// received: function(message) {
-// alert(message);
-// },
+ disconnected: function() {},
-// order: function(message) {
-// return this.perform('order', {
-// message: message
-// });
-// }
-// });
+ received: function(data) {
+ // console.log(data.order);
+ var oqs_id = $('.oqs_active').attr('data-id');
+ items = data.order;
+ for(var field in items) {
+ var price = parseFloat(items[field].price).toFixed(2);
+ if (items[field]["options"] == "[]" || items[field]["options"] == "") {
+ var options = "";
+ }else{
+ var options = items.options;
+ }
+ //for count
+ test = document.getElementsByClassName("oqs_count");
+
+ for (var i = 0; i < test.length; i++) {
+ oqs_count_id = $(".oqs_count"+i).attr("data-id");
+ oqs_count = $(".oqs_count"+i).text();
+ if ( oqs_count_id == items[field]["order_queue_station_id"]) {
+ oqs_count_total = +oqs_count +1 ;
+ $(".oqs_count"+i).text(oqs_count_total)
+ }
+ }
+ //end count
+
+ var date = new Date(items[field]["created_at"]);
+ var show_date = date.getDate() + "-" + date.getMonth() + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes();
+
+ if (oqs_id == items[field]["order_queue_station_id"]) {
+
+ row ='
'
+ +'
'+items[field]["order_id"]+' '
+ +'
'
+ +'
'
+ +''+items[field]["table_type"]+'- '
+ +''+ items[field]["zone"] +' '
+ +''+ items[field]["order_id"] +'- '
+ +' '
+
+ +'
'
+ +''+ items[field]["item_name"] +'- '
+ +''+ items[field]["qty"] +'- '
+ +' '
+
+ +'
'+ options +'
'
+
+ +'
'
+ +'Order at'
+ +''+ show_date +' - '
+
+ +''+ items[field]["item_order_by"] +' '
+ +' '
+ +'
'
+
+ +'
'+ items[field]["customer_name"] +'
'
+ +'
'+ items[field]["assigned_order_item_id"] +'
'
+ +'
'
+
+ +''
+ +'
';
+ $('.oqs_append').append(row);
+ }
+ }//end looping
+
+ var $divs = $("div.queue_station");
+ var SortListDivs = $divs.sort(function (a, b) {
+ first = $(a).attr('data-date');
+ next = $(b).attr('data-date');
+ return parseInt(next.substring(4, 16)) - parseInt(first.substring(4, 16));
+ });
+ $("#oqs_container").html(SortListDivs);
+ },
+});
-// $(function(){
-// $("#submit_order").on('click', function(event) {
-// var orderData=$("#new_order").serializeObject();
-// App.order_station.order(orderData);
-// //orderData='';
-// return event.preventDefault();
-// });
-// });
diff --git a/app/assets/stylesheets/OQS.scss b/app/assets/stylesheets/OQS.scss
index 74a8032f..108c7541 100644
--- a/app/assets/stylesheets/OQS.scss
+++ b/app/assets/stylesheets/OQS.scss
@@ -25,3 +25,5 @@
font-size: 18px;
margin: 0px 0px 5px 0px;
}
+
+
diff --git a/app/assets/stylesheets/addorder.scss b/app/assets/stylesheets/addorder.scss
index 39dce3c4..88adca00 100644
--- a/app/assets/stylesheets/addorder.scss
+++ b/app/assets/stylesheets/addorder.scss
@@ -109,9 +109,9 @@ element.style {
}
#logo{
margin: auto;
- width: 50%;
+ width: 100%;
border: 1px solid #54A5AF;
- padding: 10px;
+ padding: 0px;
}
#instance_img{
diff --git a/app/assets/stylesheets/inventory_definitions.scss b/app/assets/stylesheets/inventory_definitions.scss
index 538c2918..e7fc208e 100644
--- a/app/assets/stylesheets/inventory_definitions.scss
+++ b/app/assets/stylesheets/inventory_definitions.scss
@@ -1,3 +1,272 @@
-// Place all the styles related to the inventory_definitions controller here.
-// They will automatically be included in application.css.
-// You can use Sass (SCSS) here: http://sass-lang.com/
+@import "bootstrap";
+@import "font-awesome";
+@import "theme";
+@import "jquery-ui";
+@import "bootstrap-datepicker3";
+@import "select2";
+@import "jquery.datetimepicker";
+
+/* Show it is fixed to the top */
+// body {
+// min-height: 75rem;
+// padding-top: 4.5rem;
+// }
+.card-columns {
+ font-size: 18px !important;
+}
+
+.others-payment{
+ line-height:100px;
+ text-align:center;
+ color:white;
+ width:300px;
+ height:100px;
+ font-size:18px;
+}
+
+.orders-table {
+ cursor: pointer;
+}
+
+.cashier_number{
+ width: 33%;
+ height:70px;
+ line-height:70px;
+ text-align:center;
+ background:#54A5AF;
+ // float:left;
+ // margin:2px;
+ font-size:20px;
+ color:white;
+ // cursor:pointer;
+}
+
+.del_cashier_number{
+ opacity:0.6,
+}
+
+.pay{
+ width: 98%;
+ height:211px;
+ line-height:211px;
+ text-align:center;
+ font-size:20px;
+ color:white;
+}
+
+.payment{
+ height:70px;line-height:70px;
+ align:center;
+ color:white;
+ font-size:16px;
+ margin-top:5px;
+}
+
+.cash-color{
+ background-color:#80CBC4;
+}
+
+.credit-color{
+ background-color:#FFCCBC;
+}
+
+.other-payment-color{
+ background-color:#E1BEE7;
+}
+
+.cashier_number:hover{
+ background:#A9F5F2;
+}
+
+.action-btn {
+ white-space: normal !important;
+ height: 60px;
+ margin-bottom: 5px;
+}
+
+.bottom-5 {
+ margin-bottom: 5px;
+}
+
+.fluid {
+ width: 100%;
+}
+
+.style2 {
+ border-top: 3px double #8c8b8b;
+}
+
+.long{
+ width:49%;
+}
+
+.sold {
+ background-color: red;
+}
+
+.paid {
+ background-color: green;
+}
+
+.selected-item {
+ color: #fff !important;
+ background-color: blue !important;
+}
+
+.selected-account {
+ color: #fff !important;
+ background-color: blue !important;
+}
+
+/* Reciept Style */
+#order-charges-table td {
+ border-top: none !important;
+}
+
+.charges-name {
+ width: 80%;
+ text-align: left;
+}
+
+.item-name {
+ width: 60%;
+ text-align: left;
+}
+
+.item-attr {
+ width: 20%;
+ text-align: right;
+}
+
+.item-attr-edit{
+ width: 10%;
+ text-align: left;
+}
+
+.display-none{
+ display: none;
+}
+
+.text-white{
+ color: #fff;
+}
+
+/* Colors */
+.purple {
+ background-color:#7a62d3;
+}
+
+.orange{
+ background-color:#FF7F50;
+}
+
+.red {
+ background-color:#ff0000;
+}
+
+.green{
+ background-color: #009900;
+}
+
+.orange{
+ background-color: #FF8C00;
+}
+
+.blue{
+ background-color: blue;
+}
+
+/* End Colors */
+
+.left{
+ margin-left:1px;
+}
+
+.bottom{
+ margin-bottom: 1px;
+}
+
+/*----- Reset -----*/
+
+select.form-control {
+ height: inherit !important;
+}
+
+.form-horizontal .form-group {
+ margin-right: 0px !important;
+}
+
+/* Discount */
+
+.discount-item-row {
+ cursor: pointer;
+}
+
+tr.discount-item-row:hover {
+ background-color: #e3e3e3 !important;
+}
+.required abbr{
+ color: red !important;
+}
+
+/* Jquery Confirm */
+
+.jconfirm-box-container{
+ margin-left:-40px !important;
+ margin-top:-40px !important;
+}
+
+#sxModal {
+ display: none;
+ overflow: auto;
+ width: 100%;
+ height: 100%;
+ background-color: #000;
+ background-color: rgba(0,0,0,0.4);
+ position: fixed;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ z-index: 1100;
+}
+
+#sxModal-Content {
+ position: relative;
+ left: 42%;
+ top: 30%;
+ background-color: #d9534f;
+ color: #fff;
+ text-align: center;
+ width: 200px;
+ height: 200px;
+ padding-top: 5%;
+ border-radius: 100px;
+ z-index: 1101;
+}
+
+/*Loading gif for payment*/
+
+#loading_wrapper{
+
+ position: fixed;
+ background-color: #C8C8C8 ;
+ height: 100%;
+ width: 100%;
+ left: 0;
+ opacity: 0.6;
+ top: 0;
+ z-index: 9999999;
+}
+#loading{
+ position: relative;
+ height: 100%;
+ width: 100%;
+ background-image: url('../../../image/loading-ajax.gif');
+ background-position: center center;
+ background-repeat: no-repeat;
+ opacity: 1;
+ filter: alpha(opacity=100); /* ie */
+ -moz-opacity: 1; /* mozilla */
+
+}
diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb
index a66bc071..b2cb741f 100644
--- a/app/channels/application_cable/channel.rb
+++ b/app/channels/application_cable/channel.rb
@@ -7,8 +7,12 @@ module ApplicationCable
end
# Order Queue Station Channel
- class OQSChannel < ActionCable::Channel::Base
+ class OrderQueueStationChannel < ActionCable::Channel::Base
end
+ # Order Queue Station Channel
+ class BillChannel < ActionCable::Channel::Base
+
+ end
end
diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb
index 0ff5442f..9da60bf4 100644
--- a/app/channels/application_cable/connection.rb
+++ b/app/channels/application_cable/connection.rb
@@ -1,4 +1,7 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
+ def connect
+ logger.add_tags "ActionCable"
+ end
end
end
diff --git a/app/channels/bill_channel.rb b/app/channels/bill_channel.rb
new file mode 100644
index 00000000..ed5efbe6
--- /dev/null
+++ b/app/channels/bill_channel.rb
@@ -0,0 +1,10 @@
+class BillChannel < ApplicationCable::Channel
+ def subscribed
+ stream_from "bill_channel"
+ end
+
+ def unsubscribed
+ # Any cleanup needed when channel is unsubscribed
+ stop_all_streams
+ end
+end
diff --git a/app/channels/order_channel.rb b/app/channels/order_channel.rb
new file mode 100644
index 00000000..d261e48b
--- /dev/null
+++ b/app/channels/order_channel.rb
@@ -0,0 +1,10 @@
+class OrderChannel < ApplicationCable::Channel
+ def subscribed
+ stream_from "order_channel"
+ end
+
+ def unsubscribed
+ stop_all_streams
+ # Any cleanup needed when channel is unsubscribed
+ end
+end
diff --git a/app/channels/order_queue_station_channel.rb b/app/channels/order_queue_station_channel.rb
index 8206c64b..b815a446 100644
--- a/app/channels/order_queue_station_channel.rb
+++ b/app/channels/order_queue_station_channel.rb
@@ -4,6 +4,7 @@ class OrderQueueStationChannel < ApplicationCable::Channel
end
def unsubscribed
+ stop_all_streams
# Any cleanup needed when channel is unsubscribed
end
diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb
index 2b323d0f..ac12e453 100644
--- a/app/controllers/api/bill_controller.rb
+++ b/app/controllers/api/bill_controller.rb
@@ -7,8 +7,11 @@ class Api::BillController < Api::ApiController
@error_message = "Order ID or Booking ID is require to request for a bill."
if ShiftSale.current_shift
#create Bill by Booking ID
+ table = 0
if (params[:booking_id])
booking = Booking.find(params[:booking_id])
+ # for Job
+ table = DiningFacility.find(booking.dining_facility_id)
if booking
if booking.sale_id.nil?
@@ -23,8 +26,14 @@ class Api::BillController < Api::ApiController
elsif (params[:order_id])
@sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier)
+
+ # for Job
+ booking = Booking.find_by_sale_id(@sale_id)
+ table = DiningFacility.find(booking.dining_facility_id)
end
Promotion.promo_activate(@sale)
+
+ BillBroadcastJob.perform_later(table)
else
@status = false
@error_message = "No Current Open Shift"
diff --git a/app/controllers/api/restaurant/menu_item_attributes_controller.rb b/app/controllers/api/restaurant/menu_item_attributes_controller.rb
index 1b6a48d4..37719c37 100644
--- a/app/controllers/api/restaurant/menu_item_attributes_controller.rb
+++ b/app/controllers/api/restaurant/menu_item_attributes_controller.rb
@@ -1,9 +1,12 @@
class Api::Restaurant::MenuItemAttributesController < Api::ApiController
-
+ skip_before_action :authenticate
#Description
# Pull the default menu details and also other available (active) menus
# Input Params - order_id
def index
@menu_attributes = MenuItemAttribute.all
end
+ def show
+ @attribute = MenuItemAttribute.find(params[:id])
+ end
end
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index ead69f39..54534c4f 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -58,14 +58,7 @@ class HomeController < ApplicationController
end
def dashboard
- # if @employee && @employee.role == "cashier"
- #
- # elsif @employee && @employee.role == "waiter"
- # elsif @employee && @employee.role == "administrator"
- # elsif @employee && @employee.role == "manager"
- # elsif @employee && @employee.role == "supervisour"
- # redirect_to dashboard_path
- # end
+ @shop = Shop.first
end
def destroy
diff --git a/app/controllers/inventory/inventory_definitions_controller.rb b/app/controllers/inventory/inventory_definitions_controller.rb
index 7a8f17e1..33b7dd75 100644
--- a/app/controllers/inventory/inventory_definitions_controller.rb
+++ b/app/controllers/inventory/inventory_definitions_controller.rb
@@ -25,7 +25,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# POST /inventory_definitions.json
def create
@inventory_definition = InventoryDefinition.new(inventory_definition_params)
-
+ @inventory_definition.created_by = current_user.id
respond_to do |format|
if @inventory_definition.save
format.html { redirect_to inventory_path, notice: 'Inventory definition was successfully created.' }
diff --git a/app/controllers/inventory/stock_checks_controller.rb b/app/controllers/inventory/stock_checks_controller.rb
index 9ff9fce7..52d183de 100644
--- a/app/controllers/inventory/stock_checks_controller.rb
+++ b/app/controllers/inventory/stock_checks_controller.rb
@@ -1,7 +1,7 @@
class Inventory::StockChecksController < BaseInventoryController
-
def index
@check = StockCheck.new
+ @inventory_definitions = InventoryDefinition.active.all
end
def create
@@ -28,87 +28,86 @@ class Inventory::StockChecksController < BaseInventoryController
stockcheck = StockCheck.find(stock_id)
stockcheck_items = stockcheck.stock_check_items
member_info = nil
- unique_code = "StockPrint"
-
+ unique_code = 'StockPrint'
+
shop_details = Shop.find(1)
checker = Employee.find(stockcheck.check_by)
- print_settings=PrintSetting.find_by_unique_code(unique_code)
+ print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings)
- printer.print_stock_check_result(print_settings,stockcheck, stockcheck_items,checker.name, shop_details)
-
+ printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, shop_details)
end
# before_action :set_stock_check, only: [:show, :edit, :update, :destroy]
# GET /stock_checks
# GET /stock_checks.json
-# def index
-# @stock_checks = StockCheck.all
-# end
-#
-# # GET /stock_checks/1
-# # GET /stock_checks/1.json
-# def show
-# end
-#
-# # GET /stock_checks/new
-# def new
-# @stock_check = StockCheck.new
-# end
-#
-# # GET /stock_checks/1/edit
-# def edit
-# end
-#
-# # POST /stock_checks
-# # POST /stock_checks.json
-# def create
-# @stock_check = StockCheck.new(stock_check_params)
-#
-# respond_to do |format|
-# if @stock_check.save
-# format.html { redirect_to @stock_check, notice: 'Stock check was successfully created.' }
-# format.json { render :show, status: :created, location: @stock_check }
-# else
-# format.html { render :new }
-# format.json { render json: @stock_check.errors, status: :unprocessable_entity }
-# end
-# end
-# end
-#
-# # PATCH/PUT /stock_checks/1
-# # PATCH/PUT /stock_checks/1.json
-# def update
-# respond_to do |format|
-# if @stock_check.update(stock_check_params)
-# format.html { redirect_to @stock_check, notice: 'Stock check was successfully updated.' }
-# format.json { render :show, status: :ok, location: @stock_check }
-# else
-# format.html { render :edit }
-# format.json { render json: @stock_check.errors, status: :unprocessable_entity }
-# end
-# end
-# end
-#
-# # DELETE /stock_checks/1
-# # DELETE /stock_checks/1.json
-# def destroy
-# @stock_check.destroy
-# respond_to do |format|
-# format.html { redirect_to stock_checks_url, notice: 'Stock check was successfully destroyed.' }
-# format.json { head :no_content }
-# end
-# end
-#
-# private
-# # Use callbacks to share common setup or constraints between actions.
-# def set_stock_check
-# @stock_check = StockCheck.find(params[:id])
-# end
-#
-# # Never trust parameters from the scary internet, only allow the white list through.
-# def stock_check_params
-# params.fetch(:stock_check, {})
-# end
+ # def index
+ # @stock_checks = StockCheck.all
+ # end
+ #
+ # # GET /stock_checks/1
+ # # GET /stock_checks/1.json
+ # def show
+ # end
+ #
+ # # GET /stock_checks/new
+ # def new
+ # @stock_check = StockCheck.new
+ # end
+ #
+ # # GET /stock_checks/1/edit
+ # def edit
+ # end
+ #
+ # # POST /stock_checks
+ # # POST /stock_checks.json
+ # def create
+ # @stock_check = StockCheck.new(stock_check_params)
+ #
+ # respond_to do |format|
+ # if @stock_check.save
+ # format.html { redirect_to @stock_check, notice: 'Stock check was successfully created.' }
+ # format.json { render :show, status: :created, location: @stock_check }
+ # else
+ # format.html { render :new }
+ # format.json { render json: @stock_check.errors, status: :unprocessable_entity }
+ # end
+ # end
+ # end
+ #
+ # # PATCH/PUT /stock_checks/1
+ # # PATCH/PUT /stock_checks/1.json
+ # def update
+ # respond_to do |format|
+ # if @stock_check.update(stock_check_params)
+ # format.html { redirect_to @stock_check, notice: 'Stock check was successfully updated.' }
+ # format.json { render :show, status: :ok, location: @stock_check }
+ # else
+ # format.html { render :edit }
+ # format.json { render json: @stock_check.errors, status: :unprocessable_entity }
+ # end
+ # end
+ # end
+ #
+ # # DELETE /stock_checks/1
+ # # DELETE /stock_checks/1.json
+ # def destroy
+ # @stock_check.destroy
+ # respond_to do |format|
+ # format.html { redirect_to stock_checks_url, notice: 'Stock check was successfully destroyed.' }
+ # format.json { head :no_content }
+ # end
+ # end
+ #
+ # private
+ # # Use callbacks to share common setup or constraints between actions.
+ # def set_stock_check
+ # @stock_check = StockCheck.find(params[:id])
+ # end
+ #
+ # # Never trust parameters from the scary internet, only allow the white list through.
+ # def stock_check_params
+ # params.fetch(:stock_check, {})
+ # end
end
diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb
index dae8b02f..af843c7e 100644
--- a/app/controllers/oqs/home_controller.rb
+++ b/app/controllers/oqs/home_controller.rb
@@ -131,6 +131,7 @@ class Oqs::HomeController < BaseOqsController
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} ")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
+ .order("assigned_order_items.assigned_order_item_id desc")
.group("assigned_order_items.assigned_order_item_id")
end
diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb
index 1f9d70f3..6c9127ae 100644
--- a/app/controllers/origami/addorders_controller.rb
+++ b/app/controllers/origami/addorders_controller.rb
@@ -30,10 +30,19 @@ class Origami::AddordersController < BaseOrigamiController
else
@booking = nil
end
-
-
end
+ def get_menu_category ()
+ if (params[:id])
+ #Pull this menu
+ @menu = MenuCategory.find_by_id(params[:id])
+ return @menu
+ else
+ MenuCategory.current_menu
+ end
+ end
+
+
def create
Rails.logger.debug "Order Source - " + params[:order_source].to_s
Rails.logger.debug "Table ID - " + params[:table_id].to_s
diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb
index 1e14fbc5..8fddfa0f 100644
--- a/app/controllers/origami/discounts_controller.rb
+++ b/app/controllers/origami/discounts_controller.rb
@@ -127,88 +127,91 @@ class Origami::DiscountsController < BaseOrigamiController
# Member Discount
def member_discount
- sale_id = params[:sale_id]
- # account_types = JSON.parse(params[:account_types])
- account_types = Account.where("discount=?",true)
- sub_total = params[:sub_total]
- sale = Sale.find(sale_id)
- price = SaleItem.calculate_price_by_accounts(sale.sale_items)
-
- arr = Array.new;
-
- account_types.each do |at|
- price.each do |pc|
- if pc[:name] == at.title && pc[:price]>0
- str={type:pc[:name],amount:pc[:price]}
- arr.push(str)
- end
- end
- end
-
- generic_customer_id = sale.customer.membership_id
-
- receipt_no = sale.receipt_no
- membership = MembershipSetting.find_by_membership_type("paypar_url")
- memberaction = MembershipAction.find_by_membership_type("member_discount")
- merchant_uid = memberaction.merchant_account_id.to_s
- campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
- auth_token = memberaction.auth_token.to_s
- url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
-
- # Check for items for Paypar Cloud
- if arr.length > 0
- begin
- response = HTTParty.post(url,
- :body => { account_no: nil,
- generic_customer_id:generic_customer_id ,
- campaign_type_id: campaign_type_id,
- receipt_no: receipt_no,
- merchant_uid:merchant_uid,
- campaign_method:arr.to_json,
- total_sale_transaction_amount: sale.grand_total,
- auth_token:auth_token}.to_json,
- :headers => {
- 'Content-Type' => 'application/json',
- 'Accept' => 'application/json'
- }, :timeout => 10)
- rescue HTTParty::Error
- response = {:status=> false, :message => "Can't open membership server " }
-
- rescue Net::OpenTimeout
- response = {:status=> false, :message => "Can't open membership server " }
- rescue OpenURI::HTTPError
- response = {:status=> false, :message => "Can't open membership server " }
-
- rescue SocketError
- response = {:status=> false, :message => "Can't open membership server " }
- end
- else
- response = {:status=> false, :message => "You have no selected discount item" }
- end
-
- table_id = sale.bookings[0].dining_facility_id
- table_type = DiningFacility.find(table_id).type
-
- # Re-calc All Amount in Sale
- if response["status"] == true
- discount_amount = response["discount_earned"]
- if response["discount_bonus_earned"]
- discount_amount = discount_amount + response["discount_bonus_earned"]
- end
- sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount')
- result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type }
- end
-
- if response["status"] == "500"
- result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
- end
- if !response.nil?
- if response[:status] == false
- result = {:status=> response[:message],:title=>"Alert", :table_id => table_id,:table_type => table_type }
- end
- end
- render :json => result.to_json
+ sale_id = params[:sale_id]
+ is_card = params[:is_card]
+ sub_total = params[:sub_total]
+ sale = Sale.find(sale_id)
+
+ # Check for Card Payment
+ is_card_payment = SaleItem.get_sale_payments_by_card(sale.sale_payments)
+
+ if is_card_payment != true
+ account_types = Account.where("discount=?",true)
+ table_id = sale.bookings[0].dining_facility_id
+ table_type = DiningFacility.find(table_id).type
+
+ # Get Prices for each accounts (eg: food, beverage)
+ account_price = SaleItem.calculate_price_by_accounts(sale.sale_items)
+ acc_prices = Array.new;
+
+ account_types.each do |at|
+ account_price.each do |pc|
+ if pc[:name] == at.title && pc[:price]>0
+ str={type:pc[:name],amount:pc[:price]}
+ acc_prices.push(str)
+ end
+ end
+ end
+
+ generic_customer_id = sale.customer.membership_id
+ receipt_no = sale.receipt_no
+ membership = MembershipSetting.find_by_membership_type("paypar_url")
+ memberaction = MembershipAction.find_by_membership_type("member_discount")
+ merchant_uid = memberaction.merchant_account_id.to_s
+ campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
+ auth_token = memberaction.auth_token.to_s
+ url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
+
+ # Check for items for Paypar Cloud
+ if acc_prices.length > 0
+ begin
+ response = HTTParty.post(url,
+ :body => { account_no: nil,
+ generic_customer_id:generic_customer_id ,
+ campaign_type_id: campaign_type_id,
+ receipt_no: receipt_no,
+ merchant_uid:merchant_uid,
+ campaign_method:acc_prices.to_json,
+ total_sale_transaction_amount: sale.grand_total,
+ is_card: is_card,
+ auth_token:auth_token}.to_json,
+ :headers => {
+ 'Content-Type' => 'application/json',
+ 'Accept' => 'application/json'
+ }, :timeout => 10)
+ rescue HTTParty::Error
+ response = {"status": false, "message": "Can't open membership server " }
+
+ rescue Net::OpenTimeout
+ response = {"status": false, "message": "Can't open membership server " }
+ rescue OpenURI::HTTPError
+ response = {"status": false, "message": "Can't open membership server " }
+
+ rescue SocketError
+ response = {"status": false, "message": "Can't open membership server " }
+ end
+ else
+ response = {"status": false, "message": "You have no selected discount item" }
+ end
+
+ # Re-calc All Amount in Sale
+ if response["status"] == true
+ discount_amount = response["discount_earned"]
+ if response["discount_bonus_earned"]
+ discount_amount = discount_amount + response["discount_bonus_earned"]
+ end
+ sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount')
+ result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type }
+ elsif response["status"] == "500"
+ result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
+ else
+ result = {:status=> response["message"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
+ end
+
+ render :json => result.to_json
+
+ end #end Is Card Payment
end
#discount for selected order
diff --git a/app/controllers/origami/in_duties_controller.rb b/app/controllers/origami/in_duties_controller.rb
new file mode 100644
index 00000000..eaf23c5a
--- /dev/null
+++ b/app/controllers/origami/in_duties_controller.rb
@@ -0,0 +1,170 @@
+class Origami::InDutiesController < BaseOrigamiController
+ before_action :set_in_duty, only: %i[show edit update edit_in_duty update_for_in_duty destroy destroy_in_duty]
+
+ # GET /in_duties
+ # GET /in_duties.json
+ def index
+ @in_duties = InDuty.all
+ end
+
+ def index_in_duty
+ @duty_in = InDuty.where('dinning_id=?', params[:table_id])
+ @table = DiningFacility.find(params[:table_id])
+ @in_duty = InDuty.new
+ @duties_in = Kaminari.paginate_array(@duty_in).page(params[:page]).per(10)
+ end
+
+ # GET /in_duties/1
+ # GET /in_duties/1.json
+ def show; end
+
+ # GET /in_duties/new
+ def new
+ # this one use for new
+ @in_duty = InDuty.new
+ @table = DiningFacility.find(params[:table_id])
+ @commissioner = @in_duty.commissioner
+ render partial: 'form'
+ end
+
+ # GET /in_duties/1/edit
+ def edit; end
+
+ def edit_in_duty
+ @in_duty = InDuty.find(params[:id])
+ @table = DiningFacility.find(params[:table_id])
+ @commissioner = @in_duty.commissioner
+
+ # render json: {in_duty: @in_duty, commissioner: @commissioner}
+ render partial: 'form'
+ end
+
+ def assign_in_duty
+ @in_duty = InDuty.new
+ @table = DiningFacility.find(params[:table_id])
+ end
+
+ # POST /in_duties
+ # POST /in_duties.json
+ def create
+ @in_duty = InDuty.new(in_duty_params)
+
+ respond_to do |format|
+ if @in_duty.save
+ format.html { redirect_to origami_in_duties_path, notice: 'In duty was successfully created.' }
+ format.json { render :show, status: :created, location: @in_duty }
+ else
+ format.html { render :new }
+ format.json { render json: @in_duty.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ def create_for_in_duty
+ # this one use for create and update
+ in_duty = in_duty_params
+ in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i
+ in_time = in_time.change(offset: '+06:30')
+ out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
+ out_time = out_time.change(offset: '+06:30')
+ @in_duty = InDuty.new
+ in_duty_id = in_duty[:id]
+ unless in_duty_id.empty?
+ @in_duty = InDuty.find(in_duty_id.to_i)
+ end
+
+ @in_duty.dinning_id = in_duty_params[:dinning_id]
+ @in_duty.commissioner_ids = in_duty_params[:commissioner_ids]
+ @in_duty.in_time = in_time
+ @in_duty.out_time = out_time
+
+ respond_to do |format|
+ if @in_duty.save
+ if in_duty_id.nil?
+ format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully created.' }
+ format.json { render :show, status: :created, location: @in_duty }
+ else
+ format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully updated.' }
+ format.json { render :show, status: :created, location: @in_duty }
+ end
+ else
+ format.html { render :new }
+ format.json { render json: @in_duty.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PATCH/PUT /in_duties/1
+ # PATCH/PUT /in_duties/1.json
+ def update
+ in_duty = in_duty_params
+ in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i
+ in_time = in_time.change(offset: '+06:30')
+ out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
+ out_time = out_time.change(offset: '+06:30')
+ @in_duty.commissioner_ids = in_duty_params[:commissioner_ids]
+ @in_duty.in_time = in_time
+ @in_duty.out_time = out_time
+ respond_to do |format|
+ if @in_duty.save
+ format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully updated.' }
+ format.json { render :show, status: :ok, location: @in_duty }
+ else
+ format.html { render :edit }
+ format.json { render json: @in_duty.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ def update_for_in_duty
+ in_duty = in_duty_params
+ in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i
+ in_time = in_time.change(offset: '+06:30')
+ out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
+ out_time = out_time.change(offset: '+06:30')
+ @in_duty.commissioner_ids = in_duty_params[:commissioner_ids]
+ @in_duty.in_time = in_time
+ @in_duty.out_time = out_time
+ respond_to do |format|
+ if @in_duty.save
+ format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully updated.' }
+ format.json { render :show, status: :ok, location: @in_duty }
+ else
+ format.html { render :edit }
+ format.json { render json: @in_duty.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /in_duties/1
+ # DELETE /in_duties/1.json
+ def destroy
+ @in_duty.destroy
+ respond_to do |format|
+ format.html { redirect_to origami_in_duties_path, notice: 'In duty was successfully removed.' }
+ format.json { head :no_content }
+ end
+ end
+
+ def destroy_in_duty
+ @table_id = params[:table_id]
+ @in_duty.destroy
+
+ respond_to do |format|
+ format.html { redirect_to origami_index_in_duty_path(@table_id), notice: 'In duty was successfully removed.' }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+
+ # Use callbacks to share common setup or constraints between actions.
+ def set_in_duty
+ @in_duty = InDuty.find(params[:id])
+ end
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+ def in_duty_params
+ params.require(:in_duty).permit(:id, :dinning_id, :commissioner_ids, :in_time, :out_time)
+ end
+end
diff --git a/app/controllers/origami/in_juties_controller.rb b/app/controllers/origami/in_juties_controller.rb
deleted file mode 100644
index ff76d3b1..00000000
--- a/app/controllers/origami/in_juties_controller.rb
+++ /dev/null
@@ -1,172 +0,0 @@
-class Origami::InJutiesController < BaseOrigamiController
- before_action :set_in_juty, only: %i[show edit update edit_in_juty update_for_in_juty destroy destroy_in_juty]
-
- # GET /in_juties
- # GET /in_juties.json
- def index
- @in_juties = InJuty.all
- end
-
- def index_in_juty
- @juty_in = InJuty.where('dinning_id=?', params[:table_id])
- @table = DiningFacility.find(params[:table_id])
- @in_juty = InJuty.new
- @juties_in = Kaminari.paginate_array(@juty_in).page(params[:page]).per(10)
- end
-
- # GET /in_juties/1
- # GET /in_juties/1.json
- def show
- end
-
- # GET /in_juties/new
- def new
- # this one use for new
- @in_juty = InJuty.new
- @table = DiningFacility.find(params[:table_id])
- @commissioner = @in_juty.commissioner
- render partial: 'form'
- end
-
- # GET /in_juties/1/edit
- def edit
- end
-
- def edit_in_juty
- @in_juty = InJuty.find(params[:id])
- @table = DiningFacility.find(params[:table_id])
- @commissioner = @in_juty.commissioner
-
- # render json: {in_juty: @in_juty, commissioner: @commissioner}
- render partial: 'form'
- end
-
- def assign_in_juty
- @in_juty = InJuty.new
- @table = DiningFacility.find(params[:table_id])
- end
-
- # POST /in_juties
- # POST /in_juties.json
- def create
- @in_juty = InJuty.new(in_juty_params)
-
- respond_to do |format|
- if @in_juty.save
- format.html { redirect_to origami_in_juties_path, notice: 'In juty was successfully created.' }
- format.json { render :show, status: :created, location: @in_juty }
- else
- format.html { render :new }
- format.json { render json: @in_juty.errors, status: :unprocessable_entity }
- end
- end
- end
-
- def create_for_in_juty
- # this one use for create and update
- in_juty = in_juty_params
- in_time = DateTime.new in_juty['in_time(1i)'].to_i, in_juty['in_time(2i)'].to_i, in_juty['in_time(3i)'].to_i, in_juty['in_time(4i)'].to_i, in_juty['in_time(5i)'].to_i
- in_time = in_time.change(offset: '+06:30')
- out_time = DateTime.new in_juty['out_time(1i)'].to_i, in_juty['out_time(2i)'].to_i, in_juty['out_time(3i)'].to_i, in_juty['out_time(4i)'].to_i, in_juty['out_time(5i)'].to_i
- out_time = out_time.change(offset: '+06:30')
- @in_juty = InJuty.new
- in_juty_id = in_juty[:id]
- unless in_juty_id.nil?
- @in_juty = InJuty.find(in_juty_id.to_i)
- end
-
- @in_juty.dinning_id = in_juty_params[:dinning_id]
- @in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
- @in_juty.in_time = in_time
- @in_juty.out_time = out_time
-
- respond_to do |format|
- if @in_juty.save
- if in_juty_id.nil?
- format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully created.' }
- format.json { render :show, status: :created, location: @in_juty }
- else
- format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully updated.' }
- format.json { render :show, status: :created, location: @in_juty }
- end
- else
- format.html { render :new }
- format.json { render json: @in_juty.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # PATCH/PUT /in_juties/1
- # PATCH/PUT /in_juties/1.json
- def update
- in_juty = in_juty_params
- in_time = DateTime.new in_juty['in_time(1i)'].to_i, in_juty['in_time(2i)'].to_i, in_juty['in_time(3i)'].to_i, in_juty['in_time(4i)'].to_i, in_juty['in_time(5i)'].to_i
- in_time = in_time.change(offset: '+06:30')
- out_time = DateTime.new in_juty['out_time(1i)'].to_i, in_juty['out_time(2i)'].to_i, in_juty['out_time(3i)'].to_i, in_juty['out_time(4i)'].to_i, in_juty['out_time(5i)'].to_i
- out_time = out_time.change(offset: '+06:30')
- @in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
- @in_juty.in_time = in_time
- @in_juty.out_time = out_time
- respond_to do |format|
- if @in_juty.save
- format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully updated.' }
- format.json { render :show, status: :ok, location: @in_juty }
- else
- format.html { render :edit }
- format.json { render json: @in_juty.errors, status: :unprocessable_entity }
- end
- end
- end
-
- def update_for_in_juty
- in_juty = in_juty_params
- in_time = DateTime.new in_juty['in_time(1i)'].to_i, in_juty['in_time(2i)'].to_i, in_juty['in_time(3i)'].to_i, in_juty['in_time(4i)'].to_i, in_juty['in_time(5i)'].to_i
- in_time = in_time.change(offset: '+06:30')
- out_time = DateTime.new in_juty['out_time(1i)'].to_i, in_juty['out_time(2i)'].to_i, in_juty['out_time(3i)'].to_i, in_juty['out_time(4i)'].to_i, in_juty['out_time(5i)'].to_i
- out_time = out_time.change(offset: '+06:30')
- @in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
- @in_juty.in_time = in_time
- @in_juty.out_time = out_time
- respond_to do |format|
- if @in_juty.save
- format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully updated.' }
- format.json { render :show, status: :ok, location: @in_juty }
- else
- format.html { render :edit }
- format.json { render json: @in_juty.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # DELETE /in_juties/1
- # DELETE /in_juties/1.json
- def destroy
- @in_juty.destroy
- respond_to do |format|
- format.html { redirect_to origami_in_juties_path, notice: 'In juty was successfully removed.' }
- format.json { head :no_content }
- end
- end
-
- def destroy_in_juty
- @table_id = params[:table_id]
- @in_juty.destroy
-
- respond_to do |format|
- format.html { redirect_to origami_index_in_juty_path(@table_id), notice: 'In juty was successfully removed.' }
- format.json { head :no_content }
- end
- end
-
- private
-
- # Use callbacks to share common setup or constraints between actions.
- def set_in_juty
- @in_juty = InJuty.find(params[:id])
- end
-
- # Never trust parameters from the scary internet, only allow the white list through.
- def in_juty_params
- params.require(:in_juty).permit(:id, :dinning_id, :commissioner_ids, :in_time, :out_time)
- end
-end
diff --git a/app/controllers/origami/jcb_controller.rb b/app/controllers/origami/jcb_controller.rb
index 5bed3470..a8b77861 100644
--- a/app/controllers/origami/jcb_controller.rb
+++ b/app/controllers/origami/jcb_controller.rb
@@ -17,6 +17,9 @@ class Origami::JcbController < BaseOrigamiController
end
@can_jcb = total - @jcbcount - others
+ @member_discount = MembershipSetting.find_by_discount(1)
+ @sub_total = sale_data.total_amount
+ @membership_id = sale_data.customer.membership_id
end
def create
diff --git a/app/controllers/origami/master_controller.rb b/app/controllers/origami/master_controller.rb
index 67107167..ba97cad9 100644
--- a/app/controllers/origami/master_controller.rb
+++ b/app/controllers/origami/master_controller.rb
@@ -16,6 +16,9 @@ class Origami::MasterController < BaseOrigamiController
end
end
@can_master = total - @mastercount - others
+ @member_discount = MembershipSetting.find_by_discount(1)
+ @sub_total = sale_data.total_amount
+ @membership_id = sale_data.customer.membership_id
end
def create
diff --git a/app/controllers/origami/mpu_controller.rb b/app/controllers/origami/mpu_controller.rb
index 3707d1f4..c9f707e3 100644
--- a/app/controllers/origami/mpu_controller.rb
+++ b/app/controllers/origami/mpu_controller.rb
@@ -5,9 +5,10 @@ class Origami::MpuController < BaseOrigamiController
# limit mpu_amount
sale_data = Sale.find_by_sale_id(@sale_id)
- total = sale_data.grand_total
+ total = sale_data.grand_total
@mpucount = 0
- others = 0
+ others = 0
+
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "mpu"
@mpucount = @mpucount + sale_payment.payment_amount
@@ -17,6 +18,9 @@ class Origami::MpuController < BaseOrigamiController
end
@can_mpu = total - @mpucount - others
+ @member_discount = MembershipSetting.find_by_discount(1)
+ @sub_total = sale_data.total_amount
+ @membership_id = sale_data.customer.membership_id
end
def create
diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb
index 109138a5..2a9fe5d9 100644
--- a/app/controllers/origami/payments_controller.rb
+++ b/app/controllers/origami/payments_controller.rb
@@ -75,6 +75,8 @@ class Origami::PaymentsController < BaseOrigamiController
def show
sale_id = params[:sale_id]
+
+ @member_discount = MembershipSetting.find_by_discount(1)
if Sale.exists?(sale_id)
@cash = 0.0
diff --git a/app/controllers/origami/product_commissions_controller.rb b/app/controllers/origami/product_commissions_controller.rb
index ada68f59..74dd8095 100644
--- a/app/controllers/origami/product_commissions_controller.rb
+++ b/app/controllers/origami/product_commissions_controller.rb
@@ -1,4 +1,4 @@
-class Origami::ProductCommissionsController < ApplicationController
+class Origami::ProductCommissionsController < BaseOrigamiController
before_action :set_product_commission, only: [:show, :edit, :update, :destroy]
# GET /product_commissions
diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb
index 900b0431..61c8b00f 100644
--- a/app/controllers/origami/sale_edit_controller.rb
+++ b/app/controllers/origami/sale_edit_controller.rb
@@ -1,5 +1,5 @@
class Origami::SaleEditController < BaseOrigamiController
- authorize_resource :class => false
+ authorize_resource class: false
# Index for sale item void OR edit
def edit
sale_id = params[:sale_id]
@@ -19,12 +19,13 @@ class Origami::SaleEditController < BaseOrigamiController
@newsaleitem.qty = saleitemObj.qty * -1
@newsaleitem.price = saleitemObj.price * -1
@newsaleitem.is_taxable = 1
- @newsaleitem.product_name = saleitemObj.product_name + " - void"
+ @newsaleitem.product_name = saleitemObj.product_name + ' - void'
@newsaleitem.save
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void
+ ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
end
def item_foc
@@ -44,6 +45,7 @@ class Origami::SaleEditController < BaseOrigamiController
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void
+ ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
end
# def item_edit
@@ -77,14 +79,19 @@ class Origami::SaleEditController < BaseOrigamiController
saleitemObj.unit_price = update_price
saleitemObj.taxable_price = update_qty.to_f * update_price.to_f
# saleitemObj.remark = 'edit'
- saleitemObj.product_name = saleitemObj.product_name + " - updated"
+
+ unless saleitemObj.product_name.include? 'updated'
+ saleitemObj.product_name = saleitemObj.product_name + ' - updated'
+ end
+
saleitemObj.save
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void
- end
+ ProductCommission.edit_product_commission(saleitemObj)
+ end
# make cancel void item
def item_void_cancel
@@ -102,6 +109,7 @@ class Origami::SaleEditController < BaseOrigamiController
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void
+ ProductCommission.remove_product_commission(saleitemObj)
end
# remove all void items
@@ -115,6 +123,7 @@ class Origami::SaleEditController < BaseOrigamiController
item.remark = nil
end
item.save
+ ProductCommission.remove_product_commission(item)
end
# re-calc tax
@@ -125,5 +134,8 @@ class Origami::SaleEditController < BaseOrigamiController
sale_id = params[:sale_id]
saleObj = Sale.find(sale_id)
saleObj.compute_without_void
+ saleObj.sale_items.each do |item|
+ ProductCommission.remove_product_commission(item)
+ end
end
end
diff --git a/app/controllers/origami/visa_controller.rb b/app/controllers/origami/visa_controller.rb
index 3cb8cabb..552d960b 100644
--- a/app/controllers/origami/visa_controller.rb
+++ b/app/controllers/origami/visa_controller.rb
@@ -16,6 +16,9 @@ class Origami::VisaController < BaseOrigamiController
end
end
@can_visa = total - @visacount - others
+ @member_discount = MembershipSetting.find_by_discount(1)
+ @sub_total = sale_data.total_amount
+ @membership_id = sale_data.customer.membership_id
end
def create
diff --git a/app/controllers/reports/stock_check_controller.rb b/app/controllers/reports/stock_check_controller.rb
new file mode 100644
index 00000000..c6799cb1
--- /dev/null
+++ b/app/controllers/reports/stock_check_controller.rb
@@ -0,0 +1,48 @@
+class Reports::StockCheckController < BaseReportController
+ # authorize_resource :class => false
+
+ def index
+ from_date = DateTime.now.beginning_of_day.utc.getlocal
+ to_date = DateTime.now.end_of_day.utc.getlocal
+ unless params[:daterange].blank?
+ from_date = Date.parse(params[:daterange].split(' - ')[0]).beginning_of_day.utc.getlocal
+ to_date = Date.parse(params[:daterange].split(' - ')[1]).end_of_day.utc.getlocal
+ @daterange = params[:daterange]
+ end
+ @item_code = params[:item_code]
+ @inventory_definitions = InventoryDefinition.active.all
+
+ @transaction = StockCheckItem.get_transaction(from_date, to_date, @item_code)
+ @from = from_date
+ @to = to_date
+
+ respond_to do |format|
+ format.html
+ format.xls
+ end
+ end
+
+ def show
+ from, to = get_date_range_from_params
+
+ @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
+
+ date_arr = Array.new
+ @sale_data.each do |sale|
+ local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
+ local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
+ opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
+ closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
+ shift_id = sale.id.nil? ? '-' : sale.id
+ str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
+ date_arr.push(str)
+ end
+
+ out = {:status => 'ok', :message => date_arr}
+
+ respond_to do |format|
+ format.json { render json: out }
+ end
+ end
+end
+
diff --git a/app/controllers/settings/menu_item_instances_controller.rb b/app/controllers/settings/menu_item_instances_controller.rb
index 6b5f8652..ac2acc7f 100644
--- a/app/controllers/settings/menu_item_instances_controller.rb
+++ b/app/controllers/settings/menu_item_instances_controller.rb
@@ -92,12 +92,14 @@ class Settings::MenuItemInstancesController < ApplicationController
category = MenuCategory.find(id)
# Bind for Item Sets
- if params[:menu_item_instance][:item_sets].count > 1
+ if params[:menu_item_instance][:item_sets].count > 0
params[:menu_item_instance][:item_sets].delete_at(0)
sets = ItemSet.find(params[:menu_item_instance][:item_sets])
- if sets.count > 0
+ if sets.count >= 0
+ # destroy all item sets for edit
+ @settings_menu_item_instances.item_sets.destroy
@settings_menu_item_instances.item_sets = sets
end
end
diff --git a/app/controllers/settings/promotions_controller.rb b/app/controllers/settings/promotions_controller.rb
index af8bedc1..8acc7764 100644
--- a/app/controllers/settings/promotions_controller.rb
+++ b/app/controllers/settings/promotions_controller.rb
@@ -69,6 +69,9 @@ class Settings::PromotionsController < ApplicationController
# DELETE /promotions/1
# DELETE /promotions/1.json
def destroy
+ @promotion.promotion_products.each do |pp|
+ pp.destroy
+ end
@promotion.destroy
respond_to do |format|
format.html { redirect_to settings_promotions_path, notice: 'Promotion was successfully destroyed.' }
@@ -87,6 +90,21 @@ class Settings::PromotionsController < ApplicationController
end
end
+ def find_parent_item
+ res = []
+ item = MenuItemInstance.find_by_item_instance_code(params[:item_instance_code])
+ if item.nil?
+ product = Product.where("item_code = ?",params[:item_instance_code]).pluck(:name,:item_code)
+ res.push(product.name)
+ res.push(product.item_code)
+ else
+ # menu_item = item.menu_item.pluck(:name,:item_code)
+ res.push(item.item_instance_name)
+ res.push(item.menu_item.item_code)
+ end
+ render json: res
+ end
+
private
# Use callbacks to share common setup or constraints between actions.
def set_promotion
diff --git a/app/controllers/settings/set_menu_items_controller.rb b/app/controllers/settings/set_menu_items_controller.rb
index a9e91a94..d37a59c9 100644
--- a/app/controllers/settings/set_menu_items_controller.rb
+++ b/app/controllers/settings/set_menu_items_controller.rb
@@ -75,12 +75,14 @@ class Settings::SetMenuItemsController < ApplicationController
params[:set_menu_item][:item_options].delete_at(0)
# Bind for Item Sets
- if params[:set_menu_item][:item_sets].count > 1
+ if params[:set_menu_item][:item_sets].count > 0
params[:set_menu_item][:item_sets].delete_at(0)
sets = ItemSet.find(params[:set_menu_item][:item_sets])
- if sets.count > 0
+ if sets.count >= 0
+ # destroy all item sets for edit
+ @settings_menu_item.item_sets.destroy
@settings_menu_item.item_sets = sets
end
end
diff --git a/app/controllers/settings/simple_menu_items_controller.rb b/app/controllers/settings/simple_menu_items_controller.rb
index e3010e30..319934ca 100644
--- a/app/controllers/settings/simple_menu_items_controller.rb
+++ b/app/controllers/settings/simple_menu_items_controller.rb
@@ -98,12 +98,14 @@ class Settings::SimpleMenuItemsController < ApplicationController
params[:simple_menu_item][:item_options].delete_at(0)
# Bind for Item Sets
- if params[:simple_menu_item][:item_sets].count > 1
+ if params[:simple_menu_item][:item_sets].count > 0
params[:simple_menu_item][:item_sets].delete_at(0)
sets = ItemSet.find(params[:simple_menu_item][:item_sets])
- if sets.count > 0
+ if sets.count >= 0
+ # destroy all item sets for edit
+ @settings_menu_item.item_sets.destroy
@settings_menu_item.item_sets = sets
end
end
diff --git a/app/helpers/origami/in_duties_helper.rb b/app/helpers/origami/in_duties_helper.rb
new file mode 100644
index 00000000..afd35e07
--- /dev/null
+++ b/app/helpers/origami/in_duties_helper.rb
@@ -0,0 +1,2 @@
+module Origami::InDutiesHelper
+end
diff --git a/app/helpers/origami/in_juties_helper.rb b/app/helpers/origami/in_juties_helper.rb
deleted file mode 100644
index 2792da8d..00000000
--- a/app/helpers/origami/in_juties_helper.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module Origami::InJutiesHelper
-end
diff --git a/app/jobs/bill_broadcast_job.rb b/app/jobs/bill_broadcast_job.rb
new file mode 100644
index 00000000..d6be4d0a
--- /dev/null
+++ b/app/jobs/bill_broadcast_job.rb
@@ -0,0 +1,7 @@
+class BillBroadcastJob < ApplicationJob
+ queue_as :default
+
+ def perform(table)
+ ActionCable.server.broadcast "bill_channel",table: table
+ end
+end
diff --git a/app/jobs/order_broadcast_job.rb b/app/jobs/order_broadcast_job.rb
index 28a152ce..55ba2f21 100644
--- a/app/jobs/order_broadcast_job.rb
+++ b/app/jobs/order_broadcast_job.rb
@@ -1,9 +1,7 @@
class OrderBroadcastJob < ApplicationJob
queue_as :default
- def perform(message)
- order = Order.find(message) # message come as order_id
- ApplicationCable.server.broadcast "order_queue_station_channel", order: order
-
+ def perform(table)
+ ActionCable.server.broadcast "order_channel",table: table
end
end
diff --git a/app/jobs/order_queue_processor_job.rb b/app/jobs/order_queue_processor_job.rb
index 5b3423dc..96b08220 100644
--- a/app/jobs/order_queue_processor_job.rb
+++ b/app/jobs/order_queue_processor_job.rb
@@ -4,14 +4,24 @@ class OrderQueueProcessorJob < ApplicationJob
def perform(order_id, table_id)
# Do something later
#Order ID
- order = Order.find(order_id)
- #Loop through the order stations and process the items
+ order = Order.find(order_id)
+ assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
+
#Execute orders and send to order stations
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id)
end
-
+ ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
+
+ # private
+
+ # def render_order(assign_order)
+ # ApplicationController.renderer.render(partial: 'oqs/oqs_test',
+ # locals: { order: assign_order})
+ # end
+# Read more at https://www.pluralsight.com/guides/ruby-ruby-on-rails/creating-a-chat-using-rails-action-cable#TehYiuqlHDOXaQQk.99
+
end
diff --git a/app/models/assigned_order_item.rb b/app/models/assigned_order_item.rb
index 3ac84077..34c97c6f 100644
--- a/app/models/assigned_order_item.rb
+++ b/app/models/assigned_order_item.rb
@@ -17,6 +17,29 @@ class AssignedOrderItem < ApplicationRecord
assigned_order_item.save
end
+ def self.assigned_order_item_by_job(order_id)
+ order_item = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id,
+ assigned_order_items.order_queue_station_id,
+ oqs.id as station_id, oqs.station_name,
+ oqs.is_active, oqpz.zone_id,
+ df.name as zone, df.type as table_type,
+ odt.order_id, odt.item_code, odt.item_name,
+ odt.price, odt.qty, odt.item_order_by, odt.options,
+ cus.name as customer_name, odt.created_at")
+ .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
+ left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
+ left join orders as od ON od.order_id = assigned_order_items.order_id
+ left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id
+ left join customers as cus ON cus.customer_id = od.customer_id
+ left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
+ left join bookings as bk on bk.booking_id = bo.booking_id
+ left join dining_facilities as df on df.id = bk.dining_facility_id")
+ .where("assigned_order_items.order_id = '#{order_id}' AND assigned_order_items.delivery_status = false AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' ")
+ .order("assigned_order_items.assigned_order_item_id desc")
+ .group("assigned_order_items.assigned_order_item_id")
+ return order_item
+ end
+
private
def generate_custom_id
self.assigned_order_item_id = SeedGenerator.generate_id(self.class.name, "AOI")
diff --git a/app/models/dining_charge.rb b/app/models/dining_charge.rb
index b7be007d..ae1b8f46 100644
--- a/app/models/dining_charge.rb
+++ b/app/models/dining_charge.rb
@@ -8,8 +8,8 @@ class DiningCharge < ApplicationRecord
price = 0
minutes = DiningCharge.time_diff(checkout, checkin)
free_time = DiningCharge.convert_to_minutes(dining_charges_obj.minimum_free_time.utc.localtime.strftime('%H:%M'))
- dining_minutes = minutes - free_time # stayminutes - free minutes
- if dining_minutes <= 0
+ dining_minutes = minutes #- free_time # stayminutes - free minutes
+ if dining_minutes <= free_time
price = 0
else
charge_type = dining_charges_obj.charge_type
diff --git a/app/models/in_juty.rb b/app/models/in_duty.rb
similarity index 78%
rename from app/models/in_juty.rb
rename to app/models/in_duty.rb
index 2f023ff0..485787c7 100644
--- a/app/models/in_juty.rb
+++ b/app/models/in_duty.rb
@@ -1,4 +1,4 @@
-class InJuty < ApplicationRecord
+class InDuty < ApplicationRecord
belongs_to :dining_facility, foreign_key: 'dinning_id'
belongs_to :commissioner, foreign_key: 'commissioner_ids'
end
diff --git a/app/models/menu_item_instance.rb b/app/models/menu_item_instance.rb
index de5be7b5..c8019063 100644
--- a/app/models/menu_item_instance.rb
+++ b/app/models/menu_item_instance.rb
@@ -6,14 +6,24 @@ class MenuItemInstance < ApplicationRecord
# before_create :generate_menu_item_instance_code
def self.findParentCategory(item)
- if item.menu_category_id
- return item.menu_category_id
+ if item.menu_category_id
+ item.menu_category_id
else
parentitem = MenuItem.find(item.menu_item_id)
findParentCategory(parentitem)
end
end
+ def self.get_item_name(item_code)
+ menu_item = MenuItemInstance.find_by_item_instance_code(item_code)
+ if menu_item.nil?
+ item_name = Product.find_by_item_code(item_code).name
+ else
+ item_name = menu_item.menu_item.name + ' - ' + menu_item.item_instance_name
+ end
+ item_name
+ end
+
# private
# def generate_menu_item_instance_code
diff --git a/app/models/order.rb b/app/models/order.rb
index 0551a1c9..1887585c 100644
--- a/app/models/order.rb
+++ b/app/models/order.rb
@@ -49,7 +49,7 @@ class Order < ApplicationRecord
process_order_queue
#send order to broadcast job
- #send_order_broadcast
+ send_order_broadcast(booking)
return true, booking
@@ -214,9 +214,10 @@ class Order < ApplicationRecord
#send order items and send to order queue
- def send_order_broadcast
+ def send_order_broadcast(booking)
+ table = DiningFacility.find(booking.dining_facility_id)
#Send to background job for processing
- OrderBroadcastJob.perform_later(self.id)
+ OrderBroadcastJob.perform_later(table)
end
#Origami: Cashier : to view order Table
diff --git a/app/models/product_commission.rb b/app/models/product_commission.rb
index 0e39f9f3..9b56e889 100644
--- a/app/models/product_commission.rb
+++ b/app/models/product_commission.rb
@@ -5,14 +5,67 @@ class ProductCommission < ApplicationRecord
belongs_to :sale_item, foreign_key: 'sale_item_id'
belongs_to :sale, foreign_key: 'sale_id'
+ def self.create_product_commission(newSaleItem, oldSaleItem)
+ old_product_commission = ProductCommission.find_by_sale_item_id(oldSaleItem.id)
+ return if old_product_commission.nil?
+ menu_item = MenuItem.find_by_item_code(newSaleItem.product_code)
+ return if menu_item.nil?
+ product_commission = ProductCommission.new
+ commission = Commission.where('product_code = ? AND is_active = ?', menu_item.id, true).take
+ product_commission.product_code = menu_item.id
+ product_commission.product_type = 'menu_item' # use for dummy data ToDo::need to change product type
+ unless commission.nil?
+ product_commission.commission_id = commission.id
+ if commission.commission_type == 'Percentage'
+ product_commission.price = newSaleItem.unit_price * (commission.amount / 100.0)
+ product_commission.amount = product_commission.price * newSaleItem.qty
+ elsif commission.commission_type == 'Net Amount'
+ product_commission.price = commission.amount
+ product_commission.amount = product_commission.price * newSaleItem.qty
+ end
+ end
+ unless old_product_commission.nil?
+ product_commission.commissioner_id = old_product_commission.commissioner_id
+ end
+ product_commission.qty = newSaleItem.qty
+ product_commission.sale_id = newSaleItem.sale_id
+ product_commission.sale_item_id = newSaleItem.sale_item_id
+ product_commission.save
+ end
+
+ def self.edit_product_commission(saleItemObj)
+ menu_item = MenuItem.find_by_item_code(saleItemObj.product_code)
+ commission = Commission.where('product_code = ? AND is_active = ?', menu_item.id, true).take
+ product_commission = ProductCommission.where('sale_item_id = ?', saleItemObj.id).take
+
+ return if commission.nil?
+ product_commission.qty = saleItemObj.qty
+ if commission.commission_type == 'Percentage'
+ product_commission.price = saleItemObj.unit_price * (commission.amount / 100.0)
+ product_commission.amount = product_commission.price * saleItemObj.qty
+ elsif commission.commission_type == 'Net Amount'
+ product_commission.price = commission.amount
+ product_commission.amount = product_commission.price * saleItemObj.qty
+ end
+ product_commission.save
+ puts 'Edit Product Commission Success'
+ end
+
+ def self.remove_product_commission(sale_item_id)
+ transaction = ProductCommission.find_by_sale_item_id(sale_item_id)
+ return if transaction.nil?
+ transaction.destroy
+ puts 'Remove Product Commission Success'
+ end
+
def self.get_transaction(from, to, commissioner)
- transaction = self.all
+ transaction = all
if !from.nil? && !to.nil?
transaction = transaction.where('updated_at between ? and ?', from, to)
end
if commissioner != 0
transaction = transaction.where(commissioner_id: commissioner)
end
- return transaction
+ transaction
end
end
diff --git a/app/models/promotion.rb b/app/models/promotion.rb
index dfab86e9..021fda65 100644
--- a/app/models/promotion.rb
+++ b/app/models/promotion.rb
@@ -1,5 +1,5 @@
class Promotion < ApplicationRecord
- validates_presence_of :promo_code,:promo_start_date,:promo_end_date,:promo_start_hour,:promo_end_hour,:promo_day,:promo_type,:original_product,:min_qty
+ validates_presence_of :promo_code,:promo_start_date,:promo_end_date,:promo_start_hour,:promo_end_hour,:promo_type,:original_product,:min_qty
has_many :promotion_products
@@ -23,13 +23,18 @@ class Promotion < ApplicationRecord
end
def self.is_between_promo_datetime(current_day,current_time) #database is not local time
- promoList = Promotion.where("(TO_CHAR(promo_start_date, 'YYYY-MM-DD') <=? AND TO_CHAR(promo_end_date, 'YYYY-MM-DD') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
+ promoList = Promotion.where("(Date_Format(promo_start_date, 'YYYY-MM-DD') <=? AND Date_Format(promo_end_date, 'YYYY-MM-DD') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
return promoList
end
def self.combine_item(saleObj)
- order_id = saleObj.sale_orders[0].order_id
- itemList = OrderItem.where("order_id = ?", order_id).group(:item_instance_code).sum(:qty)
+ # order_id = saleObj.sale_orders[0].order_id
+ # itemList = OrderItem.where("order_id = ?", order_id).group(:item_instance_code).sum(:qty)
+ itemList = []
+ saleObj.sale_orders.each do |so|
+ itemList << OrderItem.where("order_id = ?",so.order_id).group(:item_instance_code).sum(:qty)
+ end
+ return itemList
end
def self.is_promo_day(promoList, day, orderitemList, sale_id)
@@ -46,20 +51,29 @@ class Promotion < ApplicationRecord
def self.find_promo_item(promo, orderitem, sale_id)
# item_code = OrderItem.find_by_item_instance_code(orderitem[0]).item_code
- if promo.original_product.to_s == orderitem[0]
- if promo.min_qty.to_i > orderitem[1].to_i
- return false
- else
- check_promo_type(promo,orderitem, sale_id)
- end
- end
+ orderitem.each do |odr_item|
+ if promo.original_product.to_s == odr_item[0]
+ if promo.min_qty.to_i > odr_item[1].to_i
+ return false
+ else
+ check_promo_type(promo,odr_item, sale_id)
+ end
+ end
+ end
end
def self.check_promo_type(promo, orderitem, sale_id)
- same, promo_product = check_giveaway_product(promo, orderitem[0])
+ promo.promotion_products.each do |promo_product|
+ if promo_product.item_code == orderitem[0]
+ same = true
+ else
+ # return false, promo_product
+ same = false
+ end
+ # same, promo_product = check_giveaway_product(promo, orderitem[0])
if promo.promo_type == Promotion::PROMO_TYPE1
if same
- give_promotion_same_product(orderitem[1], promo.min_qty, promo_product.min_qty, orderitem, sale_id)
+ give_promotion_same_product(orderitem[1], promo.min_qty, promo_product.min_qty, orderitem, sale_id,promo_product.item_code)
else
give_promotion_second_product(orderitem[1], promo.min_qty, promo_product.item_code, orderitem, sale_id)
end
@@ -73,19 +87,23 @@ class Promotion < ApplicationRecord
elsif promo.promo_type == Promotion::PROMO_TYPE4
give_promotion_discount(same,promo_product,promo.min_qty, orderitem, sale_id)
end
+ end
end
def self.check_giveaway_product(promo, orderitem)
- promo.promotion_products.each do |promo_product|
- if promo_product.item_code == orderitem
- return true, promo_product
- else
- return false, promo_product
- end
- end
+ # promo_pp = []
+ # flag = false
+ # promo.promotion_products.each do |promo_product|
+ # if promo_product.item_code == orderitem
+ # # return true, promo_product
+ # promo_pp.push(promo_product)
+ # else
+ # # return false, promo_product
+ # end
+ # end
end
- def self.give_promotion_same_product(qty, promoqty, foc_min_qty, orderitem, sale_id)
+ def self.give_promotion_same_product(qty, promoqty, foc_min_qty, orderitem, sale_id,promo_product)
puts " Order qty: " + qty.to_s + " / promoqty: " + promoqty.to_s + " / giveaway: " + foc_min_qty.to_s
multiple = qty.to_i / promoqty.to_i # loop count
charge_qty = 0
@@ -113,7 +131,7 @@ class Promotion < ApplicationRecord
charge_qty += qty
end
item = OrderItem.find_by_item_instance_code(orderitem[0])
- if promo_product == OrderItem.find_by_item_instance_code(orderitem[0]).item_code
+ if promo_product == OrderItem.find_by_item_instance_code(orderitem[0]).item_instance_code
item = OrderItem.find_by_item_instance_code(orderitem[0])
else
item = OrderItem.find_by_item_code(promo_product)
@@ -126,7 +144,6 @@ class Promotion < ApplicationRecord
# AA - 10 # 3 # BB # orderList, #S34345
def self.give_promotion_second_product(orderitem_count, foc_min_qty, promo_product, orderitem, sale_id)
puts "..... orderitem_count: " + orderitem_count.to_s + " / foc_min_qty: " + foc_min_qty.to_s + " /promo_product: " + promo_product + " orderitem: " + orderitem.to_s
- byebug
promotion_qty = orderitem_count.to_i / foc_min_qty.to_i # get foc item qty
foc_qty = find_second_item_qty(sale_id, promo_product)
if (foc_qty < promotion_qty)
@@ -212,9 +229,11 @@ class Promotion < ApplicationRecord
saleObj = Sale.find_by_sale_id(sale_id)
itemList = combine_item(saleObj)
itemList.each do |item|
- if item[0] == promo_item
- return item[1]
- end
+ item.each do |i|
+ if i[0] == promo_item
+ return i[1]
+ end
+ end
end
return 0
end
diff --git a/app/models/sale.rb b/app/models/sale.rb
index 6eec518f..78596b42 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -158,6 +158,7 @@ class Sale < ApplicationRecord
#pull
sale_item.product_code = item.item_code
+ sale_item.item_instance_code = item.item_instance_code
sale_item.product_name = item.item_name
sale_item.product_alt_name = item.alt_name
sale_item.account_id = item.account_id
@@ -177,7 +178,7 @@ class Sale < ApplicationRecord
sale_item = SaleItem.new
sale_item.product_code = chargeObj.item_code
sale_item.product_name = dining_name.to_s + " ( " + dining_time.to_s + " )"
- # sale_item.account_id = item.account_id
+ sale_item.account_id = 0
sale_item.product_alt_name = "-"
sale_item.qty = 1
sale_item.unit_price = chargeObj.unit_price
@@ -186,7 +187,10 @@ class Sale < ApplicationRecord
sale_item.sale_id = self.id
sale_item.price = diningprice
sale_item.save
- self.compute
+
+ # Re-calc
+ sale = Sale.find(self.id)
+ self.compute_by_sale_items(self.id, sale.sale_items, self.total_discount)
end
def update_item (item)
@@ -223,7 +227,9 @@ class Sale < ApplicationRecord
subtotal_price = subtotal_price + item.price
total_taxable = total_taxable + (item.taxable_price * item.qty)
end
+
apply_tax (total_taxable)
+
self.total_amount = subtotal_price
self.total_discount = total_discount
self.grand_total = (self.total_amount - self.total_discount) + self.total_tax
@@ -291,6 +297,8 @@ class Sale < ApplicationRecord
# Tax Re-Calculte
def compute_tax(sale, total_taxable, total_discount = 0)
+ shop = Shop.first();
+
#if tax is not apply create new record
SaleTax.where("sale_id='#{sale.sale_id}'").find_each do |existing_tax|
#delete existing and create new
@@ -321,7 +329,9 @@ class Sale < ApplicationRecord
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end
#new taxable amount is standard rule for step by step
- # total_taxable = total_taxable + sale_tax.tax_payable_amount
+ if shop.calc_tax_order
+ total_taxable = total_taxable + sale_tax.tax_payable_amount
+ end
sale_tax.inclusive = tax.inclusive
sale_tax.save
@@ -334,6 +344,8 @@ class Sale < ApplicationRecord
# Tax Calculate
def apply_tax(total_taxable)
+ shop = Shop.first();
+
#if tax is not apply create new record
SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax|
#delete existing and create new
@@ -345,7 +357,7 @@ class Sale < ApplicationRecord
tax_profiles = TaxProfile.all.order("order_by asc")
customer = Customer.find(self.customer_id)
- puts customer
+
#Create new tax records
tax_profiles.each do |tax|
customer.tax_profiles.each do |cus_tax|
@@ -367,7 +379,9 @@ class Sale < ApplicationRecord
end
#new taxable amount is standard rule for step by step
- # total_taxable = total_taxable + sale_tax.tax_payable_amount
+ if shop.calc_tax_order
+ total_taxable = total_taxable + sale_tax.tax_payable_amount
+ end
sale_tax.inclusive = tax.inclusive
sale_tax.save
diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb
index b8ae456d..c4aae1fa 100644
--- a/app/models/sale_item.rb
+++ b/app/models/sale_item.rb
@@ -107,7 +107,17 @@ class SaleItem < ApplicationRecord
return price,type
end
+ # Check for Card Payment
+ def self.get_sale_payments_by_card(sale_payments)
+ # Check for Card Payment
+ sale_payments.each do |sp|
+ if sp.payment_method == "jcb" || sp.payment_method == "mpu" || sp.payment_method == "visa" || sp.payment_method == "master"
+ return true;
+ end
+ end
+
+ end
# def self.get_overall_discount(sale_id)
# price = 0.0
# item=SaleItem.where("product_code=?", sale_id)
diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb
index 4719e546..5f97bcfc 100644
--- a/app/models/sale_payment.rb
+++ b/app/models/sale_payment.rb
@@ -263,6 +263,8 @@ class SalePayment < ApplicationRecord
end
def sale_update_payment_status(paid_amount)
+ puts paid_amount
+ puts "parid Masssssssssssssssssssssssssssssssssssssssss"
#update amount_outstanding
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
self.sale.save!
diff --git a/app/models/stock_check.rb b/app/models/stock_check.rb
index 7a8f8d65..c2499c29 100644
--- a/app/models/stock_check.rb
+++ b/app/models/stock_check.rb
@@ -1,17 +1,16 @@
class StockCheck < ApplicationRecord
-
has_many :stock_check_items
- def create(user, eason, item_list)
+ def create(user, reason, item_list)
self.reason = reason
self.check_by = user.id
self.check_start = Time.now
self.check_end = Time.now
- self.save
+ save
item_list.each do |item|
stockItem = StockCheckItem.new
- stockItem.create(self.id,item)
+ stockItem.create(id, item)
end
- return self
+ self
end
end
diff --git a/app/models/stock_check_item.rb b/app/models/stock_check_item.rb
index e02972a6..8653837c 100644
--- a/app/models/stock_check_item.rb
+++ b/app/models/stock_check_item.rb
@@ -1,5 +1,4 @@
class StockCheckItem < ApplicationRecord
-
belongs_to :stock_check
def create(stock_id, item)
@@ -33,4 +32,15 @@ class StockCheckItem < ApplicationRecord
return 'missing stock', stock_check_qty.to_i - journal_balance.to_i
end
end
+
+ def self.get_transaction(from, to, item_code)
+ transaction = all
+ if !from.nil? && !to.nil?
+ transaction = transaction.where('created_at between ? and ?', from, to)
+ end
+ if item_code.present?
+ transaction = transaction.where(item_code: item_code)
+ end
+ transaction
+ end
end
diff --git a/app/pdf/stock_result_pdf.rb b/app/pdf/stock_result_pdf.rb
index 489fb0ae..ef615a9c 100644
--- a/app/pdf/stock_result_pdf.rb
+++ b/app/pdf/stock_result_pdf.rb
@@ -1,8 +1,8 @@
class StockResultPdf < Prawn::Document
- attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
+ attr_accessor :label_width, :price_column_width, :page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size, :item_height, :qty_width, :total_width, :item_description_width, :text_width
- def initialize(printer_settings,stockcheck, stockcheck_items,checker_name, shop_details)
- self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
+ def initialize(printer_settings, stockcheck, stockcheck_items, checker_name, shop_details)
+ self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height
self.margin = 5
self.price_width = 40
@@ -27,66 +27,68 @@ class StockResultPdf < Prawn::Document
self.header_font_size = 10
self.item_font_size = 8
- header( shop_details)
+ header(shop_details)
stroke_horizontal_rule
- detail(stockcheck,stockcheck_items, checker_name)
+ detail(stockcheck, stockcheck_items, checker_name)
end
def header (shop_details)
move_down 7
- text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
+ text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size, :align => :center
move_down 5
- text "#{shop_details.address}", :size => self.item_font_size,:align => :center
+ text "#{shop_details.address}", :size => self.item_font_size, :align => :center
# move_down self.item_height
move_down 5
- text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
+ text "#{shop_details.phone_no}", :size => self.item_font_size, :align => :center
move_down 5
stroke_horizontal_rule
end
def detail(stockcheck, stockcheck_items, checker_name)
- move_down 7
- y_position = cursor
- bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
- text "Checker : ", :size => self.item_font_size,:align => :left
- end
- bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
- text "#{checker_name}" , :size => self.item_font_size,:align => :left
- end
+ move_down 7
+ y_position = cursor
+ bounding_box([0, y_position], :width => self.label_width, :height => self.item_height) do
+ text "Checker : ", :size => self.item_font_size, :align => :left
+ end
+ bounding_box([self.label_width, y_position], :width => self.label_width, :height => self.item_height) do
+ text "#{checker_name}", :size => self.item_font_size, :align => :left
+ end
- y_position = cursor
- bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
- text "Check Start Time : ", :size => self.item_font_size,:align => :left
- end
- bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
- text "#{ stockcheck.check_start.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
- end
+ y_position = cursor
+ bounding_box([0, y_position], :width => self.label_width, :height => self.item_height) do
+ text "Check Start Time : ", :size => self.item_font_size, :align => :left
+ end
+ bounding_box([self.label_width, y_position], :width => self.label_width, :height => self.item_height) do
+ text "#{ stockcheck.check_start.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }", :size => self.item_font_size, :align => :left
+ end
- y_position = cursor
- bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
- text "Check End Time ", :size => self.item_font_size,:align => :left
- end
- bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
- text "#{ stockcheck.check_start.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
- end
+ y_position = cursor
+ bounding_box([0, y_position], :width => self.label_width, :height => self.item_height) do
+ text "Check End Time ", :size => self.item_font_size, :align => :left
+ end
+ bounding_box([self.label_width, y_position], :width => self.label_width, :height => self.item_height) do
+ text "#{ stockcheck.check_start.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }", :size => self.item_font_size, :align => :left
+ end
- if stockcheck_items.length > 0
- stockcheck_items.each do |st|
- move_down 5
- y_position = cursor
-
- bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
- text "#{ st.item_code }", :size => self.item_font_size,:align => :left
- end
- bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
- text "#{st.stock_count.to_i}" , :size => self.item_font_size,:align => :right
- end
- end
- end
+ if stockcheck_items.length > 0
+ stockcheck_items.each do |st|
move_down 5
- stroke_horizontal_rule
+ y_position = cursor
+
+ item_name = MenuItemInstance.get_item_name(st.item_code)
+
+ bounding_box([0, y_position], :width => self.item_description_width, :height => self.item_height) do
+ text item_name.to_s, :size => self.item_font_size, :align => :left
+ end
+ bounding_box([self.item_description_width, y_position], :width => self.label_width) do
+ text "#{st.stock_count.to_i}", :size => self.item_font_size, :align => :right
+ end
+ end
+ end
+ move_down 5
+ stroke_horizontal_rule
end
end
diff --git a/app/views/api/restaurant/menu/_menu_item.json.jbuilder b/app/views/api/restaurant/menu/_menu_item.json.jbuilder
index 66cebece..94b29837 100644
--- a/app/views/api/restaurant/menu/_menu_item.json.jbuilder
+++ b/app/views/api/restaurant/menu/_menu_item.json.jbuilder
@@ -92,9 +92,9 @@ json.options opt_format
json.instances item.menu_item_instances do |is|
# Convert id to name for attributes
instance_attr = []
- is.item_attributes do |ia|
- mItemAttr = MenuItemAttribute.find(is)
- instance_attr.push(ia.name)
+ is.item_attributes.each do |ia|
+ # mItemAttr = MenuItemAttribute.find(is)
+ instance_attr.push(ia)
end
json.id is.id
diff --git a/app/views/api/restaurant/menu_item_attributes/show.json.jbuilder b/app/views/api/restaurant/menu_item_attributes/show.json.jbuilder
new file mode 100644
index 00000000..e158f807
--- /dev/null
+++ b/app/views/api/restaurant/menu_item_attributes/show.json.jbuilder
@@ -0,0 +1,8 @@
+if(@attribute)
+ json.id @attribute.id
+ json.type @attribute.attribute_type
+ json.name @attribute.name
+ json.value @attribute.value
+else
+ json.success false
+end
\ No newline at end of file
diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb
index fa61114f..0883cc92 100644
--- a/app/views/home/dashboard.html.erb
+++ b/app/views/home/dashboard.html.erb
@@ -1,20 +1,3 @@
-
-
-
- <% if current_login_employee.role = "admin" %>
-
- <% elsif current_login_employee.role = "cashier" %>
- <%= link_to "Cashier Station", origami_path %>
- <% elsif current_login_employee = "account" %>
- <%= link_to "Cashier Station", oishi_path %>
- <% else %>
- <%= link_to "Cashier Station", oishi_path %>
- <% end %>
- <% shop = Shop.first %>
-
-
-
-
Role Features
@@ -205,14 +188,14 @@
- <%= shop.address %>
+ <%= @shop.address %>
- <%= shop.phone_no %>
+ <%= @shop.phone_no %>
diff --git a/app/views/inventory/inventory/_inventory_list.html.erb b/app/views/inventory/inventory/_inventory_list.html.erb
index 115c80c5..7869bc10 100644
--- a/app/views/inventory/inventory/_inventory_list.html.erb
+++ b/app/views/inventory/inventory/_inventory_list.html.erb
@@ -22,11 +22,19 @@
%>
<%= count %>
- <%= item.item_code rescue ""%>
+
+ <% menu_item = MenuItemInstance.find_by_item_instance_code(item.item_code)%>
+ <% if menu_item.nil? %>
+ <%= Product.find_by_item_code(item.item_code).name rescue "-" %>
+ <% else %>
+ <%= menu_item.menu_item.name rescue "-" %>
+ - <%= menu_item.item_instance_name rescue "-" %>
+ <% end %>
+
<%= item.min_order_level %>
<%= item.max_stock_level %>
- <%= item.created_by%>
- <%= item.created_at%>
+ <%= Employee.find(item.created_by).name rescue '-' %>
+ <%= item.created_at.utc.getlocal.strftime("%e %b %Y %I:%M %p") rescue '-' %>
<% end %>
diff --git a/app/views/inventory/inventory/index.html.erb b/app/views/inventory/inventory/index.html.erb
index 7aeb4464..07d6f253 100644
--- a/app/views/inventory/inventory/index.html.erb
+++ b/app/views/inventory/inventory/index.html.erb
@@ -1,22 +1,27 @@
-
-
+
- <%= render 'inventory_list' %>
+ <%= render 'inventory_list' %>
- <%if current_login_employee.role == "administrator" || current_login_employee.role == "manager" %>
- Back
- <%end%>
- New Stock Taking
+ <% if current_login_employee.role == "administrator" || current_login_employee.role == 'manager' %>
+ Back
+ <% end %>
+ New Stock Taking
Stock Check Report
diff --git a/app/views/inventory/inventory_definitions/_form.html.erb b/app/views/inventory/inventory_definitions/_form.html.erb
index 36b80822..31a1a9a2 100644
--- a/app/views/inventory/inventory_definitions/_form.html.erb
+++ b/app/views/inventory/inventory_definitions/_form.html.erb
@@ -1,15 +1,84 @@
+<%= simple_form_for([:inventory, @inventory_definition]) do |f| %>
+ <%= f.error_notification %>
-<%= simple_form_for([:inventory,@inventory_definition]) do |f| %>
- <%= f.error_notification %>
+
+
+
+ <%= link_to 'Back', inventory_path, class: 'btn btn-success' %>
+ <%= f.button :submit, class: 'btn btn-primary' %>
+
<% end %>
+
+
\ No newline at end of file
diff --git a/app/views/inventory/inventory_definitions/edit.html.erb b/app/views/inventory/inventory_definitions/edit.html.erb
index 80ce29e1..b6d6a7bb 100644
--- a/app/views/inventory/inventory_definitions/edit.html.erb
+++ b/app/views/inventory/inventory_definitions/edit.html.erb
@@ -1,6 +1,10 @@
-
Editing Inventory Definition
-
-<%= render 'form', inventory_definition: @inventory_definition %>
-
-<%= link_to 'Show', @inventory_definition %> |
-<%= link_to 'Back', inventory_definitions_path %>
+
+
+ <%= render 'form', inventory: @inventory_definition %>
+
diff --git a/app/views/inventory/stock_checks/index.html.erb b/app/views/inventory/stock_checks/index.html.erb
index 812d4409..69af59a4 100644
--- a/app/views/inventory/stock_checks/index.html.erb
+++ b/app/views/inventory/stock_checks/index.html.erb
@@ -7,17 +7,29 @@
- Product
+ Item
-
+
+ Select Product
+ <% @inventory_definitions.each do |id| %>
+
+ <% menu_item = MenuItemInstance.find_by_item_instance_code(id.item_code) %>
+ <% if menu_item.nil? %>
+ <%= Product.find_by_item_code(id.item_code).name rescue "-" %>
+ <% else %>
+ <%= menu_item.menu_item.name rescue '-' %> - <%= menu_item.item_instance_name rescue '-' %>
+ <% end %>
+
+ <% end %>
+
@@ -27,14 +39,14 @@
Qty