From 1ce8b9a3b8c17c7af0f96c628d3fd47596c62bf8 Mon Sep 17 00:00:00 2001 From: Yousef Date: Sat, 12 Aug 2023 17:01:17 +0200 Subject: [PATCH 1/5] fix: Sales taxes are zeroed out on Sales Invoice #362 --- posawesome/hooks.py | 6 ++--- posawesome/posawesome/api/posapp.py | 38 ++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/posawesome/hooks.py b/posawesome/hooks.py index 46a71f9d..2bf447ce 100644 --- a/posawesome/hooks.py +++ b/posawesome/hooks.py @@ -143,9 +143,9 @@ # "Task": "posawesome.task.get_dashboard_data" # } -override_doctype_class = { - "Sales Invoice": "posawesome.posawesome.api.taxes.customSalesInvoice", -} +# override_doctype_class = { +# "doctype": "method", +# } # exempt linked doctypes from being automatically cancelled # diff --git a/posawesome/posawesome/api/posapp.py b/posawesome/posawesome/api/posapp.py index 23fbb0f1..5073f836 100644 --- a/posawesome/posawesome/api/posapp.py +++ b/posawesome/posawesome/api/posapp.py @@ -21,7 +21,7 @@ get_dummy_message, get_existing_payment_request_amount, ) -from erpnext.controllers.accounts_controller import add_taxes_from_tax_template + from erpnext.accounts.doctype.loyalty_program.loyalty_program import ( get_loyalty_program_details_with_points, ) @@ -444,6 +444,42 @@ def get_sales_person_names(): return sales_persons +def add_taxes_from_tax_template(item, parent_doc): + accounts_settings = frappe.get_cached_doc("Accounts Settings") + add_taxes_from_item_tax_template = ( + accounts_settings.add_taxes_from_item_tax_template + ) + if item.get("item_tax_template") and add_taxes_from_item_tax_template: + item_tax_template = item.get("item_tax_template") + taxes_template_details = frappe.get_all( + "Item Tax Template Detail", + filters={"parent": item_tax_template}, + fields=["tax_type"], + ) + + for tax_detail in taxes_template_details: + tax_type = tax_detail.get("tax_type") + + found = any(tax.account_head == tax_type for tax in parent_doc.taxes) + if not found: + tax_row = parent_doc.append("taxes", {}) + tax_row.update( + { + "description": str(tax_type).split(" - ")[0], + "charge_type": "On Net Total", + "account_head": tax_type, + } + ) + + if parent_doc.doctype == "Purchase Order": + tax_row.update({"category": "Total", "add_deduct_tax": "Add"}) + tax_row.db_insert() + + +def get_taxes_fieldname_for_item(): + return "taxes" + + @frappe.whitelist() def update_invoice(data): data = json.loads(data) From 5b57800c074afbe60b0f354bbd6af9e4db09752a Mon Sep 17 00:00:00 2001 From: Yousef Date: Sat, 12 Aug 2023 17:49:03 +0200 Subject: [PATCH 2/5] fix: auto allocatinvoice amount for Mpesa Payments. #367 --- posawesome/public/js/posapp/components/pos/Payments.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/posawesome/public/js/posapp/components/pos/Payments.vue b/posawesome/public/js/posapp/components/pos/Payments.vue index f3c2c399..3c83a7f1 100644 --- a/posawesome/public/js/posapp/components/pos/Payments.vue +++ b/posawesome/public/js/posapp/components/pos/Payments.vue @@ -1229,11 +1229,18 @@ export default { set_mpesa_payment(payment) { this.pos_profile.use_customer_credit = 1; this.redeem_customer_credit = true; + const invoiceAmount = + this.invoice_doc.rounded_total || this.invoice_doc.grand_total; + let amount = + payment.unallocated_amount > invoiceAmount + ? invoiceAmount + : payment.unallocated_amount; + if (amount < 0 || !amount) amount = 0; const advance = { type: "Advance", credit_origin: payment.name, total_credit: flt(payment.unallocated_amount), - credit_to_redeem: flt(payment.unallocated_amount), + credit_to_redeem: flt(amount), }; this.clear_all_amounts(); this.customer_credit_dict.push(advance); From 3c9790b4b4cc24738b8a8b5cebff7758d3870db9 Mon Sep 17 00:00:00 2001 From: Yousef Date: Sat, 12 Aug 2023 21:35:32 +0200 Subject: [PATCH 3/5] fix: respect valid from and vaild up to on getting item prices #363 --- posawesome/posawesome/api/posapp.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/posawesome/posawesome/api/posapp.py b/posawesome/posawesome/api/posapp.py index 5073f836..6f1a96c6 100644 --- a/posawesome/posawesome/api/posapp.py +++ b/posawesome/posawesome/api/posapp.py @@ -225,7 +225,13 @@ def _get_items(pos_profile, price_list, item_group, search_value): "item_code": ["in", items], "currency": pos_profile.get("currency"), "selling": 1, + "valid_from": ["<=", today], }, + or_filters=[ + ["valid_upto", ">=", today], + ["valid_upto", "in", ["", None]], + ], + order_by="valid_from ASC, valid_upto DESC", ) item_prices = {} From 666bd59c475983888e3401b9ad039622c5f7e644 Mon Sep 17 00:00:00 2001 From: Yousef Date: Sat, 12 Aug 2023 21:43:16 +0200 Subject: [PATCH 4/5] chore: cleanup the code --- posawesome/posawesome/api/posapp.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/posawesome/posawesome/api/posapp.py b/posawesome/posawesome/api/posapp.py index 6f1a96c6..07b9b834 100644 --- a/posawesome/posawesome/api/posapp.py +++ b/posawesome/posawesome/api/posapp.py @@ -482,10 +482,6 @@ def add_taxes_from_tax_template(item, parent_doc): tax_row.db_insert() -def get_taxes_fieldname_for_item(): - return "taxes" - - @frappe.whitelist() def update_invoice(data): data = json.loads(data) From 863de92cd46e782778e7cb3a2747dbf55d6b0997 Mon Sep 17 00:00:00 2001 From: Yousef Date: Sun, 13 Aug 2023 01:12:49 +0200 Subject: [PATCH 5/5] Version: 6.1.3 --- posawesome/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posawesome/__init__.py b/posawesome/__init__.py index 36bec1d3..dc8a62b6 100644 --- a/posawesome/__init__.py +++ b/posawesome/__init__.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals import frappe -__version__ = "6.1.2" +__version__ = "6.1.3" def console(*data):