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

View File

@@ -0,0 +1 @@
json.status true

View File

@@ -2,6 +2,7 @@ if @customer.present?
json.status true
else
json.status false
json.message @message
end
json.data @customer

View File

@@ -0,0 +1 @@
json.status true

View File

@@ -1,6 +1,7 @@
if @status == true
#show invoice number and stuff
json.status @status
json.booking_id @booking.booking_id
json.sale_id @sale_data.sale_id
sale = Sale.find(@sale_data.sale_id)

View File

@@ -1,8 +1,14 @@
if sale_item
json.sale_item_id sale_item.sale_item_id
json.product_name sale_item.product_name
json.product_alt_name sale_item.product_alt_name
json.qty sale_item.qty
json.unit_price sale_item.unit_price
json.price sale_item.price
json.taxable_price sale_item.taxable_price
json.status sale_item.status
if discount_item = sale_item.discount_item
json.discount discount_item.discount
json.discount_type discount_item.discount_type
end
end

View File

@@ -26,7 +26,7 @@ if sale
json.shift_sale_id sale.shift_sale_id
json.sale_items sale.sale_items, partial: "api/sale_items/sale_item", as: :sale_item
json.sale_items sale.sale_items.includes(:discount_item).where(status: nil), partial: "api/sale_items/sale_item", as: :sale_item
json.sale_taxes sale.sale_taxes, partial: "api/sale_taxes/sale_tax", as: :sale_tax
end

View File

@@ -1,4 +1,2 @@
json.status true
json.data do
json.tax_profiles @tax_profiles, :name, :group_type, :rate, :inclusive, :order_by
end
json.data @tax_profiles, :name, :group_type, :rate, :inclusive, :order_by

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>