Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/frappe/erpnext into sale…
Browse files Browse the repository at this point in the history
…s_order_item_dimensions
  • Loading branch information
deepeshgarg007 committed Oct 17, 2023
2 parents e31db18 + f900a78 commit 88be7ad
Show file tree
Hide file tree
Showing 160 changed files with 630 additions and 15,222 deletions.
46 changes: 7 additions & 39 deletions erpnext/accounts/doctype/payment_request/payment_request.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt


import json

import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import flt, get_url, nowdate
from frappe.utils import flt, nowdate
from frappe.utils.background_jobs import enqueue

from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
Expand Down Expand Up @@ -363,33 +359,6 @@ def make_communication_entry(self):
def get_payment_success_url(self):
return self.payment_success_url

def on_payment_authorized(self, status=None):
if not status:
return

shopping_cart_settings = frappe.get_doc("E Commerce Settings")

if status in ["Authorized", "Completed"]:
redirect_to = None
self.set_as_paid()

# if shopping cart enabled and in session
if (
shopping_cart_settings.enabled
and hasattr(frappe.local, "session")
and frappe.local.session.user != "Guest"
) and self.payment_channel != "Phone":

success_url = shopping_cart_settings.payment_success_url
if success_url:
redirect_to = ({"Orders": "/orders", "Invoices": "/invoices", "My Account": "/me"}).get(
success_url, "/me"
)
else:
redirect_to = get_url("/orders/{0}".format(self.reference_name))

return redirect_to

def create_subscription(self, payment_provider, gateway_controller, data):
if payment_provider == "stripe":
with payment_app_import_guard():
Expand Down Expand Up @@ -546,13 +515,12 @@ def get_existing_payment_request_amount(ref_dt, ref_dn):


def get_gateway_details(args): # nosemgrep
"""return gateway and payment account of default payment gateway"""
if args.get("payment_gateway_account"):
return get_payment_gateway_account(args.get("payment_gateway_account"))

if args.order_type == "Shopping Cart":
payment_gateway_account = frappe.get_doc("E Commerce Settings").payment_gateway_account
return get_payment_gateway_account(payment_gateway_account)
"""
Return gateway and payment account of default payment gateway
"""
gateway_account = args.get("payment_gateway_account", {"is_default": 1})
if gateway_account:
return get_payment_gateway_account(gateway_account)

gateway_account = get_payment_gateway_account({"is_default": 1})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def validate_interval_count(self):

@frappe.whitelist()
def get_plan_rate(
plan, quantity=1, customer=None, start_date=None, end_date=None, prorate_factor=1
plan, quantity=1, customer=None, start_date=None, end_date=None, prorate_factor=1, party=None
):
plan = frappe.get_doc("Subscription Plan", plan)
if plan.price_determination == "Fixed Rate":
Expand All @@ -40,6 +40,7 @@ def get_plan_rate(
customer_group=customer_group,
company=None,
qty=quantity,
party=party,
)
if not price:
return 0
Expand Down
18 changes: 1 addition & 17 deletions erpnext/accounts/doctype/tax_rule/tax_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from frappe import _
from frappe.contacts.doctype.address.address import get_default_address
from frappe.model.document import Document
from frappe.utils import cint, cstr
from frappe.utils import cstr
from frappe.utils.nestedset import get_root_of

from erpnext.setup.doctype.customer_group.customer_group import get_parent_customer_groups
Expand All @@ -34,7 +34,6 @@ def validate(self):
self.validate_tax_template()
self.validate_from_to_dates("from_date", "to_date")
self.validate_filters()
self.validate_use_for_shopping_cart()

def validate_tax_template(self):
if self.tax_type == "Sales":
Expand Down Expand Up @@ -106,21 +105,6 @@ def validate_filters(self):
if tax_rule[0].priority == self.priority:
frappe.throw(_("Tax Rule Conflicts with {0}").format(tax_rule[0].name), ConflictingTaxRule)

def validate_use_for_shopping_cart(self):
"""If shopping cart is enabled and no tax rule exists for shopping cart, enable this one"""
if (
not self.use_for_shopping_cart
and cint(frappe.db.get_single_value("E Commerce Settings", "enabled"))
and not frappe.db.get_value("Tax Rule", {"use_for_shopping_cart": 1, "name": ["!=", self.name]})
):

self.use_for_shopping_cart = 1
frappe.msgprint(
_(
"Enabling 'Use for Shopping Cart', as Shopping Cart is enabled and there should be at least one Tax Rule for Shopping Cart"
)
)


@frappe.whitelist()
def get_party_details(party, party_type, args=None):
Expand Down
29 changes: 11 additions & 18 deletions erpnext/controllers/item_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from frappe import _
from frappe.utils import cstr, flt

from erpnext.utilities.product import get_item_codes_by_attributes


class ItemVariantExistsError(frappe.ValidationError):
pass
Expand All @@ -24,7 +26,8 @@ class ItemTemplateCannotHaveStock(frappe.ValidationError):

@frappe.whitelist()
def get_variant(template, args=None, variant=None, manufacturer=None, manufacturer_part_no=None):
"""Validates Attributes and their Values, then looks for an exactly
"""
Validates Attributes and their Values, then looks for an exactly
matching Item Variant
:param item: Template Item
Expand All @@ -34,13 +37,14 @@ def get_variant(template, args=None, variant=None, manufacturer=None, manufactur

if item_template.variant_based_on == "Manufacturer" and manufacturer:
return make_variant_based_on_manufacturer(item_template, manufacturer, manufacturer_part_no)
else:
if isinstance(args, str):
args = json.loads(args)

if not args:
frappe.throw(_("Please specify at least one attribute in the Attributes table"))
return find_variant(template, args, variant)
if isinstance(args, str):
args = json.loads(args)

if not args:
frappe.throw(_("Please specify at least one attribute in the Attributes table"))

return find_variant(template, args, variant)


def make_variant_based_on_manufacturer(template, manufacturer, manufacturer_part_no):
Expand Down Expand Up @@ -157,17 +161,6 @@ def get_attribute_values(item):


def find_variant(template, args, variant_item_code=None):
conditions = [
"""(iv_attribute.attribute={0} and iv_attribute.attribute_value={1})""".format(
frappe.db.escape(key), frappe.db.escape(cstr(value))
)
for key, value in args.items()
]

conditions = " or ".join(conditions)

from erpnext.e_commerce.variant_selector.utils import get_item_codes_by_attributes

possible_variants = [
i for i in get_item_codes_by_attributes(args, template) if i != variant_item_code
]
Expand Down
Empty file removed erpnext/e_commerce/__init__.py
Empty file.
81 changes: 0 additions & 81 deletions erpnext/e_commerce/api.py

This file was deleted.

Empty file.
Empty file.

This file was deleted.

Loading

0 comments on commit 88be7ad

Please sign in to comment.