refactor: POS workflow (#20789)
* refactor: add pos invoice doctype replacing sales invoice in POS
* refactor: move pos.py to pos invoice
* feat: add pos invoice merge log doctype
* feat: ability to merge pos invoices into a sales invoice
* feat: [wip] new ui for point of sale
* fix: pos.py moved to pos_invoice
* feat: loyalty points for POS Invoice
* fix: loyalty points on merging
* feat: return against pos invoices
* Merge 'fork/serial-no-selector' into refactor-pos-invoice
* chore: status fix and set warehouse from pos profile
* fix: naming series
* feat: merge pos returns into credit notes
* feat: add pos list action for merging into sales invoices
* feat[UX]: add shortcuts & focus on search after customer selection
* feat: stock validation from previous pos transactions
* Merge 'fork/serial-no-selector' into refactor-pos-invoice
* chore: fix df not found for base_amount precision
* feat: serial no validation from previous pos transactions
* chore: move pos.py into pos page
* feat: pos opening voucher
* feat: link pos closing voucher with opening voucher
* chore: use map_doc instead of get_mapped_doc for better perf
* feat: enforce opening voucher on pos page
* feat: [ui] [wip] point of sale beta ui refactor
* fix: auto fetching serial nos with batch no
* feat: [ui] item details section for new pos ui
* feat: remove item from cart
* refactor: [ui] [wip] split point_of_sale into components
* new payment component
* new numberpad
* fix pos opening status
* move from flex to grids
* fix: search from item selector
* feat: loyalty points as payment method
* feat: pos invoice status
* fix a bug with invalid JSON
* fix: loyalty program ui fixes
* feat: past order list and past order summary
* feat: (minor) setting discount from item details
* fix: adding item before customer selection
* feat: post order submission summary
* save and open draft orders
* fix: item group filter
* fix: item_det not defined while submitting sle
* fix: minor bugs
* fix: minor ux fixes
* feat: show opening time in pos ui
* feat: item and customer images
* feat: emailing and printing an invoice
* fix: item details field edit shows empty alert
* fix: (minor) ux fixes
* chore: rename pos opening voucher to pos opening entry
* chore: (minor) rename pos closing voucher and sub doctypes
* chore: add patch for renaming pos closing doctypes
* fix: negative stock not allowed in pos invoices* default is_pos in pos invoices* fix: transalation
* fix: invoices not getting fetched on pos closing
* fix: indentation
* feat: view / edit customer info
* fix: minor bugs
* fix: minor bug
* fix: patch
* fix: minor ux issues
* fix: remove uppercase status
* refactor: pos closing payment reconciliation
* fix: move pos invoice print formats to pos invoice doctype
* fix: ui issues
* feat: new child doctype to store pos payment mode details
* fix: add to patches.txt
* feat: search by serial no
* chore: [wip] code cleanup
* fix: item not selectable from cart
* chore: [wip] code cleanup
* fix: minor issues
* loyalty points transactions
* default payment mode
* fix: minor fixes
* set correct mop amount with loaylty points
* editing draft invoices from UI
* chore: pos invoice merge log tests
* fix: batch / serial validation in pos ui and on submission
* feat: use onscan js for barcode scan events
* fix: cart header with amount column
* fix: validate batch no and qty in pos transactions
* chore: do not fetch closing balances as opening balance
* feat: show available qty in item selector
* feat: shortcuts
* fix: onscan.js not found
* fix: onscan.js not found
* fix: cannot return partial items
* fix: neagtive stock indicator
* feat: invoice discount
* fix: change available stock on warehouse change
* chore: cleanup code
* fix: pos profile payment method table
* feat: adding same item with different uom
* fix: loyalty points deleted after consolidation
* fix: enter loyalty amount instead of loyalty points
* chore: return print format
* feat: custom fields in pos view
* chore: pos invoice test
* chore: remove offline pos
* fix: cyclic dependency
* fix: cyclic dependency
* patch: remove pos page and order fixes
* chore: little fixes
* fix: patch perf and plural naming
* chore: tidy up pos invoice validation
* chore: move pos closing to accounts
* fix: move pos doctypes to accounts
* fix: move pos doctypes to accounts
* fix: item description in cart
* fix: item description in cart
* chore: loyalty tests
* minor fixes
* chore: rename point of sale beta to point of sale
* chore: reset past order summary on filter change
* chore: add point of sale to accounting desk
* fix: payment reconciliation table in pos closing
* fix: travis
* Update accounting.json
* fix: test cases
* fix: tests
* patch loyalty point entries
* fix: remove test
* default mode of payment is mandatory for pos transaction
* chore: remove unused checks from pos profile
* fix: loyalty point entry patch
* fix: numpad reset and patches
* fix: minor bugs
* fix: travis
* fix: travis
* fix: travis
* fix: travis
Co-authored-by: Nabin Hait <nabinhait@gmail.com>
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index b72ceb2..405a33c 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -34,12 +34,12 @@
this.calculate_discount_amount();
// Advance calculation applicable to Sales /Purchase Invoice
- if(in_list(["Sales Invoice", "Purchase Invoice"], this.frm.doc.doctype)
+ if(in_list(["Sales Invoice", "POS Invoice", "Purchase Invoice"], this.frm.doc.doctype)
&& this.frm.doc.docstatus < 2 && !this.frm.doc.is_return) {
this.calculate_total_advance(update_paid_amount);
}
- if (this.frm.doc.doctype == "Sales Invoice" && this.frm.doc.is_pos &&
+ if (in_list(["Sales Invoice", "POS Invoice"], this.frm.doc.doctype) && this.frm.doc.is_pos &&
this.frm.doc.is_return) {
this.update_paid_amount_for_return();
}
@@ -425,7 +425,7 @@
? this.frm.doc["taxes"][tax_count - 1].total + flt(this.frm.doc.rounding_adjustment)
: this.frm.doc.net_total);
- if(in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"], this.frm.doc.doctype)) {
+ if(in_list(["Quotation", "Sales Order", "Delivery Note", "Sales Invoice", "POS Invoice"], this.frm.doc.doctype)) {
this.frm.doc.base_grand_total = (this.frm.doc.total_taxes_and_charges) ?
flt(this.frm.doc.grand_total * this.frm.doc.conversion_rate) : this.frm.doc.base_net_total;
} else {
@@ -604,7 +604,7 @@
// NOTE:
// paid_amount and write_off_amount is only for POS/Loyalty Point Redemption Invoice
// total_advance is only for non POS Invoice
- if(this.frm.doc.doctype == "Sales Invoice" && this.frm.doc.is_return){
+ if(in_list(["Sales Invoice", "POS Invoice"], this.frm.doc.doctype) && this.frm.doc.is_return){
this.calculate_paid_amount();
}
@@ -612,7 +612,7 @@
frappe.model.round_floats_in(this.frm.doc, ["grand_total", "total_advance", "write_off_amount"]);
- if(in_list(["Sales Invoice", "Purchase Invoice"], this.frm.doc.doctype)) {
+ if(in_list(["Sales Invoice", "POS Invoice", "Purchase Invoice"], this.frm.doc.doctype)) {
var grand_total = this.frm.doc.rounded_total || this.frm.doc.grand_total;
if(this.frm.doc.party_account_currency == this.frm.doc.currency) {
@@ -634,7 +634,7 @@
this.frm.refresh_field("base_paid_amount");
}
- if(this.frm.doc.doctype == "Sales Invoice") {
+ if(in_list(["Sales Invoice", "POS Invoice"], this.frm.doc.doctype)) {
let total_amount_for_payment = (this.frm.doc.redeem_loyalty_points && this.frm.doc.loyalty_amount)
? flt(total_amount_to_pay - this.frm.doc.loyalty_amount, precision("base_grand_total"))
: total_amount_to_pay;
@@ -691,11 +691,13 @@
if(this.frm.doc.is_pos && (update_paid_amount===undefined || update_paid_amount)) {
$.each(this.frm.doc['payments'] || [], function(index, data) {
if(data.default && payment_status && total_amount_to_pay > 0) {
- data.base_amount = flt(total_amount_to_pay, precision("base_amount"));
- data.amount = flt(total_amount_to_pay / me.frm.doc.conversion_rate, precision("amount"));
+ let base_amount = flt(total_amount_to_pay, precision("base_amount", data));
+ frappe.model.set_value(data.doctype, data.name, "base_amount", base_amount);
+ let amount = flt(total_amount_to_pay / me.frm.doc.conversion_rate, precision("amount", data));
+ frappe.model.set_value(data.doctype, data.name, "amount", amount);
payment_status = false;
} else if(me.frm.doc.paid_amount) {
- data.amount = 0.0;
+ frappe.model.set_value(data.doctype, data.name, "amount", 0.0);
}
});
}
@@ -707,7 +709,7 @@
var base_paid_amount = 0.0;
if(this.frm.doc.is_pos) {
$.each(this.frm.doc['payments'] || [], function(index, data){
- data.base_amount = flt(data.amount * me.frm.doc.conversion_rate, precision("base_amount"));
+ data.base_amount = flt(data.amount * me.frm.doc.conversion_rate, precision("base_amount", data));
paid_amount += data.amount;
base_paid_amount += data.base_amount;
});
@@ -719,14 +721,14 @@
paid_amount += flt(this.frm.doc.loyalty_amount / me.frm.doc.conversion_rate, precision("paid_amount"));
}
- this.frm.doc.paid_amount = flt(paid_amount, precision("paid_amount"));
- this.frm.doc.base_paid_amount = flt(base_paid_amount, precision("base_paid_amount"));
+ this.frm.set_value('paid_amount', flt(paid_amount, precision("paid_amount")));
+ this.frm.set_value('base_paid_amount', flt(base_paid_amount, precision("base_paid_amount")));
},
calculate_change_amount: function(){
this.frm.doc.change_amount = 0.0;
this.frm.doc.base_change_amount = 0.0;
- if(this.frm.doc.doctype == "Sales Invoice"
+ if(in_list(["Sales Invoice", "POS Invoice"], this.frm.doc.doctype)
&& this.frm.doc.paid_amount > this.frm.doc.grand_total && !this.frm.doc.is_return) {
var payment_types = $.map(this.frm.doc.payments, function(d) { return d.type; });
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 3c56a63..4e50f3d 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -651,7 +651,7 @@
let child = frappe.model.add_child(me.frm.doc, "taxes");
child.charge_type = "On Net Total";
child.account_head = tax;
- child.rate = 0;
+ child.rate = rate;
}
});
}