api discount and change tax

This commit is contained in:
Thein Lin Kyaw
2023-10-17 16:52:12 +06:30
parent 81eb30c03a
commit 3441811bb0
27 changed files with 1225 additions and 1067 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -398,28 +398,34 @@
<i class="material-icons">reply</i>
<%= t("views.btn.back") %>
</button>
<button type="button" class="btn btn-block btn-default waves-effect" id='refresh'>Refresh</button>
<% if @booking && @booking.booking_status == 'assign' %>
<button type="button" class="btn btn-primary btn-block waves-effect create" id="done_order">
DONE
</button>
<% end %>
<% if @booking && @booking.booking_status != 'void' %>
<hr>
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void </a>
<% end %>
<!-- pending order button list -->
<% if @pending && params[:active].nil? %>
<% if current_user.role != "waiter" || @status != "sale"%>
<% if current_user.role != "waiter" && @status == "order"%>
<hr>
<button type="button" id="addorder" class="btn bg-blue btn-block">Update Order</button>
<%end%>
<% if current_user.role != "waiter" && @status != "order"%>
<button type="button" id="pay" class="btn bg-blue btn-block" data-toggle="modal" data-target="#read_modal">Pay</button>
<% if current_user.role != "waiter" && @status == "sale"%>
<hr>
<button type="button" id="void" class="btn btn-block bg-red waves-effect" >VOID</button>
<button type="button" id="pay" class="btn bg-blue btn-block" data-toggle="modal" data-target="#read_modal">Pay</button>
<%end%>
<% if @status != "sale"%>
<hr>
<!-- <button type="button" id="request_bills" class="btn btn-block bg-blue waves-effect">Req.Bill</button> -->
<% order_id = @pending.try(:orders).try(:first).try(:order_id) if @status == 'order' %>
<button type="button" class="btn btn-block bg-blue waves-effect req_bill" data-toggle="modal" data-target="#read_modal" >Req.Bill</button>
@@ -430,6 +436,7 @@
<% elsif @pending && params[:active] == 'completed' %>
<% if current_user.role != "waiter" %>
<% if @pending.sale_status != 'void' && @pending.sale_status != 'waste' && @pending.sale_status != 'spoile' %>
<hr>
<% if current_user.role == "cashier" %>
<% if @pending.payment_status != 'foc' %>
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a>
@@ -439,7 +446,7 @@
<% if @pending.payment_status != 'foc' %>
<button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" readonly= "<%= (can? :overall_void, :void)? 'true': 'false' %>" > Void </button>
<% end %>
<button type="button" id="reprint" class="btn bg-blue btn-block">Re.Print</button>
<button type="button" id="reprint" class="btn bg-blue btn-block">Re.Print</button>
<% end %>
<% end %>
<% end %>

View File

@@ -198,11 +198,13 @@
<!-- Action Panel -->
<div>
<%if !@table.nil?%>
<button type="button" class="btn bg-default btn-block" onclick="window.location.href = '/foodcourt/<%=@table.type.downcase%>/<%=@table.id%>'"><i class="material-icons">reply</i> Back </button>
<button type="button" class="btn btn-block btn-default waves-effect" onclick="window.location.href='/foodcourt/<%=@table.type.downcase%>/<%=@table.id%>'" id="back"><i class="material-icons">reply</i> Back</button>
<%else%>
<button type="button" class="btn bg-default btn-block" onclick="window.location.href = '/foodcourt/sale/<%=@sale_data.sale_id%>/<%=@cashier_type%>/payment'"><i class="material-icons">reply</i> Back </button>
<button type="button" class="btn btn-block btn-default waves-effect" onclick="window.location.href='/foodcourt/sale/<%=@sale_data.sale_id%>/<%=@cashier_type%>/payment'" id="back"><i class="material-icons">reply</i> Back</button>
<%end%>
<button id="charge_other" class="btn bg-primary btn-block action-btn">Enter</button>
<button type="button" class="btn btn-block btn-default waves-effect" id='refresh'>Refresh</button>
<hr>
<button id="charge_other" class="btn bg-primary btn-block action-btn">Enter</button>
</div>
</div>
</div>

View File

@@ -210,17 +210,12 @@
Refresh
</button>
<% if @sale_payment.nil? %>
<% if current_login_employee.role == "cashier" %>
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a>
<% else %>
<button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button>
<%end %>
<% end %>
<% if @sale_payment.nil? %>
<hr>
<% if current_login_employee.role == "cashier" %>
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a>
<a class="btn btn-block bg-blue waves-effect access_modal" data-toggle="modal" data-type="edit">Edit</a>
<% else %>
<button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
<% end %>
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
@@ -460,14 +455,7 @@ $(document).ready(function(){
});
$("#refresh").on('click', function(){
window.location.reload();
})
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){
}
else {
if(localStorage.getItem("cash") != null && localStorage.getItem("cash") != 'null'){
$('#cash').text(localStorage.getItem("cash"));
}
update_balance();

View File

@@ -40,71 +40,64 @@
</tr>
</thead>
<tbody>
<%
count = 0
sub_total = 0
@saleobj.sale_items.each do |sale_item|
count += 1
sub_total = sub_total + sale_item.price
%>
<% sub_total = BigDecimal("0.0") %>
<% count = 0 %>
<% @saleobj.sale_items.each do |sale_item| %>
<% sub_total = sub_total + sale_item.price %>
<input type="hidden" id="sale_id" value="<%= @saleobj.sale_id %>">
<%
# Can't check for discount
unless sale_item.price == 0
%>
<tr>
<td class="p-1" width="2%"><%= count %></td>
<td class="p-2" width="20%">
<%= sale_item.product_name %>
</td>
<% if sale_item.status != 'void' && sale_item.status != 'edit' && sale_item.status != 'foc' %>
<td class="p-1" width="5%">
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control " onkeyup="checkQuantity(this.value,'<%= sale_item.id %>');" onkeypress="return isNumberKey(event);" />
<span id="<%= sale_item.id %>_qtyErr" style="color:red;"></span>
</td>
<td class="p-1" width="10%">
<input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" onkeypress="return isNumberKey(event);"/>
<span id="<%= sale_item.id %>_priceErr" style="color:red;"></span>
</td>
<!-- <td class='' width="17%">
<input id="<%= sale_item.id %>_price" data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control"/>
</td> -->
<td class="p-1" width="25%">
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-blue waves-effect update'>Update</button>
<button data-id="<%= sale_item.id %>" data-type="void" class='editModal btn btn-lg bg-danger waves-effect' data-toggle="modal" data-target="#editModal">Void</button>
<% if sale_item.price > 0 %>
<% count += 1 %>
<tr class="item-row">
<td class="p-1" width="2%"><%= count %></td>
<td class="p-2" width="20%">
<% if sale_item.foc_item %>
<span><%= sale_item.foc_item.product_name %></span>
<% elsif sale_item.void_item %>
<span><%= sale_item.void_item.product_name %></span>
<% else %>
<span><%= sale_item.product_name %></span>
<% end %>
<% if sale_item.discount_item %>
<% if sale_item.discount_item.nett? %>
<div id="item-discount" class="text-secondary">With a <strong><%= number_format(sale_item.discount_item.discount) %></strong> discount</div>
<% elsif sale_item.discount_item.percentage? %>
<div id="item-discount" class="text-secondary">With a <strong><%= number_format(sale_item.discount_item.discount, precision: 0) %>%</strong> discount</div>
<% end %>
<% end %>
</td>
<% if sale_item.status != 'void' && sale_item.status != 'edit' && sale_item.status != 'foc' %>
<td class="p-1" width="5%">
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control " onkeyup="checkQuantity(this.value,'<%= sale_item.id %>');" onkeypress="return isNumberKey(event);" />
<span id="<%= sale_item.id %>_qtyErr" style="color:red;"></span>
</td>
<td class="p-1" width="10%">
<input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" onkeypress="return isNumberKey(event);"/>
<span id="<%= sale_item.id %>_priceErr" style="color:red;"></span>
</td>
<td class="p-1" width="25%">
<button data-id="<%= sale_item.id %>" class='btn btn-lg btn-primary waves-effect update'>Update</button>
<button data-id="<%= sale_item.id %>" data-type="void" class='editModal btn btn-lg btn-danger waves-effect' data-toggle="modal" data-target="#editModal">Void</button>
<button data-id="<%= sale_item.id %>" data-type="foc" class='editModal btn btn-lg bg-danger waves-effect' data-toggle="modal" data-target="#editModal">FOC</button>
</td>
<% elsif sale_item.qty.to_i < 0 || sale_item.status == 'edit' %>
<td class="p-1" width="5%">
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
</td>
<td class='' width="10%">
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" disabled/>
</td>
<!-- <td class='' width="17%">
<input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/>
</td> -->
<td class="p-1" width="25%">
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-danger waves-effect cancel'>Cancel
Void/Update
</button>
</td>
<% else %>
<td class="p-1" width="5%">
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
</td>
<td class="p-1" width="10%">
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/>
</td>
<td></td>
<% end %>
</tr>
<%
end
end
%>
<button data-id="<%= sale_item.id %>" data-type="foc" class='editModal btn btn-lg btn-danger waves-effect' data-toggle="modal" data-target="#editModal">FOC</button>
</td>
<% elsif sale_item.status == 'foc' || sale_item.status == 'void' %>
<td class="p-1" width="5%">
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
</td>
<td class='' width="10%">
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" disabled/>
</td>
<td class="p-1" width="25%">
<button data-id="<%= sale_item.id %>" class='btn btn-lg btn-danger waves-effect cancel'>Cancel
<%= sale_item.status %>
</button>
</td>
<% end %>
</tr>
<%
end
end
%>
</tbody>
</table>
</div>
@@ -121,7 +114,7 @@
</div>
</div>
<div class="col-md-4 col-lg-4 col-sm-4">
<div class="p-l-20">
<div class="row bottom">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 m-l--5">
@@ -208,10 +201,11 @@
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- Waiter Buttons -->
<button type="button" class="btn btn-block btn-lg bg-default waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
<button type="button" id="add_order" class="btn btn-block bg-blue waves-effect"><%= t("views.btn.add") %> <%= t("views.right_panel.detail.order") %></button>
<button type="button" class="btn btn-danger btn- action-btn" id='cancel_all_void'>Cancel All Void</button>
<button type="button" class="btn btn-block btn-lg bg-blue waves-effect" id='apply'>Apply</button>
<button type="button" class="btn btn-block bg-default waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
<button type="button" class="btn btn-block btn-default waves-effect" id='refresh'>Refresh</button>
<hr>
<button type="button" class="btn btn-block btn-danger waves-effect" id='cancel_all_void'>Cancel All</button>
<button type="button" class="btn btn-block btn-primary waves-effect" id='apply'>Apply</button>
</div>
</div>
</div>
@@ -475,8 +469,4 @@ var access_code = localStorage.getItem("access_code");
$("#"+sale_item_id+"_qty").val('1');
}
}
$('#add_order').on('click', function () {
window.location.href = '/foodcourt/food_court?sale_id=<%=@saleobj.sale_id %>';
});
</script>