update rounding adj
This commit is contained in:
@@ -54,6 +54,15 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
shop_details = Shop.find(1)
|
||||
|
||||
if shop_details.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
|
||||
rounding_adj = new_total-saleObj.grand_total
|
||||
saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
|
||||
#end rounding adjment
|
||||
end
|
||||
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_payment(saleObj, @user, cash, "cash")
|
||||
|
||||
@@ -75,9 +84,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# For Print
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
#shop detail
|
||||
shop_details = Shop.find(1)
|
||||
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
@@ -114,6 +121,14 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@accountable_type = ''
|
||||
@table_no = ''
|
||||
|
||||
@shop = Shop.find_by_id(1)
|
||||
if @shop.is_rounding_adj
|
||||
new_total = Sale.get_rounding_adjustment(@sale_data.grand_total)
|
||||
else
|
||||
new_total = @sale_data.grand_total
|
||||
end
|
||||
@rounding_adj = new_total-@sale_data.grand_total
|
||||
|
||||
#get customer amount
|
||||
@customer = Customer.find(@sale_data.customer_id)
|
||||
accounts = @customer.tax_profiles
|
||||
@@ -127,7 +142,6 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# get member information
|
||||
if @customer.membership_id != nil && rebate
|
||||
response = Customer.get_member_account(@customer)
|
||||
puts response.to_json
|
||||
if response["status"]==true
|
||||
response["account_data"].each do |res|
|
||||
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
|
||||
|
||||
@@ -524,19 +524,20 @@
|
||||
});
|
||||
});
|
||||
|
||||
// $('#pay').on('click', function () {
|
||||
// var sale_id = $('#sale_id').val();
|
||||
// var url = '/origami/sale/' + sale_id + "/rounding_adj";
|
||||
// $.ajax({
|
||||
// type: "POST",
|
||||
// url: '/origami/sale/' + sale_id + "/rounding_adj",
|
||||
// success: function (result) {
|
||||
// window.location.href = '/origami/sale/' + sale_id + "/payment";
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
$('#pay').on('click', function () {
|
||||
var sale_id = $('#sale_id').val();
|
||||
|
||||
var url = '/origami/sale/' + sale_id + "/rounding_adj";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: '/origami/sale/' + sale_id + "/rounding_adj",
|
||||
success: function (result) {
|
||||
window.location.href = '/origami/sale/' + sale_id + "/payment";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
window.location.href = '/origami/sale/' + sale_id + "/payment";
|
||||
});
|
||||
|
||||
// Bill Request
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Rounding Adj:</strong></td>
|
||||
<td class="item-attr"><strong><span><%=@sale_data.rounding_adjustment rescue 0%></span></strong></td>
|
||||
<td class="item-attr"><strong><span id="rounding_adj"><%=@rounding_adj rescue 0%></span></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total</strong></td>
|
||||
@@ -109,7 +109,7 @@
|
||||
</tfooter>
|
||||
</table>
|
||||
</div>
|
||||
<!-- <div> -->
|
||||
<!-- <div> -->
|
||||
<!-- <INPUT TYPE="Button" class='btn btn-primary' VALUE="Reprint" onClick="" style='width:120px'/>
|
||||
<INPUT TYPE="Submit" class='btn btn-primary' VALUE="CANCEL" action="origami/index" style='width:120px'/> -->
|
||||
<!-- </div> -->
|
||||
|
||||
Reference in New Issue
Block a user