mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-07 07:02:54 +00:00
Merge branch 'develop' into develop
This commit is contained in:
@@ -84,6 +84,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
this.get_data_from_server(function () {
|
||||
me.make_control();
|
||||
me.create_new();
|
||||
me.make();
|
||||
});
|
||||
},
|
||||
|
||||
@@ -178,41 +179,12 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
}
|
||||
},
|
||||
|
||||
dialog_actions: function () {
|
||||
var me = this;
|
||||
|
||||
$(this.list_body).find('.list-select-all').click(function () {
|
||||
me.removed_items = [];
|
||||
$(me.list_body).find('.list-delete').prop("checked", $(this).is(":checked"))
|
||||
if ($(this).is(":checked")) {
|
||||
$.each(me.si_docs, function (index, data) {
|
||||
for (key in data) {
|
||||
me.removed_items.push(key)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
me.toggle_delete_button();
|
||||
})
|
||||
|
||||
$(this.list_body).find('.list-delete').click(function () {
|
||||
me.name = $(this).parent().parent().attr('invoice-name');
|
||||
if ($(this).is(":checked")) {
|
||||
me.removed_items.push(me.name);
|
||||
} else {
|
||||
me.removed_items.pop(me.name)
|
||||
}
|
||||
|
||||
me.toggle_delete_button();
|
||||
})
|
||||
},
|
||||
|
||||
edit_record: function () {
|
||||
var me = this;
|
||||
|
||||
doc_data = this.get_invoice_doc(this.si_docs);
|
||||
if (doc_data) {
|
||||
this.frm.doc = doc_data[0][this.name];
|
||||
this.frm.doc = doc_data[0][this.frm.doc.offline_pos_name];
|
||||
this.set_missing_values();
|
||||
this.refresh(false);
|
||||
this.toggle_input_field();
|
||||
@@ -225,16 +197,15 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
this.validate_list()
|
||||
this.remove_doc_from_localstorage()
|
||||
this.update_localstorage();
|
||||
// this.dialog_actions();
|
||||
this.toggle_delete_button();
|
||||
},
|
||||
|
||||
validate_list: function() {
|
||||
var me = this;
|
||||
this.si_docs = this.get_submitted_invoice()
|
||||
$.each(this.removed_items, function(index, name){
|
||||
$.each(this.removed_items, function(index, pos_name){
|
||||
$.each(me.si_docs, function(key, data){
|
||||
if(me.si_docs[key][name] && me.si_docs[key][name].offline_pos_name == name ){
|
||||
if(me.si_docs[key][pos_name] && me.si_docs[key][pos_name].offline_pos_name == pos_name ){
|
||||
frappe.throw(__("Submitted orders can not be deleted"))
|
||||
}
|
||||
})
|
||||
@@ -293,7 +264,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
|
||||
return $.grep(this.si_docs, function (data) {
|
||||
for (key in data) {
|
||||
return key == me.name
|
||||
return key == me.frm.doc.offline_pos_name;
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -347,7 +318,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
create_new: function () {
|
||||
var me = this;
|
||||
this.frm = {}
|
||||
this.name = null;
|
||||
this.load_data(true);
|
||||
this.setup();
|
||||
this.set_default_customer()
|
||||
@@ -361,6 +331,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
|
||||
if (load_doc) {
|
||||
this.frm.doc = JSON.parse(localStorage.getItem('doc'));
|
||||
this.frm.doc.offline_pos_name = null;
|
||||
}
|
||||
|
||||
$.each(this.meta, function (i, data) {
|
||||
@@ -382,7 +353,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
},
|
||||
|
||||
setup: function () {
|
||||
this.make();
|
||||
this.set_primary_action();
|
||||
this.party_field.$input.attr('disabled', false);
|
||||
if(this.selected_row) {
|
||||
@@ -629,6 +599,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
// this.list_customers.empty();
|
||||
this.si_docs = this.get_doc_from_localstorage();
|
||||
if (!this.si_docs.length) {
|
||||
this.list_customers.find('.list-customers-table').html("");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -655,7 +626,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
me.list_customers_btn.toggleClass("view_customer");
|
||||
me.pos_bill.show();
|
||||
me.list_customers_btn.show();
|
||||
me.name = $(this).parents().attr('invoice-name')
|
||||
me.frm.doc.offline_pos_name = $(this).parents().attr('invoice-name')
|
||||
me.edit_record();
|
||||
})
|
||||
|
||||
@@ -675,11 +646,11 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
});
|
||||
|
||||
$(this.wrapper).find('.list-delete').click(function () {
|
||||
me.name = $(this).parent().parent().attr('invoice-name');
|
||||
me.frm.doc.offline_pos_name = $(this).parent().parent().attr('invoice-name');
|
||||
if ($(this).is(":checked")) {
|
||||
me.removed_items.push(me.name);
|
||||
me.removed_items.push(me.frm.doc.offline_pos_name);
|
||||
} else {
|
||||
me.removed_items.pop(me.name)
|
||||
me.removed_items.pop(me.frm.doc.offline_pos_name)
|
||||
}
|
||||
|
||||
me.toggle_delete_button();
|
||||
@@ -1341,6 +1312,12 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
|
||||
this.wrapper.find('input.discount-percentage').on("change", function () {
|
||||
me.frm.doc.additional_discount_percentage = flt($(this).val(), precision("additional_discount_percentage"));
|
||||
|
||||
if(me.frm.doc.additional_discount_percentage && me.frm.doc.discount_amount) {
|
||||
// Reset discount amount
|
||||
me.frm.doc.discount_amount = 0;
|
||||
}
|
||||
|
||||
var total = me.frm.doc.grand_total
|
||||
|
||||
if (me.frm.doc.apply_discount_on == 'Net Total') {
|
||||
@@ -1348,15 +1325,15 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
}
|
||||
|
||||
me.frm.doc.discount_amount = flt(total * flt(me.frm.doc.additional_discount_percentage) / 100, precision("discount_amount"));
|
||||
me.wrapper.find('input.discount-amount').val(me.frm.doc.discount_amount)
|
||||
me.refresh();
|
||||
me.wrapper.find('input.discount-amount').val(me.frm.doc.discount_amount)
|
||||
});
|
||||
|
||||
this.wrapper.find('input.discount-amount').on("change", function () {
|
||||
me.frm.doc.discount_amount = flt($(this).val(), precision("discount_amount"));
|
||||
me.frm.doc.additional_discount_percentage = 0.0;
|
||||
me.wrapper.find('input.discount-percentage').val(0);
|
||||
me.refresh();
|
||||
me.wrapper.find('input.discount-percentage').val(0);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1429,7 +1406,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
},
|
||||
|
||||
update_paid_amount_status: function (update_paid_amount) {
|
||||
if (this.name) {
|
||||
if (this.frm.doc.offline_pos_name) {
|
||||
update_paid_amount = update_paid_amount ? false : true;
|
||||
}
|
||||
|
||||
@@ -1517,6 +1494,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
var me = this;
|
||||
this.wrapper.find(".net-total").text(format_currency(me.frm.doc.total, me.frm.doc.currency));
|
||||
this.wrapper.find(".grand-total").text(format_currency(me.frm.doc.grand_total, me.frm.doc.currency));
|
||||
this.wrapper.find('input.discount-percentage').val(this.frm.doc.additional_discount_percentage);
|
||||
this.wrapper.find('input.discount-amount').val(this.frm.doc.discount_amount);
|
||||
},
|
||||
|
||||
set_primary_action: function () {
|
||||
@@ -1526,11 +1505,15 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
me.make_menu_list()
|
||||
}, "fa fa-plus")
|
||||
|
||||
if (this.frm.doc.docstatus == 1) {
|
||||
if (this.frm.doc.docstatus == 1 || this.pos_profile_data["allow_print_before_pay"]) {
|
||||
this.page.set_secondary_action(__("Print"), function () {
|
||||
me.create_invoice();
|
||||
var html = frappe.render(me.print_template_data, me.frm.doc)
|
||||
me.print_document(html)
|
||||
})
|
||||
}
|
||||
|
||||
if (this.frm.doc.docstatus == 1) {
|
||||
this.page.add_menu_item(__("Email"), function () {
|
||||
me.email_prompt()
|
||||
})
|
||||
@@ -1635,26 +1618,25 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
|
||||
create_invoice: function () {
|
||||
var me = this;
|
||||
var invoice_data = {}
|
||||
var invoice_data = {};
|
||||
this.si_docs = this.get_doc_from_localstorage();
|
||||
if (this.name) {
|
||||
|
||||
if (this.frm.doc.offline_pos_name) {
|
||||
this.update_invoice()
|
||||
//to retrieve and set the default payment
|
||||
invoice_data[this.name] = this.frm.doc;
|
||||
invoice_data[this.name].payments[0].amount = this.frm.doc.net_total
|
||||
invoice_data[this.name].payments[0].base_amount = this.frm.doc.net_total
|
||||
invoice_data[this.frm.doc.offline_pos_name] = this.frm.doc;
|
||||
invoice_data[this.frm.doc.offline_pos_name].payments[0].amount = this.frm.doc.net_total
|
||||
invoice_data[this.frm.doc.offline_pos_name].payments[0].base_amount = this.frm.doc.net_total
|
||||
|
||||
this.frm.doc.paid_amount = this.frm.doc.net_total
|
||||
this.frm.doc.outstanding_amount = 0
|
||||
|
||||
} else {
|
||||
this.name = $.now();
|
||||
this.frm.doc.offline_pos_name = this.name;
|
||||
this.frm.doc.offline_pos_name = $.now();
|
||||
this.frm.doc.posting_date = frappe.datetime.get_today();
|
||||
this.frm.doc.posting_time = frappe.datetime.now_time();
|
||||
this.frm.doc.pos_profile = this.pos_profile_data['name'];
|
||||
invoice_data[this.name] = this.frm.doc
|
||||
this.si_docs.push(invoice_data)
|
||||
invoice_data[this.frm.doc.offline_pos_name] = this.frm.doc;
|
||||
this.si_docs.push(invoice_data);
|
||||
this.update_localstorage();
|
||||
this.set_primary_action();
|
||||
}
|
||||
@@ -1666,12 +1648,12 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
this.si_docs = this.get_doc_from_localstorage();
|
||||
$.each(this.si_docs, function (index, data) {
|
||||
for (var key in data) {
|
||||
if (key == me.name) {
|
||||
if (key == me.frm.doc.offline_pos_name) {
|
||||
me.si_docs[index][key] = me.frm.doc;
|
||||
me.update_localstorage();
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
update_localstorage: function () {
|
||||
@@ -1710,6 +1692,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
freeze_screen = this.freeze_screen || false;
|
||||
|
||||
if ((this.si_docs.length || this.email_queue_list || this.customers_list) && !this.freeze) {
|
||||
this.freeze = true;
|
||||
|
||||
frappe.call({
|
||||
method: "erpnext.accounts.doctype.sales_invoice.pos.make_invoice",
|
||||
freeze: freeze_screen,
|
||||
@@ -1720,17 +1704,19 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
||||
},
|
||||
callback: function (r) {
|
||||
if (r.message) {
|
||||
me.freeze = false;
|
||||
me.customers = r.message.synced_customers_list;
|
||||
me.address = r.message.synced_address;
|
||||
me.contacts = r.message.synced_contacts;
|
||||
me.removed_items = r.message.invoice;
|
||||
me.removed_email = r.message.email_queue
|
||||
me.removed_customers = r.message.customers
|
||||
me.removed_email = r.message.email_queue;
|
||||
me.removed_customers = r.message.customers;
|
||||
me.remove_doc_from_localstorage();
|
||||
me.remove_email_queue_from_localstorage();
|
||||
me.remove_customer_from_localstorage();
|
||||
me.prepare_customer_mapper()
|
||||
me.autocomplete_customers()
|
||||
me.prepare_customer_mapper();
|
||||
me.autocomplete_customers();
|
||||
me.render_list_customers();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -6,6 +6,7 @@ QUnit.test("test:Sales Invoice", function(assert) {
|
||||
() => {
|
||||
return frappe.tests.make("POS Profile", [
|
||||
{naming_series: "SINV"},
|
||||
{pos_profile_name: "_Test POS Profile"},
|
||||
{country: "India"},
|
||||
{currency: "INR"},
|
||||
{write_off_account: "Write Off - FT"},
|
||||
|
||||
Reference in New Issue
Block a user