Merge branch 'develop' into bank-trans-party-automatch
This commit is contained in:
commit
36de35c6d9
@ -497,7 +497,7 @@ def get_amount(ref_doc, payment_account=None):
|
||||
if dt in ["Sales Order", "Purchase Order"]:
|
||||
grand_total = flt(ref_doc.rounded_total) or flt(ref_doc.grand_total)
|
||||
elif dt in ["Sales Invoice", "Purchase Invoice"]:
|
||||
if not ref_doc.is_pos:
|
||||
if not ref_doc.get("is_pos"):
|
||||
if ref_doc.party_account_currency == ref_doc.currency:
|
||||
grand_total = flt(ref_doc.outstanding_amount)
|
||||
else:
|
||||
|
@ -6,6 +6,7 @@ import unittest
|
||||
import frappe
|
||||
|
||||
from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request
|
||||
from erpnext.accounts.doctype.purchase_invoice.test_purchase_invoice import make_purchase_invoice
|
||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||
from erpnext.setup.utils import get_exchange_rate
|
||||
@ -74,6 +75,29 @@ class TestPaymentRequest(unittest.TestCase):
|
||||
self.assertEqual(pr.reference_name, si_usd.name)
|
||||
self.assertEqual(pr.currency, "USD")
|
||||
|
||||
def test_payment_entry_against_purchase_invoice(self):
|
||||
si_usd = make_purchase_invoice(
|
||||
customer="_Test Supplier USD",
|
||||
debit_to="_Test Payable USD - _TC",
|
||||
currency="USD",
|
||||
conversion_rate=50,
|
||||
)
|
||||
|
||||
pr = make_payment_request(
|
||||
dt="Purchase Invoice",
|
||||
dn=si_usd.name,
|
||||
recipient_id="user@example.com",
|
||||
mute_email=1,
|
||||
payment_gateway_account="_Test Gateway - USD",
|
||||
submit_doc=1,
|
||||
return_doc=1,
|
||||
)
|
||||
|
||||
pe = pr.create_payment_entry()
|
||||
pr.load_from_db()
|
||||
|
||||
self.assertEqual(pr.status, "Paid")
|
||||
|
||||
def test_payment_entry(self):
|
||||
frappe.db.set_value(
|
||||
"Company", "_Test Company", "exchange_gain_loss_account", "_Test Exchange Gain/Loss - _TC"
|
||||
|
@ -36,7 +36,7 @@ frappe.listview_settings['Asset'] = {
|
||||
}
|
||||
},
|
||||
onload: function(me) {
|
||||
me.page.add_action_item('Make Asset Movement', function() {
|
||||
me.page.add_action_item(__("Make Asset Movement"), function() {
|
||||
const assets = me.get_checked_items();
|
||||
frappe.call({
|
||||
method: "erpnext.assets.doctype.asset.asset.make_asset_movement",
|
||||
|
@ -14,6 +14,7 @@ from erpnext.assets.doctype.asset.asset import get_asset_value_after_depreciatio
|
||||
from erpnext.assets.doctype.asset.depreciation import get_depreciation_accounts
|
||||
from erpnext.assets.doctype.asset_depreciation_schedule.asset_depreciation_schedule import (
|
||||
get_asset_depr_schedule_doc,
|
||||
get_depreciation_amount,
|
||||
)
|
||||
|
||||
|
||||
@ -162,7 +163,7 @@ class AssetValueAdjustment(Document):
|
||||
depreciation_amount = days * rate_per_day
|
||||
from_date = data.schedule_date
|
||||
else:
|
||||
depreciation_amount = asset.get_depreciation_amount(value_after_depreciation, d)
|
||||
depreciation_amount = get_depreciation_amount(asset, value_after_depreciation, d)
|
||||
|
||||
if depreciation_amount:
|
||||
value_after_depreciation -= flt(depreciation_amount)
|
||||
|
@ -9,15 +9,14 @@
|
||||
"production_item_tab",
|
||||
"item",
|
||||
"company",
|
||||
"item_name",
|
||||
"uom",
|
||||
"quantity",
|
||||
"cb0",
|
||||
"is_active",
|
||||
"is_default",
|
||||
"allow_alternative_item",
|
||||
"set_rate_of_sub_assembly_item_based_on_bom",
|
||||
"project",
|
||||
"quantity",
|
||||
"image",
|
||||
"currency_detail",
|
||||
"rm_cost_as_per",
|
||||
@ -27,6 +26,8 @@
|
||||
"column_break_ivyw",
|
||||
"currency",
|
||||
"conversion_rate",
|
||||
"materials_section",
|
||||
"items",
|
||||
"section_break_21",
|
||||
"operations_section_section",
|
||||
"with_operations",
|
||||
@ -38,8 +39,6 @@
|
||||
"operating_cost_per_bom_quantity",
|
||||
"operations_section",
|
||||
"operations",
|
||||
"materials_section",
|
||||
"items",
|
||||
"scrap_section",
|
||||
"scrap_items_section",
|
||||
"scrap_items",
|
||||
@ -59,6 +58,7 @@
|
||||
"total_cost",
|
||||
"base_total_cost",
|
||||
"more_info_tab",
|
||||
"item_name",
|
||||
"description",
|
||||
"column_break_27",
|
||||
"has_variants",
|
||||
@ -192,6 +192,7 @@
|
||||
"options": "Quality Inspection Template"
|
||||
},
|
||||
{
|
||||
"collapsible": 1,
|
||||
"fieldname": "currency_detail",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Cost Configuration"
|
||||
@ -417,7 +418,7 @@
|
||||
{
|
||||
"collapsible": 1,
|
||||
"fieldname": "website_section",
|
||||
"fieldtype": "Section Break",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Website"
|
||||
},
|
||||
{
|
||||
@ -482,7 +483,7 @@
|
||||
{
|
||||
"fieldname": "section_break_21",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Operations & Materials"
|
||||
"label": "Operations"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_23",
|
||||
@ -605,7 +606,7 @@
|
||||
"image_field": "image",
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2023-02-13 17:31:37.504565",
|
||||
"modified": "2023-04-06 12:47:58.514795",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Manufacturing",
|
||||
"name": "BOM",
|
||||
|
@ -22,17 +22,13 @@
|
||||
"produced_qty",
|
||||
"process_loss_qty",
|
||||
"project",
|
||||
"serial_no_and_batch_for_finished_good_section",
|
||||
"has_serial_no",
|
||||
"has_batch_no",
|
||||
"column_break_17",
|
||||
"serial_no",
|
||||
"batch_size",
|
||||
"section_break_ndpq",
|
||||
"required_items",
|
||||
"work_order_configuration",
|
||||
"settings_section",
|
||||
"allow_alternative_item",
|
||||
"use_multi_level_bom",
|
||||
"column_break_18",
|
||||
"column_break_17",
|
||||
"skip_transfer",
|
||||
"from_wip_warehouse",
|
||||
"update_consumed_material_cost_in_project",
|
||||
@ -42,9 +38,14 @@
|
||||
"column_break_12",
|
||||
"fg_warehouse",
|
||||
"scrap_warehouse",
|
||||
"serial_no_and_batch_for_finished_good_section",
|
||||
"has_serial_no",
|
||||
"has_batch_no",
|
||||
"column_break_18",
|
||||
"serial_no",
|
||||
"batch_size",
|
||||
"required_items_section",
|
||||
"materials_and_operations_tab",
|
||||
"required_items",
|
||||
"operations_section",
|
||||
"operations",
|
||||
"transfer_material_against",
|
||||
@ -586,7 +587,11 @@
|
||||
{
|
||||
"fieldname": "materials_and_operations_tab",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Materials & Operations"
|
||||
"label": "Operations"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_ndpq",
|
||||
"fieldtype": "Section Break"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-cogs",
|
||||
@ -594,7 +599,7 @@
|
||||
"image_field": "image",
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2023-01-03 14:16:35.427731",
|
||||
"modified": "2023-04-06 12:35:12.149827",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Manufacturing",
|
||||
"name": "Work Order",
|
||||
|
@ -36,8 +36,24 @@ class ItemGroup(NestedSet, WebsiteGenerator):
|
||||
|
||||
self.make_route()
|
||||
self.validate_item_group_defaults()
|
||||
self.check_item_tax()
|
||||
ECommerceSettings.validate_field_filters(self.filter_fields, enable_field_filters=True)
|
||||
|
||||
def check_item_tax(self):
|
||||
"""Check whether Tax Rate is not entered twice for same Tax Type"""
|
||||
check_list = []
|
||||
for d in self.get("taxes"):
|
||||
if d.item_tax_template:
|
||||
if (d.item_tax_template, d.tax_category) in check_list:
|
||||
frappe.throw(
|
||||
_("{0} entered twice {1} in Item Taxes").format(
|
||||
frappe.bold(d.item_tax_template),
|
||||
"for tax category {0}".format(frappe.bold(d.tax_category)) if d.tax_category else "",
|
||||
)
|
||||
)
|
||||
else:
|
||||
check_list.append((d.item_tax_template, d.tax_category))
|
||||
|
||||
def on_update(self):
|
||||
NestedSet.on_update(self)
|
||||
invalidate_cache_for(self)
|
||||
|
@ -6,6 +6,7 @@ import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.model.naming import make_autoname, revert_series_if_last
|
||||
from frappe.query_builder.functions import CurDate, Sum, Timestamp
|
||||
from frappe.utils import cint, flt, get_link_to_form, nowtime
|
||||
from frappe.utils.data import add_days
|
||||
from frappe.utils.jinja import render_template
|
||||
@ -176,49 +177,41 @@ def get_batch_qty(
|
||||
:param warehouse: Optional - give qty for this warehouse
|
||||
:param item_code: Optional - give qty for this item"""
|
||||
|
||||
sle = frappe.qb.DocType("Stock Ledger Entry")
|
||||
|
||||
out = 0
|
||||
if batch_no and warehouse:
|
||||
cond = ""
|
||||
query = (
|
||||
frappe.qb.from_(sle)
|
||||
.select(Sum(sle.actual_qty))
|
||||
.where((sle.is_cancelled == 0) & (sle.warehouse == warehouse) & (sle.batch_no == batch_no))
|
||||
)
|
||||
|
||||
if posting_date:
|
||||
if posting_time is None:
|
||||
posting_time = nowtime()
|
||||
|
||||
cond = " and timestamp(posting_date, posting_time) <= timestamp('{0}', '{1}')".format(
|
||||
posting_date, posting_time
|
||||
query = query.where(
|
||||
Timestamp(sle.posting_date, sle.posting_time) <= Timestamp(posting_date, posting_time)
|
||||
)
|
||||
|
||||
out = float(
|
||||
frappe.db.sql(
|
||||
"""select sum(actual_qty)
|
||||
from `tabStock Ledger Entry`
|
||||
where is_cancelled = 0 and warehouse=%s and batch_no=%s {0}""".format(
|
||||
cond
|
||||
),
|
||||
(warehouse, batch_no),
|
||||
)[0][0]
|
||||
or 0
|
||||
)
|
||||
out = query.run(as_list=True)[0][0] or 0
|
||||
|
||||
if batch_no and not warehouse:
|
||||
out = frappe.db.sql(
|
||||
"""select warehouse, sum(actual_qty) as qty
|
||||
from `tabStock Ledger Entry`
|
||||
where is_cancelled = 0 and batch_no=%s
|
||||
group by warehouse""",
|
||||
batch_no,
|
||||
as_dict=1,
|
||||
)
|
||||
out = (
|
||||
frappe.qb.from_(sle)
|
||||
.select(sle.warehouse, Sum(sle.actual_qty).as_("qty"))
|
||||
.where((sle.is_cancelled == 0) & (sle.batch_no == batch_no))
|
||||
.groupby(sle.warehouse)
|
||||
).run(as_dict=True)
|
||||
|
||||
if not batch_no and item_code and warehouse:
|
||||
out = frappe.db.sql(
|
||||
"""select batch_no, sum(actual_qty) as qty
|
||||
from `tabStock Ledger Entry`
|
||||
where is_cancelled = 0 and item_code = %s and warehouse=%s
|
||||
group by batch_no""",
|
||||
(item_code, warehouse),
|
||||
as_dict=1,
|
||||
)
|
||||
out = (
|
||||
frappe.qb.from_(sle)
|
||||
.select(sle.batch_no, Sum(sle.actual_qty).as_("qty"))
|
||||
.where((sle.is_cancelled == 0) & (sle.item_code == item_code) & (sle.warehouse == warehouse))
|
||||
.groupby(sle.batch_no)
|
||||
).run(as_dict=True)
|
||||
|
||||
return out
|
||||
|
||||
@ -314,40 +307,44 @@ def get_batch_no(item_code, warehouse, qty=1, throw=False, serial_no=None):
|
||||
def get_batches(item_code, warehouse, qty=1, throw=False, serial_no=None):
|
||||
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
|
||||
|
||||
cond = ""
|
||||
batch = frappe.qb.DocType("Batch")
|
||||
sle = frappe.qb.DocType("Stock Ledger Entry")
|
||||
|
||||
query = (
|
||||
frappe.qb.from_(batch)
|
||||
.join(sle)
|
||||
.on(batch.batch_id == sle.batch_no)
|
||||
.select(
|
||||
batch.batch_id,
|
||||
Sum(sle.actual_qty).as_("qty"),
|
||||
)
|
||||
.where(
|
||||
(sle.item_code == item_code)
|
||||
& (sle.warehouse == warehouse)
|
||||
& (sle.is_cancelled == 0)
|
||||
& ((batch.expiry_date >= CurDate()) | (batch.expiry_date.isnull()))
|
||||
)
|
||||
.groupby(batch.batch_id)
|
||||
.orderby(batch.expiry_date, batch.creation)
|
||||
)
|
||||
|
||||
if serial_no and frappe.get_cached_value("Item", item_code, "has_batch_no"):
|
||||
serial_nos = get_serial_nos(serial_no)
|
||||
batch = frappe.get_all(
|
||||
batches = frappe.get_all(
|
||||
"Serial No",
|
||||
fields=["distinct batch_no"],
|
||||
filters={"item_code": item_code, "warehouse": warehouse, "name": ("in", serial_nos)},
|
||||
)
|
||||
|
||||
if not batch:
|
||||
if not batches:
|
||||
validate_serial_no_with_batch(serial_nos, item_code)
|
||||
|
||||
if batch and len(batch) > 1:
|
||||
if batches and len(batches) > 1:
|
||||
return []
|
||||
|
||||
cond = " and `tabBatch`.name = %s" % (frappe.db.escape(batch[0].batch_no))
|
||||
query = query.where(batch.name == batches[0].batch_no)
|
||||
|
||||
return frappe.db.sql(
|
||||
"""
|
||||
select batch_id, sum(`tabStock Ledger Entry`.actual_qty) as qty
|
||||
from `tabBatch`
|
||||
join `tabStock Ledger Entry` ignore index (item_code, warehouse)
|
||||
on (`tabBatch`.batch_id = `tabStock Ledger Entry`.batch_no )
|
||||
where `tabStock Ledger Entry`.item_code = %s and `tabStock Ledger Entry`.warehouse = %s
|
||||
and `tabStock Ledger Entry`.is_cancelled = 0
|
||||
and (`tabBatch`.expiry_date >= CURRENT_DATE or `tabBatch`.expiry_date IS NULL) {0}
|
||||
group by batch_id
|
||||
order by `tabBatch`.expiry_date ASC, `tabBatch`.creation ASC
|
||||
""".format(
|
||||
cond
|
||||
),
|
||||
(item_code, warehouse),
|
||||
as_dict=True,
|
||||
)
|
||||
return query.run(as_dict=True)
|
||||
|
||||
|
||||
def validate_serial_no_with_batch(serial_nos, item_code):
|
||||
|
@ -83,6 +83,8 @@
|
||||
"actual_qty",
|
||||
"installed_qty",
|
||||
"item_tax_rate",
|
||||
"column_break_atna",
|
||||
"received_qty",
|
||||
"accounting_details_section",
|
||||
"expense_account",
|
||||
"allow_zero_valuation_rate",
|
||||
@ -832,13 +834,27 @@
|
||||
"fieldname": "material_request_item",
|
||||
"fieldtype": "Data",
|
||||
"label": "Material Request Item"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_atna",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval: parent.is_internal_customer",
|
||||
"fieldname": "received_qty",
|
||||
"fieldtype": "Float",
|
||||
"label": "Received Qty",
|
||||
"no_copy": 1,
|
||||
"print_hide": 1,
|
||||
"read_only": 1,
|
||||
"report_hide": 1
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
"index_web_pages_for_search": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2023-03-20 14:24:10.406746",
|
||||
"modified": "2023-04-06 09:28:29.182053",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Delivery Note Item",
|
||||
|
@ -117,7 +117,6 @@ class Item(Document):
|
||||
self.validate_auto_reorder_enabled_in_stock_settings()
|
||||
self.cant_change()
|
||||
self.validate_item_tax_net_rate_range()
|
||||
set_item_tax_from_hsn_code(self)
|
||||
|
||||
if not self.is_new():
|
||||
self.old_item_group = frappe.db.get_value(self.doctype, self.name, "item_group")
|
||||
@ -352,10 +351,15 @@ class Item(Document):
|
||||
check_list = []
|
||||
for d in self.get("taxes"):
|
||||
if d.item_tax_template:
|
||||
if d.item_tax_template in check_list:
|
||||
frappe.throw(_("{0} entered twice in Item Tax").format(d.item_tax_template))
|
||||
if (d.item_tax_template, d.tax_category) in check_list:
|
||||
frappe.throw(
|
||||
_("{0} entered twice {1} in Item Taxes").format(
|
||||
frappe.bold(d.item_tax_template),
|
||||
"for tax category {0}".format(frappe.bold(d.tax_category)) if d.tax_category else "",
|
||||
)
|
||||
)
|
||||
else:
|
||||
check_list.append(d.item_tax_template)
|
||||
check_list.append((d.item_tax_template, d.tax_category))
|
||||
|
||||
def validate_barcode(self):
|
||||
import barcodenumber
|
||||
@ -1316,11 +1320,6 @@ def update_variants(variants, template, publish_progress=True):
|
||||
frappe.publish_progress(count / total * 100, title=_("Updating Variants..."))
|
||||
|
||||
|
||||
@erpnext.allow_regional
|
||||
def set_item_tax_from_hsn_code(item):
|
||||
pass
|
||||
|
||||
|
||||
def validate_item_default_company_links(item_defaults: List[ItemDefault]) -> None:
|
||||
for item_default in item_defaults:
|
||||
for doctype, field in [
|
||||
|
@ -65,6 +65,16 @@ class PurchaseReceipt(BuyingController):
|
||||
"percent_join_field": "purchase_invoice",
|
||||
"overflow_type": "receipt",
|
||||
},
|
||||
{
|
||||
"source_dt": "Purchase Receipt Item",
|
||||
"target_dt": "Delivery Note Item",
|
||||
"join_field": "delivery_note_item",
|
||||
"source_field": "received_qty",
|
||||
"target_field": "received_qty",
|
||||
"target_parent_dt": "Delivery Note",
|
||||
"target_ref_field": "qty",
|
||||
"overflow_type": "receipt",
|
||||
},
|
||||
]
|
||||
|
||||
if cint(self.is_return):
|
||||
|
@ -1544,6 +1544,72 @@ class TestPurchaseReceipt(FrappeTestCase):
|
||||
res = get_item_details(args)
|
||||
self.assertEqual(res.get("last_purchase_rate"), 100)
|
||||
|
||||
def test_validate_received_qty_for_internal_pr(self):
|
||||
prepare_data_for_internal_transfer()
|
||||
customer = "_Test Internal Customer 2"
|
||||
company = "_Test Company with perpetual inventory"
|
||||
from_warehouse = create_warehouse("_Test Internal From Warehouse New", company=company)
|
||||
target_warehouse = create_warehouse("_Test Internal GIT Warehouse New", company=company)
|
||||
to_warehouse = create_warehouse("_Test Internal To Warehouse New", company=company)
|
||||
|
||||
# Step 1: Create Item
|
||||
item = make_item(properties={"is_stock_item": 1, "valuation_rate": 100})
|
||||
|
||||
# Step 2: Create Stock Entry (Material Receipt)
|
||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
||||
|
||||
make_stock_entry(
|
||||
purpose="Material Receipt",
|
||||
item_code=item.name,
|
||||
qty=15,
|
||||
company=company,
|
||||
to_warehouse=from_warehouse,
|
||||
)
|
||||
|
||||
# Step 3: Create Delivery Note with Internal Customer
|
||||
from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note
|
||||
|
||||
dn = create_delivery_note(
|
||||
item_code=item.name,
|
||||
company=company,
|
||||
customer=customer,
|
||||
cost_center="Main - TCP1",
|
||||
expense_account="Cost of Goods Sold - TCP1",
|
||||
qty=10,
|
||||
rate=100,
|
||||
warehouse=from_warehouse,
|
||||
target_warehouse=target_warehouse,
|
||||
)
|
||||
|
||||
# Step 4: Create Internal Purchase Receipt
|
||||
from erpnext.controllers.status_updater import OverAllowanceError
|
||||
from erpnext.stock.doctype.delivery_note.delivery_note import make_inter_company_purchase_receipt
|
||||
|
||||
pr = make_inter_company_purchase_receipt(dn.name)
|
||||
pr.items[0].qty = 15
|
||||
pr.items[0].from_warehouse = target_warehouse
|
||||
pr.items[0].warehouse = to_warehouse
|
||||
pr.items[0].rejected_warehouse = from_warehouse
|
||||
pr.save()
|
||||
|
||||
self.assertRaises(OverAllowanceError, pr.submit)
|
||||
|
||||
# Step 5: Test Over Receipt Allowance
|
||||
frappe.db.set_single_value("Stock Settings", "over_delivery_receipt_allowance", 50)
|
||||
|
||||
make_stock_entry(
|
||||
purpose="Material Transfer",
|
||||
item_code=item.name,
|
||||
qty=5,
|
||||
company=company,
|
||||
from_warehouse=from_warehouse,
|
||||
to_warehouse=target_warehouse,
|
||||
)
|
||||
|
||||
pr.submit()
|
||||
|
||||
frappe.db.set_single_value("Stock Settings", "over_delivery_receipt_allowance", 0)
|
||||
|
||||
|
||||
def prepare_data_for_internal_transfer():
|
||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_internal_supplier
|
||||
|
@ -27,7 +27,6 @@
|
||||
"set_posting_time",
|
||||
"inspection_required",
|
||||
"apply_putaway_rule",
|
||||
"items_tab",
|
||||
"bom_info_section",
|
||||
"from_bom",
|
||||
"use_multi_level_bom",
|
||||
@ -256,7 +255,7 @@
|
||||
"description": "As per Stock UOM",
|
||||
"fieldname": "fg_completed_qty",
|
||||
"fieldtype": "Float",
|
||||
"label": "For Quantity",
|
||||
"label": "Finished Good Quantity ",
|
||||
"oldfieldname": "fg_completed_qty",
|
||||
"oldfieldtype": "Currency",
|
||||
"print_hide": 1
|
||||
@ -612,11 +611,7 @@
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "items_tab",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Items"
|
||||
},
|
||||
{
|
||||
"collapsible": 1,
|
||||
"fieldname": "bom_info_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "BOM Info"
|
||||
@ -644,8 +639,10 @@
|
||||
"oldfieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"collapsible": 1,
|
||||
"fieldname": "section_break_7qsm",
|
||||
"fieldtype": "Section Break"
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Process Loss"
|
||||
},
|
||||
{
|
||||
"depends_on": "process_loss_percentage",
|
||||
@ -677,7 +674,7 @@
|
||||
"index_web_pages_for_search": 1,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2023-01-03 16:02:50.741816",
|
||||
"modified": "2023-04-06 12:42:56.673180",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Stock Entry",
|
||||
|
@ -5,6 +5,7 @@ from typing import Optional
|
||||
|
||||
import frappe
|
||||
from frappe import _, bold, msgprint
|
||||
from frappe.query_builder.functions import Sum
|
||||
from frappe.utils import cint, cstr, flt
|
||||
|
||||
import erpnext
|
||||
@ -569,6 +570,54 @@ class StockReconciliation(StockController):
|
||||
else:
|
||||
self._cancel()
|
||||
|
||||
def recalculate_current_qty(self, item_code, batch_no):
|
||||
for row in self.items:
|
||||
if not (row.item_code == item_code and row.batch_no == batch_no):
|
||||
continue
|
||||
|
||||
row.current_qty = get_batch_qty_for_stock_reco(item_code, row.warehouse, batch_no)
|
||||
|
||||
qty, val_rate = get_stock_balance(
|
||||
item_code,
|
||||
row.warehouse,
|
||||
self.posting_date,
|
||||
self.posting_time,
|
||||
with_valuation_rate=True,
|
||||
)
|
||||
|
||||
row.current_valuation_rate = val_rate
|
||||
|
||||
row.db_set(
|
||||
{
|
||||
"current_qty": row.current_qty,
|
||||
"current_valuation_rate": row.current_valuation_rate,
|
||||
"current_amount": flt(row.current_qty * row.current_valuation_rate),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def get_batch_qty_for_stock_reco(item_code, warehouse, batch_no):
|
||||
ledger = frappe.qb.DocType("Stock Ledger Entry")
|
||||
|
||||
query = (
|
||||
frappe.qb.from_(ledger)
|
||||
.select(
|
||||
Sum(ledger.actual_qty).as_("batch_qty"),
|
||||
)
|
||||
.where(
|
||||
(ledger.item_code == item_code)
|
||||
& (ledger.warehouse == warehouse)
|
||||
& (ledger.docstatus == 1)
|
||||
& (ledger.is_cancelled == 0)
|
||||
& (ledger.batch_no == batch_no)
|
||||
)
|
||||
.groupby(ledger.batch_no)
|
||||
)
|
||||
|
||||
sle = query.run(as_dict=True)
|
||||
|
||||
return flt(sle[0].batch_qty) if sle else 0
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_items(
|
||||
|
@ -637,7 +637,9 @@ def _get_item_tax_template(args, taxes, out=None, for_validate=False):
|
||||
taxes_with_no_validity.append(tax)
|
||||
|
||||
if taxes_with_validity:
|
||||
taxes = sorted(taxes_with_validity, key=lambda i: i.valid_from, reverse=True)
|
||||
taxes = sorted(
|
||||
taxes_with_validity, key=lambda i: i.valid_from or tax.maximum_net_rate, reverse=True
|
||||
)
|
||||
else:
|
||||
taxes = taxes_with_no_validity
|
||||
|
||||
|
@ -1337,6 +1337,9 @@ def update_qty_in_future_sle(args, allow_negative_stock=False):
|
||||
next_stock_reco_detail = get_next_stock_reco(args)
|
||||
if next_stock_reco_detail:
|
||||
detail = next_stock_reco_detail[0]
|
||||
if detail.batch_no:
|
||||
regenerate_sle_for_batch_stock_reco(detail)
|
||||
|
||||
# add condition to update SLEs before this date & time
|
||||
datetime_limit_condition = get_datetime_limit_condition(detail)
|
||||
|
||||
@ -1364,6 +1367,16 @@ def update_qty_in_future_sle(args, allow_negative_stock=False):
|
||||
validate_negative_qty_in_future_sle(args, allow_negative_stock)
|
||||
|
||||
|
||||
def regenerate_sle_for_batch_stock_reco(detail):
|
||||
doc = frappe.get_cached_doc("Stock Reconciliation", detail.voucher_no)
|
||||
doc.docstatus = 2
|
||||
doc.update_stock_ledger()
|
||||
|
||||
doc.recalculate_current_qty(detail.item_code, detail.batch_no)
|
||||
doc.docstatus = 1
|
||||
doc.update_stock_ledger()
|
||||
|
||||
|
||||
def get_stock_reco_qty_shift(args):
|
||||
stock_reco_qty_shift = 0
|
||||
if args.get("is_cancelled"):
|
||||
@ -1393,7 +1406,7 @@ def get_next_stock_reco(args):
|
||||
return frappe.db.sql(
|
||||
"""
|
||||
select
|
||||
name, posting_date, posting_time, creation, voucher_no
|
||||
name, posting_date, posting_time, creation, voucher_no, item_code, batch_no, actual_qty
|
||||
from
|
||||
`tabStock Ledger Entry`
|
||||
where
|
||||
|
@ -245,17 +245,17 @@ class SubcontractingReceipt(SubcontractingController):
|
||||
item.expense_account = expense_account
|
||||
|
||||
def update_status(self, status=None, update_modified=False):
|
||||
if self.docstatus >= 1 and not status:
|
||||
if self.docstatus == 1:
|
||||
if not status:
|
||||
if self.docstatus == 0:
|
||||
status = "Draft"
|
||||
elif self.docstatus == 1:
|
||||
status = "Completed"
|
||||
if self.is_return:
|
||||
status = "Return"
|
||||
return_against = frappe.get_doc("Subcontracting Receipt", self.return_against)
|
||||
return_against.run_method("update_status")
|
||||
else:
|
||||
if self.per_returned == 100:
|
||||
status = "Return Issued"
|
||||
elif self.status == "Draft":
|
||||
status = "Completed"
|
||||
elif self.per_returned == 100:
|
||||
status = "Return Issued"
|
||||
elif self.docstatus == 2:
|
||||
status = "Cancelled"
|
||||
|
||||
|
@ -1875,6 +1875,7 @@ Parents Teacher Meeting Attendance,Eltern Lehrer Treffen Teilnahme,
|
||||
Part-time,Teilzeit,
|
||||
Partially Depreciated,Teilweise abgeschrieben,
|
||||
Partially Received,Teilweise erhalten,
|
||||
Partly Paid,Teilweise bezahlt,
|
||||
Party,Partei,
|
||||
Party Name,Name der Partei,
|
||||
Party Type,Partei-Typ,
|
||||
|
Can't render this file because it is too large.
|
Loading…
Reference in New Issue
Block a user