Skip to content

Commit

Permalink
Merge pull request #371 from yrestom/develop
Browse files Browse the repository at this point in the history
Version: 6.1.3
  • Loading branch information
yrestom authored Aug 12, 2023
2 parents f83f4eb + 863de92 commit b71398f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 6 deletions.
2 changes: 1 addition & 1 deletion posawesome/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import unicode_literals
import frappe

__version__ = "6.1.2"
__version__ = "6.1.3"


def console(*data):
Expand Down
6 changes: 3 additions & 3 deletions posawesome/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
40 changes: 39 additions & 1 deletion posawesome/posawesome/api/posapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -444,6 +450,38 @@ 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()


@frappe.whitelist()
def update_invoice(data):
data = json.loads(data)
Expand Down
9 changes: 8 additions & 1 deletion posawesome/public/js/posapp/components/pos/Payments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b71398f

Please sign in to comment.