mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-19 23:12:13 +00:00
Merge pull request #41574 from frappe/version-15-hotfix
chore: release v15
This commit is contained in:
@@ -222,7 +222,7 @@ frappe.treeview_settings["Account"] = {
|
||||
"General Ledger",
|
||||
"Balance Sheet",
|
||||
"Profit and Loss Statement",
|
||||
"Cash Flow Statement",
|
||||
"Cash Flow",
|
||||
"Accounts Payable",
|
||||
"Accounts Receivable",
|
||||
]) {
|
||||
|
||||
@@ -59,6 +59,10 @@ frappe.ui.form.on("Bank Reconciliation Tool", {
|
||||
);
|
||||
|
||||
frm.add_custom_button(__("Auto Reconcile"), function () {
|
||||
if (!frm.doc.bank_account) {
|
||||
frappe.msgprint(__("Please select Bank Account"));
|
||||
return;
|
||||
}
|
||||
frappe.call({
|
||||
method: "erpnext.accounts.doctype.bank_reconciliation_tool.bank_reconciliation_tool.auto_reconcile_vouchers",
|
||||
args: {
|
||||
|
||||
@@ -495,12 +495,12 @@ def check_matching(
|
||||
bank_account,
|
||||
company,
|
||||
transaction,
|
||||
document_types,
|
||||
from_date,
|
||||
to_date,
|
||||
filter_by_reference_date,
|
||||
from_reference_date,
|
||||
to_reference_date,
|
||||
document_types=None,
|
||||
from_date=None,
|
||||
to_date=None,
|
||||
filter_by_reference_date=None,
|
||||
from_reference_date=None,
|
||||
to_reference_date=None,
|
||||
):
|
||||
exact_match = True if "exact_match" in document_types else False
|
||||
|
||||
@@ -540,14 +540,14 @@ def get_queries(
|
||||
bank_account,
|
||||
company,
|
||||
transaction,
|
||||
document_types,
|
||||
from_date,
|
||||
to_date,
|
||||
filter_by_reference_date,
|
||||
from_reference_date,
|
||||
to_reference_date,
|
||||
exact_match,
|
||||
common_filters,
|
||||
document_types=None,
|
||||
from_date=None,
|
||||
to_date=None,
|
||||
filter_by_reference_date=None,
|
||||
from_reference_date=None,
|
||||
to_reference_date=None,
|
||||
exact_match=None,
|
||||
common_filters=None,
|
||||
):
|
||||
# get queries to get matching vouchers
|
||||
account_from_to = "paid_to" if transaction.deposit > 0.0 else "paid_from"
|
||||
@@ -580,15 +580,15 @@ def get_matching_queries(
|
||||
bank_account,
|
||||
company,
|
||||
transaction,
|
||||
document_types,
|
||||
exact_match,
|
||||
account_from_to,
|
||||
from_date,
|
||||
to_date,
|
||||
filter_by_reference_date,
|
||||
from_reference_date,
|
||||
to_reference_date,
|
||||
common_filters,
|
||||
document_types=None,
|
||||
exact_match=None,
|
||||
account_from_to=None,
|
||||
from_date=None,
|
||||
to_date=None,
|
||||
filter_by_reference_date=None,
|
||||
from_reference_date=None,
|
||||
to_reference_date=None,
|
||||
common_filters=None,
|
||||
):
|
||||
queries = []
|
||||
currency = get_account_currency(bank_account)
|
||||
|
||||
@@ -141,7 +141,19 @@ class Dunning(AccountsController):
|
||||
|
||||
def on_cancel(self):
|
||||
super().on_cancel()
|
||||
self.ignore_linked_doctypes = ["GL Entry"]
|
||||
self.ignore_linked_doctypes = [
|
||||
"GL Entry",
|
||||
"Stock Ledger Entry",
|
||||
"Repost Item Valuation",
|
||||
"Repost Payment Ledger",
|
||||
"Repost Payment Ledger Items",
|
||||
"Repost Accounting Ledger",
|
||||
"Repost Accounting Ledger Items",
|
||||
"Unreconcile Payment",
|
||||
"Unreconcile Payment Entries",
|
||||
"Payment Ledger Entry",
|
||||
"Serial and Batch Bundle",
|
||||
]
|
||||
|
||||
|
||||
def resolve_dunning(doc, state):
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
"party",
|
||||
"party_name",
|
||||
"book_advance_payments_in_separate_party_account",
|
||||
"reconcile_on_advance_payment_date",
|
||||
"column_break_11",
|
||||
"bank_account",
|
||||
"party_bank_account",
|
||||
@@ -750,6 +751,7 @@
|
||||
"fieldtype": "Check",
|
||||
"hidden": 1,
|
||||
"label": "Book Advance Payments in Separate Party Account",
|
||||
"no_copy": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
@@ -765,6 +767,16 @@
|
||||
"label": "In Words",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fetch_from": "company.reconcile_on_advance_payment_date",
|
||||
"fieldname": "reconcile_on_advance_payment_date",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 1,
|
||||
"label": "Reconcile on Advance Payment Date",
|
||||
"no_copy": 1,
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
@@ -778,7 +790,7 @@
|
||||
"table_fieldname": "payment_entries"
|
||||
}
|
||||
],
|
||||
"modified": "2024-04-11 11:25:07.366347",
|
||||
"modified": "2024-05-17 10:21:11.199445",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Payment Entry",
|
||||
|
||||
@@ -1249,13 +1249,16 @@ class PaymentEntry(AccountsController):
|
||||
"voucher_detail_no": invoice.name,
|
||||
}
|
||||
|
||||
date_field = "posting_date"
|
||||
if invoice.reference_doctype in ["Sales Order", "Purchase Order"]:
|
||||
date_field = "transaction_date"
|
||||
posting_date = frappe.db.get_value(invoice.reference_doctype, invoice.reference_name, date_field)
|
||||
|
||||
if getdate(posting_date) < getdate(self.posting_date):
|
||||
if self.reconcile_on_advance_payment_date:
|
||||
posting_date = self.posting_date
|
||||
else:
|
||||
date_field = "posting_date"
|
||||
if invoice.reference_doctype in ["Sales Order", "Purchase Order"]:
|
||||
date_field = "transaction_date"
|
||||
posting_date = frappe.db.get_value(invoice.reference_doctype, invoice.reference_name, date_field)
|
||||
|
||||
if getdate(posting_date) < getdate(self.posting_date):
|
||||
posting_date = self.posting_date
|
||||
|
||||
dr_or_cr, account = self.get_dr_and_account_for_advances(invoice)
|
||||
args_dict["account"] = account
|
||||
|
||||
@@ -1525,6 +1525,55 @@ class TestPaymentReconciliation(FrappeTestCase):
|
||||
]
|
||||
self.assertEqual(pl_entries, expected_ple)
|
||||
|
||||
def test_advance_payment_reconciliation_date(self):
|
||||
frappe.db.set_value(
|
||||
"Company",
|
||||
self.company,
|
||||
{
|
||||
"book_advance_payments_in_separate_party_account": 1,
|
||||
"default_advance_paid_account": self.advance_payable_account,
|
||||
"reconcile_on_advance_payment_date": 1,
|
||||
},
|
||||
)
|
||||
|
||||
self.supplier = "_Test Supplier"
|
||||
amount = 1500
|
||||
|
||||
pe = self.create_payment_entry(amount=amount)
|
||||
pe.posting_date = add_days(nowdate(), -1)
|
||||
pe.party_type = "Supplier"
|
||||
pe.party = self.supplier
|
||||
pe.payment_type = "Pay"
|
||||
pe.paid_from = self.cash
|
||||
pe.paid_to = self.advance_payable_account
|
||||
pe.save().submit()
|
||||
|
||||
pi = self.create_purchase_invoice(qty=10, rate=100)
|
||||
self.assertNotEqual(pe.posting_date, pi.posting_date)
|
||||
|
||||
pr = self.create_payment_reconciliation(party_is_customer=False)
|
||||
pr.default_advance_account = self.advance_payable_account
|
||||
pr.from_payment_date = pe.posting_date
|
||||
pr.get_unreconciled_entries()
|
||||
self.assertEqual(len(pr.invoices), 1)
|
||||
self.assertEqual(len(pr.payments), 1)
|
||||
invoices = [invoice.as_dict() for invoice in pr.invoices]
|
||||
payments = [payment.as_dict() for payment in pr.payments]
|
||||
pr.allocate_entries(frappe._dict({"invoices": invoices, "payments": payments}))
|
||||
pr.reconcile()
|
||||
|
||||
# Assert Ledger Entries
|
||||
gl_entries = frappe.db.get_all(
|
||||
"GL Entry",
|
||||
filters={"voucher_no": pe.name, "is_cancelled": 0, "posting_date": pe.posting_date},
|
||||
)
|
||||
self.assertEqual(len(gl_entries), 4)
|
||||
pl_entries = frappe.db.get_all(
|
||||
"Payment Ledger Entry",
|
||||
filters={"voucher_no": pe.name, "delinked": 0, "posting_date": pe.posting_date},
|
||||
)
|
||||
self.assertEqual(len(pl_entries), 3)
|
||||
|
||||
|
||||
def make_customer(customer_name, currency=None):
|
||||
if not frappe.db.exists("Customer", customer_name):
|
||||
|
||||
@@ -74,15 +74,21 @@
|
||||
"discount_amount",
|
||||
"discount_percentage",
|
||||
"for_price_list",
|
||||
"section_break_13",
|
||||
"threshold_percentage",
|
||||
"priority",
|
||||
"dynamic_condition_tab",
|
||||
"condition",
|
||||
"column_break_66",
|
||||
"section_break_13",
|
||||
"apply_multiple_pricing_rules",
|
||||
"apply_discount_on_rate",
|
||||
"column_break_66",
|
||||
"threshold_percentage",
|
||||
"validate_pricing_rule_section",
|
||||
"validate_applied_rule",
|
||||
"column_break_texp",
|
||||
"rule_description",
|
||||
"priority_section",
|
||||
"has_priority",
|
||||
"column_break_sayg",
|
||||
"priority",
|
||||
"help_section",
|
||||
"pricing_rule_help",
|
||||
"reference_section",
|
||||
@@ -477,7 +483,7 @@
|
||||
{
|
||||
"collapsible": 1,
|
||||
"fieldname": "section_break_13",
|
||||
"fieldtype": "Section Break",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Advanced Settings"
|
||||
},
|
||||
{
|
||||
@@ -487,6 +493,7 @@
|
||||
"label": "Threshold for Suggestion (In Percentage)"
|
||||
},
|
||||
{
|
||||
"depends_on": "has_priority",
|
||||
"description": "Higher the number, higher the priority",
|
||||
"fieldname": "priority",
|
||||
"fieldtype": "Select",
|
||||
@@ -513,6 +520,7 @@
|
||||
{
|
||||
"default": "0",
|
||||
"depends_on": "eval:doc.price_or_product_discount == 'Price'",
|
||||
"description": "If enabled, then system will only validate the pricing rule and not apply automatically. User has to manually set the discount percentage / margin / free items to validate the pricing rule",
|
||||
"fieldname": "validate_applied_rule",
|
||||
"fieldtype": "Check",
|
||||
"label": "Validate Applied Rule"
|
||||
@@ -525,7 +533,8 @@
|
||||
},
|
||||
{
|
||||
"fieldname": "help_section",
|
||||
"fieldtype": "Section Break",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Help Article",
|
||||
"options": "Simple"
|
||||
},
|
||||
{
|
||||
@@ -603,12 +612,42 @@
|
||||
"fieldname": "apply_recursion_over",
|
||||
"fieldtype": "Float",
|
||||
"label": "Apply Recursion Over (As Per Transaction UOM)"
|
||||
},
|
||||
{
|
||||
"fieldname": "priority_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Priority"
|
||||
},
|
||||
{
|
||||
"fieldname": "dynamic_condition_tab",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Dynamic Condition"
|
||||
},
|
||||
{
|
||||
"fieldname": "validate_pricing_rule_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Validate Pricing Rule"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_texp",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_sayg",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"description": "Enable this checkbox even if you want to set the zero priority",
|
||||
"fieldname": "has_priority",
|
||||
"fieldtype": "Check",
|
||||
"label": "Has Priority"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-gift",
|
||||
"idx": 1,
|
||||
"links": [],
|
||||
"modified": "2023-02-14 04:53:34.887358",
|
||||
"modified": "2024-05-17 13:16:34.496704",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Pricing Rule",
|
||||
|
||||
@@ -27,9 +27,7 @@ class PricingRule(Document):
|
||||
from frappe.types import DF
|
||||
|
||||
from erpnext.accounts.doctype.pricing_rule_brand.pricing_rule_brand import PricingRuleBrand
|
||||
from erpnext.accounts.doctype.pricing_rule_item_code.pricing_rule_item_code import (
|
||||
PricingRuleItemCode,
|
||||
)
|
||||
from erpnext.accounts.doctype.pricing_rule_item_code.pricing_rule_item_code import PricingRuleItemCode
|
||||
from erpnext.accounts.doctype.pricing_rule_item_group.pricing_rule_item_group import (
|
||||
PricingRuleItemGroup,
|
||||
)
|
||||
@@ -67,6 +65,7 @@ class PricingRule(Document):
|
||||
free_item_rate: DF.Currency
|
||||
free_item_uom: DF.Link | None
|
||||
free_qty: DF.Float
|
||||
has_priority: DF.Check
|
||||
is_cumulative: DF.Check
|
||||
is_recursive: DF.Check
|
||||
item_groups: DF.Table[PricingRuleItemGroup]
|
||||
@@ -156,6 +155,12 @@ class PricingRule(Document):
|
||||
frappe.throw(_("Duplicate {0} found in the table").format(self.apply_on))
|
||||
|
||||
def validate_mandatory(self):
|
||||
if self.has_priority and not self.priority:
|
||||
throw(_("Priority is mandatory"), frappe.MandatoryError, _("Please Set Priority"))
|
||||
|
||||
if self.priority and not self.has_priority:
|
||||
self.has_priority = 1
|
||||
|
||||
for apply_on, field in apply_on_dict.items():
|
||||
if self.apply_on == apply_on and len(self.get(field) or []) < 1:
|
||||
throw(_("{0} is not added in the table").format(apply_on), frappe.MandatoryError)
|
||||
|
||||
@@ -1157,6 +1157,62 @@ 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_priority_of_multiple_pricing_rules(self):
|
||||
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule 1")
|
||||
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule 2")
|
||||
|
||||
test_record = {
|
||||
"doctype": "Pricing Rule",
|
||||
"title": "_Test Pricing Rule 1",
|
||||
"name": "_Test Pricing Rule 1",
|
||||
"apply_on": "Item Code",
|
||||
"currency": "USD",
|
||||
"items": [
|
||||
{
|
||||
"item_code": "_Test Item",
|
||||
}
|
||||
],
|
||||
"selling": 1,
|
||||
"price_or_product_discount": "Price",
|
||||
"rate_or_discount": "Discount Percentage",
|
||||
"discount_percentage": 10,
|
||||
"has_priority": 1,
|
||||
"priority": 1,
|
||||
"company": "_Test Company",
|
||||
}
|
||||
|
||||
frappe.get_doc(test_record.copy()).insert()
|
||||
|
||||
test_record = {
|
||||
"doctype": "Pricing Rule",
|
||||
"title": "_Test Pricing Rule 2",
|
||||
"name": "_Test Pricing Rule 2",
|
||||
"apply_on": "Item Code",
|
||||
"currency": "USD",
|
||||
"items": [
|
||||
{
|
||||
"item_code": "_Test Item",
|
||||
}
|
||||
],
|
||||
"selling": 1,
|
||||
"price_or_product_discount": "Price",
|
||||
"rate_or_discount": "Discount Percentage",
|
||||
"discount_percentage": 20,
|
||||
"has_priority": 1,
|
||||
"priority": 3,
|
||||
"company": "_Test Company",
|
||||
}
|
||||
|
||||
frappe.get_doc(test_record.copy()).insert()
|
||||
|
||||
so = make_sales_order(item_code="_Test Item", qty=1, price_list_rate=1000, do_not_submit=True)
|
||||
self.assertEqual(so.items[0].discount_percentage, 20)
|
||||
self.assertEqual(so.items[0].rate, 800)
|
||||
|
||||
frappe.delete_doc_if_exists("Sales Order", so.name)
|
||||
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule 1")
|
||||
frappe.delete_doc_if_exists("Pricing Rule", "_Test Pricing Rule 2")
|
||||
|
||||
|
||||
test_dependencies = ["Campaign"]
|
||||
|
||||
@@ -1185,6 +1241,7 @@ def make_pricing_rule(**args):
|
||||
"priority": args.priority or 1,
|
||||
"discount_amount": args.discount_amount or 0.0,
|
||||
"apply_multiple_pricing_rules": args.apply_multiple_pricing_rules or 0,
|
||||
"has_priority": args.has_priority or 0,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@ def get_pricing_rules(args, doc=None):
|
||||
|
||||
for apply_on in ["Item Code", "Item Group", "Brand"]:
|
||||
pricing_rules.extend(_get_pricing_rules(apply_on, args, values))
|
||||
if pricing_rules and pricing_rules[0].has_priority:
|
||||
continue
|
||||
|
||||
if pricing_rules and not apply_multiple_pricing_rules(pricing_rules):
|
||||
break
|
||||
|
||||
|
||||
@@ -485,10 +485,12 @@ function hide_fields(doc) {
|
||||
|
||||
var item_fields_stock = ["warehouse_section", "received_qty", "rejected_qty"];
|
||||
|
||||
cur_frm.fields_dict["items"].grid.set_column_disp(
|
||||
item_fields_stock,
|
||||
cint(doc.update_stock) == 1 || cint(doc.is_return) == 1 ? true : false
|
||||
);
|
||||
if (cur_frm.fields_dict["items"]) {
|
||||
cur_frm.fields_dict["items"].grid.set_column_disp(
|
||||
item_fields_stock,
|
||||
cint(doc.update_stock) == 1 || cint(doc.is_return) == 1 ? true : false
|
||||
);
|
||||
}
|
||||
|
||||
cur_frm.refresh_fields();
|
||||
}
|
||||
|
||||
@@ -1035,10 +1035,10 @@ class PurchaseInvoice(BuyingController):
|
||||
|
||||
if provisional_accounting_for_non_stock_items:
|
||||
if item.purchase_receipt:
|
||||
provisional_account, pr_qty, pr_base_rate = frappe.get_cached_value(
|
||||
provisional_account, pr_qty, pr_base_rate, pr_rate = frappe.get_cached_value(
|
||||
"Purchase Receipt Item",
|
||||
item.pr_detail,
|
||||
["provisional_expense_account", "qty", "base_rate"],
|
||||
["provisional_expense_account", "qty", "base_rate", "rate"],
|
||||
)
|
||||
provisional_account = provisional_account or self.get_company_default(
|
||||
"default_provisional_account"
|
||||
@@ -1072,7 +1072,10 @@ class PurchaseInvoice(BuyingController):
|
||||
self.posting_date,
|
||||
provisional_account,
|
||||
reverse=1,
|
||||
item_amount=(min(item.qty, pr_qty) * pr_base_rate),
|
||||
item_amount=(
|
||||
(min(item.qty, pr_qty) * pr_rate)
|
||||
* purchase_receipt_doc.get("conversion_rate")
|
||||
),
|
||||
)
|
||||
|
||||
if not self.is_internal_transfer():
|
||||
|
||||
@@ -219,7 +219,8 @@ def get_conditions(filters):
|
||||
|
||||
if filters.get("account"):
|
||||
filters.account = get_accounts_with_children(filters.account)
|
||||
conditions.append("account in %(account)s")
|
||||
if filters.account:
|
||||
conditions.append("account in %(account)s")
|
||||
|
||||
if filters.get("cost_center"):
|
||||
filters.cost_center = get_cost_centers_with_children(filters.cost_center)
|
||||
@@ -329,7 +330,7 @@ def get_accounts_with_children(accounts):
|
||||
else:
|
||||
frappe.throw(_("Account: {0} does not exist").format(d))
|
||||
|
||||
return list(set(all_accounts))
|
||||
return list(set(all_accounts)) if all_accounts else None
|
||||
|
||||
|
||||
def get_data_with_opening_closing(filters, account_details, accounting_dimensions, gl_entries):
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.require("assets/erpnext/js/purchase_trends_filters.js", function () {
|
||||
frappe.query_reports["Purchase Invoice Trends"] = {
|
||||
filters: erpnext.get_purchase_trends_filters(),
|
||||
};
|
||||
});
|
||||
frappe.query_reports["Purchase Invoice Trends"] = $.extend({}, erpnext.purchase_trends_filters);
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.require("assets/erpnext/js/sales_trends_filters.js", function () {
|
||||
frappe.query_reports["Sales Invoice Trends"] = {
|
||||
filters: erpnext.get_sales_trends_filters(),
|
||||
};
|
||||
});
|
||||
frappe.query_reports["Sales Invoice Trends"] = $.extend({}, erpnext.sales_trends_filters);
|
||||
|
||||
@@ -363,6 +363,16 @@ class AssetDepreciationSchedule(Document):
|
||||
row.depreciation_start_date,
|
||||
has_wdv_or_dd_non_yearly_pro_rata,
|
||||
)
|
||||
if flt(depreciation_amount, asset_doc.precision("gross_purchase_amount")) <= 0:
|
||||
frappe.throw(
|
||||
_(
|
||||
"Gross Purchase Amount Too Low: {0} cannot be depreciated over {1} cycles with a frequency of {2} depreciations."
|
||||
).format(
|
||||
frappe.bold(asset_doc.gross_purchase_amount),
|
||||
frappe.bold(row.total_number_of_depreciations),
|
||||
frappe.bold(row.frequency_of_depreciation),
|
||||
)
|
||||
)
|
||||
elif n == 0 and has_wdv_or_dd_non_yearly_pro_rata and self.opening_accumulated_depreciation:
|
||||
if not is_first_day_of_the_month(getdate(asset_doc.available_for_use_date)):
|
||||
from_date = get_last_day(
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.require("assets/erpnext/js/purchase_trends_filters.js", function () {
|
||||
frappe.query_reports["Purchase Order Trends"] = {
|
||||
filters: erpnext.get_purchase_trends_filters(),
|
||||
};
|
||||
});
|
||||
frappe.query_reports["Purchase Order Trends"] = $.extend({}, erpnext.purchase_trends_filters);
|
||||
|
||||
@@ -2183,10 +2183,10 @@ class AccountsController(TransactionBase):
|
||||
for d in self.get("payment_schedule"):
|
||||
if d.invoice_portion:
|
||||
d.payment_amount = flt(
|
||||
grand_total * flt(d.invoice_portion / 100), d.precision("payment_amount")
|
||||
grand_total * flt(d.invoice_portion) / 100, d.precision("payment_amount")
|
||||
)
|
||||
d.base_payment_amount = flt(
|
||||
base_grand_total * flt(d.invoice_portion / 100), d.precision("base_payment_amount")
|
||||
base_grand_total * flt(d.invoice_portion) / 100, d.precision("base_payment_amount")
|
||||
)
|
||||
d.outstanding = d.payment_amount
|
||||
elif not d.invoice_portion:
|
||||
|
||||
@@ -80,6 +80,18 @@ class BOMCreator(Document):
|
||||
if row.is_expandable and row.item_code == self.item_code:
|
||||
frappe.throw(_("Item {0} cannot be added as a sub-assembly of itself").format(row.item_code))
|
||||
|
||||
if not row.parent_row_no and row.fg_item and row.fg_item != self.item_code:
|
||||
frappe.throw(
|
||||
_("At row {0}: set Parent Row No for item {1}").format(row.idx, row.item_code),
|
||||
title=_("Set Parent Row No in Items Table"),
|
||||
)
|
||||
|
||||
elif row.parent_row_no and row.fg_item == self.item_code:
|
||||
frappe.throw(
|
||||
_("At row {0}: Parent Row No cannot be set for item {1}").format(row.idx, row.item_code),
|
||||
title=_("Remove Parent Row No in Items Table"),
|
||||
)
|
||||
|
||||
def set_status(self, save=False):
|
||||
self.status = {
|
||||
0: "Draft",
|
||||
@@ -410,6 +422,10 @@ def add_sub_assembly(**kwargs):
|
||||
|
||||
parent_row_no = item_row.idx
|
||||
name = ""
|
||||
else:
|
||||
parent_row_no = [row.idx for row in doc.items if row.name == kwargs.fg_reference_id]
|
||||
if parent_row_no:
|
||||
parent_row_no = parent_row_no[0]
|
||||
|
||||
for row in bom_item.get("items"):
|
||||
row = frappe._dict(row)
|
||||
|
||||
@@ -214,7 +214,11 @@ class JobCard(Document):
|
||||
if d.to_time and get_datetime(d.from_time) > get_datetime(d.to_time):
|
||||
frappe.throw(_("Row {0}: From time must be less than to time").format(d.idx))
|
||||
|
||||
data = self.get_overlap_for(d)
|
||||
open_job_cards = []
|
||||
if d.get("employee"):
|
||||
open_job_cards = self.get_open_job_cards(d.get("employee"))
|
||||
|
||||
data = self.get_overlap_for(d, open_job_cards=open_job_cards)
|
||||
if data:
|
||||
frappe.throw(
|
||||
_("Row {0}: From Time and To Time of {1} is overlapping with {2}").format(
|
||||
@@ -235,12 +239,12 @@ class JobCard(Document):
|
||||
for row in self.sub_operations:
|
||||
self.total_completed_qty += row.completed_qty
|
||||
|
||||
def get_overlap_for(self, args):
|
||||
def get_overlap_for(self, args, open_job_cards=None):
|
||||
time_logs = []
|
||||
|
||||
time_logs.extend(self.get_time_logs(args, "Job Card Time Log"))
|
||||
|
||||
time_logs.extend(self.get_time_logs(args, "Job Card Scheduled Time"))
|
||||
time_logs.extend(self.get_time_logs(args, "Job Card Scheduled Time", open_job_cards=open_job_cards))
|
||||
|
||||
if not time_logs:
|
||||
return {}
|
||||
@@ -304,7 +308,7 @@ class JobCard(Document):
|
||||
return True
|
||||
return overlap
|
||||
|
||||
def get_time_logs(self, args, doctype):
|
||||
def get_time_logs(self, args, doctype, open_job_cards=None):
|
||||
jc = frappe.qb.DocType("Job Card")
|
||||
jctl = frappe.qb.DocType(doctype)
|
||||
|
||||
@@ -341,8 +345,14 @@ class JobCard(Document):
|
||||
if self.workstation:
|
||||
query = query.where(jc.workstation == self.workstation)
|
||||
|
||||
if args.get("employee") and doctype == "Job Card Time Log":
|
||||
query = query.where(jctl.employee == args.get("employee"))
|
||||
if args.get("employee"):
|
||||
if not open_job_cards and doctype == "Job Card Scheduled Time":
|
||||
return []
|
||||
|
||||
if doctype == "Job Card Time Log":
|
||||
query = query.where(jctl.employee == args.get("employee"))
|
||||
else:
|
||||
query = query.where(jc.name.isin(open_job_cards))
|
||||
|
||||
if doctype != "Job Card Time Log":
|
||||
query = query.where(jc.total_time_in_mins == 0)
|
||||
@@ -351,6 +361,27 @@ class JobCard(Document):
|
||||
|
||||
return time_logs
|
||||
|
||||
def get_open_job_cards(self, employee):
|
||||
jc = frappe.qb.DocType("Job Card")
|
||||
jctl = frappe.qb.DocType("Job Card Time Log")
|
||||
|
||||
query = (
|
||||
frappe.qb.from_(jc)
|
||||
.left_join(jctl)
|
||||
.on(jc.name == jctl.parent)
|
||||
.select(jc.name)
|
||||
.where(
|
||||
(jctl.parent == jc.name)
|
||||
& (jc.workstation == self.workstation)
|
||||
& (jctl.employee == employee)
|
||||
& (jc.docstatus < 1)
|
||||
& (jc.name != self.name)
|
||||
)
|
||||
)
|
||||
|
||||
jobs = query.run(as_dict=True)
|
||||
return [job.get("name") for job in jobs] if jobs else []
|
||||
|
||||
def get_workstation_based_on_available_slot(self, existing_time_logs) -> dict:
|
||||
workstations = get_workstations(self.workstation_type)
|
||||
if workstations:
|
||||
|
||||
@@ -42,8 +42,7 @@
|
||||
"fieldname": "completed_qty",
|
||||
"fieldtype": "Float",
|
||||
"in_list_view": 1,
|
||||
"label": "Completed Qty",
|
||||
"reqd": 1
|
||||
"label": "Completed Qty"
|
||||
},
|
||||
{
|
||||
"fieldname": "employee",
|
||||
@@ -64,7 +63,7 @@
|
||||
"index_web_pages_for_search": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2020-12-23 14:30:00.970916",
|
||||
"modified": "2024-05-21 12:40:55.765860",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Manufacturing",
|
||||
"name": "Job Card Time Log",
|
||||
@@ -74,4 +73,4 @@
|
||||
"sort_field": "modified",
|
||||
"sort_order": "ASC",
|
||||
"track_changes": 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ def get_exploded_items(bom, data, indent=0, qty=1):
|
||||
exploded_items = frappe.get_all(
|
||||
"BOM Item",
|
||||
filters={"parent": bom},
|
||||
fields=["qty", "bom_no", "qty", "item_code", "item_name", "description", "uom"],
|
||||
fields=["qty", "bom_no", "qty", "item_code", "item_name", "description", "uom", "idx"],
|
||||
order_by="idx ASC",
|
||||
)
|
||||
|
||||
for item in exploded_items:
|
||||
|
||||
@@ -93,4 +93,11 @@ frappe.query_reports["Exponential Smoothing Forecasting"] = {
|
||||
},
|
||||
},
|
||||
],
|
||||
formatter: function (value, row, column, data, default_formatter) {
|
||||
value = default_formatter(value, row, column, data);
|
||||
if (column.fieldname === "item_code" && value.includes("Total Quantity")) {
|
||||
value = "<strong>" + value + "</strong>";
|
||||
}
|
||||
return value;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -144,7 +144,7 @@ class ForecastingReport(ExponentialSmoothingForecast):
|
||||
if not self.data:
|
||||
return
|
||||
|
||||
total_row = {"item_code": _(frappe.bold("Total Quantity"))}
|
||||
total_row = {"item_code": _("Total Quantity")}
|
||||
|
||||
for value in self.data:
|
||||
for period in self.period_list:
|
||||
|
||||
@@ -364,3 +364,4 @@ erpnext.patches.v15_0.delete_orphaned_asset_movement_item_records
|
||||
erpnext.patches.v15_0.fix_debit_credit_in_transaction_currency
|
||||
erpnext.patches.v15_0.remove_cancelled_asset_capitalization_from_asset
|
||||
erpnext.patches.v15_0.rename_purchase_receipt_amount_to_purchase_amount
|
||||
erpnext.patches.v14_0.enable_set_priority_for_pricing_rules #1
|
||||
|
||||
@@ -13,8 +13,9 @@ def execute():
|
||||
for d in accounting_dimensions:
|
||||
doctype = "Asset Repair"
|
||||
field = frappe.db.get_value("Custom Field", {"dt": doctype, "fieldname": d.fieldname})
|
||||
docfield = frappe.db.get_value("DocField", {"parent": doctype, "fieldname": d.fieldname})
|
||||
|
||||
if field:
|
||||
if field or docfield:
|
||||
continue
|
||||
|
||||
df = {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
pr_table = frappe.qb.DocType("Pricing Rule")
|
||||
(
|
||||
frappe.qb.update(pr_table)
|
||||
.set(pr_table.has_priority, 1)
|
||||
.where((pr_table.priority.isnotnull()) & (pr_table.priority != ""))
|
||||
).run()
|
||||
@@ -34,5 +34,7 @@ import "./utils/sales_common.js";
|
||||
import "./controllers/buying.js";
|
||||
import "./utils/demo.js";
|
||||
import "./financial_statements.js";
|
||||
import "./sales_trends_filters.js";
|
||||
import "./purchase_trends_filters.js";
|
||||
|
||||
// import { sum } from 'frappe/public/utils/util.js'
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
erpnext.get_purchase_trends_filters = function () {
|
||||
return [
|
||||
erpnext.purchase_trends_filters = {
|
||||
filters: [
|
||||
{
|
||||
fieldname: "company",
|
||||
label: __("Company"),
|
||||
@@ -63,5 +63,5 @@ erpnext.get_purchase_trends_filters = function () {
|
||||
options: ["", { value: "Item", label: __("Item") }, { value: "Supplier", label: __("Supplier") }],
|
||||
default: "",
|
||||
},
|
||||
];
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
erpnext.get_sales_trends_filters = function () {
|
||||
return [
|
||||
erpnext.sales_trends_filters = {
|
||||
filters: [
|
||||
{
|
||||
fieldname: "period",
|
||||
label: __("Period"),
|
||||
@@ -53,5 +53,5 @@ erpnext.get_sales_trends_filters = function () {
|
||||
options: "Company",
|
||||
default: frappe.defaults.get_user_default("Company"),
|
||||
},
|
||||
];
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1183,4 +1183,39 @@ $.extend(erpnext.stock.utils, {
|
||||
const barcode_scanner = new erpnext.utils.BarcodeScanner({ frm: frm });
|
||||
barcode_scanner.scan_api_call(child_row.barcode, callback);
|
||||
},
|
||||
|
||||
get_serial_range(range_string, separator) {
|
||||
/* Return an array of serial numbers generated from a range string.
|
||||
|
||||
Examples (using separator "::"):
|
||||
- "1::5" => ["1", "2", "3", "4", "5"]
|
||||
- "SN0009::12" => ["SN0009", "SN0010", "SN0011", "SN0012"]
|
||||
- "ABC//05::8" => ["ABC//05", "ABC//06", "ABC//07", "ABC//08"]
|
||||
*/
|
||||
if (!range_string) {
|
||||
return;
|
||||
}
|
||||
|
||||
const [start_str, end_str] = range_string.trim().split(separator);
|
||||
|
||||
if (!start_str || !end_str) {
|
||||
return;
|
||||
}
|
||||
|
||||
const end_int = parseInt(end_str);
|
||||
const length_difference = start_str.length - end_str.length;
|
||||
const start_int = parseInt(start_str.substring(length_difference));
|
||||
|
||||
if (isNaN(start_int) || isNaN(end_int)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const serial_numbers = Array(end_int - start_int + 1)
|
||||
.fill(1)
|
||||
.map((x, y) => x + y)
|
||||
.map((x) => x + start_int - 1);
|
||||
return serial_numbers.map((val) => {
|
||||
return start_str.substring(0, length_difference) + val.toString().padStart(end_str.length, "0");
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -206,6 +206,16 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
|
||||
label: __("{0} {1} Manually", [primary_label, label]),
|
||||
depends_on: "eval:doc.import_using_csv_file === 0",
|
||||
},
|
||||
{
|
||||
fieldtype: "Data",
|
||||
label: __("Enter Serial No Range"),
|
||||
fieldname: "serial_no_range",
|
||||
depends_on: "eval:doc.import_using_csv_file === 0",
|
||||
description: __('Enter "ABC-001::100" for serial nos "ABC-001" to "ABC-100".'),
|
||||
onchange: () => {
|
||||
this.set_serial_nos_from_range();
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldtype: "Small Text",
|
||||
label: __("Enter Serial Nos"),
|
||||
@@ -255,6 +265,20 @@ erpnext.SerialBatchPackageSelector = class SerialNoBatchBundleUpdate {
|
||||
return fields;
|
||||
}
|
||||
|
||||
set_serial_nos_from_range() {
|
||||
const serial_no_range = this.dialog.get_value("serial_no_range");
|
||||
|
||||
if (!serial_no_range) {
|
||||
return;
|
||||
}
|
||||
|
||||
const serial_nos = erpnext.stock.utils.get_serial_range(serial_no_range, "::");
|
||||
|
||||
if (serial_nos) {
|
||||
this.dialog.set_value("upload_serial_nos", serial_nos.join("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
create_serial_nos() {
|
||||
let { upload_serial_nos } = this.dialog.get_values();
|
||||
|
||||
|
||||
@@ -684,7 +684,7 @@ erpnext.PointOfSale.Controller = class {
|
||||
const is_stock_item = resp[1];
|
||||
|
||||
frappe.dom.unfreeze();
|
||||
const bold_uom = item_row.stock_uom.bold();
|
||||
const bold_uom = item_row.uom.bold();
|
||||
const bold_item_code = item_row.item_code.bold();
|
||||
const bold_warehouse = warehouse.bold();
|
||||
const bold_available_qty = available_qty.toString().bold();
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.require("assets/erpnext/js/sales_trends_filters.js", function () {
|
||||
frappe.query_reports["Quotation Trends"] = {
|
||||
filters: erpnext.get_sales_trends_filters(),
|
||||
};
|
||||
});
|
||||
frappe.query_reports["Quotation Trends"] = $.extend({}, erpnext.sales_trends_filters);
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.require("assets/erpnext/js/sales_trends_filters.js", function () {
|
||||
frappe.query_reports["Sales Order Trends"] = {
|
||||
filters: erpnext.get_sales_trends_filters(),
|
||||
};
|
||||
});
|
||||
frappe.query_reports["Sales Order Trends"] = $.extend({}, erpnext.sales_trends_filters);
|
||||
|
||||
@@ -164,9 +164,10 @@ def prepare_data(
|
||||
rows = {}
|
||||
|
||||
target_qty_amt_field = "target_qty" if filters.get("target_on") == "Quantity" else "target_amount"
|
||||
|
||||
qty_or_amount_field = "stock_qty" if filters.get("target_on") == "Quantity" else "base_net_amount"
|
||||
|
||||
item_group_parent_child_map = get_item_group_parent_child_map()
|
||||
|
||||
for d in sales_users_data:
|
||||
key = (d.parent, d.item_group)
|
||||
dist_data = get_periodwise_distribution_data(d.distribution_id, period_list, filters.get("period"))
|
||||
@@ -191,7 +192,11 @@ def prepare_data(
|
||||
r.get(sales_field) == d.parent
|
||||
and period.from_date <= r.get(date_field)
|
||||
and r.get(date_field) <= period.to_date
|
||||
and (not sales_user_wise_item_groups.get(d.parent) or r.item_group == d.item_group)
|
||||
and (
|
||||
not sales_user_wise_item_groups.get(d.parent)
|
||||
or r.item_group == d.item_group
|
||||
or r.item_group in item_group_parent_child_map.get(d.item_group, [])
|
||||
)
|
||||
):
|
||||
details[p_key] += r.get(qty_or_amount_field, 0)
|
||||
details[variance_key] = details.get(p_key) - details.get(target_key)
|
||||
@@ -204,6 +209,25 @@ def prepare_data(
|
||||
return rows
|
||||
|
||||
|
||||
def get_item_group_parent_child_map():
|
||||
"""
|
||||
Returns a dict of all item group parents and leaf children associated with them.
|
||||
"""
|
||||
|
||||
item_groups = frappe.get_all(
|
||||
"Item Group", fields=["name", "parent_item_group"], order_by="lft desc, rgt desc"
|
||||
)
|
||||
item_group_parent_child_map = {}
|
||||
|
||||
for item_group in item_groups:
|
||||
children = item_group_parent_child_map.get(item_group.name, [])
|
||||
if not children:
|
||||
children = [item_group.name]
|
||||
item_group_parent_child_map.setdefault(item_group.parent_item_group, []).extend(children)
|
||||
|
||||
return item_group_parent_child_map
|
||||
|
||||
|
||||
def get_actual_data(filters, sales_users_or_territory_data, date_field, sales_field):
|
||||
fiscal_year = get_fiscal_year(fiscal_year=filters.get("fiscal_year"), as_dict=1)
|
||||
|
||||
|
||||
@@ -205,8 +205,11 @@ def clear_demo_record(document):
|
||||
if key not in valid_columns:
|
||||
filters.pop(key, None)
|
||||
|
||||
doc = frappe.get_doc(document_type, filters)
|
||||
doc.delete(ignore_permissions=True)
|
||||
try:
|
||||
doc = frappe.get_doc(document_type, filters)
|
||||
doc.delete(ignore_permissions=True)
|
||||
except frappe.exceptions.DoesNotExistError:
|
||||
pass
|
||||
|
||||
|
||||
def delete_company(company):
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
"default_finance_book",
|
||||
"advance_payments_section",
|
||||
"book_advance_payments_in_separate_party_account",
|
||||
"reconcile_on_advance_payment_date",
|
||||
"column_break_fwcf",
|
||||
"default_advance_received_account",
|
||||
"default_advance_paid_account",
|
||||
@@ -779,6 +780,14 @@
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Dashboard",
|
||||
"show_dashboard": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"depends_on": "eval: doc.book_advance_payments_in_separate_party_account",
|
||||
"description": "If <b>Enabled</b> - Reconciliation happens on the <b>Advance Payment posting date</b><br>\nIf <b>Disabled</b> - Reconciliation happens on oldest of 2 Dates: <b>Invoice Date</b> or the <b>Advance Payment posting date</b><br>\n",
|
||||
"fieldname": "reconcile_on_advance_payment_date",
|
||||
"fieldtype": "Check",
|
||||
"label": "Reconcile on Advance Payment Date"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-building",
|
||||
@@ -786,7 +795,7 @@
|
||||
"image_field": "company_logo",
|
||||
"is_tree": 1,
|
||||
"links": [],
|
||||
"modified": "2024-04-23 12:38:33.173938",
|
||||
"modified": "2024-05-16 12:39:54.694232",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Company",
|
||||
|
||||
@@ -85,6 +85,7 @@ class Company(NestedSet):
|
||||
parent_company: DF.Link | None
|
||||
payment_terms: DF.Link | None
|
||||
phone_no: DF.Data | None
|
||||
reconcile_on_advance_payment_date: DF.Check
|
||||
registration_details: DF.Code | None
|
||||
rgt: DF.Int
|
||||
round_off_account: DF.Link | None
|
||||
|
||||
@@ -47,9 +47,14 @@ frappe.ui.form.on("Batch", {
|
||||
},
|
||||
make_dashboard: (frm) => {
|
||||
if (!frm.is_new()) {
|
||||
let for_stock_levels = 0;
|
||||
if (!frm.doc.batch_qty && frm.doc.expiry_date) {
|
||||
for_stock_levels = 1;
|
||||
}
|
||||
|
||||
frappe.call({
|
||||
method: "erpnext.stock.doctype.batch.batch.get_batch_qty",
|
||||
args: { batch_no: frm.doc.name, item_code: frm.doc.item },
|
||||
args: { batch_no: frm.doc.name, item_code: frm.doc.item, for_stock_levels: for_stock_levels },
|
||||
callback: (r) => {
|
||||
if (!r.message) {
|
||||
return;
|
||||
|
||||
@@ -199,6 +199,7 @@ def get_batch_qty(
|
||||
posting_date=None,
|
||||
posting_time=None,
|
||||
ignore_voucher_nos=None,
|
||||
for_stock_levels=False,
|
||||
):
|
||||
"""Returns batch actual qty if warehouse is passed,
|
||||
or returns dict of qty by warehouse if warehouse is None
|
||||
@@ -222,6 +223,7 @@ def get_batch_qty(
|
||||
"posting_time": posting_time,
|
||||
"batch_no": batch_no,
|
||||
"ignore_voucher_nos": ignore_voucher_nos,
|
||||
"for_stock_levels": for_stock_levels,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@ frappe.listview_settings["Batch"] = {
|
||||
get_indicator: (doc) => {
|
||||
if (doc.disabled) {
|
||||
return [__("Disabled"), "gray", "disabled,=,1"];
|
||||
} else if (!doc.batch_qty) {
|
||||
return [__("Empty"), "gray", "batch_qty,=,0|disabled,=,0"];
|
||||
} else if (
|
||||
doc.expiry_date &&
|
||||
frappe.datetime.get_diff(doc.expiry_date, frappe.datetime.nowdate()) <= 0
|
||||
@@ -14,6 +12,8 @@ frappe.listview_settings["Batch"] = {
|
||||
"red",
|
||||
"expiry_date,not in,|expiry_date,<=,Today|batch_qty,>,0|disabled,=,0",
|
||||
];
|
||||
} else if (!doc.batch_qty) {
|
||||
return [__("Empty"), "gray", "batch_qty,=,0|disabled,=,0"];
|
||||
} else {
|
||||
return [__("Active"), "green", "batch_qty,>,0|disabled,=,0"];
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import copy
|
||||
import json
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe import _, bold
|
||||
from frappe.model.document import Document
|
||||
from frappe.query_builder import Interval
|
||||
from frappe.query_builder.functions import Count, CurDate, UnixTimestamp
|
||||
@@ -469,6 +469,13 @@ class Item(Document):
|
||||
def validate_warehouse_for_reorder(self):
|
||||
"""Validate Reorder level table for duplicate and conditional mandatory"""
|
||||
warehouse_material_request_type: list[tuple[str, str]] = []
|
||||
|
||||
_warehouse_before_save = frappe._dict()
|
||||
if not self.is_new() and self._doc_before_save:
|
||||
_warehouse_before_save = {
|
||||
d.name: d.warehouse for d in self._doc_before_save.get("reorder_levels") or []
|
||||
}
|
||||
|
||||
for d in self.get("reorder_levels"):
|
||||
if not d.warehouse_group:
|
||||
d.warehouse_group = d.warehouse
|
||||
@@ -485,6 +492,19 @@ class Item(Document):
|
||||
if d.warehouse_reorder_level and not d.warehouse_reorder_qty:
|
||||
frappe.throw(_("Row #{0}: Please set reorder quantity").format(d.idx))
|
||||
|
||||
if d.warehouse_group and d.warehouse:
|
||||
if _warehouse_before_save.get(d.name) == d.warehouse:
|
||||
continue
|
||||
|
||||
child_warehouses = get_child_warehouses(d.warehouse_group)
|
||||
if d.warehouse not in child_warehouses:
|
||||
frappe.throw(
|
||||
_(
|
||||
"Row #{0}: The warehouse {1} is not a child warehouse of a group warehouse {2}"
|
||||
).format(d.idx, bold(d.warehouse), bold(d.warehouse_group)),
|
||||
title=_("Incorrect Check in (group) Warehouse for Reorder"),
|
||||
)
|
||||
|
||||
def stock_ledger_created(self):
|
||||
if not hasattr(self, "_stock_ledger_created"):
|
||||
self._stock_ledger_created = len(
|
||||
@@ -1360,3 +1380,10 @@ def get_asset_naming_series():
|
||||
from erpnext.assets.doctype.asset.asset import get_asset_naming_series
|
||||
|
||||
return get_asset_naming_series()
|
||||
|
||||
|
||||
@frappe.request_cache
|
||||
def get_child_warehouses(warehouse):
|
||||
from erpnext.stock.doctype.warehouse.warehouse import get_child_warehouses
|
||||
|
||||
return get_child_warehouses(warehouse)
|
||||
|
||||
@@ -862,6 +862,27 @@ class TestItem(FrappeTestCase):
|
||||
self.assertEqual(data[0].description, item.description)
|
||||
self.assertTrue("description" in data[0])
|
||||
|
||||
def test_group_warehouse_for_reorder_item(self):
|
||||
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse
|
||||
|
||||
item_doc = make_item("_Test Group Warehouse For Reorder Item", {"is_stock_item": 1})
|
||||
warehouse = create_warehouse("_Test Warehouse - _TC")
|
||||
warehouse_doc = frappe.get_doc("Warehouse", warehouse)
|
||||
warehouse_doc.db_set("parent_warehouse", "")
|
||||
|
||||
item_doc.append(
|
||||
"reorder_levels",
|
||||
{
|
||||
"warehouse": warehouse,
|
||||
"warehouse_reorder_level": 10,
|
||||
"warehouse_reorder_qty": 100,
|
||||
"material_request_type": "Purchase",
|
||||
"warehouse_group": "_Test Warehouse Group - _TC",
|
||||
},
|
||||
)
|
||||
|
||||
self.assertRaises(frappe.ValidationError, item_doc.save)
|
||||
|
||||
|
||||
def set_item_variant_settings(fields):
|
||||
doc = frappe.get_doc("Item Variant Settings")
|
||||
|
||||
@@ -923,6 +923,15 @@ class PurchaseReceipt(BuyingController):
|
||||
notify=True,
|
||||
)
|
||||
|
||||
def enable_recalculate_rate_in_sles(self):
|
||||
sle_table = frappe.qb.DocType("Stock Ledger Entry")
|
||||
(
|
||||
frappe.qb.update(sle_table)
|
||||
.set(sle_table.recalculate_rate, 1)
|
||||
.where(sle_table.voucher_no == self.name)
|
||||
.where(sle_table.voucher_type == "Purchase Receipt")
|
||||
).run()
|
||||
|
||||
|
||||
def get_stock_value_difference(voucher_no, voucher_detail_no, warehouse):
|
||||
return frappe.db.get_value(
|
||||
@@ -1095,15 +1104,10 @@ def adjust_incoming_rate_for_pr(doc):
|
||||
for item in doc.get("items"):
|
||||
item.db_update()
|
||||
|
||||
doc.docstatus = 2
|
||||
doc.update_stock_ledger(allow_negative_stock=True, via_landed_cost_voucher=True)
|
||||
doc.make_gl_entries_on_cancel()
|
||||
if doc.doctype == "Purchase Receipt":
|
||||
doc.enable_recalculate_rate_in_sles()
|
||||
|
||||
# update stock & gl entries for submit state of PR
|
||||
doc.docstatus = 1
|
||||
doc.update_stock_ledger(allow_negative_stock=True, via_landed_cost_voucher=True)
|
||||
doc.make_gl_entries()
|
||||
doc.repost_future_sle_and_gle()
|
||||
doc.repost_future_sle_and_gle(force=True)
|
||||
|
||||
|
||||
def get_item_wise_returned_qty(pr_doc):
|
||||
|
||||
@@ -1865,14 +1865,14 @@ def get_available_batches(kwargs):
|
||||
batch_ledger.warehouse,
|
||||
Sum(batch_ledger.qty).as_("qty"),
|
||||
)
|
||||
.where(
|
||||
(batch_table.disabled == 0)
|
||||
& ((batch_table.expiry_date >= today()) | (batch_table.expiry_date.isnull()))
|
||||
)
|
||||
.where(batch_table.disabled == 0)
|
||||
.where(stock_ledger_entry.is_cancelled == 0)
|
||||
.groupby(batch_ledger.batch_no, batch_ledger.warehouse)
|
||||
)
|
||||
|
||||
if not kwargs.get("for_stock_levels"):
|
||||
query = query.where((batch_table.expiry_date >= today()) | (batch_table.expiry_date.isnull()))
|
||||
|
||||
if kwargs.get("posting_date"):
|
||||
if kwargs.get("posting_time") is None:
|
||||
kwargs.posting_time = nowtime()
|
||||
|
||||
@@ -93,11 +93,15 @@ class StockLedgerEntry(Document):
|
||||
self.validate_with_last_transaction_posting_time()
|
||||
self.validate_inventory_dimension_negative_stock()
|
||||
|
||||
def set_posting_datetime(self):
|
||||
def set_posting_datetime(self, save=False):
|
||||
from erpnext.stock.utils import get_combine_datetime
|
||||
|
||||
self.posting_datetime = get_combine_datetime(self.posting_date, self.posting_time)
|
||||
self.db_set("posting_datetime", self.posting_datetime)
|
||||
if save:
|
||||
posting_datetime = get_combine_datetime(self.posting_date, self.posting_time)
|
||||
if not self.posting_datetime or self.posting_datetime != posting_datetime:
|
||||
self.db_set("posting_datetime", posting_datetime)
|
||||
else:
|
||||
self.posting_datetime = get_combine_datetime(self.posting_date, self.posting_time)
|
||||
|
||||
def validate_inventory_dimension_negative_stock(self):
|
||||
if self.is_cancelled:
|
||||
@@ -169,7 +173,7 @@ class StockLedgerEntry(Document):
|
||||
return inv_dimension_dict
|
||||
|
||||
def on_submit(self):
|
||||
self.set_posting_datetime()
|
||||
self.set_posting_datetime(save=True)
|
||||
self.check_stock_frozen_date()
|
||||
|
||||
# Added to handle few test cases where serial_and_batch_bundles are not required
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.require("assets/erpnext/js/sales_trends_filters.js", function () {
|
||||
frappe.query_reports["Delivery Note Trends"] = {
|
||||
filters: erpnext.get_sales_trends_filters(),
|
||||
};
|
||||
});
|
||||
frappe.query_reports["Delivery Note Trends"] = $.extend({}, erpnext.sales_trends_filters);
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
frappe.require("assets/erpnext/js/purchase_trends_filters.js", function () {
|
||||
frappe.query_reports["Purchase Receipt Trends"] = {
|
||||
filters: erpnext.get_purchase_trends_filters(),
|
||||
};
|
||||
});
|
||||
frappe.query_reports["Purchase Receipt Trends"] = $.extend({}, erpnext.purchase_trends_filters);
|
||||
|
||||
@@ -220,6 +220,7 @@ def make_entry(args, allow_negative_stock=False, via_landed_cost_voucher=False):
|
||||
sle.flags.ignore_permissions = 1
|
||||
sle.allow_negative_stock = allow_negative_stock
|
||||
sle.via_landed_cost_voucher = via_landed_cost_voucher
|
||||
sle.set_posting_datetime()
|
||||
sle.submit()
|
||||
|
||||
# Added to handle the case when the stock ledger entry is created from the repostig
|
||||
|
||||
@@ -332,7 +332,7 @@ frappe.ui.form.on("Subcontracting Receipt Item", {
|
||||
set_missing_values(frm);
|
||||
},
|
||||
|
||||
items_remove: (frm) => {
|
||||
items_delete: (frm) => {
|
||||
set_missing_values(frm);
|
||||
},
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<div class="row">
|
||||
<div class="row {% if df.bold %}important{% endif %} data-field">
|
||||
{% if doc.flags.show_inclusive_tax_in_print %}
|
||||
<div class="col-xs-5 {%- if doc.align_labels_right %} text-right{%- endif -%}">
|
||||
<label>{{ _("Total (Without Tax)") }}</label></div>
|
||||
<div class="col-xs-7 text-right">
|
||||
<div class="col-xs-7 text-right value">
|
||||
{{ doc.get_formatted("net_total", doc) }}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="col-xs-5 {%- if doc.align_labels_right %} text-right{%- endif -%}">
|
||||
<label>{{ _(df.label) }}</label></div>
|
||||
<div class="col-xs-7 text-right">
|
||||
<div class="col-xs-7 text-right value">
|
||||
{{ doc.get_formatted("total", doc) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user