[POS] Currency format issue
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index 2892412..06298ca 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -572,7 +572,10 @@
 			var paid_amount = (this.frm.doc.party_account_currency == this.frm.doc.currency) ?
 				this.frm.doc.paid_amount : this.frm.doc.base_paid_amount;
 
-			this.frm.doc.outstanding_amount =  flt(total_amount_to_pay - flt(paid_amount) + 
+			var change_amount = (this.frm.doc.party_account_currency == this.frm.doc.currency) ?
+				this.frm.doc.change_amount : this.frm.doc.base_change_amount;
+
+			this.frm.doc.outstanding_amount =  flt(total_amount_to_pay - flt(paid_amount) +
 				flt(this.frm.doc.change_amount * this.frm.doc.conversion_rate), precision("outstanding_amount"));
 
 		} else if(this.frm.doc.doctype == "Purchase Invoice") {
@@ -612,12 +615,11 @@
 	calculate_change_amount: function(){
 		this.frm.doc.change_amount = 0.0;
 		if(this.frm.doc.paid_amount > this.frm.doc.grand_total && !this.frm.doc.is_return){
-			this.frm.doc.change_amount = flt(this.frm.doc.paid_amount - this.frm.doc.grand_total + 
+			this.frm.doc.change_amount = flt(this.frm.doc.paid_amount - this.frm.doc.grand_total +
 				this.frm.doc.write_off_amount, precision("change_amount"));
+			this.frm.doc.base_change_amount = flt(this.frm.doc.base_paid_amount - this.frm.doc.base_grand_total +
+				this.frm.doc.base_write_off_amount, precision("base_change_amount"));
 		}
-
-		this.frm.doc.base_change_amount = flt(this.frm.doc.change_amount * this.frm.doc.conversion_rate,
-			precision("base_change_amount"));
 	},
 
 	calculate_write_off_amount: function(){
diff --git a/erpnext/public/js/payment/payment_details.html b/erpnext/public/js/payment/payment_details.html
index 596f139..3e63944 100644
--- a/erpnext/public/js/payment/payment_details.html
+++ b/erpnext/public/js/payment/payment_details.html
@@ -2,7 +2,7 @@
     <div class="col-xs-6" style="padding:20px">{{mode_of_payment}}</div>
 	<div class="col-xs-6">
 		<div class="input-group">
-			<input disabled class="form-control text-right amount" idx="{{idx}}" type="text" value="{{format_number(amount, 2)}}">
+			<input disabled class="form-control text-right amount" idx="{{idx}}" type="text" value="{%= format_currency(amount, currency) %}">
 			<span class="input-group-btn">
 				<button type="button" class="btn btn-default clr" idx="{{idx}}" style="border:1px solid #d1d8dd">C</button>
 			</span>
diff --git a/erpnext/public/js/payment/payments.js b/erpnext/public/js/payment/payments.js
index 4fa0390..c5d0749 100644
--- a/erpnext/public/js/payment/payments.js
+++ b/erpnext/public/js/payment/payments.js
@@ -85,7 +85,7 @@
 		if(this.frm.doc.outstanding_amount > 0 && flt(this.selected_mode.val()) == 0.0){
 			//When user first time click on row
 			this.payment_val = flt(this.frm.doc.outstanding_amount / this.frm.doc.conversion_rate, precision("outstanding_amount"))
-			this.selected_mode.val(format_number(this.payment_val, 2));
+			this.selected_mode.val(format_currency(this.payment_val, this.frm.doc.currency));
 			this.update_payment_amount()
 		}else if(flt(this.selected_mode.val()) > 0){
 			//If user click on existing row which has value
@@ -137,14 +137,14 @@
 		var me = this;
 		$(this.$body).find('.pos-keyboard-key').click(function(){
 			me.payment_val += $(this).text();
-			me.selected_mode.val(format_number(me.payment_val, 2))
+			me.selected_mode.val(format_currency(me.payment_val, me.frm.doc.currency))
 			me.idx = me.selected_mode.attr("idx")
 			me.update_paid_amount()
 		})
 		
 		$(this.$body).find('.delete-btn').click(function(){
 			me.payment_val =  cstr(flt(me.selected_mode.val())).slice(0, -1);
-			me.selected_mode.val(format_number(me.payment_val, 2));
+			me.selected_mode.val(format_currency(me.payment_val, me.frm.doc.currency));
 			me.idx = me.selected_mode.attr("idx")
 			me.update_paid_amount();
 		})
@@ -155,7 +155,7 @@
 		var me = this;
 		this.selected_mode.change(function(){
 			me.payment_val =  flt($(this).val()) || 0.0;
-			me.selected_mode.val(format_number(me.payment_val, 2))
+			me.selected_mode.val(format_currency(me.payment_val, me.frm.doc.currency))
 			me.idx = me.selected_mode.attr("idx")
 			me.update_payment_amount()
 		})
@@ -199,7 +199,7 @@
 			if(me.idx == 'change_amount'){
 				me.change_amount(value)
 			} else{
-				if(value == 0 && update_write_off) {
+				if(flt(value) == 0 && update_write_off) {
 					value = flt(me.frm.doc.outstanding_amount / me.frm.doc.conversion_rate, precision(me.idx));
 				}
 				me.write_off_amount(value)
@@ -224,9 +224,9 @@
 
 	show_amounts: function(){
 		var me = this;
-		$(this.$body).find(".write_off_amount").val(format_number(this.frm.doc.write_off_amount, precision("write_off_amount")));
+		$(this.$body).find(".write_off_amount").val(format_currency(this.frm.doc.write_off_amount, this.frm.doc.currency));
 		$(this.$body).find('.paid_amount').text(format_currency(this.frm.doc.paid_amount, this.frm.doc.currency));
-		$(this.$body).find('.change_amount').val(format_number(this.frm.doc.change_amount, precision("change_amount")))
+		$(this.$body).find('.change_amount').val(format_currency(this.frm.doc.change_amount, this.frm.doc.currency))
 		$(this.$body).find('.outstanding_amount').text(format_currency(this.frm.doc.outstanding_amount, frappe.get_doc(":Company", this.frm.doc.company).default_currency))
 		this.update_invoice();
 	}