Skip to content

Commit

Permalink
fix: item qty format
Browse files Browse the repository at this point in the history
  • Loading branch information
yrestom committed Jun 17, 2023
1 parent 3a19e04 commit 0bebc9b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 25 deletions.
6 changes: 0 additions & 6 deletions posawesome/public/js/posapp/components/payments/Pay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,6 @@ export default {
customer_name: '',
customer_info: '',
company: '',
float_precision: 2,
currency_precision: 2,
singleSelect: false,
invoices_loading: false,
unallocated_payments_loading: false,
Expand Down Expand Up @@ -777,10 +775,6 @@ export default {
mounted: function () {
this.$nextTick(function () {
this.float_precision =
frappe.defaults.get_default('float_precision') || 2;
this.currency_precision =
frappe.defaults.get_default('currency_precision') || 2;
this.check_opening_entry();
evntBus.$on('update_customer', (customer_name) => {
this.clear_all(true);
Expand Down
2 changes: 1 addition & 1 deletion posawesome/public/js/posapp/components/pos/Invoice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
:value="formtFloat(item.qty)"
@change="
[
setFormatedCurrency(item, 'qty', null, false, $event),
setFormatedFloat(item, 'qty', null, false, $event),
calc_stock_qty(item, $event),
]
"
Expand Down
6 changes: 0 additions & 6 deletions posawesome/public/js/posapp/components/pos/ItemsSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ export default {
couponsCount: 0,
appliedCouponsCount: 0,
customer_price_list: null,
float_precision: 2,
currency_precision: 2,
new_line: false,
qty: 1,
}),
Expand Down Expand Up @@ -610,10 +608,6 @@ export default {
this.pos_profile = data.pos_profile;
this.get_items();
this.get_items_groups();
this.float_precision =
frappe.defaults.get_default('float_precision') || 2;
this.currency_precision =
frappe.defaults.get_default('currency_precision') || 2;
this.items_view = this.pos_profile.posa_default_card_view
? 'card'
: 'list';
Expand Down
6 changes: 0 additions & 6 deletions posawesome/public/js/posapp/components/pos/Payments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,6 @@ export default {
pos_settings: '',
customer_info: '',
mpesa_modes: [],
float_precision: 2,
currency_precision: 2,
}),
methods: {
Expand Down Expand Up @@ -1311,10 +1309,6 @@ export default {
evntBus.$on('register_pos_profile', (data) => {
this.pos_profile = data.pos_profile;
this.get_mpesa_modes();
this.float_precision =
frappe.defaults.get_default('float_precision') || 2;
this.currency_precision =
frappe.defaults.get_default('currency_precision') || 2;
});
evntBus.$on('add_the_new_address', (data) => {
this.addresses.push(data);
Expand Down
2 changes: 1 addition & 1 deletion posawesome/public/js/posapp/components/pos/Pos.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div fluid>
<div fluid class="mt-2">
<ClosingDialog></ClosingDialog>
<Drafts></Drafts>
<Returns></Returns>
Expand Down
22 changes: 17 additions & 5 deletions posawesome/public/js/posapp/format.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
export default {
data () {
return {
float_precision: 2,
currency_precision: 2
};
},
methods: {
flt (value, precision, number_format, rounding_method) {
if (!precision && precision != 0) {
Expand All @@ -10,17 +16,17 @@ export default {
return flt(value, precision, number_format, rounding_method);
},
formtCurrency (value, precision) {
const fomrat = get_number_format(this.pos_profile?.currency);
const format = get_number_format(this.pos_profile?.currency);
value = format_number(
value,
fomrat,
format,
precision || this.currency_precision || 2
);
return value;
},
formtFloat (value, precision) {
const fomrat = get_number_format(this.pos_profile.currency);
value = format_number(value, fomrat, precision || this.float_precision || 2);
const format = get_number_format(this.pos_profile.currency);
value = format_number(value, format, precision || this.float_precision || 2);
return value;
},
setFormatedCurrency (el, field_name, precision, no_negative = false, $event) {
Expand Down Expand Up @@ -60,7 +66,7 @@ export default {
} else if (no_negative && value < 0) {
value = value * -1;
}
value = this.formtCurrency($event, precision);
value = this.formtFloat($event, precision);
} catch (e) {
console.error(e);
value = 0;
Expand All @@ -83,4 +89,10 @@ export default {

}
},
mounted () {
this.float_precision =
frappe.defaults.get_default('float_precision') || 2;
this.currency_precision =
frappe.defaults.get_default('currency_precision') || 2;
}
};

0 comments on commit 0bebc9b

Please sign in to comment.