mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-18 20:49:19 +00:00
Merge branch 'version-13-pre-release' into version-13
This commit is contained in:
@@ -7,7 +7,7 @@ import frappe
|
|||||||
|
|
||||||
from erpnext.hooks import regional_overrides
|
from erpnext.hooks import regional_overrides
|
||||||
|
|
||||||
__version__ = '13.14.1'
|
__version__ = '13.15.0'
|
||||||
|
|
||||||
def get_default_company(user=None):
|
def get_default_company(user=None):
|
||||||
'''Get default company for user'''
|
'''Get default company for user'''
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ frappe.ui.form.on('Accounting Dimension Filter', {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let help_content =
|
let help_content =
|
||||||
`<table class="table table-bordered" style="background-color: #f9f9f9;">
|
`<table class="table table-bordered" style="background-color: var(--scrollbar-track-color);">
|
||||||
<tr><td>
|
<tr><td>
|
||||||
<p>
|
<p>
|
||||||
<i class="fa fa-hand-right"></i>
|
<i class="fa fa-hand-right"></i>
|
||||||
|
|||||||
@@ -344,7 +344,15 @@ def get_pe_matching_query(amount_condition, account_from_to, transaction):
|
|||||||
|
|
||||||
def get_je_matching_query(amount_condition, transaction):
|
def get_je_matching_query(amount_condition, transaction):
|
||||||
# get matching journal entry query
|
# get matching journal entry query
|
||||||
cr_or_dr = "credit" if transaction.withdrawal > 0 else "debit"
|
|
||||||
|
company_account = frappe.get_value("Bank Account", transaction.bank_account, "account")
|
||||||
|
root_type = frappe.get_value("Account", company_account, "root_type")
|
||||||
|
|
||||||
|
if root_type == "Liability":
|
||||||
|
cr_or_dr = "debit" if transaction.withdrawal > 0 else "credit"
|
||||||
|
else:
|
||||||
|
cr_or_dr = "credit" if transaction.withdrawal > 0 else "debit"
|
||||||
|
|
||||||
return f"""
|
return f"""
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ frappe.provide("erpnext.accounts.dimensions");
|
|||||||
frappe.ui.form.on('Loyalty Program', {
|
frappe.ui.form.on('Loyalty Program', {
|
||||||
setup: function(frm) {
|
setup: function(frm) {
|
||||||
var help_content =
|
var help_content =
|
||||||
`<table class="table table-bordered" style="background-color: #f9f9f9;">
|
`<table class="table table-bordered" style="background-color: var(--scrollbar-track-color);">
|
||||||
<tr><td>
|
<tr><td>
|
||||||
<h4>
|
<h4>
|
||||||
<i class="fa fa-hand-right"></i>
|
<i class="fa fa-hand-right"></i>
|
||||||
|
|||||||
@@ -113,9 +113,15 @@ class POSInvoiceMergeLog(Document):
|
|||||||
|
|
||||||
def merge_pos_invoice_into(self, invoice, data):
|
def merge_pos_invoice_into(self, invoice, data):
|
||||||
items, payments, taxes = [], [], []
|
items, payments, taxes = [], [], []
|
||||||
|
|
||||||
loyalty_amount_sum, loyalty_points_sum = 0, 0
|
loyalty_amount_sum, loyalty_points_sum = 0, 0
|
||||||
|
|
||||||
rounding_adjustment, base_rounding_adjustment = 0, 0
|
rounding_adjustment, base_rounding_adjustment = 0, 0
|
||||||
rounded_total, base_rounded_total = 0, 0
|
rounded_total, base_rounded_total = 0, 0
|
||||||
|
|
||||||
|
loyalty_amount_sum, loyalty_points_sum, idx = 0, 0, 1
|
||||||
|
|
||||||
|
|
||||||
for doc in data:
|
for doc in data:
|
||||||
map_doc(doc, invoice, table_map={ "doctype": invoice.doctype })
|
map_doc(doc, invoice, table_map={ "doctype": invoice.doctype })
|
||||||
|
|
||||||
@@ -149,6 +155,8 @@ class POSInvoiceMergeLog(Document):
|
|||||||
found = True
|
found = True
|
||||||
if not found:
|
if not found:
|
||||||
tax.charge_type = 'Actual'
|
tax.charge_type = 'Actual'
|
||||||
|
tax.idx = idx
|
||||||
|
idx += 1
|
||||||
tax.included_in_print_rate = 0
|
tax.included_in_print_rate = 0
|
||||||
tax.tax_amount = tax.tax_amount_after_discount_amount
|
tax.tax_amount = tax.tax_amount_after_discount_amount
|
||||||
tax.base_tax_amount = tax.base_tax_amount_after_discount_amount
|
tax.base_tax_amount = tax.base_tax_amount_after_discount_amount
|
||||||
@@ -166,8 +174,8 @@ class POSInvoiceMergeLog(Document):
|
|||||||
payments.append(payment)
|
payments.append(payment)
|
||||||
rounding_adjustment += doc.rounding_adjustment
|
rounding_adjustment += doc.rounding_adjustment
|
||||||
rounded_total += doc.rounded_total
|
rounded_total += doc.rounded_total
|
||||||
base_rounding_adjustment += doc.rounding_adjustment
|
base_rounding_adjustment += doc.base_rounding_adjustment
|
||||||
base_rounded_total += doc.rounded_total
|
base_rounded_total += doc.base_rounded_total
|
||||||
|
|
||||||
|
|
||||||
if loyalty_points_sum:
|
if loyalty_points_sum:
|
||||||
@@ -179,9 +187,9 @@ class POSInvoiceMergeLog(Document):
|
|||||||
invoice.set('payments', payments)
|
invoice.set('payments', payments)
|
||||||
invoice.set('taxes', taxes)
|
invoice.set('taxes', taxes)
|
||||||
invoice.set('rounding_adjustment',rounding_adjustment)
|
invoice.set('rounding_adjustment',rounding_adjustment)
|
||||||
invoice.set('rounding_adjustment',base_rounding_adjustment)
|
invoice.set('base_rounding_adjustment',base_rounding_adjustment)
|
||||||
invoice.set('base_rounded_total',base_rounded_total)
|
|
||||||
invoice.set('rounded_total',rounded_total)
|
invoice.set('rounded_total',rounded_total)
|
||||||
|
invoice.set('base_rounded_total',base_rounded_total)
|
||||||
invoice.additional_discount_percentage = 0
|
invoice.additional_discount_percentage = 0
|
||||||
invoice.discount_amount = 0.0
|
invoice.discount_amount = 0.0
|
||||||
invoice.taxes_and_charges = None
|
invoice.taxes_and_charges = None
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ frappe.ui.form.on('Pricing Rule', {
|
|||||||
|
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
var help_content =
|
var help_content =
|
||||||
`<table class="table table-bordered" style="background-color: #f9f9f9;">
|
`<table class="table table-bordered" style="background-color: var(--scrollbar-track-color);">
|
||||||
<tr><td>
|
<tr><td>
|
||||||
<h4>
|
<h4>
|
||||||
<i class="fa fa-hand-right"></i>
|
<i class="fa fa-hand-right"></i>
|
||||||
|
|||||||
@@ -546,6 +546,75 @@ class TestPricingRule(unittest.TestCase):
|
|||||||
frappe.get_doc("Item Price", {"item_code": "Water Flask"}).delete()
|
frappe.get_doc("Item Price", {"item_code": "Water Flask"}).delete()
|
||||||
item.delete()
|
item.delete()
|
||||||
|
|
||||||
|
def test_pricing_rule_for_different_currency(self):
|
||||||
|
make_item("Test Sanitizer Item")
|
||||||
|
|
||||||
|
pricing_rule_record = {
|
||||||
|
"doctype": "Pricing Rule",
|
||||||
|
"title": "_Test Sanitizer Rule",
|
||||||
|
"apply_on": "Item Code",
|
||||||
|
"items": [{
|
||||||
|
"item_code": "Test Sanitizer Item",
|
||||||
|
}],
|
||||||
|
"selling": 1,
|
||||||
|
"currency": "INR",
|
||||||
|
"rate_or_discount": "Rate",
|
||||||
|
"rate": 0,
|
||||||
|
"priority": 2,
|
||||||
|
"margin_type": "Percentage",
|
||||||
|
"margin_rate_or_amount": 0.0,
|
||||||
|
"company": "_Test Company"
|
||||||
|
}
|
||||||
|
|
||||||
|
rule = frappe.get_doc(pricing_rule_record)
|
||||||
|
rule.rate_or_discount = 'Rate'
|
||||||
|
rule.rate = 100.0
|
||||||
|
rule.insert()
|
||||||
|
|
||||||
|
rule1 = frappe.get_doc(pricing_rule_record)
|
||||||
|
rule1.currency = 'USD'
|
||||||
|
rule1.rate_or_discount = 'Rate'
|
||||||
|
rule1.rate = 2.0
|
||||||
|
rule1.priority = 1
|
||||||
|
rule1.insert()
|
||||||
|
|
||||||
|
args = frappe._dict({
|
||||||
|
"item_code": "Test Sanitizer Item",
|
||||||
|
"company": "_Test Company",
|
||||||
|
"price_list": "_Test Price List",
|
||||||
|
"currency": "USD",
|
||||||
|
"doctype": "Sales Invoice",
|
||||||
|
"conversion_rate": 1,
|
||||||
|
"price_list_currency": "_Test Currency",
|
||||||
|
"plc_conversion_rate": 1,
|
||||||
|
"order_type": "Sales",
|
||||||
|
"customer": "_Test Customer",
|
||||||
|
"name": None,
|
||||||
|
"transaction_date": frappe.utils.nowdate()
|
||||||
|
})
|
||||||
|
|
||||||
|
details = get_item_details(args)
|
||||||
|
self.assertEqual(details.price_list_rate, 2.0)
|
||||||
|
|
||||||
|
|
||||||
|
args = frappe._dict({
|
||||||
|
"item_code": "Test Sanitizer Item",
|
||||||
|
"company": "_Test Company",
|
||||||
|
"price_list": "_Test Price List",
|
||||||
|
"currency": "INR",
|
||||||
|
"doctype": "Sales Invoice",
|
||||||
|
"conversion_rate": 1,
|
||||||
|
"price_list_currency": "_Test Currency",
|
||||||
|
"plc_conversion_rate": 1,
|
||||||
|
"order_type": "Sales",
|
||||||
|
"customer": "_Test Customer",
|
||||||
|
"name": None,
|
||||||
|
"transaction_date": frappe.utils.nowdate()
|
||||||
|
})
|
||||||
|
|
||||||
|
details = get_item_details(args)
|
||||||
|
self.assertEqual(details.price_list_rate, 100.0)
|
||||||
|
|
||||||
def test_pricing_rule_for_transaction(self):
|
def test_pricing_rule_for_transaction(self):
|
||||||
make_item("Water Flask 1")
|
make_item("Water Flask 1")
|
||||||
frappe.delete_doc_if_exists('Pricing Rule', '_Test Pricing Rule')
|
frappe.delete_doc_if_exists('Pricing Rule', '_Test Pricing Rule')
|
||||||
|
|||||||
@@ -265,6 +265,11 @@ def filter_pricing_rules(args, pricing_rules, doc=None):
|
|||||||
else:
|
else:
|
||||||
p.variant_of = None
|
p.variant_of = None
|
||||||
|
|
||||||
|
if len(pricing_rules) > 1:
|
||||||
|
filtered_rules = list(filter(lambda x: x.currency==args.get('currency'), pricing_rules))
|
||||||
|
if filtered_rules:
|
||||||
|
pricing_rules = filtered_rules
|
||||||
|
|
||||||
# find pricing rule with highest priority
|
# find pricing rule with highest priority
|
||||||
if pricing_rules:
|
if pricing_rules:
|
||||||
max_priority = max(cint(p.priority) for p in pricing_rules)
|
max_priority = max(cint(p.priority) for p in pricing_rules)
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ price_discount_fields = ['rate_or_discount', 'apply_discount_on', 'apply_discoun
|
|||||||
product_discount_fields = ['free_item', 'free_qty', 'free_item_uom',
|
product_discount_fields = ['free_item', 'free_qty', 'free_item_uom',
|
||||||
'free_item_rate', 'same_item', 'is_recursive', 'apply_multiple_pricing_rules']
|
'free_item_rate', 'same_item', 'is_recursive', 'apply_multiple_pricing_rules']
|
||||||
|
|
||||||
|
class TransactionExists(frappe.ValidationError):
|
||||||
|
pass
|
||||||
|
|
||||||
class PromotionalScheme(Document):
|
class PromotionalScheme(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
if not self.selling and not self.buying:
|
if not self.selling and not self.buying:
|
||||||
@@ -30,6 +33,40 @@ class PromotionalScheme(Document):
|
|||||||
or self.product_discount_slabs):
|
or self.product_discount_slabs):
|
||||||
frappe.throw(_("Price or product discount slabs are required"))
|
frappe.throw(_("Price or product discount slabs are required"))
|
||||||
|
|
||||||
|
self.validate_applicable_for()
|
||||||
|
self.validate_pricing_rules()
|
||||||
|
|
||||||
|
def validate_applicable_for(self):
|
||||||
|
if self.applicable_for:
|
||||||
|
applicable_for = frappe.scrub(self.applicable_for)
|
||||||
|
|
||||||
|
if not self.get(applicable_for):
|
||||||
|
msg = (f'The field {frappe.bold(self.applicable_for)} is required')
|
||||||
|
frappe.throw(_(msg))
|
||||||
|
|
||||||
|
def validate_pricing_rules(self):
|
||||||
|
if self.is_new():
|
||||||
|
return
|
||||||
|
|
||||||
|
transaction_exists = False
|
||||||
|
docnames = []
|
||||||
|
|
||||||
|
# If user has changed applicable for
|
||||||
|
if self._doc_before_save.applicable_for == self.applicable_for:
|
||||||
|
return
|
||||||
|
|
||||||
|
docnames = frappe.get_all('Pricing Rule',
|
||||||
|
filters= {'promotional_scheme': self.name})
|
||||||
|
|
||||||
|
for docname in docnames:
|
||||||
|
if frappe.db.exists('Pricing Rule Detail',
|
||||||
|
{'pricing_rule': docname.name, 'docstatus': ('<', 2)}):
|
||||||
|
raise_for_transaction_exists(self.name)
|
||||||
|
|
||||||
|
if docnames and not transaction_exists:
|
||||||
|
for docname in docnames:
|
||||||
|
frappe.delete_doc('Pricing Rule', docname.name)
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
pricing_rules = frappe.get_all(
|
pricing_rules = frappe.get_all(
|
||||||
'Pricing Rule',
|
'Pricing Rule',
|
||||||
@@ -69,6 +106,13 @@ class PromotionalScheme(Document):
|
|||||||
{'promotional_scheme': self.name}):
|
{'promotional_scheme': self.name}):
|
||||||
frappe.delete_doc('Pricing Rule', rule.name)
|
frappe.delete_doc('Pricing Rule', rule.name)
|
||||||
|
|
||||||
|
def raise_for_transaction_exists(name):
|
||||||
|
msg = (f"""You can't change the {frappe.bold(_('Applicable For'))}
|
||||||
|
because transactions are present against the Promotional Scheme {frappe.bold(name)}. """)
|
||||||
|
msg += 'Kindly disable this Promotional Scheme and create new for new Applicable For.'
|
||||||
|
|
||||||
|
frappe.throw(_(msg), TransactionExists)
|
||||||
|
|
||||||
def get_pricing_rules(doc, rules=None):
|
def get_pricing_rules(doc, rules=None):
|
||||||
if rules is None:
|
if rules is None:
|
||||||
rules = {}
|
rules = {}
|
||||||
@@ -86,45 +130,59 @@ def _get_pricing_rules(doc, child_doc, discount_fields, rules=None):
|
|||||||
new_doc = []
|
new_doc = []
|
||||||
args = get_args_for_pricing_rule(doc)
|
args = get_args_for_pricing_rule(doc)
|
||||||
applicable_for = frappe.scrub(doc.get('applicable_for'))
|
applicable_for = frappe.scrub(doc.get('applicable_for'))
|
||||||
|
|
||||||
for idx, d in enumerate(doc.get(child_doc)):
|
for idx, d in enumerate(doc.get(child_doc)):
|
||||||
if d.name in rules:
|
if d.name in rules:
|
||||||
for applicable_for_value in args.get(applicable_for):
|
if not args.get(applicable_for):
|
||||||
temp_args = args.copy()
|
docname = get_pricing_rule_docname(d)
|
||||||
docname = frappe.get_all(
|
pr = prepare_pricing_rule(args, doc, child_doc, discount_fields, d, docname)
|
||||||
'Pricing Rule',
|
|
||||||
fields = ["promotional_scheme_id", "name", applicable_for],
|
|
||||||
filters = {
|
|
||||||
'promotional_scheme_id': d.name,
|
|
||||||
applicable_for: applicable_for_value
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
if docname:
|
|
||||||
pr = frappe.get_doc('Pricing Rule', docname[0].get('name'))
|
|
||||||
temp_args[applicable_for] = applicable_for_value
|
|
||||||
pr = set_args(temp_args, pr, doc, child_doc, discount_fields, d)
|
|
||||||
else:
|
|
||||||
pr = frappe.new_doc("Pricing Rule")
|
|
||||||
pr.title = doc.name
|
|
||||||
temp_args[applicable_for] = applicable_for_value
|
|
||||||
pr = set_args(temp_args, pr, doc, child_doc, discount_fields, d)
|
|
||||||
|
|
||||||
new_doc.append(pr)
|
new_doc.append(pr)
|
||||||
|
else:
|
||||||
|
for applicable_for_value in args.get(applicable_for):
|
||||||
|
docname = get_pricing_rule_docname(d, applicable_for, applicable_for_value)
|
||||||
|
pr = prepare_pricing_rule(args, doc, child_doc, discount_fields,
|
||||||
|
d, docname, applicable_for, applicable_for_value)
|
||||||
|
new_doc.append(pr)
|
||||||
|
|
||||||
else:
|
elif args.get(applicable_for):
|
||||||
applicable_for_values = args.get(applicable_for) or []
|
applicable_for_values = args.get(applicable_for) or []
|
||||||
for applicable_for_value in applicable_for_values:
|
for applicable_for_value in applicable_for_values:
|
||||||
pr = frappe.new_doc("Pricing Rule")
|
pr = prepare_pricing_rule(args, doc, child_doc, discount_fields,
|
||||||
pr.title = doc.name
|
d, applicable_for=applicable_for, value= applicable_for_value)
|
||||||
temp_args = args.copy()
|
|
||||||
temp_args[applicable_for] = applicable_for_value
|
|
||||||
pr = set_args(temp_args, pr, doc, child_doc, discount_fields, d)
|
|
||||||
new_doc.append(pr)
|
new_doc.append(pr)
|
||||||
|
else:
|
||||||
|
pr = prepare_pricing_rule(args, doc, child_doc, discount_fields, d)
|
||||||
|
new_doc.append(pr)
|
||||||
|
|
||||||
return new_doc
|
return new_doc
|
||||||
|
|
||||||
|
def get_pricing_rule_docname(row: dict, applicable_for: str = None, applicable_for_value: str = None) -> str:
|
||||||
|
fields = ['promotional_scheme_id', 'name']
|
||||||
|
filters = {
|
||||||
|
'promotional_scheme_id': row.name
|
||||||
|
}
|
||||||
|
|
||||||
|
if applicable_for:
|
||||||
|
fields.append(applicable_for)
|
||||||
|
filters[applicable_for] = applicable_for_value
|
||||||
|
|
||||||
|
docname = frappe.get_all('Pricing Rule', fields = fields, filters = filters)
|
||||||
|
return docname[0].name if docname else ''
|
||||||
|
|
||||||
|
def prepare_pricing_rule(args, doc, child_doc, discount_fields, d, docname=None, applicable_for=None, value=None):
|
||||||
|
if docname:
|
||||||
|
pr = frappe.get_doc("Pricing Rule", docname)
|
||||||
|
else:
|
||||||
|
pr = frappe.new_doc("Pricing Rule")
|
||||||
|
|
||||||
|
pr.title = doc.name
|
||||||
|
temp_args = args.copy()
|
||||||
|
|
||||||
|
if value:
|
||||||
|
temp_args[applicable_for] = value
|
||||||
|
|
||||||
|
return set_args(temp_args, pr, doc, child_doc, discount_fields, d)
|
||||||
|
|
||||||
def set_args(args, pr, doc, child_doc, discount_fields, child_doc_fields):
|
def set_args(args, pr, doc, child_doc, discount_fields, child_doc_fields):
|
||||||
pr.update(args)
|
pr.update(args)
|
||||||
@@ -147,6 +205,7 @@ def set_args(args, pr, doc, child_doc, discount_fields, child_doc_fields):
|
|||||||
apply_on: d.get(apply_on),
|
apply_on: d.get(apply_on),
|
||||||
'uom': d.uom
|
'uom': d.uom
|
||||||
})
|
})
|
||||||
|
|
||||||
return pr
|
return pr
|
||||||
|
|
||||||
def get_args_for_pricing_rule(doc):
|
def get_args_for_pricing_rule(doc):
|
||||||
|
|||||||
@@ -7,10 +7,17 @@ import unittest
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
|
from erpnext.accounts.doctype.promotional_scheme.promotional_scheme import TransactionExists
|
||||||
|
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||||
|
|
||||||
|
|
||||||
class TestPromotionalScheme(unittest.TestCase):
|
class TestPromotionalScheme(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
if frappe.db.exists('Promotional Scheme', '_Test Scheme'):
|
||||||
|
frappe.delete_doc('Promotional Scheme', '_Test Scheme')
|
||||||
|
|
||||||
def test_promotional_scheme(self):
|
def test_promotional_scheme(self):
|
||||||
ps = make_promotional_scheme()
|
ps = make_promotional_scheme(applicable_for='Customer', customer='_Test Customer')
|
||||||
price_rules = frappe.get_all('Pricing Rule', fields = ["promotional_scheme_id", "name", "creation"],
|
price_rules = frappe.get_all('Pricing Rule', fields = ["promotional_scheme_id", "name", "creation"],
|
||||||
filters = {'promotional_scheme': ps.name})
|
filters = {'promotional_scheme': ps.name})
|
||||||
self.assertTrue(len(price_rules),1)
|
self.assertTrue(len(price_rules),1)
|
||||||
@@ -41,22 +48,62 @@ class TestPromotionalScheme(unittest.TestCase):
|
|||||||
filters = {'promotional_scheme': ps.name})
|
filters = {'promotional_scheme': ps.name})
|
||||||
self.assertEqual(price_rules, [])
|
self.assertEqual(price_rules, [])
|
||||||
|
|
||||||
def make_promotional_scheme():
|
def test_promotional_scheme_without_applicable_for(self):
|
||||||
|
ps = make_promotional_scheme()
|
||||||
|
price_rules = frappe.get_all('Pricing Rule', filters = {'promotional_scheme': ps.name})
|
||||||
|
|
||||||
|
self.assertTrue(len(price_rules), 1)
|
||||||
|
frappe.delete_doc('Promotional Scheme', ps.name)
|
||||||
|
|
||||||
|
price_rules = frappe.get_all('Pricing Rule', filters = {'promotional_scheme': ps.name})
|
||||||
|
self.assertEqual(price_rules, [])
|
||||||
|
|
||||||
|
def test_change_applicable_for_in_promotional_scheme(self):
|
||||||
|
ps = make_promotional_scheme()
|
||||||
|
price_rules = frappe.get_all('Pricing Rule', filters = {'promotional_scheme': ps.name})
|
||||||
|
self.assertTrue(len(price_rules), 1)
|
||||||
|
|
||||||
|
so = make_sales_order(qty=5, currency='USD', do_not_save=True)
|
||||||
|
so.set_missing_values()
|
||||||
|
so.save()
|
||||||
|
self.assertEqual(price_rules[0].name, so.pricing_rules[0].pricing_rule)
|
||||||
|
|
||||||
|
ps.applicable_for = 'Customer'
|
||||||
|
ps.append('customer', {
|
||||||
|
'customer': '_Test Customer'
|
||||||
|
})
|
||||||
|
|
||||||
|
self.assertRaises(TransactionExists, ps.save)
|
||||||
|
|
||||||
|
frappe.delete_doc('Sales Order', so.name)
|
||||||
|
frappe.delete_doc('Promotional Scheme', ps.name)
|
||||||
|
price_rules = frappe.get_all('Pricing Rule', filters = {'promotional_scheme': ps.name})
|
||||||
|
self.assertEqual(price_rules, [])
|
||||||
|
|
||||||
|
def make_promotional_scheme(**args):
|
||||||
|
args = frappe._dict(args)
|
||||||
|
|
||||||
ps = frappe.new_doc('Promotional Scheme')
|
ps = frappe.new_doc('Promotional Scheme')
|
||||||
ps.name = '_Test Scheme'
|
ps.name = '_Test Scheme'
|
||||||
ps.append('items',{
|
ps.append('items',{
|
||||||
'item_code': '_Test Item'
|
'item_code': '_Test Item'
|
||||||
})
|
})
|
||||||
|
|
||||||
ps.selling = 1
|
ps.selling = 1
|
||||||
ps.append('price_discount_slabs',{
|
ps.append('price_discount_slabs',{
|
||||||
'min_qty': 4,
|
'min_qty': 4,
|
||||||
|
'validate_applied_rule': 0,
|
||||||
'discount_percentage': 20,
|
'discount_percentage': 20,
|
||||||
'rule_description': 'Test'
|
'rule_description': 'Test'
|
||||||
})
|
})
|
||||||
ps.applicable_for = 'Customer'
|
|
||||||
ps.append('customer',{
|
ps.company = '_Test Company'
|
||||||
'customer': "_Test Customer"
|
if args.applicable_for:
|
||||||
})
|
ps.applicable_for = args.applicable_for
|
||||||
|
ps.append(frappe.scrub(args.applicable_for), {
|
||||||
|
frappe.scrub(args.applicable_for): args.get(frappe.scrub(args.applicable_for))
|
||||||
|
})
|
||||||
|
|
||||||
ps.save()
|
ps.save()
|
||||||
|
|
||||||
return ps
|
return ps
|
||||||
|
|||||||
@@ -136,7 +136,7 @@
|
|||||||
"label": "Threshold for Suggestion"
|
"label": "Threshold for Suggestion"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "1",
|
"default": "0",
|
||||||
"fieldname": "validate_applied_rule",
|
"fieldname": "validate_applied_rule",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Validate Applied Rule"
|
"label": "Validate Applied Rule"
|
||||||
@@ -169,7 +169,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-08-19 15:49:29.598727",
|
"modified": "2021-11-16 00:25:33.843996",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Promotional Scheme Price Discount",
|
"name": "Promotional Scheme Price Discount",
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ def _get_party_details(party=None, account=None, party_type="Customer", company=
|
|||||||
if party_type=="Customer":
|
if party_type=="Customer":
|
||||||
party_details["sales_team"] = [{
|
party_details["sales_team"] = [{
|
||||||
"sales_person": d.sales_person,
|
"sales_person": d.sales_person,
|
||||||
"allocated_percentage": d.allocated_percentage or None
|
"allocated_percentage": d.allocated_percentage or None,
|
||||||
|
"commission_rate": d.commission_rate
|
||||||
} for d in party.get("sales_team")]
|
} for d in party.get("sales_team")]
|
||||||
|
|
||||||
# supplier tax withholding category
|
# supplier tax withholding category
|
||||||
|
|||||||
@@ -425,8 +425,7 @@ def set_gl_entries_by_account(
|
|||||||
{additional_conditions}
|
{additional_conditions}
|
||||||
and posting_date <= %(to_date)s
|
and posting_date <= %(to_date)s
|
||||||
and is_cancelled = 0
|
and is_cancelled = 0
|
||||||
{distributed_cost_center_query}
|
{distributed_cost_center_query}""".format(
|
||||||
order by account, posting_date""".format(
|
|
||||||
additional_conditions=additional_conditions,
|
additional_conditions=additional_conditions,
|
||||||
distributed_cost_center_query=distributed_cost_center_query), gl_filters, as_dict=True) #nosec
|
distributed_cost_center_query=distributed_cost_center_query), gl_filters, as_dict=True) #nosec
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from collections import OrderedDict
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _, _dict
|
from frappe import _, _dict
|
||||||
from frappe.utils import cstr, flt, getdate
|
from frappe.utils import cstr, getdate
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
|
|
||||||
from erpnext import get_company_currency, get_default_company
|
from erpnext import get_company_currency, get_default_company
|
||||||
@@ -19,6 +19,8 @@ from erpnext.accounts.report.financial_statements import get_cost_centers_with_c
|
|||||||
from erpnext.accounts.report.utils import convert_to_presentation_currency, get_currency
|
from erpnext.accounts.report.utils import convert_to_presentation_currency, get_currency
|
||||||
from erpnext.accounts.utils import get_account_currency
|
from erpnext.accounts.utils import get_account_currency
|
||||||
|
|
||||||
|
# to cache translations
|
||||||
|
TRANSLATIONS = frappe._dict()
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
if not filters:
|
if not filters:
|
||||||
@@ -44,10 +46,20 @@ def execute(filters=None):
|
|||||||
|
|
||||||
columns = get_columns(filters)
|
columns = get_columns(filters)
|
||||||
|
|
||||||
|
update_translations()
|
||||||
|
|
||||||
res = get_result(filters, account_details)
|
res = get_result(filters, account_details)
|
||||||
|
|
||||||
return columns, res
|
return columns, res
|
||||||
|
|
||||||
|
def update_translations():
|
||||||
|
TRANSLATIONS.update(
|
||||||
|
dict(
|
||||||
|
OPENING = _('Opening'),
|
||||||
|
TOTAL = _('Total'),
|
||||||
|
CLOSING_TOTAL = _('Closing (Opening + Total)')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def validate_filters(filters, account_details):
|
def validate_filters(filters, account_details):
|
||||||
if not filters.get("company"):
|
if not filters.get("company"):
|
||||||
@@ -353,9 +365,9 @@ def get_totals_dict():
|
|||||||
credit_in_account_currency=0.0
|
credit_in_account_currency=0.0
|
||||||
)
|
)
|
||||||
return _dict(
|
return _dict(
|
||||||
opening = _get_debit_credit_dict(_('Opening')),
|
opening = _get_debit_credit_dict(TRANSLATIONS.OPENING),
|
||||||
total = _get_debit_credit_dict(_('Total')),
|
total = _get_debit_credit_dict(TRANSLATIONS.TOTAL),
|
||||||
closing = _get_debit_credit_dict(_('Closing (Opening + Total)'))
|
closing = _get_debit_credit_dict(TRANSLATIONS.CLOSING_TOTAL)
|
||||||
)
|
)
|
||||||
|
|
||||||
def group_by_field(group_by):
|
def group_by_field(group_by):
|
||||||
@@ -380,22 +392,23 @@ def get_accountwise_gle(filters, accounting_dimensions, gl_entries, gle_map):
|
|||||||
entries = []
|
entries = []
|
||||||
consolidated_gle = OrderedDict()
|
consolidated_gle = OrderedDict()
|
||||||
group_by = group_by_field(filters.get('group_by'))
|
group_by = group_by_field(filters.get('group_by'))
|
||||||
|
group_by_voucher_consolidated = filters.get("group_by") == 'Group by Voucher (Consolidated)'
|
||||||
|
|
||||||
if filters.get('show_net_values_in_party_account'):
|
if filters.get('show_net_values_in_party_account'):
|
||||||
account_type_map = get_account_type_map(filters.get('company'))
|
account_type_map = get_account_type_map(filters.get('company'))
|
||||||
|
|
||||||
def update_value_in_dict(data, key, gle):
|
def update_value_in_dict(data, key, gle):
|
||||||
data[key].debit += flt(gle.debit)
|
data[key].debit += gle.debit
|
||||||
data[key].credit += flt(gle.credit)
|
data[key].credit += gle.credit
|
||||||
|
|
||||||
data[key].debit_in_account_currency += flt(gle.debit_in_account_currency)
|
data[key].debit_in_account_currency += gle.debit_in_account_currency
|
||||||
data[key].credit_in_account_currency += flt(gle.credit_in_account_currency)
|
data[key].credit_in_account_currency += gle.credit_in_account_currency
|
||||||
|
|
||||||
if filters.get('show_net_values_in_party_account') and \
|
if filters.get('show_net_values_in_party_account') and \
|
||||||
account_type_map.get(data[key].account) in ('Receivable', 'Payable'):
|
account_type_map.get(data[key].account) in ('Receivable', 'Payable'):
|
||||||
net_value = flt(data[key].debit) - flt(data[key].credit)
|
net_value = data[key].debit - data[key].credit
|
||||||
net_value_in_account_currency = flt(data[key].debit_in_account_currency) \
|
net_value_in_account_currency = data[key].debit_in_account_currency \
|
||||||
- flt(data[key].credit_in_account_currency)
|
- data[key].credit_in_account_currency
|
||||||
|
|
||||||
if net_value < 0:
|
if net_value < 0:
|
||||||
dr_or_cr = 'credit'
|
dr_or_cr = 'credit'
|
||||||
@@ -413,19 +426,29 @@ def get_accountwise_gle(filters, accounting_dimensions, gl_entries, gle_map):
|
|||||||
data[key].against_voucher += ', ' + gle.against_voucher
|
data[key].against_voucher += ', ' + gle.against_voucher
|
||||||
|
|
||||||
from_date, to_date = getdate(filters.from_date), getdate(filters.to_date)
|
from_date, to_date = getdate(filters.from_date), getdate(filters.to_date)
|
||||||
for gle in gl_entries:
|
show_opening_entries = filters.get("show_opening_entries")
|
||||||
if (gle.posting_date < from_date or
|
|
||||||
(cstr(gle.is_opening) == "Yes" and not filters.get("show_opening_entries"))):
|
|
||||||
update_value_in_dict(gle_map[gle.get(group_by)].totals, 'opening', gle)
|
|
||||||
update_value_in_dict(totals, 'opening', gle)
|
|
||||||
|
|
||||||
update_value_in_dict(gle_map[gle.get(group_by)].totals, 'closing', gle)
|
for gle in gl_entries:
|
||||||
|
group_by_value = gle.get(group_by)
|
||||||
|
|
||||||
|
if (gle.posting_date < from_date or (cstr(gle.is_opening) == "Yes" and not show_opening_entries)):
|
||||||
|
if not group_by_voucher_consolidated:
|
||||||
|
update_value_in_dict(gle_map[group_by_value].totals, 'opening', gle)
|
||||||
|
update_value_in_dict(gle_map[group_by_value].totals, 'closing', gle)
|
||||||
|
|
||||||
|
update_value_in_dict(totals, 'opening', gle)
|
||||||
update_value_in_dict(totals, 'closing', gle)
|
update_value_in_dict(totals, 'closing', gle)
|
||||||
|
|
||||||
elif gle.posting_date <= to_date:
|
elif gle.posting_date <= to_date:
|
||||||
if filters.get("group_by") != 'Group by Voucher (Consolidated)':
|
if not group_by_voucher_consolidated:
|
||||||
gle_map[gle.get(group_by)].entries.append(gle)
|
update_value_in_dict(gle_map[group_by_value].totals, 'total', gle)
|
||||||
elif filters.get("group_by") == 'Group by Voucher (Consolidated)':
|
update_value_in_dict(gle_map[group_by_value].totals, 'closing', gle)
|
||||||
|
update_value_in_dict(totals, 'total', gle)
|
||||||
|
update_value_in_dict(totals, 'closing', gle)
|
||||||
|
|
||||||
|
gle_map[group_by_value].entries.append(gle)
|
||||||
|
|
||||||
|
elif group_by_voucher_consolidated:
|
||||||
keylist = [gle.get("voucher_type"), gle.get("voucher_no"), gle.get("account")]
|
keylist = [gle.get("voucher_type"), gle.get("voucher_no"), gle.get("account")]
|
||||||
for dim in accounting_dimensions:
|
for dim in accounting_dimensions:
|
||||||
keylist.append(gle.get(dim))
|
keylist.append(gle.get(dim))
|
||||||
@@ -437,9 +460,7 @@ def get_accountwise_gle(filters, accounting_dimensions, gl_entries, gle_map):
|
|||||||
update_value_in_dict(consolidated_gle, key, gle)
|
update_value_in_dict(consolidated_gle, key, gle)
|
||||||
|
|
||||||
for key, value in consolidated_gle.items():
|
for key, value in consolidated_gle.items():
|
||||||
update_value_in_dict(gle_map[value.get(group_by)].totals, 'total', value)
|
|
||||||
update_value_in_dict(totals, 'total', value)
|
update_value_in_dict(totals, 'total', value)
|
||||||
update_value_in_dict(gle_map[value.get(group_by)].totals, 'closing', value)
|
|
||||||
update_value_in_dict(totals, 'closing', value)
|
update_value_in_dict(totals, 'closing', value)
|
||||||
entries.append(value)
|
entries.append(value)
|
||||||
|
|
||||||
|
|||||||
@@ -1,184 +1,70 @@
|
|||||||
{
|
{
|
||||||
"allow_copy": 0,
|
"actions": [],
|
||||||
"allow_guest_to_view": 0,
|
"allow_rename": 1,
|
||||||
"allow_import": 0,
|
"autoname": "field:criteria_name",
|
||||||
"allow_rename": 0,
|
"creation": "2017-05-29 01:32:43.064891",
|
||||||
"autoname": "field:criteria_name",
|
"doctype": "DocType",
|
||||||
"beta": 0,
|
"editable_grid": 1,
|
||||||
"creation": "2017-05-29 01:32:43.064891",
|
"engine": "InnoDB",
|
||||||
"custom": 0,
|
"field_order": [
|
||||||
"docstatus": 0,
|
"criteria_name",
|
||||||
"doctype": "DocType",
|
"max_score",
|
||||||
"document_type": "",
|
"formula",
|
||||||
"editable_grid": 1,
|
"weight"
|
||||||
"engine": "InnoDB",
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"fieldname": "criteria_name",
|
||||||
"allow_on_submit": 0,
|
"fieldtype": "Data",
|
||||||
"bold": 0,
|
"label": "Criteria Name",
|
||||||
"collapsible": 0,
|
"reqd": 1,
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "criteria_name",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Criteria Name",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"unique": 1
|
"unique": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"default": "100",
|
||||||
"allow_on_submit": 0,
|
"fieldname": "max_score",
|
||||||
"bold": 0,
|
"fieldtype": "Float",
|
||||||
"collapsible": 0,
|
"in_list_view": 1,
|
||||||
"columns": 0,
|
"label": "Max Score",
|
||||||
"default": "100",
|
"reqd": 1
|
||||||
"fieldname": "max_score",
|
},
|
||||||
"fieldtype": "Float",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Max Score",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"fieldname": "formula",
|
||||||
"allow_on_submit": 0,
|
"fieldtype": "Small Text",
|
||||||
"bold": 0,
|
"ignore_xss_filter": 1,
|
||||||
"collapsible": 0,
|
"in_list_view": 1,
|
||||||
"columns": 0,
|
"label": "Criteria Formula",
|
||||||
"fieldname": "formula",
|
"reqd": 1
|
||||||
"fieldtype": "Small Text",
|
},
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 1,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Criteria Formula",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"fieldname": "weight",
|
||||||
"allow_on_submit": 0,
|
"fieldtype": "Percent",
|
||||||
"bold": 0,
|
"label": "Criteria Weight"
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "weight",
|
|
||||||
"fieldtype": "Percent",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Criteria Weight",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"unique": 0
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"has_web_view": 0,
|
"links": [],
|
||||||
"hide_heading": 0,
|
"modified": "2021-11-11 18:34:58.477648",
|
||||||
"hide_toolbar": 0,
|
"modified_by": "Administrator",
|
||||||
"idx": 0,
|
"module": "Buying",
|
||||||
"image_view": 0,
|
"name": "Supplier Scorecard Criteria",
|
||||||
"in_create": 0,
|
"naming_rule": "By fieldname",
|
||||||
"is_submittable": 0,
|
"owner": "Administrator",
|
||||||
"issingle": 0,
|
|
||||||
"istable": 0,
|
|
||||||
"max_attachments": 0,
|
|
||||||
"modified": "2019-01-22 10:47:00.000822",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"module": "Buying",
|
|
||||||
"name": "Supplier Scorecard Criteria",
|
|
||||||
"name_case": "",
|
|
||||||
"owner": "Administrator",
|
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
"amend": 0,
|
"create": 1,
|
||||||
"apply_user_permissions": 0,
|
"delete": 1,
|
||||||
"cancel": 0,
|
"email": 1,
|
||||||
"create": 1,
|
"export": 1,
|
||||||
"delete": 1,
|
"print": 1,
|
||||||
"email": 1,
|
"read": 1,
|
||||||
"export": 1,
|
"report": 1,
|
||||||
"if_owner": 0,
|
"role": "System Manager",
|
||||||
"import": 0,
|
"share": 1,
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
|
||||||
"report": 1,
|
|
||||||
"role": "System Manager",
|
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 1,
|
|
||||||
"submit": 0,
|
|
||||||
"write": 1
|
"write": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"quick_entry": 1,
|
"quick_entry": 1,
|
||||||
"read_only": 0,
|
"sort_field": "modified",
|
||||||
"read_only_onload": 0,
|
"sort_order": "DESC",
|
||||||
"show_name_in_global_search": 0,
|
"track_changes": 1
|
||||||
"sort_field": "modified",
|
|
||||||
"sort_order": "DESC",
|
|
||||||
"track_changes": 1,
|
|
||||||
"track_seen": 0
|
|
||||||
}
|
}
|
||||||
@@ -41,10 +41,13 @@ def get_conditions(filters):
|
|||||||
if filters.get("from_date") and filters.get("to_date"):
|
if filters.get("from_date") and filters.get("to_date"):
|
||||||
conditions += " and po.transaction_date between %(from_date)s and %(to_date)s"
|
conditions += " and po.transaction_date between %(from_date)s and %(to_date)s"
|
||||||
|
|
||||||
for field in ['company', 'name', 'status']:
|
for field in ['company', 'name']:
|
||||||
if filters.get(field):
|
if filters.get(field):
|
||||||
conditions += f" and po.{field} = %({field})s"
|
conditions += f" and po.{field} = %({field})s"
|
||||||
|
|
||||||
|
if filters.get('status'):
|
||||||
|
conditions += " and po.status in %(status)s"
|
||||||
|
|
||||||
if filters.get('project'):
|
if filters.get('project'):
|
||||||
conditions += " and poi.project = %(project)s"
|
conditions += " and poi.project = %(project)s"
|
||||||
|
|
||||||
|
|||||||
36
erpnext/change_log/v13/v13_15_0.md
Normal file
36
erpnext/change_log/v13/v13_15_0.md
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# Version 13.15.0 Release Notes
|
||||||
|
|
||||||
|
### Features & Enhancements
|
||||||
|
|
||||||
|
- Add count for Healthcare Practitioner on Healthcare dashboard
|
||||||
|
([#28286](https://github.com/frappe/erpnext/pull/28286))
|
||||||
|
- Improved financial statement report loading time ([#28238](https://github.com/frappe/erpnext/pull/28238))
|
||||||
|
- Improved general ledger report loading time ([#27987](https://github.com/frappe/erpnext/pull/27987))
|
||||||
|
- Replaced "=" with "in" for multiple statuses in query ([#28193](https://github.com/frappe/erpnext/pull/28193))
|
||||||
|
- Update rate in the item price if the Update Existing Price List Rate is enabled in the stock settings ([#28255](https://github.com/frappe/erpnext/pull/28255))
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
|
||||||
|
- Serial Nos not set in the row after scanning in popup ([#28202](https://github.com/frappe/erpnext/pull/28202))
|
||||||
|
- Help section background in dark mode ([#28406](https://github.com/frappe/erpnext/pull/28406))
|
||||||
|
- Don't make naming series mandatory for items ([#28394](https://github.com/frappe/erpnext/pull/28394))
|
||||||
|
- Work order creation from sales order ([#28388](https://github.com/frappe/erpnext/pull/28388))
|
||||||
|
- Workspace links to ecommerce settings ([#28360](https://github.com/frappe/erpnext/pull/28360))
|
||||||
|
- Currency wise pricing rule was not working ([#28417](https://github.com/frappe/erpnext/pull/28417))
|
||||||
|
- Bug with qrcode generation for the Urdu language ([#28471](https://github.com/frappe/erpnext/pull/28471))
|
||||||
|
- Removed item - item group name validation ([#28392](https://github.com/frappe/erpnext/pull/28392))
|
||||||
|
- Silter only submitted fees in student fee collection report ([#28280](https://github.com/frappe/erpnext/pull/28280))
|
||||||
|
- Update tax template name for 18% GST ([#28156](https://github.com/frappe/erpnext/pull/28156))
|
||||||
|
- Get credit amount for bank account of type liability ([#28132](https://github.com/frappe/erpnext/pull/28132))
|
||||||
|
- Default party account getting overriden in invoices ([#28363](https://github.com/frappe/erpnext/pull/28363))
|
||||||
|
- Remove warehouse filter on Batch field for Material Receipt ([#28195](https://github.com/frappe/erpnext/pull/28195))
|
||||||
|
- POS idx issue in taxes table while merging ([#28389](https://github.com/frappe/erpnext/pull/28389))
|
||||||
|
- Address not set in the Dispatch Address field ([#28333](https://github.com/frappe/erpnext/pull/28333))
|
||||||
|
- Not able to edit the supplier scorecard criteria name once created ([#28348](https://github.com/frappe/erpnext/pull/28348))
|
||||||
|
- GST category not getting auto updated ([#28459](https://github.com/frappe/erpnext/pull/28459))
|
||||||
|
- Sales Invoice with duplicate items not showing correct taxable value ([#28334](https://github.com/frappe/erpnext/pull/28334))
|
||||||
|
- KSA Invoice print format for multicurrency invoices ([#28489](https://github.com/frappe/erpnext/pull/28489))
|
||||||
|
- Performance issue while submitting the Journal Entry ([#28425](https://github.com/frappe/erpnext/pull/28425))
|
||||||
|
- Pricing Rule not created against the Promotional Scheme ([#28398](https://github.com/frappe/erpnext/pull/28398))
|
||||||
|
- Pull only Items that are in Job Card in a Stock Entry against Job Card ([#28228](https://github.com/frappe/erpnext/pull/28228))
|
||||||
|
- Fixed sum of components in salary register ([#28237](https://github.com/frappe/erpnext/pull/28237))
|
||||||
@@ -201,7 +201,9 @@ def add_new_address(doc):
|
|||||||
def create_lead_for_item_inquiry(lead, subject, message):
|
def create_lead_for_item_inquiry(lead, subject, message):
|
||||||
lead = frappe.parse_json(lead)
|
lead = frappe.parse_json(lead)
|
||||||
lead_doc = frappe.new_doc('Lead')
|
lead_doc = frappe.new_doc('Lead')
|
||||||
lead_doc.update(lead)
|
for fieldname in ("lead_name", "company_name", "email_id", "phone"):
|
||||||
|
lead_doc.set(fieldname, lead.get(fieldname))
|
||||||
|
|
||||||
lead_doc.set('lead_owner', '')
|
lead_doc.set('lead_owner', '')
|
||||||
|
|
||||||
if not frappe.db.exists('Lead Source', 'Product Inquiry'):
|
if not frappe.db.exists('Lead Source', 'Product Inquiry'):
|
||||||
@@ -209,6 +211,7 @@ def create_lead_for_item_inquiry(lead, subject, message):
|
|||||||
'doctype': 'Lead Source',
|
'doctype': 'Lead Source',
|
||||||
'source_name' : 'Product Inquiry'
|
'source_name' : 'Product Inquiry'
|
||||||
}).insert(ignore_permissions=True)
|
}).insert(ignore_permissions=True)
|
||||||
|
|
||||||
lead_doc.set('source', 'Product Inquiry')
|
lead_doc.set('source', 'Product Inquiry')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"add_total_row": 0,
|
"add_total_row": 1,
|
||||||
"creation": "2016-06-22 02:58:41.024538",
|
"creation": "2016-06-22 02:58:41.024538",
|
||||||
"disable_prepared_report": 0,
|
"disable_prepared_report": 0,
|
||||||
"disabled": 0,
|
"disabled": 0,
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
"name": "Student Fee Collection",
|
"name": "Student Fee Collection",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"prepared_report": 0,
|
"prepared_report": 0,
|
||||||
"query": "SELECT\n student as \"Student:Link/Student:200\",\n student_name as \"Student Name::200\",\n sum(grand_total) - sum(outstanding_amount) as \"Paid Amount:Currency:150\",\n sum(outstanding_amount) as \"Outstanding Amount:Currency:150\",\n sum(grand_total) as \"Grand Total:Currency:150\"\nFROM\n `tabFees` \nGROUP BY\n student",
|
"query": "SELECT\n student as \"Student:Link/Student:200\",\n student_name as \"Student Name::200\",\n sum(grand_total) - sum(outstanding_amount) as \"Paid Amount:Currency:150\",\n sum(outstanding_amount) as \"Outstanding Amount:Currency:150\",\n sum(grand_total) as \"Grand Total:Currency:150\"\nFROM\n `tabFees` \nWHERE\n docstatus=1 \nGROUP BY\n student",
|
||||||
"ref_doctype": "Fees",
|
"ref_doctype": "Fees",
|
||||||
"report_name": "Student Fee Collection",
|
"report_name": "Student Fee Collection",
|
||||||
"report_type": "Query Report",
|
"report_type": "Query Report",
|
||||||
@@ -22,4 +22,4 @@
|
|||||||
"role": "Academics User"
|
"role": "Academics User"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,7 @@ def verify_request():
|
|||||||
)
|
)
|
||||||
|
|
||||||
if frappe.request.data and \
|
if frappe.request.data and \
|
||||||
frappe.get_request_header("X-Wc-Webhook-Signature") and \
|
not sig == frappe.get_request_header("X-Wc-Webhook-Signature", "").encode():
|
||||||
not sig == bytes(frappe.get_request_header("X-Wc-Webhook-Signature").encode()):
|
|
||||||
frappe.throw(_("Unverified Webhook Data"))
|
frappe.throw(_("Unverified Webhook Data"))
|
||||||
frappe.set_user(woocommerce_settings.creation_user)
|
frappe.set_user(woocommerce_settings.creation_user)
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,9 @@ def verify_transaction(**kwargs):
|
|||||||
transaction_response = frappe._dict(kwargs["Body"]["stkCallback"])
|
transaction_response = frappe._dict(kwargs["Body"]["stkCallback"])
|
||||||
|
|
||||||
checkout_id = getattr(transaction_response, "CheckoutRequestID", "")
|
checkout_id = getattr(transaction_response, "CheckoutRequestID", "")
|
||||||
|
if not isinstance(checkout_id, str):
|
||||||
|
frappe.throw(_("Invalid Checkout Request ID"))
|
||||||
|
|
||||||
integration_request = frappe.get_doc("Integration Request", checkout_id)
|
integration_request = frappe.get_doc("Integration Request", checkout_id)
|
||||||
transaction_data = frappe._dict(loads(integration_request.data))
|
transaction_data = frappe._dict(loads(integration_request.data))
|
||||||
total_paid = 0 # for multiple integration request made against a pos invoice
|
total_paid = 0 # for multiple integration request made against a pos invoice
|
||||||
@@ -233,6 +236,9 @@ def process_balance_info(**kwargs):
|
|||||||
account_balance_response = frappe._dict(kwargs["Result"])
|
account_balance_response = frappe._dict(kwargs["Result"])
|
||||||
|
|
||||||
conversation_id = getattr(account_balance_response, "ConversationID", "")
|
conversation_id = getattr(account_balance_response, "ConversationID", "")
|
||||||
|
if not isinstance(conversation_id, str):
|
||||||
|
frappe.throw(_("Invalid Conversation ID"))
|
||||||
|
|
||||||
request = frappe.get_doc("Integration Request", conversation_id)
|
request = frappe.get_doc("Integration Request", conversation_id)
|
||||||
|
|
||||||
if request.status == "Completed":
|
if request.status == "Completed":
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ def validate_webhooks_request(doctype, hmac_key, secret_key='secret'):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if frappe.request.data and \
|
if frappe.request.data and \
|
||||||
frappe.get_request_header(hmac_key) and \
|
|
||||||
not sig == bytes(frappe.get_request_header(hmac_key).encode()):
|
not sig == bytes(frappe.get_request_header(hmac_key).encode()):
|
||||||
frappe.throw(_("Unverified Webhook Data"))
|
frappe.throw(_("Unverified Webhook Data"))
|
||||||
frappe.set_user(settings.modified_by)
|
frappe.set_user(settings.modified_by)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
"hide_custom": 0,
|
"hide_custom": 0,
|
||||||
"icon": "healthcare",
|
"icon": "healthcare",
|
||||||
"idx": 0,
|
"idx": 0,
|
||||||
|
"is_default": 0,
|
||||||
"is_standard": 1,
|
"is_standard": 1,
|
||||||
"label": "Healthcare",
|
"label": "Healthcare",
|
||||||
"links": [
|
"links": [
|
||||||
@@ -534,7 +535,7 @@
|
|||||||
"type": "Link"
|
"type": "Link"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2021-01-30 19:35:45.316999",
|
"modified": "2021-10-29 14:31:16.795628",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Healthcare",
|
"module": "Healthcare",
|
||||||
"name": "Healthcare",
|
"name": "Healthcare",
|
||||||
@@ -569,8 +570,12 @@
|
|||||||
"type": "DocType"
|
"type": "DocType"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"color": "#29CD42",
|
||||||
|
"doc_view": "List",
|
||||||
|
"format": "{} Active",
|
||||||
"label": "Healthcare Practitioner",
|
"label": "Healthcare Practitioner",
|
||||||
"link_to": "Healthcare Practitioner",
|
"link_to": "Healthcare Practitioner",
|
||||||
|
"stats_filter": "{\n \"status\": \"Active\"\n}",
|
||||||
"type": "DocType"
|
"type": "DocType"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -316,7 +316,8 @@ doc_events = {
|
|||||||
'validate': ["erpnext.erpnext_integrations.taxjar_integration.set_sales_tax"]
|
'validate': ["erpnext.erpnext_integrations.taxjar_integration.set_sales_tax"]
|
||||||
},
|
},
|
||||||
"Company": {
|
"Company": {
|
||||||
"on_trash": "erpnext.regional.india.utils.delete_gst_settings_for_company"
|
"on_trash": ["erpnext.regional.india.utils.delete_gst_settings_for_company",
|
||||||
|
"erpnext.regional.saudi_arabia.utils.delete_vat_settings_for_company"]
|
||||||
},
|
},
|
||||||
"Integration Request": {
|
"Integration Request": {
|
||||||
"validate": "erpnext.accounts.doctype.payment_request.payment_request.validate_payment"
|
"validate": "erpnext.accounts.doctype.payment_request.payment_request.validate_payment"
|
||||||
|
|||||||
@@ -397,6 +397,7 @@
|
|||||||
"options": "Batch"
|
"options": "Batch"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"collapsible": 1,
|
||||||
"fieldname": "scrap_items_section",
|
"fieldname": "scrap_items_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Scrap Items"
|
"label": "Scrap Items"
|
||||||
@@ -419,7 +420,7 @@
|
|||||||
],
|
],
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-11-09 14:07:20.290306",
|
"modified": "2021-11-12 10:15:06.572401",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Job Card",
|
"name": "Job Card",
|
||||||
|
|||||||
@@ -505,13 +505,11 @@ class JobCard(Document):
|
|||||||
self.status = 'Work In Progress'
|
self.status = 'Work In Progress'
|
||||||
|
|
||||||
if (self.docstatus == 1 and
|
if (self.docstatus == 1 and
|
||||||
(self.for_quantity <= self.transferred_qty or not self.items)):
|
(self.for_quantity <= self.total_completed_qty or not self.items)):
|
||||||
# consider excess transfer
|
|
||||||
# completed qty is checked via separate validation
|
|
||||||
self.status = 'Completed'
|
self.status = 'Completed'
|
||||||
|
|
||||||
if self.status != 'Completed':
|
if self.status != 'Completed':
|
||||||
if self.for_quantity == self.transferred_qty:
|
if self.for_quantity <= self.transferred_qty:
|
||||||
self.status = 'Material Transferred'
|
self.status = 'Material Transferred'
|
||||||
|
|
||||||
if update_status:
|
if update_status:
|
||||||
@@ -619,7 +617,8 @@ def make_material_request(source_name, target_doc=None):
|
|||||||
"doctype": "Material Request Item",
|
"doctype": "Material Request Item",
|
||||||
"field_map": {
|
"field_map": {
|
||||||
"required_qty": "qty",
|
"required_qty": "qty",
|
||||||
"uom": "stock_uom"
|
"uom": "stock_uom",
|
||||||
|
"name": "job_card_item"
|
||||||
},
|
},
|
||||||
"postprocess": update_item,
|
"postprocess": update_item,
|
||||||
}
|
}
|
||||||
@@ -629,17 +628,22 @@ def make_material_request(source_name, target_doc=None):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_stock_entry(source_name, target_doc=None):
|
def make_stock_entry(source_name, target_doc=None):
|
||||||
def update_item(obj, target, source_parent):
|
def update_item(source, target, source_parent):
|
||||||
target.t_warehouse = source_parent.wip_warehouse
|
target.t_warehouse = source_parent.wip_warehouse
|
||||||
|
|
||||||
if not target.conversion_factor:
|
if not target.conversion_factor:
|
||||||
target.conversion_factor = 1
|
target.conversion_factor = 1
|
||||||
|
|
||||||
|
pending_rm_qty = flt(source.required_qty) - flt(source.transferred_qty)
|
||||||
|
if pending_rm_qty > 0:
|
||||||
|
target.qty = pending_rm_qty
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
target.purpose = "Material Transfer for Manufacture"
|
target.purpose = "Material Transfer for Manufacture"
|
||||||
target.from_bom = 1
|
target.from_bom = 1
|
||||||
|
|
||||||
# avoid negative 'For Quantity'
|
# avoid negative 'For Quantity'
|
||||||
pending_fg_qty = source.get('for_quantity', 0) - source.get('transferred_qty', 0)
|
pending_fg_qty = flt(source.get('for_quantity', 0)) - flt(source.get('transferred_qty', 0))
|
||||||
target.fg_completed_qty = pending_fg_qty if pending_fg_qty > 0 else 0
|
target.fg_completed_qty = pending_fg_qty if pending_fg_qty > 0 else 0
|
||||||
|
|
||||||
target.set_transfer_qty()
|
target.set_transfer_qty()
|
||||||
|
|||||||
@@ -16,11 +16,22 @@ from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
|||||||
|
|
||||||
|
|
||||||
class TestJobCard(unittest.TestCase):
|
class TestJobCard(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
make_bom_for_jc_tests()
|
||||||
|
|
||||||
transfer_material_against, source_warehouse = None, None
|
transfer_material_against, source_warehouse = None, None
|
||||||
tests_that_transfer_against_jc = ("test_job_card_multiple_materials_transfer",
|
|
||||||
"test_job_card_excess_material_transfer")
|
tests_that_skip_setup = (
|
||||||
|
"test_job_card_material_transfer_correctness",
|
||||||
|
)
|
||||||
|
tests_that_transfer_against_jc = (
|
||||||
|
"test_job_card_multiple_materials_transfer",
|
||||||
|
"test_job_card_excess_material_transfer",
|
||||||
|
"test_job_card_partial_material_transfer"
|
||||||
|
)
|
||||||
|
|
||||||
|
if self._testMethodName in tests_that_skip_setup:
|
||||||
|
return
|
||||||
|
|
||||||
if self._testMethodName in tests_that_transfer_against_jc:
|
if self._testMethodName in tests_that_transfer_against_jc:
|
||||||
transfer_material_against = "Job Card"
|
transfer_material_against = "Job Card"
|
||||||
@@ -191,4 +202,132 @@ class TestJobCard(unittest.TestCase):
|
|||||||
job_card.submit()
|
job_card.submit()
|
||||||
|
|
||||||
# JC is Completed with excess transfer
|
# JC is Completed with excess transfer
|
||||||
self.assertEqual(job_card.status, "Completed")
|
self.assertEqual(job_card.status, "Completed")
|
||||||
|
|
||||||
|
def test_job_card_partial_material_transfer(self):
|
||||||
|
"Test partial material transfer against Job Card"
|
||||||
|
|
||||||
|
make_stock_entry(item_code="_Test Item", target="Stores - _TC",
|
||||||
|
qty=25, basic_rate=100)
|
||||||
|
make_stock_entry(item_code="_Test Item Home Desktop Manufactured",
|
||||||
|
target="Stores - _TC", qty=15, basic_rate=100)
|
||||||
|
|
||||||
|
job_card_name = frappe.db.get_value("Job Card", {'work_order': self.work_order.name})
|
||||||
|
job_card = frappe.get_doc("Job Card", job_card_name)
|
||||||
|
|
||||||
|
# partially transfer
|
||||||
|
transfer_entry = make_stock_entry_from_jc(job_card_name)
|
||||||
|
transfer_entry.fg_completed_qty = 1
|
||||||
|
transfer_entry.get_items()
|
||||||
|
transfer_entry.insert()
|
||||||
|
transfer_entry.submit()
|
||||||
|
|
||||||
|
job_card.reload()
|
||||||
|
self.assertEqual(job_card.transferred_qty, 1)
|
||||||
|
self.assertEqual(transfer_entry.items[0].qty, 5)
|
||||||
|
self.assertEqual(transfer_entry.items[1].qty, 3)
|
||||||
|
|
||||||
|
# transfer remaining
|
||||||
|
transfer_entry_2 = make_stock_entry_from_jc(job_card_name)
|
||||||
|
|
||||||
|
self.assertEqual(transfer_entry_2.fg_completed_qty, 1)
|
||||||
|
self.assertEqual(transfer_entry_2.items[0].qty, 5)
|
||||||
|
self.assertEqual(transfer_entry_2.items[1].qty, 3)
|
||||||
|
|
||||||
|
transfer_entry_2.insert()
|
||||||
|
transfer_entry_2.submit()
|
||||||
|
|
||||||
|
job_card.reload()
|
||||||
|
self.assertEqual(job_card.transferred_qty, 2)
|
||||||
|
|
||||||
|
def test_job_card_material_transfer_correctness(self):
|
||||||
|
"""
|
||||||
|
1. Test if only current Job Card Items are pulled in a Stock Entry against a Job Card
|
||||||
|
2. Test impact of changing 'For Qty' in such a Stock Entry
|
||||||
|
"""
|
||||||
|
create_bom_with_multiple_operations()
|
||||||
|
work_order = make_wo_with_transfer_against_jc()
|
||||||
|
|
||||||
|
job_card_name = frappe.db.get_value(
|
||||||
|
"Job Card",
|
||||||
|
{"work_order": work_order.name,"operation": "Test Operation A"}
|
||||||
|
)
|
||||||
|
job_card = frappe.get_doc("Job Card", job_card_name)
|
||||||
|
|
||||||
|
self.assertEqual(len(job_card.items), 1)
|
||||||
|
self.assertEqual(job_card.items[0].item_code, "_Test Item")
|
||||||
|
|
||||||
|
# check if right items are mapped in transfer entry
|
||||||
|
transfer_entry = make_stock_entry_from_jc(job_card_name)
|
||||||
|
transfer_entry.insert()
|
||||||
|
|
||||||
|
self.assertEqual(len(transfer_entry.items), 1)
|
||||||
|
self.assertEqual(transfer_entry.items[0].item_code, "_Test Item")
|
||||||
|
self.assertEqual(transfer_entry.items[0].qty, 4)
|
||||||
|
|
||||||
|
# change 'For Qty' and check impact on items table
|
||||||
|
# no.of items should be the same with qty change
|
||||||
|
transfer_entry.fg_completed_qty = 2
|
||||||
|
transfer_entry.get_items()
|
||||||
|
|
||||||
|
self.assertEqual(len(transfer_entry.items), 1)
|
||||||
|
self.assertEqual(transfer_entry.items[0].item_code, "_Test Item")
|
||||||
|
self.assertEqual(transfer_entry.items[0].qty, 2)
|
||||||
|
|
||||||
|
# rollback via tearDown method
|
||||||
|
|
||||||
|
def create_bom_with_multiple_operations():
|
||||||
|
"Create a BOM with multiple operations and Material Transfer against Job Card"
|
||||||
|
from erpnext.manufacturing.doctype.operation.test_operation import make_operation
|
||||||
|
|
||||||
|
test_record = frappe.get_test_records("BOM")[2]
|
||||||
|
bom_doc = frappe.get_doc(test_record)
|
||||||
|
|
||||||
|
row = {
|
||||||
|
"operation": "Test Operation A",
|
||||||
|
"workstation": "_Test Workstation A",
|
||||||
|
"hour_rate_rent": 300,
|
||||||
|
"time_in_mins": 60
|
||||||
|
}
|
||||||
|
make_workstation(row)
|
||||||
|
make_operation(row)
|
||||||
|
|
||||||
|
bom_doc.append("operations", {
|
||||||
|
"operation": "Test Operation A",
|
||||||
|
"description": "Test Operation A",
|
||||||
|
"workstation": "_Test Workstation A",
|
||||||
|
"hour_rate": 300,
|
||||||
|
"time_in_mins": 60,
|
||||||
|
"operating_cost": 100
|
||||||
|
})
|
||||||
|
|
||||||
|
bom_doc.transfer_material_against = "Job Card"
|
||||||
|
bom_doc.save()
|
||||||
|
bom_doc.submit()
|
||||||
|
|
||||||
|
return bom_doc
|
||||||
|
|
||||||
|
def make_wo_with_transfer_against_jc():
|
||||||
|
"Create a WO with multiple operations and Material Transfer against Job Card"
|
||||||
|
|
||||||
|
work_order = make_wo_order_test_record(
|
||||||
|
item="_Test FG Item 2",
|
||||||
|
qty=4,
|
||||||
|
transfer_material_against="Job Card",
|
||||||
|
source_warehouse="Stores - _TC",
|
||||||
|
do_not_submit=True
|
||||||
|
)
|
||||||
|
work_order.required_items[0].operation = "Test Operation A"
|
||||||
|
work_order.required_items[1].operation = "_Test Operation 1"
|
||||||
|
work_order.submit()
|
||||||
|
|
||||||
|
return work_order
|
||||||
|
|
||||||
|
def make_bom_for_jc_tests():
|
||||||
|
test_records = frappe.get_test_records('BOM')
|
||||||
|
bom = frappe.copy_doc(test_records[2])
|
||||||
|
bom.set_rate_of_sub_assembly_item_based_on_bom = 0
|
||||||
|
bom.rm_cost_as_per = "Valuation Rate"
|
||||||
|
bom.items[0].uom = "_Test UOM 1"
|
||||||
|
bom.items[0].conversion_factor = 5
|
||||||
|
bom.insert()
|
||||||
@@ -18,15 +18,13 @@ def make_operation(*args, **kwargs):
|
|||||||
|
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
|
|
||||||
try:
|
if not frappe.db.exists("Operation", args.operation):
|
||||||
doc = frappe.get_doc({
|
doc = frappe.get_doc({
|
||||||
"doctype": "Operation",
|
"doctype": "Operation",
|
||||||
"name": args.operation,
|
"name": args.operation,
|
||||||
"workstation": args.workstation
|
"workstation": args.workstation
|
||||||
})
|
})
|
||||||
|
|
||||||
doc.insert()
|
doc.insert()
|
||||||
|
|
||||||
return doc
|
return doc
|
||||||
except frappe.DuplicateEntryError:
|
|
||||||
return frappe.get_doc("Operation", args.operation)
|
return frappe.get_doc("Operation", args.operation)
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ frappe.ui.form.on('Production Plan', {
|
|||||||
}
|
}
|
||||||
frm.trigger("material_requirement");
|
frm.trigger("material_requirement");
|
||||||
|
|
||||||
const projected_qty_formula = ` <table class="table table-bordered" style="background-color: #f9f9f9;">
|
const projected_qty_formula = ` <table class="table table-bordered" style="background-color: var(--scrollbar-track-color);">
|
||||||
<tr><td style="padding-left:25px">
|
<tr><td style="padding-left:25px">
|
||||||
<div>
|
<div>
|
||||||
<h3 style="text-decoration: underline;">
|
<h3 style="text-decoration: underline;">
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ def make_workstation(*args, **kwargs):
|
|||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
|
|
||||||
workstation_name = args.workstation_name or args.workstation
|
workstation_name = args.workstation_name or args.workstation
|
||||||
try:
|
if not frappe.db.exists("Workstation", workstation_name):
|
||||||
doc = frappe.get_doc({
|
doc = frappe.get_doc({
|
||||||
"doctype": "Workstation",
|
"doctype": "Workstation",
|
||||||
"workstation_name": workstation_name
|
"workstation_name": workstation_name
|
||||||
@@ -100,5 +100,5 @@ def make_workstation(*args, **kwargs):
|
|||||||
doc.insert()
|
doc.insert()
|
||||||
|
|
||||||
return doc
|
return doc
|
||||||
except frappe.DuplicateEntryError:
|
|
||||||
return frappe.get_doc("Workstation", workstation_name)
|
return frappe.get_doc("Workstation", workstation_name)
|
||||||
|
|||||||
@@ -29,8 +29,15 @@ def get_production_plan_item_details(filters, data, order_details):
|
|||||||
|
|
||||||
production_plan_doc = frappe.get_cached_doc("Production Plan", filters.get("production_plan"))
|
production_plan_doc = frappe.get_cached_doc("Production Plan", filters.get("production_plan"))
|
||||||
for row in production_plan_doc.po_items:
|
for row in production_plan_doc.po_items:
|
||||||
work_order = frappe.get_cached_value("Work Order", {"production_plan_item": row.name,
|
work_order = frappe.get_value(
|
||||||
"bom_no": row.bom_no, "production_item": row.item_code}, "name")
|
"Work Order",
|
||||||
|
{
|
||||||
|
"production_plan_item": row.name,
|
||||||
|
"bom_no": row.bom_no,
|
||||||
|
"production_item": row.item_code
|
||||||
|
},
|
||||||
|
"name"
|
||||||
|
)
|
||||||
|
|
||||||
if row.item_code not in itemwise_indent:
|
if row.item_code not in itemwise_indent:
|
||||||
itemwise_indent.setdefault(row.item_code, {})
|
itemwise_indent.setdefault(row.item_code, {})
|
||||||
@@ -41,10 +48,10 @@ def get_production_plan_item_details(filters, data, order_details):
|
|||||||
"item_name": frappe.get_cached_value("Item", row.item_code, "item_name"),
|
"item_name": frappe.get_cached_value("Item", row.item_code, "item_name"),
|
||||||
"qty": row.planned_qty,
|
"qty": row.planned_qty,
|
||||||
"document_type": "Work Order",
|
"document_type": "Work Order",
|
||||||
"document_name": work_order,
|
"document_name": work_order or "",
|
||||||
"bom_level": frappe.get_cached_value("BOM", row.bom_no, "bom_level"),
|
"bom_level": frappe.get_cached_value("BOM", row.bom_no, "bom_level"),
|
||||||
"produced_qty": order_details.get((work_order, row.item_code)).get("produced_qty"),
|
"produced_qty": order_details.get((work_order, row.item_code), {}).get("produced_qty", 0),
|
||||||
"pending_qty": flt(row.planned_qty) - flt(order_details.get((work_order, row.item_code)).get("produced_qty"))
|
"pending_qty": flt(row.planned_qty) - flt(order_details.get((work_order, row.item_code), {}).get("produced_qty", 0))
|
||||||
})
|
})
|
||||||
|
|
||||||
get_production_plan_sub_assembly_item_details(filters, row, production_plan_doc, data, order_details)
|
get_production_plan_sub_assembly_item_details(filters, row, production_plan_doc, data, order_details)
|
||||||
@@ -55,11 +62,23 @@ def get_production_plan_sub_assembly_item_details(filters, row, production_plan_
|
|||||||
subcontracted_item = (item.type_of_manufacturing == 'Subcontract')
|
subcontracted_item = (item.type_of_manufacturing == 'Subcontract')
|
||||||
|
|
||||||
if subcontracted_item:
|
if subcontracted_item:
|
||||||
docname = frappe.get_cached_value("Purchase Order Item",
|
docname = frappe.get_value(
|
||||||
{"production_plan_sub_assembly_item": item.name, "docstatus": ("<", 2)}, "parent")
|
"Purchase Order Item",
|
||||||
|
{
|
||||||
|
"production_plan_sub_assembly_item": item.name,
|
||||||
|
"docstatus": ("<", 2)
|
||||||
|
},
|
||||||
|
"parent"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
docname = frappe.get_cached_value("Work Order",
|
docname = frappe.get_value(
|
||||||
{"production_plan_sub_assembly_item": item.name, "docstatus": ("<", 2)}, "name")
|
"Work Order",
|
||||||
|
{
|
||||||
|
"production_plan_sub_assembly_item": item.name,
|
||||||
|
"docstatus": ("<", 2)
|
||||||
|
},
|
||||||
|
"name"
|
||||||
|
)
|
||||||
|
|
||||||
data.append({
|
data.append({
|
||||||
"indent": 1,
|
"indent": 1,
|
||||||
@@ -67,10 +86,10 @@ def get_production_plan_sub_assembly_item_details(filters, row, production_plan_
|
|||||||
"item_name": item.item_name,
|
"item_name": item.item_name,
|
||||||
"qty": item.qty,
|
"qty": item.qty,
|
||||||
"document_type": "Work Order" if not subcontracted_item else "Purchase Order",
|
"document_type": "Work Order" if not subcontracted_item else "Purchase Order",
|
||||||
"document_name": docname,
|
"document_name": docname or "",
|
||||||
"bom_level": item.bom_level,
|
"bom_level": item.bom_level,
|
||||||
"produced_qty": order_details.get((docname, item.production_item)).get("produced_qty"),
|
"produced_qty": order_details.get((docname, item.production_item), {}).get("produced_qty", 0),
|
||||||
"pending_qty": flt(item.qty) - flt(order_details.get((docname, item.production_item)).get("produced_qty"))
|
"pending_qty": flt(item.qty) - flt(order_details.get((docname, item.production_item), {}).get("produced_qty", 0))
|
||||||
})
|
})
|
||||||
|
|
||||||
def get_work_order_details(filters, order_details):
|
def get_work_order_details(filters, order_details):
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ frappe.query_reports["Work Order Summary"] = {
|
|||||||
label: __("Status"),
|
label: __("Status"),
|
||||||
fieldname: "status",
|
fieldname: "status",
|
||||||
fieldtype: "Select",
|
fieldtype: "Select",
|
||||||
options: ["", "Not Started", "In Process", "Completed", "Stopped"]
|
options: ["", "Not Started", "In Process", "Completed", "Stopped", "Closed"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: __("Sales Orders"),
|
label: __("Sales Orders"),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
|
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from collections import defaultdict
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
@@ -59,21 +59,16 @@ def get_chart_data(data, filters):
|
|||||||
return get_chart_based_on_qty(data, filters)
|
return get_chart_based_on_qty(data, filters)
|
||||||
|
|
||||||
def get_chart_based_on_status(data):
|
def get_chart_based_on_status(data):
|
||||||
labels = ["Completed", "In Process", "Stopped", "Not Started"]
|
labels = frappe.get_meta("Work Order").get_options("status").split("\n")
|
||||||
|
if "" in labels:
|
||||||
|
labels.remove("")
|
||||||
|
|
||||||
status_wise_data = {
|
status_wise_data = defaultdict(int)
|
||||||
"Not Started": 0,
|
|
||||||
"In Process": 0,
|
|
||||||
"Stopped": 0,
|
|
||||||
"Completed": 0,
|
|
||||||
"Draft": 0
|
|
||||||
}
|
|
||||||
|
|
||||||
for d in data:
|
for d in data:
|
||||||
status_wise_data[d.status] += 1
|
status_wise_data[d.status] += 1
|
||||||
|
|
||||||
values = [status_wise_data["Completed"], status_wise_data["In Process"],
|
values = [status_wise_data[label] for label in labels]
|
||||||
status_wise_data["Stopped"], status_wise_data["Not Started"]]
|
|
||||||
|
|
||||||
chart = {
|
chart = {
|
||||||
"data": {
|
"data": {
|
||||||
|
|||||||
@@ -329,6 +329,8 @@ erpnext.patches.v13_0.trim_sales_invoice_custom_field_length
|
|||||||
erpnext.patches.v13_0.enable_scheduler_job_for_item_reposting
|
erpnext.patches.v13_0.enable_scheduler_job_for_item_reposting
|
||||||
erpnext.patches.v13_0.requeue_failed_reposts
|
erpnext.patches.v13_0.requeue_failed_reposts
|
||||||
erpnext.patches.v13_0.fetch_thumbnail_in_website_items
|
erpnext.patches.v13_0.fetch_thumbnail_in_website_items
|
||||||
|
erpnext.patches.v13_0.update_job_card_status
|
||||||
erpnext.patches.v12_0.update_production_plan_status
|
erpnext.patches.v12_0.update_production_plan_status
|
||||||
|
erpnext.patches.v13_0.item_naming_series_not_mandatory
|
||||||
erpnext.patches.v13_0.update_category_in_ltds_certificate
|
erpnext.patches.v13_0.update_category_in_ltds_certificate
|
||||||
erpnext.patches.v13_0.create_ksa_vat_custom_fields
|
erpnext.patches.v13_0.create_ksa_vat_custom_fields
|
||||||
|
|||||||
11
erpnext/patches/v13_0/item_naming_series_not_mandatory.py
Normal file
11
erpnext/patches/v13_0/item_naming_series_not_mandatory.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
from erpnext.setup.doctype.naming_series.naming_series import set_by_naming_series
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
|
||||||
|
stock_settings = frappe.get_doc("Stock Settings")
|
||||||
|
|
||||||
|
set_by_naming_series("Item", "item_code",
|
||||||
|
stock_settings.get("item_naming_by")=="Naming Series", hide_name_field=True, make_mandatory=0)
|
||||||
18
erpnext/patches/v13_0/update_job_card_status.py
Normal file
18
erpnext/patches/v13_0/update_job_card_status.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Copyright (c) 2021, Frappe and Contributors
|
||||||
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
|
||||||
|
job_card = frappe.qb.DocType("Job Card")
|
||||||
|
(frappe.qb
|
||||||
|
.update(job_card)
|
||||||
|
.set(job_card.status, "Completed")
|
||||||
|
.where(
|
||||||
|
(job_card.docstatus == 1)
|
||||||
|
& (job_card.for_quantity <= job_card.total_completed_qty)
|
||||||
|
& (job_card.status.isin(["Work In Progress", "Material Transferred"]))
|
||||||
|
)
|
||||||
|
).run()
|
||||||
@@ -135,11 +135,11 @@ def get_ss_earning_map(salary_slips, currency, company_currency):
|
|||||||
|
|
||||||
ss_earning_map = {}
|
ss_earning_map = {}
|
||||||
for d in ss_earnings:
|
for d in ss_earnings:
|
||||||
ss_earning_map.setdefault(d.parent, frappe._dict()).setdefault(d.salary_component, [])
|
ss_earning_map.setdefault(d.parent, frappe._dict()).setdefault(d.salary_component, 0.0)
|
||||||
if currency == company_currency:
|
if currency == company_currency:
|
||||||
ss_earning_map[d.parent][d.salary_component] = flt(d.amount) * flt(d.exchange_rate if d.exchange_rate else 1)
|
ss_earning_map[d.parent][d.salary_component] += flt(d.amount) * flt(d.exchange_rate if d.exchange_rate else 1)
|
||||||
else:
|
else:
|
||||||
ss_earning_map[d.parent][d.salary_component] = flt(d.amount)
|
ss_earning_map[d.parent][d.salary_component] += flt(d.amount)
|
||||||
|
|
||||||
return ss_earning_map
|
return ss_earning_map
|
||||||
|
|
||||||
@@ -150,10 +150,10 @@ def get_ss_ded_map(salary_slips, currency, company_currency):
|
|||||||
|
|
||||||
ss_ded_map = {}
|
ss_ded_map = {}
|
||||||
for d in ss_deductions:
|
for d in ss_deductions:
|
||||||
ss_ded_map.setdefault(d.parent, frappe._dict()).setdefault(d.salary_component, [])
|
ss_ded_map.setdefault(d.parent, frappe._dict()).setdefault(d.salary_component, 0.0)
|
||||||
if currency == company_currency:
|
if currency == company_currency:
|
||||||
ss_ded_map[d.parent][d.salary_component] = flt(d.amount) * flt(d.exchange_rate if d.exchange_rate else 1)
|
ss_ded_map[d.parent][d.salary_component] += flt(d.amount) * flt(d.exchange_rate if d.exchange_rate else 1)
|
||||||
else:
|
else:
|
||||||
ss_ded_map[d.parent][d.salary_component] = flt(d.amount)
|
ss_ded_map[d.parent][d.salary_component] += flt(d.amount)
|
||||||
|
|
||||||
return ss_ded_map
|
return ss_ded_map
|
||||||
|
|||||||
@@ -10,6 +10,10 @@
|
|||||||
"sandbox_mode",
|
"sandbox_mode",
|
||||||
"applicable_from",
|
"applicable_from",
|
||||||
"credentials",
|
"credentials",
|
||||||
|
"advanced_settings_section",
|
||||||
|
"client_id",
|
||||||
|
"column_break_8",
|
||||||
|
"client_secret",
|
||||||
"auth_token",
|
"auth_token",
|
||||||
"token_expiry"
|
"token_expiry"
|
||||||
],
|
],
|
||||||
@@ -56,12 +60,32 @@
|
|||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Applicable From",
|
"label": "Applicable From",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"collapsible": 1,
|
||||||
|
"fieldname": "advanced_settings_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Advanced Settings"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "client_id",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Client ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "client_secret",
|
||||||
|
"fieldtype": "Password",
|
||||||
|
"label": "Client Secret"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_8",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-03-30 12:26:25.538294",
|
"modified": "2021-11-16 19:50:28.029517",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Regional",
|
"module": "Regional",
|
||||||
"name": "E Invoice Settings",
|
"name": "E Invoice Settings",
|
||||||
|
|||||||
@@ -105,6 +105,45 @@ class TestGSTR3BReport(unittest.TestCase):
|
|||||||
gst_settings.round_off_gst_values = 1
|
gst_settings.round_off_gst_values = 1
|
||||||
gst_settings.save()
|
gst_settings.save()
|
||||||
|
|
||||||
|
def test_gst_category_auto_update(self):
|
||||||
|
if not frappe.db.exists("Customer", "_Test GST Customer With GSTIN"):
|
||||||
|
customer = frappe.get_doc({
|
||||||
|
"customer_group": "_Test Customer Group",
|
||||||
|
"customer_name": "_Test GST Customer With GSTIN",
|
||||||
|
"customer_type": "Individual",
|
||||||
|
"doctype": "Customer",
|
||||||
|
"territory": "_Test Territory"
|
||||||
|
}).insert()
|
||||||
|
|
||||||
|
self.assertEqual(customer.gst_category, 'Unregistered')
|
||||||
|
|
||||||
|
if not frappe.db.exists('Address', '_Test GST Category-1-Billing'):
|
||||||
|
address = frappe.get_doc({
|
||||||
|
"address_line1": "_Test Address Line 1",
|
||||||
|
"address_title": "_Test GST Category-1",
|
||||||
|
"address_type": "Billing",
|
||||||
|
"city": "_Test City",
|
||||||
|
"state": "Test State",
|
||||||
|
"country": "India",
|
||||||
|
"doctype": "Address",
|
||||||
|
"is_primary_address": 1,
|
||||||
|
"phone": "+91 0000000000",
|
||||||
|
"gstin": "29AZWPS7135H1ZG",
|
||||||
|
"gst_state": "Karnataka",
|
||||||
|
"gst_state_number": "29"
|
||||||
|
}).insert()
|
||||||
|
|
||||||
|
address.append("links", {
|
||||||
|
"link_doctype": "Customer",
|
||||||
|
"link_name": "_Test GST Customer With GSTIN"
|
||||||
|
})
|
||||||
|
|
||||||
|
address.save()
|
||||||
|
|
||||||
|
customer.load_from_db()
|
||||||
|
self.assertEqual(customer.gst_category, 'Registered Regular')
|
||||||
|
|
||||||
|
|
||||||
def make_sales_invoice():
|
def make_sales_invoice():
|
||||||
si = create_sales_invoice(company="_Test Company GST",
|
si = create_sales_invoice(company="_Test Company GST",
|
||||||
customer = '_Test GST Customer',
|
customer = '_Test GST Customer',
|
||||||
|
|||||||
@@ -151,6 +151,10 @@ def validate_address_fields(address, skip_gstin_validation):
|
|||||||
title=_('Missing Address Fields')
|
title=_('Missing Address Fields')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if address.address_line2 and len(address.address_line2) < 2:
|
||||||
|
# to prevent "The field Address 2 must be a string with a minimum length of 3 and a maximum length of 100"
|
||||||
|
address.address_line2 = ""
|
||||||
|
|
||||||
def get_party_details(address_name, skip_gstin_validation=False):
|
def get_party_details(address_name, skip_gstin_validation=False):
|
||||||
addr = frappe.get_doc('Address', address_name)
|
addr = frappe.get_doc('Address', address_name)
|
||||||
|
|
||||||
@@ -402,6 +406,12 @@ def validate_totals(einvoice):
|
|||||||
if abs(flt(value_details['AssVal']) - total_item_ass_value) > 1:
|
if abs(flt(value_details['AssVal']) - total_item_ass_value) > 1:
|
||||||
frappe.throw(_('Total Taxable Value of the items is not equal to the Invoice Net Total. Please check item taxes / discounts for any correction.'))
|
frappe.throw(_('Total Taxable Value of the items is not equal to the Invoice Net Total. Please check item taxes / discounts for any correction.'))
|
||||||
|
|
||||||
|
if abs(flt(value_details['CgstVal']) + flt(value_details['SgstVal']) - total_item_cgst_value - total_item_sgst_value) > 1:
|
||||||
|
frappe.throw(_('CGST + SGST value of the items is not equal to total CGST + SGST value. Please review taxes for any correction.'))
|
||||||
|
|
||||||
|
if abs(flt(value_details['IgstVal']) - total_item_igst_value) > 1:
|
||||||
|
frappe.throw(_('IGST value of all items is not equal to total IGST value. Please review taxes for any correction.'))
|
||||||
|
|
||||||
if abs(flt(value_details['TotInvVal']) + flt(value_details['Discount']) - flt(value_details['OthChrg']) - total_item_value) > 1:
|
if abs(flt(value_details['TotInvVal']) + flt(value_details['Discount']) - flt(value_details['OthChrg']) - total_item_value) > 1:
|
||||||
frappe.throw(_('Total Value of the items is not equal to the Invoice Grand Total. Please check item taxes / discounts for any correction.'))
|
frappe.throw(_('Total Value of the items is not equal to the Invoice Grand Total. Please check item taxes / discounts for any correction.'))
|
||||||
|
|
||||||
@@ -475,7 +485,11 @@ def make_einvoice(invoice):
|
|||||||
except Exception:
|
except Exception:
|
||||||
show_link_to_error_log(invoice, einvoice)
|
show_link_to_error_log(invoice, einvoice)
|
||||||
|
|
||||||
validate_totals(einvoice)
|
try:
|
||||||
|
validate_totals(einvoice)
|
||||||
|
except Exception:
|
||||||
|
log_error(einvoice)
|
||||||
|
raise
|
||||||
|
|
||||||
return einvoice
|
return einvoice
|
||||||
|
|
||||||
@@ -629,9 +643,11 @@ class GSPConnector():
|
|||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
def fetch_auth_token(self):
|
def fetch_auth_token(self):
|
||||||
|
client_id = self.e_invoice_settings.client_id or frappe.conf.einvoice_client_id
|
||||||
|
client_secret = self.e_invoice_settings.get_password('client_secret') or frappe.conf.einvoice_client_secret
|
||||||
headers = {
|
headers = {
|
||||||
'gspappid': frappe.conf.einvoice_client_id,
|
'gspappid': client_id,
|
||||||
'gspappsecret': frappe.conf.einvoice_client_secret
|
'gspappsecret': client_secret
|
||||||
}
|
}
|
||||||
res = {}
|
res = {}
|
||||||
try:
|
try:
|
||||||
@@ -936,7 +952,7 @@ class GSPConnector():
|
|||||||
if errors:
|
if errors:
|
||||||
frappe.throw(errors, title=title, as_list=1)
|
frappe.throw(errors, title=title, as_list=1)
|
||||||
else:
|
else:
|
||||||
link_to_error_list = '<a href="desk#List/Error Log/List?method=E Invoice Request Failed">Error Log</a>'
|
link_to_error_list = '<a href="/app/error-log" target="_blank">Error Log</a>'
|
||||||
frappe.msgprint(
|
frappe.msgprint(
|
||||||
_('An error occurred while making e-invoicing request. Please check {} for more information.').format(link_to_error_list),
|
_('An error occurred while making e-invoicing request. Please check {} for more information.').format(link_to_error_list),
|
||||||
title=title,
|
title=title,
|
||||||
|
|||||||
@@ -825,7 +825,7 @@ def set_tax_withholding_category(company):
|
|||||||
accounts = [dict(company=company, account=tds_account)]
|
accounts = [dict(company=company, account=tds_account)]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fiscal_year_details = get_fiscal_year(today(), verbose=0, company=company)
|
fiscal_year_details = get_fiscal_year(today(), verbose=0)
|
||||||
except FiscalYearError:
|
except FiscalYearError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -29,12 +29,13 @@ def validate_gstin_for_india(doc, method):
|
|||||||
|
|
||||||
gst_category = []
|
gst_category = []
|
||||||
|
|
||||||
if len(doc.links):
|
if hasattr(doc, 'gst_category'):
|
||||||
link_doctype = doc.links[0].get("link_doctype")
|
if len(doc.links):
|
||||||
link_name = doc.links[0].get("link_name")
|
link_doctype = doc.links[0].get("link_doctype")
|
||||||
|
link_name = doc.links[0].get("link_name")
|
||||||
|
|
||||||
if link_doctype in ["Customer", "Supplier"]:
|
if link_doctype in ["Customer", "Supplier"]:
|
||||||
gst_category = frappe.db.get_value(link_doctype, {'name': link_name}, ['gst_category'])
|
gst_category = frappe.db.get_value(link_doctype, {'name': link_name}, ['gst_category'])
|
||||||
|
|
||||||
doc.gstin = doc.gstin.upper().strip()
|
doc.gstin = doc.gstin.upper().strip()
|
||||||
if not doc.gstin or doc.gstin == 'NA':
|
if not doc.gstin or doc.gstin == 'NA':
|
||||||
@@ -78,10 +79,9 @@ def validate_tax_category(doc, method):
|
|||||||
def update_gst_category(doc, method):
|
def update_gst_category(doc, method):
|
||||||
for link in doc.links:
|
for link in doc.links:
|
||||||
if link.link_doctype in ['Customer', 'Supplier']:
|
if link.link_doctype in ['Customer', 'Supplier']:
|
||||||
if doc.get('gstin'):
|
meta = frappe.get_meta(link.link_doctype)
|
||||||
frappe.db.sql("""
|
if doc.get('gstin') and meta.has_field('gst_category'):
|
||||||
UPDATE `tab{0}` SET gst_category = %s WHERE name = %s AND gst_category = 'Unregistered'
|
frappe.db.set_value(link.link_doctype, {'name': link.link_name, 'gst_category': 'Unregistered'}, 'gst_category', 'Registered Regular')
|
||||||
""".format(link.link_doctype), ("Registered Regular", link.link_name)) #nosec
|
|
||||||
|
|
||||||
def set_gst_state_and_state_number(doc):
|
def set_gst_state_and_state_number(doc):
|
||||||
if not doc.gst_state:
|
if not doc.gst_state:
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -250,18 +250,17 @@ class Gstr1Report(object):
|
|||||||
""" % (self.doctype, ', '.join(['%s']*len(self.invoices))), tuple(self.invoices), as_dict=1)
|
""" % (self.doctype, ', '.join(['%s']*len(self.invoices))), tuple(self.invoices), as_dict=1)
|
||||||
|
|
||||||
for d in items:
|
for d in items:
|
||||||
if d.item_code not in self.invoice_items.get(d.parent, {}):
|
self.invoice_items.setdefault(d.parent, {}).setdefault(d.item_code, 0.0)
|
||||||
self.invoice_items.setdefault(d.parent, {}).setdefault(d.item_code, 0.0)
|
self.invoice_items[d.parent][d.item_code] += d.get('taxable_value', 0) or d.get('base_net_amount', 0)
|
||||||
self.invoice_items[d.parent][d.item_code] += d.get('taxable_value', 0) or d.get('base_net_amount', 0)
|
|
||||||
|
|
||||||
item_tax_rate = {}
|
item_tax_rate = {}
|
||||||
|
|
||||||
if d.item_tax_rate:
|
if d.item_tax_rate:
|
||||||
item_tax_rate = json.loads(d.item_tax_rate)
|
item_tax_rate = json.loads(d.item_tax_rate)
|
||||||
|
|
||||||
for account, rate in item_tax_rate.items():
|
for account, rate in item_tax_rate.items():
|
||||||
tax_rate_dict = self.item_tax_rate.setdefault(d.parent, {}).setdefault(d.item_code, [])
|
tax_rate_dict = self.item_tax_rate.setdefault(d.parent, {}).setdefault(d.item_code, [])
|
||||||
tax_rate_dict.append(rate)
|
tax_rate_dict.append(rate)
|
||||||
|
|
||||||
def get_items_based_on_tax_rate(self):
|
def get_items_based_on_tax_rate(self):
|
||||||
self.tax_details = frappe.db.sql("""
|
self.tax_details = frappe.db.sql("""
|
||||||
|
|||||||
@@ -28,14 +28,22 @@ def create_qr_code(doc, method):
|
|||||||
|
|
||||||
for field in meta.get_image_fields():
|
for field in meta.get_image_fields():
|
||||||
if field.fieldname == 'qr_code':
|
if field.fieldname == 'qr_code':
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
# Creating public url to print format
|
# Creating public url to print format
|
||||||
default_print_format = frappe.db.get_value('Property Setter', dict(property='default_print_format', doc_type=doc.doctype), "value")
|
default_print_format = frappe.db.get_value('Property Setter', dict(property='default_print_format', doc_type=doc.doctype), "value")
|
||||||
|
|
||||||
# System Language
|
# System Language
|
||||||
language = frappe.get_system_settings('language')
|
language = frappe.get_system_settings('language')
|
||||||
|
|
||||||
|
params = urlencode({
|
||||||
|
'format': default_print_format or 'Standard',
|
||||||
|
'_lang': language,
|
||||||
|
'key': doc.get_signature()
|
||||||
|
})
|
||||||
|
|
||||||
# creating qr code for the url
|
# creating qr code for the url
|
||||||
url = f"{ frappe.utils.get_url() }/{ doc.doctype }/{ doc.name }?format={ default_print_format or 'Standard' }&_lang={ language }&key={ doc.get_signature() }"
|
url = f"{ frappe.utils.get_url() }/{ doc.doctype }/{ doc.name }?{ params }"
|
||||||
qr_image = io.BytesIO()
|
qr_image = io.BytesIO()
|
||||||
url = qr_create(url, error='L')
|
url = qr_create(url, error='L')
|
||||||
url.png(qr_image, scale=2, quiet_zone=1)
|
url.png(qr_image, scale=2, quiet_zone=1)
|
||||||
@@ -74,4 +82,11 @@ def delete_qr_code_file(doc, method):
|
|||||||
'file_url': doc.get('qr_code')
|
'file_url': doc.get('qr_code')
|
||||||
})
|
})
|
||||||
if len(file_doc):
|
if len(file_doc):
|
||||||
frappe.delete_doc('File', file_doc[0].name)
|
frappe.delete_doc('File', file_doc[0].name)
|
||||||
|
|
||||||
|
def delete_vat_settings_for_company(doc, method):
|
||||||
|
if doc.country != 'Saudi Arabia':
|
||||||
|
return
|
||||||
|
|
||||||
|
settings_doc = frappe.get_doc('KSA VAT Setting', {'company': doc.name})
|
||||||
|
settings_doc.delete()
|
||||||
@@ -440,11 +440,14 @@ def get_customer_list(doctype, txt, searchfield, start, page_len, filters=None):
|
|||||||
|
|
||||||
|
|
||||||
def check_credit_limit(customer, company, ignore_outstanding_sales_order=False, extra_amount=0):
|
def check_credit_limit(customer, company, ignore_outstanding_sales_order=False, extra_amount=0):
|
||||||
|
credit_limit = get_credit_limit(customer, company)
|
||||||
|
if not credit_limit:
|
||||||
|
return
|
||||||
|
|
||||||
customer_outstanding = get_customer_outstanding(customer, company, ignore_outstanding_sales_order)
|
customer_outstanding = get_customer_outstanding(customer, company, ignore_outstanding_sales_order)
|
||||||
if extra_amount > 0:
|
if extra_amount > 0:
|
||||||
customer_outstanding += flt(extra_amount)
|
customer_outstanding += flt(extra_amount)
|
||||||
|
|
||||||
credit_limit = get_credit_limit(customer, company)
|
|
||||||
if credit_limit > 0 and flt(customer_outstanding) > credit_limit:
|
if credit_limit > 0 and flt(customer_outstanding) > credit_limit:
|
||||||
msgprint(_("Credit limit has been crossed for customer {0} ({1}/{2})")
|
msgprint(_("Credit limit has been crossed for customer {0} ({1}/{2})")
|
||||||
.format(customer, customer_outstanding, credit_limit))
|
.format(customer, customer_outstanding, credit_limit))
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
|
|||||||
title: __('Select Items to Manufacture'),
|
title: __('Select Items to Manufacture'),
|
||||||
fields: fields,
|
fields: fields,
|
||||||
primary_action: function() {
|
primary_action: function() {
|
||||||
var data = d.get_values();
|
var data = {items: d.fields_dict.items.grid.get_selected_children()};
|
||||||
me.frm.call({
|
me.frm.call({
|
||||||
method: 'make_work_orders',
|
method: 'make_work_orders',
|
||||||
args: {
|
args: {
|
||||||
|
|||||||
@@ -1,247 +1,100 @@
|
|||||||
{
|
{
|
||||||
"allow_copy": 0,
|
"actions": [],
|
||||||
"allow_guest_to_view": 0,
|
"creation": "2013-04-19 13:30:51",
|
||||||
"allow_import": 0,
|
"doctype": "DocType",
|
||||||
"allow_rename": 0,
|
"document_type": "Setup",
|
||||||
"beta": 0,
|
"editable_grid": 1,
|
||||||
"creation": "2013-04-19 13:30:51",
|
"engine": "InnoDB",
|
||||||
"custom": 0,
|
"field_order": [
|
||||||
"docstatus": 0,
|
"sales_person",
|
||||||
"doctype": "DocType",
|
"contact_no",
|
||||||
"document_type": "Setup",
|
"allocated_percentage",
|
||||||
"editable_grid": 1,
|
"allocated_amount",
|
||||||
"engine": "InnoDB",
|
"commission_rate",
|
||||||
|
"incentives"
|
||||||
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_on_submit": 1,
|
||||||
"allow_in_quick_entry": 0,
|
"fieldname": "sales_person",
|
||||||
"allow_on_submit": 1,
|
"fieldtype": "Link",
|
||||||
"bold": 0,
|
"in_list_view": 1,
|
||||||
"collapsible": 0,
|
"label": "Sales Person",
|
||||||
"columns": 0,
|
"oldfieldname": "sales_person",
|
||||||
"fieldname": "sales_person",
|
"oldfieldtype": "Link",
|
||||||
"fieldtype": "Link",
|
"options": "Sales Person",
|
||||||
"hidden": 0,
|
"print_width": "200px",
|
||||||
"ignore_user_permissions": 0,
|
"reqd": 1,
|
||||||
"ignore_xss_filter": 0,
|
"search_index": 1,
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Sales Person",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"oldfieldname": "sales_person",
|
|
||||||
"oldfieldtype": "Link",
|
|
||||||
"options": "Sales Person",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"print_width": "200px",
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 1,
|
|
||||||
"search_index": 1,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0,
|
|
||||||
"width": "200px"
|
"width": "200px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_on_submit": 1,
|
||||||
"allow_in_quick_entry": 0,
|
"fieldname": "contact_no",
|
||||||
"allow_on_submit": 1,
|
"fieldtype": "Data",
|
||||||
"bold": 0,
|
"hidden": 1,
|
||||||
"collapsible": 0,
|
"in_list_view": 1,
|
||||||
"columns": 0,
|
"label": "Contact No.",
|
||||||
"fieldname": "contact_no",
|
"oldfieldname": "contact_no",
|
||||||
"fieldtype": "Data",
|
"oldfieldtype": "Data",
|
||||||
"hidden": 1,
|
"print_width": "100px",
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Contact No.",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"oldfieldname": "contact_no",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"print_width": "100px",
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0,
|
|
||||||
"width": "100px"
|
"width": "100px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_on_submit": 1,
|
||||||
"allow_in_quick_entry": 0,
|
"fieldname": "allocated_percentage",
|
||||||
"allow_on_submit": 1,
|
"fieldtype": "Float",
|
||||||
"bold": 0,
|
"in_list_view": 1,
|
||||||
"collapsible": 0,
|
"label": "Contribution (%)",
|
||||||
"columns": 0,
|
"oldfieldname": "allocated_percentage",
|
||||||
"fieldname": "allocated_percentage",
|
"oldfieldtype": "Currency",
|
||||||
"fieldtype": "Float",
|
"print_width": "100px",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Contribution (%)",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"oldfieldname": "allocated_percentage",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"print_width": "100px",
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0,
|
|
||||||
"width": "100px"
|
"width": "100px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_on_submit": 1,
|
||||||
"allow_in_quick_entry": 0,
|
"fieldname": "allocated_amount",
|
||||||
"allow_on_submit": 1,
|
"fieldtype": "Currency",
|
||||||
"bold": 0,
|
"in_list_view": 1,
|
||||||
"collapsible": 0,
|
"label": "Contribution to Net Total",
|
||||||
"columns": 0,
|
"oldfieldname": "allocated_amount",
|
||||||
"fieldname": "allocated_amount",
|
"oldfieldtype": "Currency",
|
||||||
"fieldtype": "Currency",
|
"options": "Company:company:default_currency",
|
||||||
"hidden": 0,
|
"print_width": "120px",
|
||||||
"ignore_user_permissions": 0,
|
"read_only": 1,
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Contribution to Net Total",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"oldfieldname": "allocated_amount",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"print_width": "120px",
|
|
||||||
"read_only": 1,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0,
|
|
||||||
"width": "120px"
|
"width": "120px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"fetch_from": "sales_person.commission_rate",
|
||||||
"allow_in_quick_entry": 0,
|
"fetch_if_empty": 1,
|
||||||
"allow_on_submit": 0,
|
"fieldname": "commission_rate",
|
||||||
"bold": 0,
|
"fieldtype": "Data",
|
||||||
"collapsible": 0,
|
"in_list_view": 1,
|
||||||
"columns": 0,
|
"label": "Commission Rate",
|
||||||
"fieldname": "commission_rate",
|
"read_only": 1
|
||||||
"fieldtype": "Data",
|
},
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Commission Rate",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 1,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_on_submit": 1,
|
||||||
"allow_in_quick_entry": 0,
|
"fieldname": "incentives",
|
||||||
"allow_on_submit": 1,
|
"fieldtype": "Currency",
|
||||||
"bold": 0,
|
"in_list_view": 1,
|
||||||
"collapsible": 0,
|
"label": "Incentives",
|
||||||
"columns": 0,
|
"oldfieldname": "incentives",
|
||||||
"fieldname": "incentives",
|
"oldfieldtype": "Currency",
|
||||||
"fieldtype": "Currency",
|
"options": "Company:company:default_currency"
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 1,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Incentives",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"oldfieldname": "incentives",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"translatable": 0,
|
|
||||||
"unique": 0
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"has_web_view": 0,
|
"idx": 1,
|
||||||
"hide_heading": 0,
|
"istable": 1,
|
||||||
"hide_toolbar": 0,
|
"links": [],
|
||||||
"idx": 1,
|
"modified": "2021-11-09 23:55:20.670475",
|
||||||
"image_view": 0,
|
"modified_by": "Administrator",
|
||||||
"in_create": 0,
|
"module": "Selling",
|
||||||
"is_submittable": 0,
|
"name": "Sales Team",
|
||||||
"issingle": 0,
|
"owner": "Administrator",
|
||||||
"istable": 1,
|
"permissions": [],
|
||||||
"max_attachments": 0,
|
"quick_entry": 1,
|
||||||
"modified": "2018-09-17 13:03:14.755974",
|
"sort_field": "modified",
|
||||||
"modified_by": "Administrator",
|
"sort_order": "DESC",
|
||||||
"module": "Selling",
|
"track_changes": 1
|
||||||
"name": "Sales Team",
|
}
|
||||||
"owner": "Administrator",
|
|
||||||
"permissions": [],
|
|
||||||
"quick_entry": 1,
|
|
||||||
"read_only": 0,
|
|
||||||
"read_only_onload": 0,
|
|
||||||
"show_name_in_global_search": 0,
|
|
||||||
"track_changes": 1,
|
|
||||||
"track_seen": 0,
|
|
||||||
"track_views": 0
|
|
||||||
}
|
|
||||||
@@ -111,6 +111,10 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
|||||||
erpnext.utils.set_taxes_from_address(this.frm, "shipping_address_name", "customer_address", "shipping_address_name");
|
erpnext.utils.set_taxes_from_address(this.frm, "shipping_address_name", "customer_address", "shipping_address_name");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
dispatch_address_name: function() {
|
||||||
|
erpnext.utils.get_address_display(this.frm, "dispatch_address_name", "dispatch_address");
|
||||||
|
},
|
||||||
|
|
||||||
sales_partner: function() {
|
sales_partner: function() {
|
||||||
this.apply_pricing_rule();
|
this.apply_pricing_rule();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ class ItemGroup(NestedSet, WebsiteGenerator):
|
|||||||
def on_update(self):
|
def on_update(self):
|
||||||
NestedSet.on_update(self)
|
NestedSet.on_update(self)
|
||||||
invalidate_cache_for(self)
|
invalidate_cache_for(self)
|
||||||
self.validate_name_with_item()
|
|
||||||
self.validate_one_root()
|
self.validate_one_root()
|
||||||
self.delete_child_item_groups_key()
|
self.delete_child_item_groups_key()
|
||||||
|
|
||||||
@@ -65,10 +64,6 @@ class ItemGroup(NestedSet, WebsiteGenerator):
|
|||||||
WebsiteGenerator.on_trash(self)
|
WebsiteGenerator.on_trash(self)
|
||||||
self.delete_child_item_groups_key()
|
self.delete_child_item_groups_key()
|
||||||
|
|
||||||
def validate_name_with_item(self):
|
|
||||||
if frappe.db.exists("Item", self.name):
|
|
||||||
frappe.throw(frappe._("An item exists with same name ({0}), please change the item group name or rename the item").format(self.name), frappe.NameError)
|
|
||||||
|
|
||||||
def get_context(self, context):
|
def get_context(self, context):
|
||||||
context.show_search = True
|
context.show_search = True
|
||||||
context.body_class = "product-page"
|
context.body_class = "product-page"
|
||||||
|
|||||||
@@ -181,11 +181,11 @@ class NamingSeries(Document):
|
|||||||
prefix = parse_naming_series(parts)
|
prefix = parse_naming_series(parts)
|
||||||
return prefix
|
return prefix
|
||||||
|
|
||||||
def set_by_naming_series(doctype, fieldname, naming_series, hide_name_field=True):
|
def set_by_naming_series(doctype, fieldname, naming_series, hide_name_field=True, make_mandatory=1):
|
||||||
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
|
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
|
||||||
if naming_series:
|
if naming_series:
|
||||||
make_property_setter(doctype, "naming_series", "hidden", 0, "Check", validate_fields_for_doctype=False)
|
make_property_setter(doctype, "naming_series", "hidden", 0, "Check", validate_fields_for_doctype=False)
|
||||||
make_property_setter(doctype, "naming_series", "reqd", 1, "Check", validate_fields_for_doctype=False)
|
make_property_setter(doctype, "naming_series", "reqd", make_mandatory, "Check", validate_fields_for_doctype=False)
|
||||||
|
|
||||||
# set values for mandatory
|
# set values for mandatory
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1195,7 +1195,7 @@
|
|||||||
"*": {
|
"*": {
|
||||||
"item_tax_templates": [
|
"item_tax_templates": [
|
||||||
{
|
{
|
||||||
"title": "GST 9%",
|
"title": "GST 18%",
|
||||||
"taxes": [
|
"taxes": [
|
||||||
{
|
{
|
||||||
"tax_type": {
|
"tax_type": {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
"is_standard": 1,
|
"is_standard": 1,
|
||||||
"label": "ERPNext Settings",
|
"label": "ERPNext Settings",
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-10-26 21:32:55.323591",
|
"modified": "2021-11-12 01:32:55.323591",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Setup",
|
"module": "Setup",
|
||||||
"name": "ERPNext Settings",
|
"name": "ERPNext Settings",
|
||||||
@@ -76,8 +76,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"icon": "retail",
|
"icon": "retail",
|
||||||
"label": "Shopping Cart Settings",
|
"label": "E Commerce Settings",
|
||||||
"link_to": "Shopping Cart Settings",
|
"link_to": "E Commerce Settings",
|
||||||
"type": "DocType"
|
"type": "DocType"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -119,13 +119,6 @@
|
|||||||
"label": "Domain Settings",
|
"label": "Domain Settings",
|
||||||
"link_to": "Domain Settings",
|
"link_to": "Domain Settings",
|
||||||
"type": "DocType"
|
"type": "DocType"
|
||||||
},
|
|
||||||
{
|
|
||||||
"doc_view": "",
|
|
||||||
"icon": "retail",
|
|
||||||
"label": "Products Settings",
|
|
||||||
"link_to": "Products Settings",
|
|
||||||
"type": "DocType"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,7 +131,6 @@ class Item(Document):
|
|||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
invalidate_cache_for_item(self)
|
invalidate_cache_for_item(self)
|
||||||
self.validate_name_with_item_group()
|
|
||||||
self.update_variants()
|
self.update_variants()
|
||||||
self.update_item_price()
|
self.update_item_price()
|
||||||
self.update_website_item()
|
self.update_website_item()
|
||||||
@@ -377,12 +376,6 @@ class Item(Document):
|
|||||||
where item_code = %s and is_cancelled = 0 limit 1""", self.name))
|
where item_code = %s and is_cancelled = 0 limit 1""", self.name))
|
||||||
return self._stock_ledger_created
|
return self._stock_ledger_created
|
||||||
|
|
||||||
def validate_name_with_item_group(self):
|
|
||||||
# causes problem with tree build
|
|
||||||
if frappe.db.exists("Item Group", self.name):
|
|
||||||
frappe.throw(
|
|
||||||
_("An Item Group exists with same name, please change the item name or rename the item group"))
|
|
||||||
|
|
||||||
def update_item_price(self):
|
def update_item_price(self):
|
||||||
frappe.db.sql("""
|
frappe.db.sql("""
|
||||||
UPDATE `tabItem Price`
|
UPDATE `tabItem Price`
|
||||||
@@ -417,6 +410,8 @@ class Item(Document):
|
|||||||
def after_rename(self, old_name, new_name, merge):
|
def after_rename(self, old_name, new_name, merge):
|
||||||
if merge:
|
if merge:
|
||||||
self.validate_duplicate_item_in_stock_reconciliation(old_name, new_name)
|
self.validate_duplicate_item_in_stock_reconciliation(old_name, new_name)
|
||||||
|
frappe.msgprint(_("It can take upto few hours for accurate stock values to be visible after merging items."),
|
||||||
|
indicator="orange", title="Note")
|
||||||
|
|
||||||
if self.published_in_website:
|
if self.published_in_website:
|
||||||
invalidate_cache_for_item(self)
|
invalidate_cache_for_item(self)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from frappe.utils import getdate
|
||||||
|
|
||||||
|
|
||||||
class ItemPriceDuplicateItem(frappe.ValidationError):
|
class ItemPriceDuplicateItem(frappe.ValidationError):
|
||||||
@@ -27,7 +28,7 @@ class ItemPrice(Document):
|
|||||||
|
|
||||||
def validate_dates(self):
|
def validate_dates(self):
|
||||||
if self.valid_from and self.valid_upto:
|
if self.valid_from and self.valid_upto:
|
||||||
if self.valid_from > self.valid_upto:
|
if getdate(self.valid_from) > getdate(self.valid_upto):
|
||||||
frappe.throw(_("Valid From Date must be lesser than Valid Upto Date."))
|
frappe.throw(_("Valid From Date must be lesser than Valid Upto Date."))
|
||||||
|
|
||||||
def update_price_list_details(self):
|
def update_price_list_details(self):
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ erpnext.stock.LandedCostVoucher = erpnext.stock.StockController.extend({
|
|||||||
refresh: function() {
|
refresh: function() {
|
||||||
var help_content =
|
var help_content =
|
||||||
`<br><br>
|
`<br><br>
|
||||||
<table class="table table-bordered" style="background-color: #f9f9f9;">
|
<table class="table table-bordered" style="background-color: var(--scrollbar-track-color);">
|
||||||
<tr><td>
|
<tr><td>
|
||||||
<h4>
|
<h4>
|
||||||
<i class="fa fa-hand-right"></i>
|
<i class="fa fa-hand-right"></i>
|
||||||
|
|||||||
@@ -502,7 +502,8 @@ def make_stock_entry(source_name, target_doc=None):
|
|||||||
"field_map": {
|
"field_map": {
|
||||||
"name": "material_request_item",
|
"name": "material_request_item",
|
||||||
"parent": "material_request",
|
"parent": "material_request",
|
||||||
"uom": "stock_uom"
|
"uom": "stock_uom",
|
||||||
|
"job_card_item": "job_card_item"
|
||||||
},
|
},
|
||||||
"postprocess": update_item,
|
"postprocess": update_item,
|
||||||
"condition": lambda doc: doc.ordered_qty < doc.stock_qty
|
"condition": lambda doc: doc.ordered_qty < doc.stock_qty
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
"sales_order_item",
|
"sales_order_item",
|
||||||
"production_plan",
|
"production_plan",
|
||||||
"material_request_plan_item",
|
"material_request_plan_item",
|
||||||
|
"job_card_item",
|
||||||
"col_break4",
|
"col_break4",
|
||||||
"expense_account",
|
"expense_account",
|
||||||
"section_break_46",
|
"section_break_46",
|
||||||
@@ -444,16 +445,25 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "qty_info_col_break",
|
"fieldname": "qty_info_col_break",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "job_card_item",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 1,
|
||||||
|
"no_copy": 1,
|
||||||
|
"print_hide": 1,
|
||||||
|
"label": "Job Card Item"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-10-02 11:44:36.553064",
|
"modified": "2021-11-03 14:40:24.409826",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Material Request Item",
|
"name": "Material Request Item",
|
||||||
|
"naming_rule": "Random",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [],
|
"permissions": [],
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
|
|||||||
@@ -1085,6 +1085,7 @@ class TestPurchaseReceipt(ERPNextTestCase):
|
|||||||
|
|
||||||
automatically_fetch_payment_terms()
|
automatically_fetch_payment_terms()
|
||||||
|
|
||||||
|
|
||||||
po = create_purchase_order(qty=10, rate=100, do_not_save=1)
|
po = create_purchase_order(qty=10, rate=100, do_not_save=1)
|
||||||
create_payment_terms_template()
|
create_payment_terms_template()
|
||||||
po.payment_terms_template = 'Test Receivable Template'
|
po.payment_terms_template = 'Test Receivable Template'
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ class RepostItemValuation(Document):
|
|||||||
self.voucher_type = None
|
self.voucher_type = None
|
||||||
self.voucher_no = None
|
self.voucher_no = None
|
||||||
|
|
||||||
|
self.allow_negative_stock = self.allow_negative_stock or \
|
||||||
|
cint(frappe.db.get_single_value("Stock Settings", "allow_negative_stock"))
|
||||||
|
|
||||||
def set_company(self):
|
def set_company(self):
|
||||||
if self.voucher_type and self.voucher_no:
|
if self.voucher_type and self.voucher_no:
|
||||||
self.company = frappe.get_cached_value(self.voucher_type, self.voucher_no, "company")
|
self.company = frappe.get_cached_value(self.voucher_type, self.voucher_no, "company")
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ def check_serial_no_validity_on_cancel(serial_no, sle):
|
|||||||
is_stock_reco = sle.voucher_type == "Stock Reconciliation"
|
is_stock_reco = sle.voucher_type == "Stock Reconciliation"
|
||||||
msg = None
|
msg = None
|
||||||
|
|
||||||
if sr and (actual_qty < 0 or is_stock_reco) and sr.warehouse != sle.warehouse:
|
if sr and (actual_qty < 0 or is_stock_reco) and (sr.warehouse and sr.warehouse != sle.warehouse):
|
||||||
# receipt(inward) is being cancelled
|
# receipt(inward) is being cancelled
|
||||||
msg = _("Cannot cancel {0} {1} as Serial No {2} does not belong to the warehouse {3}").format(
|
msg = _("Cannot cancel {0} {1} as Serial No {2} does not belong to the warehouse {3}").format(
|
||||||
sle.voucher_type, doc_link, sr_link, frappe.bold(sle.warehouse))
|
sle.voucher_type, doc_link, sr_link, frappe.bold(sle.warehouse))
|
||||||
|
|||||||
@@ -1452,7 +1452,7 @@ class StockEntry(StockController):
|
|||||||
item_dict[item]["qty"] = 0
|
item_dict[item]["qty"] = 0
|
||||||
|
|
||||||
# delete items with 0 qty
|
# delete items with 0 qty
|
||||||
list_of_items = item_dict.keys()
|
list_of_items = list(item_dict.keys())
|
||||||
for item in list_of_items:
|
for item in list_of_items:
|
||||||
if not item_dict[item]["qty"]:
|
if not item_dict[item]["qty"]:
|
||||||
del item_dict[item]
|
del item_dict[item]
|
||||||
@@ -1464,52 +1464,94 @@ class StockEntry(StockController):
|
|||||||
return item_dict
|
return item_dict
|
||||||
|
|
||||||
def get_pro_order_required_items(self, backflush_based_on=None):
|
def get_pro_order_required_items(self, backflush_based_on=None):
|
||||||
item_dict = frappe._dict()
|
"""
|
||||||
pro_order = frappe.get_doc("Work Order", self.work_order)
|
Gets Work Order Required Items only if Stock Entry purpose is **Material Transferred for Manufacture**.
|
||||||
if not frappe.db.get_value("Warehouse", pro_order.wip_warehouse, "is_group"):
|
"""
|
||||||
wip_warehouse = pro_order.wip_warehouse
|
item_dict, job_card_items = frappe._dict(), []
|
||||||
|
work_order = frappe.get_doc("Work Order", self.work_order)
|
||||||
|
|
||||||
|
consider_job_card = work_order.transfer_material_against == "Job Card" and self.get("job_card")
|
||||||
|
if consider_job_card:
|
||||||
|
job_card_items = self.get_job_card_item_codes(self.get("job_card"))
|
||||||
|
|
||||||
|
if not frappe.db.get_value("Warehouse", work_order.wip_warehouse, "is_group"):
|
||||||
|
wip_warehouse = work_order.wip_warehouse
|
||||||
else:
|
else:
|
||||||
wip_warehouse = None
|
wip_warehouse = None
|
||||||
|
|
||||||
for d in pro_order.get("required_items"):
|
for d in work_order.get("required_items"):
|
||||||
if ( ((flt(d.required_qty) > flt(d.transferred_qty)) or
|
if consider_job_card and (d.item_code not in job_card_items):
|
||||||
(backflush_based_on == "Material Transferred for Manufacture")) and
|
continue
|
||||||
(d.include_item_in_manufacturing or self.purpose != "Material Transfer for Manufacture")):
|
|
||||||
|
transfer_pending = flt(d.required_qty) > flt(d.transferred_qty)
|
||||||
|
can_transfer = transfer_pending or (backflush_based_on == "Material Transferred for Manufacture")
|
||||||
|
|
||||||
|
if not can_transfer:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if d.include_item_in_manufacturing:
|
||||||
item_row = d.as_dict()
|
item_row = d.as_dict()
|
||||||
|
item_row["idx"] = len(item_dict) + 1
|
||||||
|
|
||||||
|
if consider_job_card:
|
||||||
|
job_card_item = frappe.db.get_value(
|
||||||
|
"Job Card Item",
|
||||||
|
{
|
||||||
|
"item_code": d.item_code,
|
||||||
|
"parent": self.get("job_card")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
item_row["job_card_item"] = job_card_item or None
|
||||||
|
|
||||||
if d.source_warehouse and not frappe.db.get_value("Warehouse", d.source_warehouse, "is_group"):
|
if d.source_warehouse and not frappe.db.get_value("Warehouse", d.source_warehouse, "is_group"):
|
||||||
item_row["from_warehouse"] = d.source_warehouse
|
item_row["from_warehouse"] = d.source_warehouse
|
||||||
|
|
||||||
item_row["to_warehouse"] = wip_warehouse
|
item_row["to_warehouse"] = wip_warehouse
|
||||||
if item_row["allow_alternative_item"]:
|
if item_row["allow_alternative_item"]:
|
||||||
item_row["allow_alternative_item"] = pro_order.allow_alternative_item
|
item_row["allow_alternative_item"] = work_order.allow_alternative_item
|
||||||
|
|
||||||
item_dict.setdefault(d.item_code, item_row)
|
item_dict.setdefault(d.item_code, item_row)
|
||||||
|
|
||||||
return item_dict
|
return item_dict
|
||||||
|
|
||||||
|
def get_job_card_item_codes(self, job_card=None):
|
||||||
|
if not job_card:
|
||||||
|
return []
|
||||||
|
|
||||||
|
job_card_items = frappe.get_all(
|
||||||
|
"Job Card Item",
|
||||||
|
filters={
|
||||||
|
"parent": job_card
|
||||||
|
},
|
||||||
|
fields=["item_code"],
|
||||||
|
distinct=True
|
||||||
|
)
|
||||||
|
return [d.item_code for d in job_card_items]
|
||||||
|
|
||||||
def add_to_stock_entry_detail(self, item_dict, bom_no=None):
|
def add_to_stock_entry_detail(self, item_dict, bom_no=None):
|
||||||
for d in item_dict:
|
for d in item_dict:
|
||||||
stock_uom = item_dict[d].get("stock_uom") or frappe.db.get_value("Item", d, "stock_uom")
|
item_row = item_dict[d]
|
||||||
|
stock_uom = item_row.get("stock_uom") or frappe.db.get_value("Item", d, "stock_uom")
|
||||||
|
|
||||||
se_child = self.append('items')
|
se_child = self.append('items')
|
||||||
se_child.s_warehouse = item_dict[d].get("from_warehouse")
|
se_child.s_warehouse = item_row.get("from_warehouse")
|
||||||
se_child.t_warehouse = item_dict[d].get("to_warehouse")
|
se_child.t_warehouse = item_row.get("to_warehouse")
|
||||||
se_child.item_code = item_dict[d].get('item_code') or cstr(d)
|
se_child.item_code = item_row.get('item_code') or cstr(d)
|
||||||
se_child.uom = item_dict[d]["uom"] if item_dict[d].get("uom") else stock_uom
|
se_child.uom = item_row["uom"] if item_row.get("uom") else stock_uom
|
||||||
se_child.stock_uom = stock_uom
|
se_child.stock_uom = stock_uom
|
||||||
se_child.qty = flt(item_dict[d]["qty"], se_child.precision("qty"))
|
se_child.qty = flt(item_row["qty"], se_child.precision("qty"))
|
||||||
se_child.allow_alternative_item = item_dict[d].get("allow_alternative_item", 0)
|
se_child.allow_alternative_item = item_row.get("allow_alternative_item", 0)
|
||||||
se_child.subcontracted_item = item_dict[d].get("main_item_code")
|
se_child.subcontracted_item = item_row.get("main_item_code")
|
||||||
se_child.cost_center = (item_dict[d].get("cost_center") or
|
se_child.cost_center = (item_row.get("cost_center") or
|
||||||
get_default_cost_center(item_dict[d], company = self.company))
|
get_default_cost_center(item_row, company = self.company))
|
||||||
se_child.is_finished_item = item_dict[d].get("is_finished_item", 0)
|
se_child.is_finished_item = item_row.get("is_finished_item", 0)
|
||||||
se_child.is_scrap_item = item_dict[d].get("is_scrap_item", 0)
|
se_child.is_scrap_item = item_row.get("is_scrap_item", 0)
|
||||||
se_child.is_process_loss = item_dict[d].get("is_process_loss", 0)
|
se_child.is_process_loss = item_row.get("is_process_loss", 0)
|
||||||
|
|
||||||
for field in ["idx", "po_detail", "original_item", "expense_account",
|
for field in ["idx", "po_detail", "original_item", "expense_account",
|
||||||
"description", "item_name", "serial_no", "batch_no", "allow_zero_valuation_rate"]:
|
"description", "item_name", "serial_no", "batch_no", "allow_zero_valuation_rate"]:
|
||||||
if item_dict[d].get(field):
|
if item_row.get(field):
|
||||||
se_child.set(field, item_dict[d].get(field))
|
se_child.set(field, item_row.get(field))
|
||||||
|
|
||||||
if se_child.s_warehouse==None:
|
if se_child.s_warehouse==None:
|
||||||
se_child.s_warehouse = self.from_warehouse
|
se_child.s_warehouse = self.from_warehouse
|
||||||
@@ -1517,12 +1559,11 @@ class StockEntry(StockController):
|
|||||||
se_child.t_warehouse = self.to_warehouse
|
se_child.t_warehouse = self.to_warehouse
|
||||||
|
|
||||||
# in stock uom
|
# in stock uom
|
||||||
se_child.conversion_factor = flt(item_dict[d].get("conversion_factor")) or 1
|
se_child.conversion_factor = flt(item_row.get("conversion_factor")) or 1
|
||||||
se_child.transfer_qty = flt(item_dict[d]["qty"]*se_child.conversion_factor, se_child.precision("qty"))
|
se_child.transfer_qty = flt(item_row["qty"]*se_child.conversion_factor, se_child.precision("qty"))
|
||||||
|
|
||||||
|
se_child.bom_no = bom_no # to be assigned for finished item
|
||||||
# to be assigned for finished item
|
se_child.job_card_item = item_row.get("job_card_item") if self.get("job_card") else None
|
||||||
se_child.bom_no = bom_no
|
|
||||||
|
|
||||||
def validate_with_material_request(self):
|
def validate_with_material_request(self):
|
||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
|
|||||||
@@ -400,6 +400,34 @@ class TestStockReconciliation(ERPNextTestCase):
|
|||||||
, do_not_submit=True)
|
, do_not_submit=True)
|
||||||
self.assertRaises(frappe.ValidationError, sr.submit)
|
self.assertRaises(frappe.ValidationError, sr.submit)
|
||||||
|
|
||||||
|
def test_serial_no_cancellation(self):
|
||||||
|
|
||||||
|
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
||||||
|
item = create_item("Stock-Reco-Serial-Item-9", is_stock_item=1)
|
||||||
|
if not item.has_serial_no:
|
||||||
|
item.has_serial_no = 1
|
||||||
|
item.serial_no_series = "SRS9.####"
|
||||||
|
item.save()
|
||||||
|
|
||||||
|
item_code = item.name
|
||||||
|
warehouse = "_Test Warehouse - _TC"
|
||||||
|
|
||||||
|
se1 = make_stock_entry(item_code=item_code, target=warehouse, qty=10, basic_rate=700)
|
||||||
|
|
||||||
|
serial_nos = get_serial_nos(se1.items[0].serial_no)
|
||||||
|
# reduce 1 item
|
||||||
|
serial_nos.pop()
|
||||||
|
new_serial_nos = "\n".join(serial_nos)
|
||||||
|
|
||||||
|
sr = create_stock_reconciliation(item_code=item.name, warehouse=warehouse, serial_no=new_serial_nos, qty=9)
|
||||||
|
sr.cancel()
|
||||||
|
|
||||||
|
active_sr_no = frappe.get_all("Serial No",
|
||||||
|
filters={"item_code": item_code, "warehouse": warehouse, "status": "Active"})
|
||||||
|
|
||||||
|
self.assertEqual(len(active_sr_no), 10)
|
||||||
|
|
||||||
|
|
||||||
def create_batch_item_with_batch(item_name, batch_id):
|
def create_batch_item_with_batch(item_name, batch_id):
|
||||||
batch_item_doc = create_item(item_name, is_stock_item=1)
|
batch_item_doc = create_item(item_name, is_stock_item=1)
|
||||||
if not batch_item_doc.has_batch_no:
|
if not batch_item_doc.has_batch_no:
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
"mr_qty_allowance",
|
"mr_qty_allowance",
|
||||||
"column_break_12",
|
"column_break_12",
|
||||||
"auto_insert_price_list_rate_if_missing",
|
"auto_insert_price_list_rate_if_missing",
|
||||||
|
"update_existing_price_list_rate",
|
||||||
"allow_negative_stock",
|
"allow_negative_stock",
|
||||||
"show_barcode_field",
|
"show_barcode_field",
|
||||||
"clean_description_html",
|
"clean_description_html",
|
||||||
@@ -290,6 +291,13 @@
|
|||||||
"fieldname": "mr_qty_allowance",
|
"fieldname": "mr_qty_allowance",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"label": "Over Transfer Allowance"
|
"label": "Over Transfer Allowance"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"depends_on": "auto_insert_price_list_rate_if_missing",
|
||||||
|
"fieldname": "update_existing_price_list_rate",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Update Existing Price List Rate"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "icon-cog",
|
"icon": "icon-cog",
|
||||||
@@ -297,7 +305,7 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-06-28 17:02:26.683002",
|
"modified": "2021-11-06 19:40:02.183592",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Stock Settings",
|
"name": "Stock Settings",
|
||||||
@@ -317,4 +325,4 @@
|
|||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "ASC",
|
"sort_order": "ASC",
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ class StockSettings(Document):
|
|||||||
|
|
||||||
from erpnext.setup.doctype.naming_series.naming_series import set_by_naming_series
|
from erpnext.setup.doctype.naming_series.naming_series import set_by_naming_series
|
||||||
set_by_naming_series("Item", "item_code",
|
set_by_naming_series("Item", "item_code",
|
||||||
self.get("item_naming_by")=="Naming Series", hide_name_field=True)
|
self.get("item_naming_by")=="Naming Series", hide_name_field=True, make_mandatory=0)
|
||||||
|
|
||||||
stock_frozen_limit = 356
|
stock_frozen_limit = 356
|
||||||
submitted_stock_frozen = self.stock_frozen_upto_days or 0
|
submitted_stock_frozen = self.stock_frozen_upto_days or 0
|
||||||
|
|||||||
@@ -708,7 +708,7 @@ def insert_item_price(args):
|
|||||||
{'item_code': args.item_code, 'price_list': args.price_list, 'currency': args.currency},
|
{'item_code': args.item_code, 'price_list': args.price_list, 'currency': args.currency},
|
||||||
['name', 'price_list_rate'], as_dict=1)
|
['name', 'price_list_rate'], as_dict=1)
|
||||||
if item_price and item_price.name:
|
if item_price and item_price.name:
|
||||||
if item_price.price_list_rate != price_list_rate:
|
if item_price.price_list_rate != price_list_rate and frappe.db.get_single_value('Stock Settings', 'update_existing_price_list_rate'):
|
||||||
frappe.db.set_value('Item Price', item_price.name, "price_list_rate", price_list_rate)
|
frappe.db.set_value('Item Price', item_price.name, "price_list_rate", price_list_rate)
|
||||||
frappe.msgprint(_("Item Price updated for {0} in Price List {1}").format(args.item_code,
|
frappe.msgprint(_("Item Price updated for {0} in Price List {1}").format(args.item_code,
|
||||||
args.price_list), alert=True)
|
args.price_list), alert=True)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ def get_incorrect_data(data):
|
|||||||
return row
|
return row
|
||||||
|
|
||||||
def get_stock_ledger_entries(report_filters):
|
def get_stock_ledger_entries(report_filters):
|
||||||
filters = {}
|
filters = {"is_cancelled": 0}
|
||||||
fields = ['name', 'voucher_type', 'voucher_no', 'item_code', 'actual_qty',
|
fields = ['name', 'voucher_type', 'voucher_no', 'item_code', 'actual_qty',
|
||||||
'posting_date', 'posting_time', 'company', 'warehouse', 'qty_after_transaction', 'batch_no']
|
'posting_date', 'posting_time', 'company', 'warehouse', 'qty_after_transaction', 'batch_no']
|
||||||
|
|
||||||
|
|||||||
@@ -256,6 +256,7 @@
|
|||||||
"fieldname": "contact_email",
|
"fieldname": "contact_email",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Contact Email",
|
"label": "Contact Email",
|
||||||
|
"options": "Email",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -361,7 +362,7 @@
|
|||||||
],
|
],
|
||||||
"icon": "fa fa-bug",
|
"icon": "fa fa-bug",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"modified": "2020-09-18 17:26:09.703215",
|
"modified": "2021-11-09 17:26:09.703215",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Support",
|
"module": "Support",
|
||||||
"name": "Warranty Claim",
|
"name": "Warranty Claim",
|
||||||
@@ -385,4 +386,4 @@
|
|||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"timeline_field": "customer",
|
"timeline_field": "customer",
|
||||||
"title_field": "customer_name"
|
"title_field": "customer_name"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user