Merge pull request #42254 from frappe/version-14-hotfix

chore: release v14
This commit is contained in:
ruthra kumar
2024-07-10 16:12:40 +05:30
committed by GitHub
21 changed files with 398 additions and 66 deletions

View File

@@ -74,7 +74,6 @@ class PaymentEntry(AccountsController):
self.set_exchange_rate()
self.validate_mandatory()
self.validate_reference_documents()
self.set_tax_withholding()
self.set_amounts()
self.validate_amounts()
self.apply_taxes()
@@ -89,6 +88,7 @@ class PaymentEntry(AccountsController):
self.validate_allocated_amount()
self.validate_paid_invoices()
self.ensure_supplier_is_not_blocked()
self.set_tax_withholding()
self.set_status()
def on_submit(self):
@@ -674,9 +674,7 @@ class PaymentEntry(AccountsController):
if not self.apply_tax_withholding_amount:
return
order_amount = self.get_order_net_total()
net_total = flt(order_amount) + flt(self.unallocated_amount)
net_total = self.calculate_tax_withholding_net_total()
# Adding args as purchase invoice to get TDS amount
args = frappe._dict(
@@ -720,7 +718,26 @@ class PaymentEntry(AccountsController):
for d in to_remove:
self.remove(d)
def get_order_net_total(self):
def calculate_tax_withholding_net_total(self):
net_total = 0
order_details = self.get_order_wise_tax_withholding_net_total()
for d in self.references:
tax_withholding_net_total = order_details.get(d.reference_name)
if not tax_withholding_net_total:
continue
net_taxable_outstanding = max(
0, d.outstanding_amount - (d.total_amount - tax_withholding_net_total)
)
net_total += min(net_taxable_outstanding, d.allocated_amount)
net_total += self.unallocated_amount
return net_total
def get_order_wise_tax_withholding_net_total(self):
if self.party_type == "Supplier":
doctype = "Purchase Order"
else:
@@ -728,12 +745,15 @@ class PaymentEntry(AccountsController):
docnames = [d.reference_name for d in self.references if d.reference_doctype == doctype]
tax_withholding_net_total = frappe.db.get_value(
doctype, {"name": ["in", docnames]}, ["sum(base_tax_withholding_net_total)"]
return frappe._dict(
frappe.db.get_all(
doctype,
filters={"name": ["in", docnames]},
fields=["name", "base_tax_withholding_net_total"],
as_list=True,
)
)
return tax_withholding_net_total
def apply_taxes(self):
self.initialize_taxes()
self.determine_exclusive_rate()

View File

@@ -31,6 +31,7 @@ class PricingRule(Document):
self.validate_price_list_with_currency()
self.validate_dates()
self.validate_condition()
self.validate_mixed_with_recursion()
if not self.margin_type:
self.margin_rate_or_amount = 0.0
@@ -201,6 +202,10 @@ class PricingRule(Document):
):
frappe.throw(_("Invalid condition expression"))
def validate_mixed_with_recursion(self):
if self.mixed_conditions and self.is_recursive:
frappe.throw(_("Recursive Discounts with Mixed condition is not supported by the system"))
# --------------------------------------------------------------------------------

View File

@@ -1087,6 +1087,18 @@ class TestPricingRule(unittest.TestCase):
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule 1")
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule 2")
def test_validation_on_mixed_condition_with_recursion(self):
pricing_rule = make_pricing_rule(
discount_percentage=10,
selling=1,
priority=2,
min_qty=4,
title="_Test Pricing Rule with Min Qty - 2",
)
pricing_rule.mixed_conditions = True
pricing_rule.is_recursive = True
self.assertRaises(frappe.ValidationError, pricing_rule.save)
test_dependencies = ["Campaign"]

View File

@@ -77,6 +77,7 @@ class PromotionalScheme(Document):
self.validate_applicable_for()
self.validate_pricing_rules()
self.validate_mixed_with_recursion()
def validate_applicable_for(self):
if self.applicable_for:
@@ -94,7 +95,7 @@ class PromotionalScheme(Document):
docnames = []
# If user has changed applicable for
if self._doc_before_save.applicable_for == self.applicable_for:
if self.get_doc_before_save() and self.get_doc_before_save().applicable_for == self.applicable_for:
return
docnames = frappe.get_all("Pricing Rule", filters={"promotional_scheme": self.name})
@@ -108,6 +109,7 @@ class PromotionalScheme(Document):
frappe.delete_doc("Pricing Rule", docname.name)
def on_update(self):
self.validate()
pricing_rules = (
frappe.get_all(
"Pricing Rule",
@@ -119,6 +121,15 @@ class PromotionalScheme(Document):
)
self.update_pricing_rules(pricing_rules)
def validate_mixed_with_recursion(self):
if self.mixed_conditions:
if self.product_discount_slabs:
for slab in self.product_discount_slabs:
if slab.is_recursive:
frappe.throw(
_("Recursive Discounts with Mixed condition is not supported by the system")
)
def update_pricing_rules(self, pricing_rules):
rules = {}
count = 0

View File

@@ -107,6 +107,25 @@ class TestPromotionalScheme(unittest.TestCase):
price_rules = frappe.get_all("Pricing Rule", filters={"promotional_scheme": ps.name})
self.assertEqual(price_rules, [])
def test_validation_on_recurse_with_mixed_condition(self):
ps = make_promotional_scheme()
ps.set("price_discount_slabs", [])
ps.set(
"product_discount_slabs",
[
{
"rule_description": "12+1",
"min_qty": 12,
"free_item": "_Test Item 2",
"free_qty": 1,
"is_recursive": 1,
"recurse_for": 12,
}
],
)
ps.mixed_conditions = True
self.assertRaises(frappe.ValidationError, ps.save)
def make_promotional_scheme(**args):
args = frappe._dict(args)

View File

@@ -12,7 +12,7 @@ def execute(filters=None):
else:
party_naming_by = frappe.db.get_single_value("Buying Settings", "supp_master_name")
filters.update({"naming_series": party_naming_by})
filters["naming_series"] = party_naming_by
validate_filters(filters)
(
@@ -63,21 +63,23 @@ def get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_
tax_withholding_category = tds_accounts.get(entry.account)
# or else the consolidated value from the voucher document
if not tax_withholding_category:
tax_withholding_category = tax_category_map.get(name)
tax_withholding_category = tax_category_map.get((voucher_type, name))
# or else from the party default
if not tax_withholding_category:
tax_withholding_category = party_map.get(party, {}).get("tax_withholding_category")
rate = tax_rate_map.get(tax_withholding_category)
if net_total_map.get(name):
if net_total_map.get((voucher_type, name)):
if voucher_type == "Journal Entry" and tax_amount and rate:
# back calcalute total amount from rate and tax_amount
if rate:
total_amount = grand_total = base_total = tax_amount / (rate / 100)
elif voucher_type == "Purchase Invoice":
total_amount, grand_total, base_total, bill_no, bill_date = net_total_map.get(name)
total_amount, grand_total, base_total, bill_no, bill_date = net_total_map.get(
(voucher_type, name)
)
else:
total_amount, grand_total, base_total = net_total_map.get(name)
total_amount, grand_total, base_total = net_total_map.get((voucher_type, name))
else:
total_amount += entry.credit
@@ -97,7 +99,7 @@ def get_result(filters, tds_docs, tds_accounts, tax_category_map, journal_entry_
}
if filters.naming_series == "Naming Series":
row.update({"party_name": party_map.get(party, {}).get(party_name)})
row["party_name"] = party_map.get(party, {}).get(party_name)
row.update(
{
@@ -279,7 +281,6 @@ def get_tds_docs(filters):
journal_entries = []
tax_category_map = frappe._dict()
net_total_map = frappe._dict()
frappe._dict()
journal_entry_party_map = frappe._dict()
bank_accounts = frappe.get_all("Account", {"is_group": 0, "account_type": "Bank"}, pluck="name")
@@ -412,7 +413,7 @@ def get_doc_info(vouchers, doctype, tax_category_map, net_total_map=None):
)
for entry in entries:
tax_category_map.update({entry.name: entry.tax_withholding_category})
tax_category_map[(doctype, entry.name)] = entry.tax_withholding_category
if doctype == "Purchase Invoice":
value = [
entry.base_tax_withholding_net_total,
@@ -427,7 +428,8 @@ def get_doc_info(vouchers, doctype, tax_category_map, net_total_map=None):
value = [entry.paid_amount, entry.paid_amount_after_tax, entry.base_paid_amount]
else:
value = [entry.total_amount] * 3
net_total_map.update({entry.name: value})
net_total_map[(doctype, entry.name)] = value
def get_tax_rate_map(filters):

View File

@@ -1689,12 +1689,12 @@ def create_asset(**args):
return asset
def create_asset_category():
def create_asset_category(enable_cwip=1):
asset_category = frappe.new_doc("Asset Category")
asset_category.asset_category_name = "Computers"
asset_category.total_number_of_depreciations = 3
asset_category.frequency_of_depreciation = 3
asset_category.enable_cwip_accounting = 1
asset_category.enable_cwip_accounting = enable_cwip
asset_category.append(
"accounts",
{

View File

@@ -742,6 +742,9 @@ class AccountsController(TransactionBase):
# reset pricing rule fields if pricing_rule_removed
item.set(fieldname, value)
elif fieldname == "expense_account" and not item.get("expense_account"):
item.expense_account = value
if self.doctype in ["Purchase Invoice", "Sales Invoice"] and item.meta.get_field(
"is_fixed_asset"
):

View File

@@ -31,7 +31,7 @@ class SellingController(StockController):
def validate(self):
super().validate()
self.validate_items()
if not self.get("is_debit_note"):
if not (self.get("is_debit_note") or self.get("is_return")):
self.validate_max_discount()
self.validate_selling_price()
self.set_qty_as_per_stock_uom()

View File

@@ -1614,12 +1614,15 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
apply_product_discount(args) {
const items = this.frm.doc.items.filter(d => (d.is_free_item)) || [];
const exist_items = items.map(row => (row.item_code, row.pricing_rules));
const exist_items = items.map(row => { return {item_code: row.item_code, pricing_rules: row.pricing_rules};});
args.free_item_data.forEach(pr_row => {
let row_to_modify = {};
if (!items || !in_list(exist_items, (pr_row.item_code, pr_row.pricing_rules))) {
// If there are no free items, or if the current free item doesn't exist in the table, add it
if (!items || !exist_items.filter(e_row => {
return e_row.item_code == pr_row.item_code && e_row.pricing_rules == pr_row.pricing_rules;
}).length) {
row_to_modify = frappe.model.add_child(this.frm.doc,
this.frm.doc.doctype + ' Item', 'items');

View File

@@ -36,7 +36,6 @@ frappe.ui.form.on("Import Supplier Invoice", {
toggle_read_only_fields: function (frm) {
if (["File Import Completed", "Processing File Data"].includes(frm.doc.status)) {
cur_frm.set_read_only();
cur_frm.refresh_fields();
frm.set_df_property("import_invoices", "hidden", 1);
} else {
frm.set_df_property("import_invoices", "hidden", 0);

View File

@@ -19,6 +19,7 @@ class HolidayList(Document):
def validate(self):
self.validate_days()
self.total_holidays = len(self.holidays)
self.sort_holidays()
@frappe.whitelist()
def get_weekly_off_dates(self):
@@ -33,8 +34,6 @@ class HolidayList(Document):
self.append("holidays", {"description": _(self.weekly_off), "holiday_date": d, "weekly_off": 1})
self.sort_holidays()
@frappe.whitelist()
def get_supported_countries(self):
from holidays.utils import list_supported_countries
@@ -76,8 +75,6 @@ class HolidayList(Document):
"holidays", {"description": holiday_name, "holiday_date": holiday_date, "weekly_off": 0}
)
self.sort_holidays()
def sort_holidays(self):
self.holidays.sort(key=lambda x: getdate(x.holiday_date))
for i in range(len(self.holidays)):

View File

@@ -156,6 +156,33 @@ class TestItem(FrappeTestCase):
for key, value in to_check.items():
self.assertEqual(value, details.get(key), key)
def test_get_asset_item_details(self):
from erpnext.assets.doctype.asset.test_asset import create_asset_category, create_fixed_asset_item
create_asset_category(0)
create_fixed_asset_item()
details = get_item_details(
{
"item_code": "Macbook Pro",
"company": "_Test Company",
"currency": "INR",
"doctype": "Purchase Receipt",
}
)
self.assertEqual(details.get("expense_account"), "_Test Fixed Asset - _TC")
frappe.db.set_value("Asset Category", "Computers", "enable_cwip_accounting", "1")
details = get_item_details(
{
"item_code": "Macbook Pro",
"company": "_Test Company",
"currency": "INR",
"doctype": "Purchase Receipt",
}
)
self.assertEqual(details.get("expense_account"), "CWIP Account - _TC")
def test_item_tax_template(self):
expected_item_tax_template = [
{

View File

@@ -6,7 +6,7 @@ from collections import OrderedDict, defaultdict
from itertools import groupby
import frappe
from frappe import _
from frappe import _, bold
from frappe.model.document import Document
from frappe.model.mapper import map_child_doc
from frappe.query_builder import Case
@@ -26,6 +26,9 @@ from erpnext.stock.get_item_details import get_conversion_factor
class PickList(Document):
def validate(self):
self.validate_for_qty()
if self.pick_manually and self.get("locations"):
self.validate_stock_qty()
self.check_serial_no_status()
def before_save(self):
self.update_status()
@@ -35,6 +38,60 @@ class PickList(Document):
if self.get("locations"):
self.validate_sales_order_percentage()
def validate_stock_qty(self):
from erpnext.stock.doctype.batch.batch import get_batch_qty
for row in self.get("locations"):
if row.batch_no and not row.qty:
batch_qty = get_batch_qty(row.batch_no, row.warehouse, row.item_code)
if row.qty > batch_qty:
frappe.throw(
_(
"At Row #{0}: The picked quantity {1} for the item {2} is greater than available stock {3} for the batch {4} in the warehouse {5}."
).format(row.idx, row.item_code, batch_qty, row.batch_no, bold(row.warehouse)),
title=_("Insufficient Stock"),
)
continue
bin_qty = frappe.db.get_value(
"Bin",
{"item_code": row.item_code, "warehouse": row.warehouse},
"actual_qty",
)
if row.qty > bin_qty:
frappe.throw(
_(
"At Row #{0}: The picked quantity {1} for the item {2} is greater than available stock {3} in the warehouse {4}."
).format(row.idx, row.qty, bold(row.item_code), bin_qty, bold(row.warehouse)),
title=_("Insufficient Stock"),
)
def check_serial_no_status(self):
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
for row in self.get("locations"):
if not row.serial_no:
continue
picked_serial_nos = get_serial_nos(row.serial_no)
validated_serial_nos = frappe.get_all(
"Serial No",
filters={"name": ("in", picked_serial_nos), "warehouse": row.warehouse},
pluck="name",
)
incorrect_serial_nos = set(picked_serial_nos) - set(validated_serial_nos)
if incorrect_serial_nos:
frappe.throw(
_("The Serial No at Row #{0}: {1} is not available in warehouse {2}.").format(
row.idx, ", ".join(incorrect_serial_nos), row.warehouse
),
title=_("Incorrect Warehouse"),
)
def validate_sales_order_percentage(self):
# set percentage picked in SO
for location in self.get("locations"):

View File

@@ -802,3 +802,45 @@ class TestPickList(FrappeTestCase):
a = set(picked_serial_no)
b = set([x for x in location.serial_no.split("\n") if x])
self.assertSetEqual(b, b.difference(a))
def test_validate_picked_qty_with_manual_option(self):
warehouse = "_Test Warehouse - _TC"
non_serialized_item = make_item(
"Test Non Serialized Pick List Item For Manual Option", properties={"is_stock_item": 1}
).name
serialized_item = make_item(
"Test Serialized Pick List Item For Manual Option",
properties={"is_stock_item": 1, "has_serial_no": 1, "serial_no_series": "SN-HSNMSPLI-.####"},
).name
batched_item = make_item(
"Test Batched Pick List Item For Manual Option",
properties={
"is_stock_item": 1,
"has_batch_no": 1,
"batch_number_series": "SN-HBNMSPLI-.####",
"create_new_batch": 1,
},
).name
make_stock_entry(item=non_serialized_item, to_warehouse=warehouse, qty=10, basic_rate=100)
make_stock_entry(item=serialized_item, to_warehouse=warehouse, qty=10, basic_rate=100)
make_stock_entry(item=batched_item, to_warehouse=warehouse, qty=10, basic_rate=100)
so = make_sales_order(
item_code=non_serialized_item, qty=10, rate=100, do_not_save=True, warehouse=warehouse
)
so.append("items", {"item_code": serialized_item, "qty": 10, "rate": 100, "warehouse": warehouse})
so.append("items", {"item_code": batched_item, "qty": 10, "rate": 100, "warehouse": warehouse})
so.set_missing_values()
so.save()
so.submit()
pl = create_pick_list(so.name)
pl.pick_manually = 1
for row in pl.locations:
row.qty = row.qty + 10
self.assertRaises(frappe.ValidationError, pl.save)

View File

@@ -558,15 +558,7 @@ class PurchaseReceipt(BuyingController):
landed_cost_entries = get_item_account_wise_additional_cost(self.name)
if d.is_fixed_asset:
account_type = (
"capital_work_in_progress_account"
if is_cwip_accounting_enabled(d.asset_category)
else "fixed_asset_account"
)
stock_asset_account_name = get_asset_account(
account_type, asset_category=d.asset_category, company=self.company
)
stock_asset_account_name = d.expense_account
stock_value_diff = (
flt(d.base_net_amount) + flt(d.item_tax_amount) + flt(d.landed_cost_voucher_amount)
@@ -670,7 +662,6 @@ class PurchaseReceipt(BuyingController):
def make_tax_gl_entries(self, gl_entries, via_landed_cost_voucher=False):
negative_expense_to_be_booked = sum([flt(d.item_tax_amount) for d in self.get("items")])
is_asset_pr = any(d.is_fixed_asset for d in self.get("items"))
# Cost center-wise amount breakup for other charges included for valuation
valuation_tax = {}
for tax in self.get("taxes"):
@@ -695,26 +686,10 @@ class PurchaseReceipt(BuyingController):
against_account = ", ".join([d.account for d in gl_entries if flt(d.debit) > 0])
total_valuation_amount = sum(valuation_tax.values())
amount_including_divisional_loss = negative_expense_to_be_booked
stock_rbnb = (
self.get("asset_received_but_not_billed")
if is_asset_pr
else self.get_company_default("stock_received_but_not_billed")
)
i = 1
for tax in self.get("taxes"):
if valuation_tax.get(tax.name):
if via_landed_cost_voucher or self.is_landed_cost_booked_for_any_item():
account = tax.account_head
else:
negative_expense_booked_in_pi = frappe.db.sql(
"""select name from `tabPurchase Invoice Item` pi
where docstatus = 1 and purchase_receipt=%s
and exists(select name from `tabGL Entry` where voucher_type='Purchase Invoice'
and voucher_no=pi.parent and account=%s)""",
(self.name, tax.account_head),
)
account = stock_rbnb if negative_expense_booked_in_pi else tax.account_head
account = tax.account_head
if i == len(valuation_tax):
applicable_amount = amount_including_divisional_loss
else:

View File

@@ -2499,6 +2499,110 @@ class TestPurchaseReceipt(FrappeTestCase):
lcv.save().submit()
return lcv
def test_tax_account_heads_on_item_repost_without_lcv(self):
"""
PO -> PR -> PI
Backdated `Repost Item valuation` should not merge tax account heads into stock_rbnb if Purchase Receipt was created first
This scenario is without LCV
"""
from erpnext.accounts.doctype.account.test_account import create_account
from erpnext.buying.doctype.purchase_order.test_purchase_order import (
create_purchase_order,
make_pr_against_po,
)
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
stock_rbnb = "Stock Received But Not Billed - _TC"
stock_in_hand = "Stock In Hand - _TC"
test_cc = "_Test Cost Center - _TC"
test_company = "_Test Company"
creditors = "Creditors - _TC"
company_doc = frappe.get_doc("Company", test_company)
company_doc.enable_perpetual_inventory = True
company_doc.stock_received_but_not_billed = stock_rbnb
company_doc.default_inventory_account = stock_in_hand
company_doc.save()
packaging_charges_account = create_account(
account_name="Packaging Charges",
parent_account="Indirect Expenses - _TC",
company=test_company,
account_type="Tax",
)
po = create_purchase_order(qty=10, rate=100, do_not_save=1)
po.taxes = []
po.append(
"taxes",
{
"category": "Valuation and Total",
"account_head": packaging_charges_account,
"cost_center": test_cc,
"description": "Test",
"add_deduct_tax": "Add",
"charge_type": "Actual",
"tax_amount": 250,
},
)
po.save().submit()
pr = make_pr_against_po(po.name, received_qty=10)
pr_gl_entries = get_gl_entries(pr.doctype, pr.name, skip_cancelled=True)
expected_pr_gles = [
{"account": stock_rbnb, "debit": 0.0, "credit": 1000.0, "cost_center": test_cc},
{"account": stock_in_hand, "debit": 1250.0, "credit": 0.0, "cost_center": test_cc},
{"account": packaging_charges_account, "debit": 0.0, "credit": 250.0, "cost_center": test_cc},
]
self.assertEqual(expected_pr_gles, pr_gl_entries)
# Make PI against Purchase Receipt
pi = make_purchase_invoice(pr.name).save().submit()
pi_gl_entries = get_gl_entries(pi.doctype, pi.name, skip_cancelled=True)
expected_pi_gles = [
{"account": stock_rbnb, "debit": 1000.0, "credit": 0.0, "cost_center": test_cc},
{"account": packaging_charges_account, "debit": 250.0, "credit": 0.0, "cost_center": test_cc},
{"account": creditors, "debit": 0.0, "credit": 1250.0, "cost_center": None},
]
self.assertEqual(expected_pi_gles, pi_gl_entries)
# Trigger Repost Item Valudation on a older date
repost_doc = frappe.get_doc(
{
"doctype": "Repost Item Valuation",
"based_on": "Item and Warehouse",
"item_code": pr.items[0].item_code,
"warehouse": pr.items[0].warehouse,
"posting_date": add_days(pr.posting_date, -1),
"posting_time": "00:00:00",
"company": pr.company,
"allow_negative_stock": 1,
"via_landed_cost_voucher": 0,
"allow_zero_rate": 0,
}
)
repost_doc.save().submit()
pr_gles_after_repost = get_gl_entries(pr.doctype, pr.name, skip_cancelled=True)
expected_pr_gles_after_repost = [
{"account": stock_rbnb, "debit": 0.0, "credit": 1000.0, "cost_center": test_cc},
{"account": stock_in_hand, "debit": 1250.0, "credit": 0.0, "cost_center": test_cc},
{"account": packaging_charges_account, "debit": 0.0, "credit": 250.0, "cost_center": test_cc},
]
self.assertEqual(len(pr_gles_after_repost), len(expected_pr_gles_after_repost))
self.assertEqual(expected_pr_gles_after_repost, pr_gles_after_repost)
# teardown
pi.reload()
pi.cancel()
pr.reload()
pr.cancel()
company_doc.enable_perpetual_inventory = False
company_doc.stock_received_but_not_billed = None
company_doc.default_inventory_account = None
company_doc.save()
def prepare_data_for_internal_transfer():
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_internal_supplier

View File

@@ -327,12 +327,26 @@ def get_basic_details(args, item, overwrite_warehouse=True):
expense_account = None
if args.get("doctype") == "Purchase Invoice" and item.is_fixed_asset:
from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account
if item.is_fixed_asset:
from erpnext.assets.doctype.asset.asset import get_asset_account, is_cwip_accounting_enabled
expense_account = get_asset_category_account(
fieldname="fixed_asset_account", item=args.item_code, company=args.company
)
if is_cwip_accounting_enabled(item.asset_category):
expense_account = get_asset_account(
"capital_work_in_progress_account",
asset_category=item.asset_category,
company=args.company,
)
elif args.get("doctype") in (
"Purchase Invoice",
"Purchase Receipt",
"Purchase Order",
"Material Request",
):
from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account
expense_account = get_asset_category_account(
fieldname="fixed_asset_account", item=args.item_code, company=args.company
)
# Set the UOM to the Default Sales UOM or Default Purchase UOM if configured in the Item Master
if not args.get("uom"):

View File

@@ -240,6 +240,12 @@ class SubcontractingReceipt(SubcontractingController):
)
def validate_available_qty_for_consumption(self):
if (
frappe.db.get_single_value("Buying Settings", "backflush_raw_materials_of_subcontract_based_on")
== "BOM"
):
return
for item in self.get("supplied_items"):
precision = item.precision("consumed_qty")
if (

View File

@@ -75,6 +75,7 @@ class TestSubcontractingReceipt(FrappeTestCase):
self.assertEqual(scr.get("items")[0].rm_supp_cost, flt(rm_supp_cost))
def test_available_qty_for_consumption(self):
set_backflush_based_on("BOM")
make_stock_entry(item_code="_Test Item", qty=100, target="_Test Warehouse 1 - _TC", basic_rate=100)
make_stock_entry(
item_code="_Test Item Home Desktop 100",
@@ -119,7 +120,7 @@ class TestSubcontractingReceipt(FrappeTestCase):
)
scr = make_subcontracting_receipt(sco.name)
scr.save()
self.assertRaises(frappe.ValidationError, scr.submit)
scr.submit()
def test_subcontracting_gle_fg_item_rate_zero(self):
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import get_gl_entries
@@ -556,6 +557,21 @@ class TestSubcontractingReceipt(FrappeTestCase):
# consumed_qty should be (accepted_qty * qty_consumed_per_unit) = (6 * 1) = 6
self.assertEqual(scr.supplied_items[0].consumed_qty, 6)
# Do not transfer materials to the supplier warehouse and check whether system allows to consumed directly from the supplier's warehouse
sco = get_subcontracting_order(service_items=service_items)
# Transfer RM's
rm_items = get_rm_items(sco.supplied_items)
itemwise_details = make_stock_in_entry(rm_items=rm_items, warehouse="_Test Warehouse 1 - _TC")
# Create Subcontracting Receipt
scr = make_subcontracting_receipt(sco.name)
scr.submit()
self.assertEqual(scr.docstatus, 1)
for item in scr.supplied_items:
self.assertFalse(item.available_qty_for_consumption)
def test_supplied_items_cost_after_reposting(self):
# Set Backflush Based On as "BOM"
set_backflush_based_on("BOM")

View File

@@ -1248,6 +1248,8 @@ Is Default,Ist Standard,
Is Existing Asset,Vermögenswert existiert bereits.,
Is Frozen,Ist gesperrt,
Is Group,Ist Gruppe,
Is Group Warehouse,Ist Lagergruppe,
Is Rejected Warehouse,Ist Lager für abgelehnte Ware,
Issue,Anfrage,
Issue Material,Material ausgeben,
Issued,Ausgestellt,
@@ -1311,6 +1313,7 @@ Items for Raw Material Request,Artikel für Rohstoffanforderung,
Job Card,Jobkarte,
Job card {0} created,Jobkarte {0} erstellt,
Join,Beitreten,
Joining,Beitritt,
Journal Entries {0} are un-linked,Buchungssätze {0} sind nicht verknüpft,
Journal Entry,Buchungssatz,
Journal Entry {0} does not have account {1} or already matched against other voucher,Buchungssatz {0} gehört nicht zu Konto {1} oder ist bereits mit einem anderen Beleg abgeglichen,
@@ -2033,6 +2036,7 @@ Product Search,Produkt Suche,
Production,Produktion,
Production Item,Produktions-Artikel,
Products,Produkte,
Profile,Profil,
Profit and Loss,Gewinn und Verlust,
Profit for the year,Jahresüberschuss,
Program,Programm,
@@ -2094,6 +2098,9 @@ Qty To Manufacture,Herzustellende Menge,
Qty Total,Gesamtmenge,
Qty for {0},Menge für {0},
Qualification,Qualifikation,
Qualification Status,Qualifikationsstatus,
Qualified By,Qualifiziert von,
Qualified on,Qualifiziert am,
Quality,Qualität,
Quality Action,Qualitätsmaßnahme,
Quality Goal.,Qualitätsziel.,
@@ -3295,6 +3302,7 @@ Warehouse Type,Lagertyp,
'Date' is required,'Datum' ist erforderlich,
Budgets,Budgets,
Bundle Qty,Bundle Menge,
Company Details,Unternehmensdetails,
Company GSTIN,Unternehmen GSTIN,
Company field is required,Firmenfeld ist erforderlich,
Creating Dimensions...,Dimensionen erstellen ...,
@@ -3659,6 +3667,7 @@ Performance,Performance,
Period based On,Zeitraum basierend auf,
Perpetual inventory required for the company {0} to view this report.,"Permanente Bestandsaufnahme erforderlich, damit das Unternehmen {0} diesen Bericht anzeigen kann.",
Phone,Telefon,
Phone Ext.,Telefon Ext.,
Pick List,Auswahlliste,
Plaid authentication error,Plaid-Authentifizierungsfehler,
Plaid public token error,Plaid public token error,
@@ -5096,7 +5105,7 @@ Number of Depreciations Booked,Anzahl der gebuchten Abschreibungen,
Finance Books,Finanzbücher,
Straight Line,Gerade Linie,
Double Declining Balance,Doppelte degressive,
Manual,Handbuch,
Manual,Manuell,
Value After Depreciation,Wert nach Abschreibung,
Total Number of Depreciations,Gesamtzahl der Abschreibungen,
Frequency of Depreciation (Months),Die Häufigkeit der Abschreibungen (Monate),
@@ -5156,6 +5165,7 @@ Maintenance Team Name,Name des Wartungsteams,
Maintenance Team Members,Mitglieder des Wartungsteams,
Purpose,Zweck,
Stock Manager,Lagerleiter,
Stock Movement,Lagerbewegung,
Asset Movement Item,Vermögensbewegungsgegenstand,
Source Location,Quellspeicherort,
From Employee,Von Mitarbeiter,
@@ -5252,6 +5262,7 @@ Default Bank Account,Standardbankkonto,
Is Transporter,Ist Transporter,
Represents Company,Repräsentiert das Unternehmen,
Supplier Type,Lieferantentyp,
Allow Purchase,Einkauf zulassen,
Allow Purchase Invoice Creation Without Purchase Order,Erstellen von Eingangsrechnung ohne Bestellung zulassen,
Allow Purchase Invoice Creation Without Purchase Receipt,Erstellen von Eingangsrechnung ohne Kaufbeleg ohne Kaufbeleg zulassen,
Warn RFQs,Warnung Ausschreibungen,
@@ -6028,6 +6039,7 @@ Occupational Hazards and Environmental Factors,Berufsrisiken und Umweltfaktoren,
Other Risk Factors,Andere Risikofaktoren,
Patient Details,Patientendetails,
Additional information regarding the patient,Zusätzliche Informationen zum Patienten,
Additional Info,Zusätzliche Informationen,
HLC-APP-.YYYY.-,HLC-APP-.YYYY.-,
Patient Age,Patient Alter,
Get Prescribed Clinical Procedures,Holen Sie sich vorgeschriebene klinische Verfahren,
@@ -6194,6 +6206,7 @@ Date Of Retirement,Zeitpunkt der Pensionierung,
Department and Grade,Abteilung und Klasse,
Reports to,Vorgesetzter,
Attendance and Leave Details,Anwesenheits- und Urlaubsdetails,
Attendance & Leaves,Anwesenheit & Urlaub,
Attendance Device ID (Biometric/RF tag ID),Anwesenheitsgeräte-ID (biometrische / RF-Tag-ID),
Applicable Holiday List,Geltende Feiertagsliste,
Default Shift,Standardverschiebung,
@@ -6746,7 +6759,7 @@ Default Costing Rate,Standardkosten,
Default Billing Rate,Standard-Rechnungspreis,
Dependent Task,Abhängiger Vorgang,
Project Type,Projekttyp,
% Complete Method,% abgeschlossene Methode,
% Complete Method,Fertigstellung bemessen nach,
Task Completion,Aufgabenerledigung,
Task Progress,Vorgangsentwicklung,
% Completed,% abgeschlossen,
@@ -6909,6 +6922,7 @@ Restaurant Reservation,Restaurant Reservierung,
Waitlisted,Auf der Warteliste,
No Show,Nicht angetreten,
No of People,Anzahl von Personen,
No of Employees,Anzahl der Mitarbeiter,
Reservation Time,Reservierungszeit,
Reservation End Time,Reservierungsendzeit,
No of Seats,Anzahl der Sitze,
@@ -6920,6 +6934,7 @@ Default Company Bank Account,Standard-Bankkonto des Unternehmens,
From Lead,Aus Lead,
Account Manager,Kundenberater,
Accounts Manager,Buchhalter,
Allow Sales,Verkauf zulassen,
Allow Sales Invoice Creation Without Sales Order,Ermöglichen Sie die Erstellung von Ausgangsrechnungen ohne Auftrag,
Allow Sales Invoice Creation Without Delivery Note,Ermöglichen Sie die Erstellung von Ausgangsrechnungen ohne Lieferschein,
Default Price List,Standardpreisliste,
@@ -6979,7 +6994,8 @@ Not Delivered,Nicht geliefert,
Fully Delivered,Komplett geliefert,
Partly Delivered,Teilweise geliefert,
Not Applicable,Nicht andwendbar,
% Delivered,% geliefert,
% Delivered,% Geliefert,
% Picked,% Kommissioniert,
% of materials delivered against this Sales Order,% der für diesen Auftrag gelieferten Materialien,
% of materials billed against this Sales Order,% der Materialien welche zu diesem Auftrag gebucht wurden,
Not Billed,Nicht abgerechnet,
@@ -7113,6 +7129,7 @@ New Income,Neuer Verdienst,
New Expenses,Neue Ausgaben,
Annual Income,Jährliches Einkommen,
Annual Expenses,Jährliche Kosten,
Annual Revenue,Jährlicher Umsatz,
Bank Balance,Kontostand,
Bank Credit Balance,Bankguthaben,
Receivables,Forderungen,
@@ -7595,6 +7612,7 @@ Actual Qty After Transaction,Tatsächliche Anzahl nach Transaktionen,
Stock Value Difference,Lagerwert-Differenz,
Stock Queue (FIFO),Lagerverfahren (FIFO),
Is Cancelled,Ist storniert,
Is Cash or Non Trade Discount,Ist Bar- oder Nicht-Handelsrabatt,
Stock Reconciliation,Bestandsabgleich,
This tool helps you to update or fix the quantity and valuation of stock in the system. It is typically used to synchronise the system values and what actually exists in your warehouses.,"Dieses Werkzeug hilft Ihnen dabei, die Menge und die Bewertung von Bestand im System zu aktualisieren oder zu ändern. Es wird in der Regel verwendet, um die Systemwerte und den aktuellen Bestand Ihrer Lager zu synchronisieren.",
Reconciliation JSON,Abgleich JSON (JavaScript Object Notation),
@@ -7696,6 +7714,7 @@ Warranty / AMC Status,Status der Garantie / des jährlichen Wartungsvertrags,
Resolved By,Entschieden von,
Service Address,Serviceadresse,
If different than customer address,Falls abweichend von Kundenadresse,
"If yes, then this warehouse will be used to store rejected materials","Falls aktiviert, wird dieses Lager verwendet, um abgelehnte Ware zu lagern",
Raised By,Gemeldet durch,
From Company,Von Unternehmen,
Rename Tool,Werkzeug zum Umbenennen,
@@ -8940,6 +8959,7 @@ Print Receipt,Druckeingang,
Edit Receipt,Beleg bearbeiten,
Focus on search input,Konzentrieren Sie sich auf die Sucheingabe,
Focus on Item Group filter,Fokus auf Artikelgruppenfilter,
Footer will display correctly only in PDF,Die Fußzeile wird nur im PDF korrekt angezeigt,
Checkout Order / Submit Order / New Order,Kaufabwicklung / Bestellung abschicken / Neue Bestellung,
Add Order Discount,Bestellrabatt hinzufügen,
Item Code: {0} is not available under warehouse {1}.,Artikelcode: {0} ist unter Lager {1} nicht verfügbar.,
Can't render this file because it is too large.