Compare commits
73 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0653f6854b | ||
|
|
ee125d5dd8 | ||
|
|
a40e410519 | ||
|
|
315d4dec90 | ||
|
|
c826b5ce6c | ||
|
|
7355fce75e | ||
|
|
8ab75560d5 | ||
|
|
7561de1f4e | ||
|
|
64099b0bf7 | ||
|
|
46762ead05 | ||
|
|
5b9905f27a | ||
|
|
8e71665e4f | ||
|
|
385b08dc50 | ||
|
|
c53ced1224 | ||
|
|
a4fbea3722 | ||
|
|
e99485bfa7 | ||
|
|
963ddac528 | ||
|
|
947f138ea4 | ||
|
|
abceb1b611 | ||
|
|
d913ec52db | ||
|
|
e337a55a0b | ||
|
|
310f338d9b | ||
|
|
b0c2d41ecb | ||
|
|
241507a87f | ||
|
|
4921b038bd | ||
|
|
229e4f65b4 | ||
|
|
a4f94ed631 | ||
|
|
b1a4249041 | ||
|
|
5894bb3bbe | ||
|
|
a83ce43845 | ||
|
|
744de8595d | ||
|
|
e827507698 | ||
|
|
8deaba8def | ||
|
|
cea0e1fb91 | ||
|
|
51dc3f57e1 | ||
|
|
ca8fb17ee8 | ||
|
|
1cca51afc6 | ||
|
|
ee9a51f93f | ||
|
|
5eaa11b9e8 | ||
|
|
45a0494318 | ||
|
|
83bf28616e | ||
|
|
22ace5cb5a | ||
|
|
4fd7b01beb | ||
|
|
ab7e323648 | ||
|
|
d0b9c568d3 | ||
|
|
6b53288975 | ||
|
|
8f58b613e4 | ||
|
|
6460e649a5 | ||
|
|
a61cffd7c2 | ||
|
|
08e02710cd | ||
|
|
24386006d6 | ||
|
|
de6e8c74c5 | ||
|
|
79a16bad15 | ||
|
|
dcf19c3ed9 | ||
|
|
157d17d0f3 | ||
|
|
f2d094d1ab | ||
|
|
8caf655529 | ||
|
|
408d026465 | ||
|
|
d6054dbdbd | ||
|
|
2885b8fa44 | ||
|
|
f79e0d1e37 | ||
|
|
a9c95567cb | ||
|
|
28b0e988db | ||
|
|
8d9b5764dd | ||
|
|
dd74728568 | ||
|
|
e97f30d8e2 | ||
|
|
33777a4d4c | ||
|
|
d62db9bb22 | ||
|
|
df9d52d3ce | ||
|
|
d6a758d1f4 | ||
|
|
de47e67dfa | ||
|
|
c56f3a58ab | ||
|
|
e3591270c6 |
@@ -3,7 +3,7 @@ import inspect
|
||||
|
||||
import frappe
|
||||
|
||||
__version__ = "14.62.2"
|
||||
__version__ = "14.63.2"
|
||||
|
||||
|
||||
def get_default_company(user=None):
|
||||
|
||||
@@ -41,9 +41,10 @@ class BankTransaction(StatusUpdater):
|
||||
else:
|
||||
allocated_amount = 0.0
|
||||
|
||||
amount = abs(flt(self.withdrawal) - flt(self.deposit))
|
||||
self.db_set("allocated_amount", flt(allocated_amount))
|
||||
self.db_set("unallocated_amount", amount - flt(allocated_amount))
|
||||
unallocated_amount = abs(flt(self.withdrawal) - flt(self.deposit)) - allocated_amount
|
||||
|
||||
self.db_set("allocated_amount", flt(allocated_amount, self.precision("allocated_amount")))
|
||||
self.db_set("unallocated_amount", flt(unallocated_amount, self.precision("unallocated_amount")))
|
||||
self.reload()
|
||||
self.set_status(update=True)
|
||||
|
||||
|
||||
@@ -11,23 +11,8 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e
|
||||
super.setup(doc);
|
||||
}
|
||||
company() {
|
||||
super.company();
|
||||
erpnext.accounts.dimensions.update_dimension(this.frm, this.frm.doctype);
|
||||
|
||||
let me = this;
|
||||
if (this.frm.doc.company) {
|
||||
frappe.call({
|
||||
method:
|
||||
"erpnext.accounts.party.get_party_account",
|
||||
args: {
|
||||
party_type: 'Customer',
|
||||
party: this.frm.doc.customer,
|
||||
company: this.frm.doc.company
|
||||
},
|
||||
callback: (response) => {
|
||||
if (response) me.frm.set_value("debit_to", response.message);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
onload() {
|
||||
var me = this;
|
||||
|
||||
@@ -85,7 +85,10 @@ class ReceivablePayableReport(object):
|
||||
self.skip_total_row = 1
|
||||
|
||||
if self.filters.get("in_party_currency"):
|
||||
self.skip_total_row = 1
|
||||
if self.filters.get("party") and len(self.filters.get("party")) == 1:
|
||||
self.skip_total_row = 0
|
||||
else:
|
||||
self.skip_total_row = 1
|
||||
|
||||
def get_data(self):
|
||||
self.get_ple_entries()
|
||||
|
||||
@@ -6,6 +6,19 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
||||
|
||||
erpnext.utils.add_dimensions('Balance Sheet', 10);
|
||||
|
||||
frappe.query_reports["Balance Sheet"]["filters"].push(
|
||||
{
|
||||
"fieldname": "selected_view",
|
||||
"label": __("Select View"),
|
||||
"fieldtype": "Select",
|
||||
"options": [
|
||||
{ "value": "Report", "label": __("Report View") },
|
||||
{ "value": "Growth", "label": __("Growth View") }
|
||||
],
|
||||
"default": "Report",
|
||||
"reqd": 1
|
||||
},
|
||||
);
|
||||
frappe.query_reports["Balance Sheet"]["filters"].push({
|
||||
"fieldname": "accumulated_values",
|
||||
"label": __("Accumulated Values"),
|
||||
|
||||
@@ -319,7 +319,8 @@ def get_items(filters, additional_query_columns):
|
||||
`tabPurchase Invoice`.supplier, `tabPurchase Invoice`.remarks, `tabPurchase Invoice`.base_net_total,
|
||||
`tabPurchase Invoice`.unrealized_profit_loss_account,
|
||||
`tabPurchase Invoice Item`.`item_code`, `tabPurchase Invoice Item`.description,
|
||||
`tabPurchase Invoice Item`.`item_name` as pi_item_name, `tabPurchase Invoice Item`.`item_group` as pi_item_group,
|
||||
`tabPurchase Invoice Item`.`item_name` as pi_item_name, `tabPurchase Invoice Item`.`item_group`
|
||||
,`tabPurchase Invoice Item`.`item_group` as pi_item_group,
|
||||
`tabItem`.`item_name` as i_item_name, `tabItem`.`item_group` as i_item_group,
|
||||
`tabPurchase Invoice Item`.`project`, `tabPurchase Invoice Item`.`purchase_order`,
|
||||
`tabPurchase Invoice Item`.`purchase_receipt`, `tabPurchase Invoice Item`.`po_detail`,
|
||||
|
||||
@@ -350,7 +350,13 @@ def get_conditions(filters, additional_conditions=None):
|
||||
and ifnull(`tabSales Invoice Payment`.mode_of_payment, '') = %(mode_of_payment)s)"""
|
||||
|
||||
if filters.get("warehouse"):
|
||||
conditions += """and ifnull(`tabSales Invoice Item`.warehouse, '') = %(warehouse)s"""
|
||||
if frappe.db.get_value("Warehouse", filters.get("warehouse"), "is_group"):
|
||||
lft, rgt = frappe.db.get_all(
|
||||
"Warehouse", filters={"name": filters.get("warehouse")}, fields=["lft", "rgt"], as_list=True
|
||||
)[0]
|
||||
conditions += f"and ifnull(`tabSales Invoice Item`.warehouse, '') in (select name from `tabWarehouse` where lft > {lft} and rgt < {rgt}) "
|
||||
else:
|
||||
conditions += """and ifnull(`tabSales Invoice Item`.warehouse, '') = %(warehouse)s"""
|
||||
|
||||
if filters.get("brand"):
|
||||
conditions += """and ifnull(`tabSales Invoice Item`.brand, '') = %(brand)s"""
|
||||
|
||||
@@ -8,6 +8,21 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
||||
|
||||
erpnext.utils.add_dimensions('Profit and Loss Statement', 10);
|
||||
|
||||
frappe.query_reports["Profit and Loss Statement"]["filters"].push(
|
||||
{
|
||||
"fieldname": "selected_view",
|
||||
"label": __("Select View"),
|
||||
"fieldtype": "Select",
|
||||
"options": [
|
||||
{ "value": "Report", "label": __("Report View") },
|
||||
{ "value": "Growth", "label": __("Growth View") },
|
||||
{ "value": "Margin", "label": __("Margin View") },
|
||||
],
|
||||
"default": "Report",
|
||||
"reqd": 1
|
||||
},
|
||||
);
|
||||
|
||||
frappe.query_reports["Profit and Loss Statement"]["filters"].push(
|
||||
{
|
||||
"fieldname": "include_default_book_entries",
|
||||
|
||||
@@ -105,7 +105,7 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
||||
"to_fiscal_year": data.fiscal_year
|
||||
};
|
||||
|
||||
if(data.based_on == 'cost_center'){
|
||||
if(data.based_on == 'Cost Center'){
|
||||
frappe.route_options["cost_center"] = data.account
|
||||
} else {
|
||||
frappe.route_options["project"] = data.account
|
||||
|
||||
@@ -10,7 +10,7 @@ import frappe.defaults
|
||||
from frappe import _, qb, throw
|
||||
from frappe.model.meta import get_field_precision
|
||||
from frappe.query_builder import AliasedQuery, Criterion, Table
|
||||
from frappe.query_builder.functions import Sum
|
||||
from frappe.query_builder.functions import Round, Sum
|
||||
from frappe.query_builder.utils import DocType
|
||||
from frappe.utils import (
|
||||
cint,
|
||||
@@ -549,16 +549,19 @@ def check_if_advance_entry_modified(args):
|
||||
args,
|
||||
)
|
||||
else:
|
||||
ret = frappe.db.sql(
|
||||
"""select name from `tabPayment Entry`
|
||||
where
|
||||
name = %(voucher_no)s and docstatus = 1
|
||||
and party_type = %(party_type)s and party = %(party)s and {0} = %(account)s
|
||||
and round(unallocated_amount, {1}) = round(%(unreconciled_amount)s, {1})
|
||||
""".format(
|
||||
party_account_field, precision
|
||||
),
|
||||
args,
|
||||
pe = qb.DocType("Payment Entry")
|
||||
ret = (
|
||||
qb.from_(pe)
|
||||
.select(pe.name)
|
||||
.where(
|
||||
(pe.name == args.voucher_no)
|
||||
& (pe.docstatus == 1)
|
||||
& (pe.party_type == args.party_type)
|
||||
& (pe.party == args.party)
|
||||
& (pe[party_account_field] == args.account)
|
||||
& (Round(pe.unallocated_amount, precision) == Round(args.unreconciled_amount, precision))
|
||||
)
|
||||
.run()
|
||||
)
|
||||
|
||||
if not ret:
|
||||
|
||||
@@ -322,7 +322,7 @@ frappe.ui.form.on('Asset', {
|
||||
},
|
||||
|
||||
make_schedules_editable: function(frm) {
|
||||
if (frm.doc.finance_books.length) {
|
||||
if (frm.doc.finance_books && frm.doc.finance_books.length) {
|
||||
var is_manual_hence_editable = frm.doc.finance_books.filter(d => d.depreciation_method == "Manual").length > 0
|
||||
? true : false;
|
||||
var is_shift_hence_editable = frm.doc.finance_books.filter(d => d.shift_based).length > 0
|
||||
|
||||
@@ -513,14 +513,15 @@ class Asset(AccountsController):
|
||||
)
|
||||
|
||||
# Adjust depreciation amount in the last period based on the expected value after useful life
|
||||
if finance_book.expected_value_after_useful_life and (
|
||||
(
|
||||
n == cint(final_number_of_depreciations) - 1
|
||||
and value_after_depreciation != finance_book.expected_value_after_useful_life
|
||||
)
|
||||
or value_after_depreciation < finance_book.expected_value_after_useful_life
|
||||
if (
|
||||
n == cint(final_number_of_depreciations) - 1
|
||||
and flt(value_after_depreciation) != flt(finance_book.expected_value_after_useful_life)
|
||||
) or flt(value_after_depreciation) < flt(
|
||||
finance_book.expected_value_after_useful_life
|
||||
):
|
||||
depreciation_amount += value_after_depreciation - finance_book.expected_value_after_useful_life
|
||||
depreciation_amount += flt(value_after_depreciation) - flt(
|
||||
finance_book.expected_value_after_useful_life
|
||||
)
|
||||
skip_row = True
|
||||
|
||||
if flt(depreciation_amount, self.precision("gross_purchase_amount")) > 0:
|
||||
|
||||
@@ -508,7 +508,7 @@ def modify_depreciation_schedule_for_asset_repairs(asset):
|
||||
|
||||
|
||||
def reverse_depreciation_entry_made_after_disposal(asset, date):
|
||||
if not asset.calculate_depreciation:
|
||||
if not asset.calculate_depreciation or not asset.get("schedules"):
|
||||
return
|
||||
|
||||
row = -1
|
||||
@@ -520,7 +520,7 @@ def reverse_depreciation_entry_made_after_disposal(asset, date):
|
||||
else:
|
||||
row += 1
|
||||
|
||||
if schedule.schedule_date == date:
|
||||
if schedule.schedule_date == date and schedule.journal_entry:
|
||||
if not disposal_was_made_on_original_schedule_date(
|
||||
asset, schedule, row, date
|
||||
) or disposal_happens_in_the_future(date):
|
||||
|
||||
@@ -7,6 +7,7 @@ frappe.provide("erpnext.assets");
|
||||
erpnext.assets.AssetCapitalization = class AssetCapitalization extends erpnext.stock.StockController {
|
||||
setup() {
|
||||
this.setup_posting_date_time_check();
|
||||
this.frm.ignore_doctypes_on_cancel_all = ["Asset Movement"];
|
||||
}
|
||||
|
||||
onload() {
|
||||
|
||||
@@ -77,6 +77,7 @@ class AssetCapitalization(StockController):
|
||||
"Stock Ledger Entry",
|
||||
"Repost Item Valuation",
|
||||
"Asset",
|
||||
"Asset Movement",
|
||||
)
|
||||
self.cancel_target_asset()
|
||||
self.update_stock_ledger()
|
||||
@@ -86,6 +87,7 @@ class AssetCapitalization(StockController):
|
||||
def cancel_target_asset(self):
|
||||
if self.entry_type == "Capitalization" and self.target_asset:
|
||||
asset_doc = frappe.get_doc("Asset", self.target_asset)
|
||||
asset_doc.db_set("capitalized_in", None)
|
||||
if asset_doc.docstatus == 1:
|
||||
asset_doc.cancel()
|
||||
|
||||
|
||||
@@ -201,6 +201,18 @@ class AccountsController(TransactionBase):
|
||||
)
|
||||
)
|
||||
|
||||
if self.get("is_return") and self.get("return_against"):
|
||||
document_type = "Credit Note" if self.doctype == "Sales Invoice" else "Debit Note"
|
||||
frappe.msgprint(
|
||||
_(
|
||||
"{0} will be treated as a standalone {0}. Post creation use {1} tool to reconcile against {2}."
|
||||
).format(
|
||||
document_type,
|
||||
get_link_to_form("Payment Reconciliation", "Payment Reconciliation"),
|
||||
get_link_to_form(self.doctype, self.get("return_against")),
|
||||
)
|
||||
)
|
||||
|
||||
pos_check_field = "is_pos" if self.doctype == "Sales Invoice" else "is_paid"
|
||||
if cint(self.allocate_advances_automatically) and not cint(self.get(pos_check_field)):
|
||||
self.set_advances()
|
||||
|
||||
@@ -190,8 +190,8 @@ class BuyingController(SubcontractingController):
|
||||
lc_voucher_data = frappe.db.sql(
|
||||
"""select sum(applicable_charges), cost_center
|
||||
from `tabLanded Cost Item`
|
||||
where docstatus = 1 and purchase_receipt_item = %s""",
|
||||
d.name,
|
||||
where docstatus = 1 and purchase_receipt_item = %s and receipt_document = %s""",
|
||||
(d.name, self.name),
|
||||
)
|
||||
d.landed_cost_voucher_amount = lc_voucher_data[0][0] if lc_voucher_data else 0.0
|
||||
if not d.cost_center and lc_voucher_data and lc_voucher_data[0][1]:
|
||||
|
||||
@@ -831,6 +831,9 @@ class StockController(AccountsController):
|
||||
"Stock Reconciliation",
|
||||
)
|
||||
|
||||
if not frappe.get_all("Putaway Rule", limit=1):
|
||||
return
|
||||
|
||||
if self.doctype == "Purchase Invoice" and self.get("update_stock") == 0:
|
||||
valid_doctype = False
|
||||
|
||||
|
||||
@@ -16,11 +16,49 @@ class BlanketOrder(Document):
|
||||
def validate(self):
|
||||
self.validate_dates()
|
||||
self.validate_duplicate_items()
|
||||
self.set_party_item_code()
|
||||
|
||||
def validate_dates(self):
|
||||
if getdate(self.from_date) > getdate(self.to_date):
|
||||
frappe.throw(_("From date cannot be greater than To date"))
|
||||
|
||||
def set_party_item_code(self):
|
||||
item_ref = {}
|
||||
if self.blanket_order_type == "Selling":
|
||||
item_ref = self.get_customer_items_ref()
|
||||
else:
|
||||
item_ref = self.get_supplier_items_ref()
|
||||
|
||||
if not item_ref:
|
||||
return
|
||||
|
||||
for row in self.items:
|
||||
row.party_item_code = item_ref.get(row.item_code)
|
||||
|
||||
def get_customer_items_ref(self):
|
||||
items = [d.item_code for d in self.items]
|
||||
|
||||
return frappe._dict(
|
||||
frappe.get_all(
|
||||
"Item Customer Detail",
|
||||
filters={"parent": ("in", items), "customer_name": self.customer},
|
||||
fields=["parent", "ref_code"],
|
||||
as_list=True,
|
||||
)
|
||||
)
|
||||
|
||||
def get_supplier_items_ref(self):
|
||||
items = [d.item_code for d in self.items]
|
||||
|
||||
return frappe._dict(
|
||||
frappe.get_all(
|
||||
"Item Supplier",
|
||||
filters={"parent": ("in", items), "supplier": self.supplier},
|
||||
fields=["parent", "supplier_part_no"],
|
||||
as_list=True,
|
||||
)
|
||||
)
|
||||
|
||||
def validate_duplicate_items(self):
|
||||
item_list = []
|
||||
for item in self.items:
|
||||
@@ -65,6 +103,7 @@ def make_order(source_name):
|
||||
def update_item(source, target, source_parent):
|
||||
target_qty = source.get("qty") - source.get("ordered_qty")
|
||||
target.qty = target_qty if not flt(target_qty) < 0 else 0
|
||||
target.rate = source.get("rate")
|
||||
item = get_item_defaults(target.item_code, source_parent.company)
|
||||
if item:
|
||||
target.item_name = item.get("item_name")
|
||||
@@ -86,6 +125,10 @@ def make_order(source_name):
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
if target_doc.doctype == "Purchase Order":
|
||||
target_doc.set_missing_values()
|
||||
|
||||
return target_doc
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ from frappe.tests.utils import FrappeTestCase
|
||||
from frappe.utils import add_months, today
|
||||
|
||||
from erpnext import get_company_currency
|
||||
from erpnext.stock.doctype.item.test_item import make_item
|
||||
|
||||
from .blanket_order import make_order
|
||||
|
||||
@@ -90,6 +91,30 @@ class TestBlanketOrder(FrappeTestCase):
|
||||
frappe.db.set_single_value("Buying Settings", "blanket_order_allowance", 10)
|
||||
po.submit()
|
||||
|
||||
def test_party_item_code(self):
|
||||
item_doc = make_item("_Test Item 1 for Blanket Order")
|
||||
item_code = item_doc.name
|
||||
|
||||
customer = "_Test Customer"
|
||||
supplier = "_Test Supplier"
|
||||
|
||||
if not frappe.db.exists(
|
||||
"Item Customer Detail", {"customer_name": customer, "parent": item_code}
|
||||
):
|
||||
item_doc.append("customer_items", {"customer_name": customer, "ref_code": "CUST-REF-1"})
|
||||
item_doc.save()
|
||||
|
||||
if not frappe.db.exists("Item Supplier", {"supplier": supplier, "parent": item_code}):
|
||||
item_doc.append("supplier_items", {"supplier": supplier, "supplier_part_no": "SUPP-PART-1"})
|
||||
item_doc.save()
|
||||
|
||||
# Blanket Order for Selling
|
||||
bo = make_blanket_order(blanket_order_type="Selling", customer=customer, item_code=item_code)
|
||||
self.assertEqual(bo.items[0].party_item_code, "CUST-REF-1")
|
||||
|
||||
bo = make_blanket_order(blanket_order_type="Purchasing", supplier=supplier, item_code=item_code)
|
||||
self.assertEqual(bo.items[0].party_item_code, "SUPP-PART-1")
|
||||
|
||||
|
||||
def make_blanket_order(**args):
|
||||
args = frappe._dict(args)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"actions": [],
|
||||
"creation": "2018-05-24 07:20:04.255236",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
@@ -6,6 +7,7 @@
|
||||
"field_order": [
|
||||
"item_code",
|
||||
"item_name",
|
||||
"party_item_code",
|
||||
"column_break_3",
|
||||
"qty",
|
||||
"rate",
|
||||
@@ -62,10 +64,17 @@
|
||||
"fieldname": "terms_and_conditions",
|
||||
"fieldtype": "Text",
|
||||
"label": "Terms and Conditions"
|
||||
},
|
||||
{
|
||||
"fieldname": "party_item_code",
|
||||
"fieldtype": "Data",
|
||||
"label": "Party Item Code",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"istable": 1,
|
||||
"modified": "2019-11-18 19:37:46.245878",
|
||||
"links": [],
|
||||
"modified": "2024-02-14 18:25:26.479672",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Manufacturing",
|
||||
"name": "Blanket Order Item",
|
||||
@@ -74,5 +83,6 @@
|
||||
"quick_entry": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"track_changes": 1
|
||||
}
|
||||
@@ -38,7 +38,8 @@
|
||||
"in_list_view": 1,
|
||||
"label": "Item Code",
|
||||
"options": "Item",
|
||||
"reqd": 1
|
||||
"reqd": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "item_name",
|
||||
@@ -53,7 +54,8 @@
|
||||
"in_standard_filter": 1,
|
||||
"label": "For Warehouse",
|
||||
"options": "Warehouse",
|
||||
"reqd": 1
|
||||
"reqd": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"columns": 1,
|
||||
@@ -141,7 +143,8 @@
|
||||
"fieldname": "from_warehouse",
|
||||
"fieldtype": "Link",
|
||||
"label": "From Warehouse",
|
||||
"options": "Warehouse"
|
||||
"options": "Warehouse",
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fetch_from": "item_code.safety_stock",
|
||||
@@ -199,7 +202,7 @@
|
||||
],
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2023-09-12 12:09:08.358326",
|
||||
"modified": "2024-02-11 16:21:11.977018",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Manufacturing",
|
||||
"name": "Material Request Plan Item",
|
||||
|
||||
@@ -298,7 +298,8 @@
|
||||
"no_copy": 1,
|
||||
"options": "\nDraft\nSubmitted\nNot Started\nIn Process\nCompleted\nClosed\nCancelled\nMaterial Requested",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
"read_only": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "amended_from",
|
||||
@@ -436,7 +437,7 @@
|
||||
"index_web_pages_for_search": 1,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2023-12-26 16:31:13.740777",
|
||||
"modified": "2024-02-11 15:42:47.642481",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Manufacturing",
|
||||
"name": "Production Plan",
|
||||
|
||||
@@ -576,7 +576,10 @@ class ProductionPlan(Document):
|
||||
"project": self.project,
|
||||
}
|
||||
|
||||
key = (d.item_code, d.sales_order, d.warehouse)
|
||||
key = (d.item_code, d.sales_order, d.sales_order_item, d.warehouse)
|
||||
if self.combine_items:
|
||||
key = (d.item_code, d.sales_order, d.warehouse)
|
||||
|
||||
if not d.sales_order:
|
||||
key = (d.name, d.item_code, d.warehouse)
|
||||
|
||||
@@ -1691,23 +1694,23 @@ def get_reserved_qty_for_production_plan(item_code, warehouse):
|
||||
return reserved_qty_for_production_plan - reserved_qty_for_production
|
||||
|
||||
|
||||
@frappe.request_cache
|
||||
def get_non_completed_production_plans():
|
||||
table = frappe.qb.DocType("Production Plan")
|
||||
child = frappe.qb.DocType("Production Plan Item")
|
||||
|
||||
query = (
|
||||
return (
|
||||
frappe.qb.from_(table)
|
||||
.inner_join(child)
|
||||
.on(table.name == child.parent)
|
||||
.select(table.name)
|
||||
.distinct()
|
||||
.where(
|
||||
(table.docstatus == 1)
|
||||
& (table.status.notin(["Completed", "Closed"]))
|
||||
& (child.planned_qty > child.ordered_qty)
|
||||
)
|
||||
).run(as_dict=True)
|
||||
|
||||
return list(set([d.name for d in query]))
|
||||
).run(pluck="name")
|
||||
|
||||
|
||||
def get_raw_materials_of_sub_assembly_items(
|
||||
|
||||
@@ -448,7 +448,8 @@
|
||||
"no_copy": 1,
|
||||
"options": "Production Plan",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
"read_only": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "production_plan_item",
|
||||
@@ -600,7 +601,7 @@
|
||||
"image_field": "image",
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2023-08-11 18:35:49.852069",
|
||||
"modified": "2024-02-11 15:47:13.454422",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Manufacturing",
|
||||
"name": "Work Order",
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Item Code",
|
||||
"options": "Item"
|
||||
"options": "Item",
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "source_warehouse",
|
||||
@@ -141,7 +142,7 @@
|
||||
],
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2022-09-28 10:50:43.512562",
|
||||
"modified": "2024-02-11 15:45:32.318374",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Manufacturing",
|
||||
"name": "Work Order Item",
|
||||
|
||||
@@ -2,7 +2,57 @@ frappe.provide("erpnext.financial_statements");
|
||||
|
||||
erpnext.financial_statements = {
|
||||
"filters": get_filters(),
|
||||
"baseData": null,
|
||||
"formatter": function(value, row, column, data, default_formatter, filter) {
|
||||
if(frappe.query_report.get_filter_value("selected_view") == "Growth" && data && column.colIndex >= 3){
|
||||
//Assuming that the first three columns are s.no, account name and the very first year of the accounting values, to calculate the relative percentage values of the successive columns.
|
||||
const lastAnnualValue = row[column.colIndex - 1].content;
|
||||
const currentAnnualvalue = data[column.fieldname];
|
||||
if(currentAnnualvalue == undefined) return 'NA'; //making this not applicable for undefined/null values
|
||||
let annualGrowth = 0;
|
||||
if(lastAnnualValue == 0 && currentAnnualvalue > 0){
|
||||
//If the previous year value is 0 and the current value is greater than 0
|
||||
annualGrowth = 1;
|
||||
}
|
||||
else if(lastAnnualValue > 0){
|
||||
annualGrowth = (currentAnnualvalue - lastAnnualValue) / lastAnnualValue;
|
||||
}
|
||||
|
||||
const growthPercent = (Math.round(annualGrowth*10000)/100); //calculating the rounded off percentage
|
||||
|
||||
value = $(`<span>${((growthPercent >=0)? '+':'' )+growthPercent+'%'}</span>`);
|
||||
if(growthPercent < 0){
|
||||
value = $(value).addClass("text-danger");
|
||||
}
|
||||
else{
|
||||
value = $(value).addClass("text-success");
|
||||
}
|
||||
value = $(value).wrap("<p></p>").parent().html();
|
||||
|
||||
return value;
|
||||
}
|
||||
else if(frappe.query_report.get_filter_value("selected_view") == "Margin" && data){
|
||||
if(column.fieldname =="account" && data.account_name == __("Income")){
|
||||
//Taking the total income from each column (for all the financial years) as the base (100%)
|
||||
this.baseData = row;
|
||||
}
|
||||
if(column.colIndex >= 2){
|
||||
//Assuming that the first two columns are s.no and account name, to calculate the relative percentage values of the successive columns.
|
||||
const currentAnnualvalue = data[column.fieldname];
|
||||
const baseValue = this.baseData[column.colIndex].content;
|
||||
if(currentAnnualvalue == undefined || baseValue <= 0) return 'NA';
|
||||
const marginPercent = Math.round((currentAnnualvalue/baseValue)*10000)/100;
|
||||
|
||||
value = $(`<span>${marginPercent+'%'}</span>`);
|
||||
if(marginPercent < 0)
|
||||
value = $(value).addClass("text-danger");
|
||||
else
|
||||
value = $(value).addClass("text-success");
|
||||
value = $(value).wrap("<p></p>").parent().html();
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
if (data && column.fieldname=="account") {
|
||||
value = data.account_name || value;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"actions": [],
|
||||
"allow_guest_to_view": 1,
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:item_group_name",
|
||||
@@ -227,13 +228,14 @@
|
||||
"label": "Include Descendants"
|
||||
}
|
||||
],
|
||||
"has_web_view": 1,
|
||||
"icon": "fa fa-sitemap",
|
||||
"idx": 1,
|
||||
"image_field": "image",
|
||||
"is_tree": 1,
|
||||
"links": [],
|
||||
"max_attachments": 3,
|
||||
"modified": "2023-01-05 12:21:30.458628",
|
||||
"modified": "2024-02-22 16:23:46.936496",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Item Group",
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{% extends "templates/web.html" %}
|
||||
|
||||
{% block page_content %}
|
||||
<h1>{{ title }}</h1>
|
||||
{% endblock %}
|
||||
|
||||
<!-- this is a sample default web page template -->
|
||||
@@ -0,0 +1,4 @@
|
||||
<div>
|
||||
<a href="{{ doc.route }}">{{ doc.title or doc.name }}</a>
|
||||
</div>
|
||||
<!-- this is a sample default list template -->
|
||||
@@ -1047,6 +1047,7 @@ def validate_cancelled_item(item_code, docstatus=None):
|
||||
frappe.throw(_("Item {0} is cancelled").format(item_code))
|
||||
|
||||
|
||||
@frappe.request_cache
|
||||
def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
|
||||
"""returns last purchase details in stock uom"""
|
||||
# get last purchase order item details
|
||||
|
||||
@@ -38,6 +38,7 @@ class LandedCostVoucher(Document):
|
||||
def validate(self):
|
||||
self.check_mandatory()
|
||||
self.validate_receipt_documents()
|
||||
self.validate_line_items()
|
||||
init_landed_taxes_and_totals(self)
|
||||
self.set_total_taxes_and_charges()
|
||||
if not self.get("items"):
|
||||
@@ -45,6 +46,26 @@ class LandedCostVoucher(Document):
|
||||
|
||||
self.set_applicable_charges_on_item()
|
||||
|
||||
def validate_line_items(self):
|
||||
for d in self.get("items"):
|
||||
if (
|
||||
d.docstatus == 0
|
||||
and d.purchase_receipt_item
|
||||
and not frappe.db.exists(
|
||||
d.receipt_document_type + " Item",
|
||||
{"name": d.purchase_receipt_item, "parent": d.receipt_document},
|
||||
)
|
||||
):
|
||||
frappe.throw(
|
||||
_("Row {0}: {2} Item {1} does not exist in {2} {3}").format(
|
||||
d.idx,
|
||||
frappe.bold(d.purchase_receipt_item),
|
||||
d.receipt_document_type,
|
||||
frappe.bold(d.receipt_document),
|
||||
),
|
||||
title=_("Incorrect Reference Document (Purchase Receipt Item)"),
|
||||
)
|
||||
|
||||
def check_mandatory(self):
|
||||
if not self.get("purchase_receipts"):
|
||||
frappe.throw(_("Please enter Receipt Document"))
|
||||
|
||||
@@ -228,9 +228,17 @@ frappe.ui.form.on('Material Request', {
|
||||
const qty_fields = ['actual_qty', 'projected_qty', 'min_order_qty'];
|
||||
|
||||
if(!r.exc) {
|
||||
$.each(r.message, function(k, v) {
|
||||
if(!d[k] || in_list(qty_fields, k)) d[k] = v;
|
||||
$.each(r.message, function(key, value) {
|
||||
if(!d[key] || qty_fields.includes(key)) {
|
||||
d[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
if (d.price_list_rate != r.message.price_list_rate) {
|
||||
d.price_list_rate = r.message.price_list_rate;
|
||||
|
||||
frappe.model.set_value(d.doctype, d.name, "rate", d.price_list_rate);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -242,7 +250,7 @@ frappe.ui.form.on('Material Request', {
|
||||
fields: [
|
||||
{"fieldname":"bom", "fieldtype":"Link", "label":__("BOM"),
|
||||
options:"BOM", reqd: 1, get_query: function() {
|
||||
return {filters: { docstatus:1 }};
|
||||
return {filters: { docstatus:1, "is_active": 1 }};
|
||||
}},
|
||||
{"fieldname":"warehouse", "fieldtype":"Link", "label":__("For Warehouse"),
|
||||
options:"Warehouse", reqd: 1},
|
||||
@@ -432,7 +440,6 @@ frappe.ui.form.on("Material Request Item", {
|
||||
item.amount = flt(item.qty) * flt(item.rate);
|
||||
frappe.model.set_value(doctype, name, "amount", item.amount);
|
||||
refresh_field("amount", item.name, item.parentfield);
|
||||
frm.events.get_item_data(frm, item, false);
|
||||
},
|
||||
|
||||
item_code: function(frm, doctype, name) {
|
||||
@@ -452,7 +459,12 @@ frappe.ui.form.on("Material Request Item", {
|
||||
set_schedule_date(frm);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
conversion_factor: function(frm, doctype, name) {
|
||||
const item = locals[doctype][name];
|
||||
frm.events.get_item_data(frm, item, false);
|
||||
},
|
||||
});
|
||||
|
||||
erpnext.buying.MaterialRequestController = class MaterialRequestController extends erpnext.buying.BuyingController {
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
"received_qty",
|
||||
"rate_and_amount_section_break",
|
||||
"rate",
|
||||
"price_list_rate",
|
||||
"col_break3",
|
||||
"amount",
|
||||
"accounting_details_section",
|
||||
@@ -474,13 +475,22 @@
|
||||
"fieldtype": "Link",
|
||||
"label": "WIP Composite Asset",
|
||||
"options": "Asset"
|
||||
},
|
||||
{
|
||||
"fieldname": "price_list_rate",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 1,
|
||||
"label": "Price List Rate",
|
||||
"options": "currency",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
"index_web_pages_for_search": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2023-11-14 18:37:59.599115",
|
||||
"modified": "2024-02-08 16:30:56.137858",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Material Request Item",
|
||||
|
||||
@@ -32,6 +32,10 @@ class PickList(Document):
|
||||
self.update_status()
|
||||
self.set_item_locations()
|
||||
|
||||
if self.get("locations"):
|
||||
self.validate_sales_order_percentage()
|
||||
|
||||
def validate_sales_order_percentage(self):
|
||||
# set percentage picked in SO
|
||||
for location in self.get("locations"):
|
||||
if (
|
||||
|
||||
@@ -572,9 +572,7 @@ class PurchaseReceipt(BuyingController):
|
||||
)
|
||||
|
||||
stock_value_diff = (
|
||||
flt(d.base_net_amount)
|
||||
+ flt(d.item_tax_amount / self.conversion_rate)
|
||||
+ flt(d.landed_cost_voucher_amount)
|
||||
flt(d.base_net_amount) + flt(d.item_tax_amount) + flt(d.landed_cost_voucher_amount)
|
||||
)
|
||||
elif warehouse_account.get(d.warehouse):
|
||||
stock_value_diff = get_stock_value_difference(self.name, d.name, d.warehouse)
|
||||
|
||||
@@ -548,7 +548,9 @@ frappe.ui.form.on('Stock Entry', {
|
||||
|
||||
let fields = [
|
||||
{"fieldname":"bom", "fieldtype":"Link", "label":__("BOM"),
|
||||
options:"BOM", reqd: 1, get_query: filters()},
|
||||
options:"BOM", reqd: 1, get_query: () => {
|
||||
return {filters: { docstatus:1, "is_active": 1 }};
|
||||
}},
|
||||
{"fieldname":"source_warehouse", "fieldtype":"Link", "label":__("Source Warehouse"),
|
||||
options:"Warehouse"},
|
||||
{"fieldname":"target_warehouse", "fieldtype":"Link", "label":__("Target Warehouse"),
|
||||
|
||||
@@ -53,6 +53,9 @@ class StockLedgerEntry(Document):
|
||||
self.validate_inventory_dimension_negative_stock()
|
||||
|
||||
def validate_inventory_dimension_negative_stock(self):
|
||||
if self.is_cancelled:
|
||||
return
|
||||
|
||||
extra_cond = ""
|
||||
kwargs = {}
|
||||
|
||||
|
||||
@@ -699,8 +699,13 @@ class StockReconciliation(StockController):
|
||||
|
||||
def has_negative_stock_allowed(self):
|
||||
allow_negative_stock = cint(frappe.db.get_single_value("Stock Settings", "allow_negative_stock"))
|
||||
if allow_negative_stock:
|
||||
return True
|
||||
|
||||
if all(d.batch_no and flt(d.qty) == flt(d.current_qty) for d in self.items):
|
||||
if any(
|
||||
(d.batch_no and flt(d.qty) == flt(d.current_qty))
|
||||
for d in self.items
|
||||
):
|
||||
allow_negative_stock = True
|
||||
|
||||
return allow_negative_stock
|
||||
|
||||
@@ -72,8 +72,8 @@ class Issue(Document):
|
||||
"reference_name": self.name,
|
||||
}
|
||||
)
|
||||
communication.ignore_permissions = True
|
||||
communication.ignore_mandatory = True
|
||||
communication.flags.ignore_permissions = True
|
||||
communication.flags.ignore_mandatory = True
|
||||
communication.save()
|
||||
|
||||
@frappe.whitelist()
|
||||
|
||||
@@ -11,7 +11,6 @@ from erpnext.stock.doctype.warehouse.warehouse import get_child_warehouses
|
||||
|
||||
|
||||
def get_web_item_qty_in_stock(item_code, item_warehouse_field, warehouse=None):
|
||||
in_stock, stock_qty = 0, ""
|
||||
template_item_code, is_stock_item = frappe.db.get_value(
|
||||
"Item", item_code, ["variant_of", "is_stock_item"]
|
||||
)
|
||||
@@ -53,9 +52,10 @@ def get_web_item_qty_in_stock(item_code, item_warehouse_field, warehouse=None):
|
||||
).run()
|
||||
|
||||
if stock_qty:
|
||||
stock_qty = flt(stock_qty[0][0])
|
||||
total_stock += adjust_qty_for_expired_items(item_code, stock_qty, warehouse)
|
||||
|
||||
in_stock = total_stock > 0 and 1 or 0
|
||||
in_stock = int(total_stock > 0)
|
||||
|
||||
return frappe._dict(
|
||||
{"in_stock": in_stock, "stock_qty": total_stock, "is_stock_item": is_stock_item}
|
||||
@@ -63,20 +63,16 @@ def get_web_item_qty_in_stock(item_code, item_warehouse_field, warehouse=None):
|
||||
|
||||
|
||||
def adjust_qty_for_expired_items(item_code, stock_qty, warehouse):
|
||||
batches = frappe.get_all("Batch", filters=[{"item": item_code}], fields=["expiry_date", "name"])
|
||||
batches = frappe.get_all("Batch", filters={"item": item_code}, fields=["expiry_date", "name"])
|
||||
expired_batches = get_expired_batches(batches)
|
||||
stock_qty = [list(item) for item in stock_qty]
|
||||
|
||||
for batch in expired_batches:
|
||||
if warehouse:
|
||||
stock_qty[0][0] = max(0, stock_qty[0][0] - get_batch_qty(batch, warehouse))
|
||||
stock_qty = max(0, stock_qty - get_batch_qty(batch, warehouse))
|
||||
else:
|
||||
stock_qty[0][0] = max(0, stock_qty[0][0] - qty_from_all_warehouses(get_batch_qty(batch)))
|
||||
stock_qty = max(0, stock_qty - qty_from_all_warehouses(get_batch_qty(batch)))
|
||||
|
||||
if not stock_qty[0][0]:
|
||||
break
|
||||
|
||||
return stock_qty[0][0] if stock_qty else 0
|
||||
return stock_qty
|
||||
|
||||
|
||||
def get_expired_batches(batches):
|
||||
|
||||
Reference in New Issue
Block a user