test: added test case to validate audit for incorrect entries
This commit is contained in:
parent
b1721b79ce
commit
f31612376a
@ -393,7 +393,6 @@ scheduler_events = {
|
|||||||
],
|
],
|
||||||
"daily": [
|
"daily": [
|
||||||
"erpnext.support.doctype.issue.issue.auto_close_tickets",
|
"erpnext.support.doctype.issue.issue.auto_close_tickets",
|
||||||
"erpnext.stock.doctype.stock_entry.stock_entry.audit_incorrect_valuation_entries",
|
|
||||||
"erpnext.crm.doctype.opportunity.opportunity.auto_close_opportunity",
|
"erpnext.crm.doctype.opportunity.opportunity.auto_close_opportunity",
|
||||||
"erpnext.controllers.accounts_controller.update_invoice_status",
|
"erpnext.controllers.accounts_controller.update_invoice_status",
|
||||||
"erpnext.accounts.doctype.fiscal_year.fiscal_year.auto_create_fiscal_year",
|
"erpnext.accounts.doctype.fiscal_year.fiscal_year.auto_create_fiscal_year",
|
||||||
@ -421,6 +420,7 @@ scheduler_events = {
|
|||||||
"erpnext.loan_management.doctype.process_loan_security_shortfall.process_loan_security_shortfall.create_process_loan_security_shortfall",
|
"erpnext.loan_management.doctype.process_loan_security_shortfall.process_loan_security_shortfall.create_process_loan_security_shortfall",
|
||||||
"erpnext.loan_management.doctype.process_loan_interest_accrual.process_loan_interest_accrual.process_loan_interest_accrual_for_term_loans",
|
"erpnext.loan_management.doctype.process_loan_interest_accrual.process_loan_interest_accrual.process_loan_interest_accrual_for_term_loans",
|
||||||
"erpnext.crm.utils.open_leads_opportunities_based_on_todays_event",
|
"erpnext.crm.utils.open_leads_opportunities_based_on_todays_event",
|
||||||
|
"erpnext.stock.doctype.stock_entry.stock_entry.audit_incorrect_valuation_entries",
|
||||||
],
|
],
|
||||||
"monthly_long": [
|
"monthly_long": [
|
||||||
"erpnext.accounts.deferred_revenue.process_deferred_accounting",
|
"erpnext.accounts.deferred_revenue.process_deferred_accounting",
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.permissions import add_user_permission, remove_user_permission
|
from frappe.permissions import add_user_permission, remove_user_permission
|
||||||
from frappe.tests.utils import FrappeTestCase, change_settings
|
from frappe.tests.utils import FrappeTestCase, change_settings
|
||||||
from frappe.utils import add_days, flt, nowdate, nowtime, today
|
from frappe.utils import add_days, flt, now, nowdate, nowtime, today
|
||||||
|
|
||||||
from erpnext.accounts.doctype.account.test_account import get_inventory_account
|
from erpnext.accounts.doctype.account.test_account import get_inventory_account
|
||||||
from erpnext.stock.doctype.item.test_item import (
|
from erpnext.stock.doctype.item.test_item import (
|
||||||
@ -17,6 +17,8 @@ from erpnext.stock.doctype.item.test_item import (
|
|||||||
from erpnext.stock.doctype.serial_no.serial_no import * # noqa
|
from erpnext.stock.doctype.serial_no.serial_no import * # noqa
|
||||||
from erpnext.stock.doctype.stock_entry.stock_entry import (
|
from erpnext.stock.doctype.stock_entry.stock_entry import (
|
||||||
FinishedGoodError,
|
FinishedGoodError,
|
||||||
|
audit_incorrect_valuation_entries,
|
||||||
|
get_incorrect_stock_entries,
|
||||||
move_sample_to_retention_warehouse,
|
move_sample_to_retention_warehouse,
|
||||||
)
|
)
|
||||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
||||||
@ -1614,6 +1616,44 @@ class TestStockEntry(FrappeTestCase):
|
|||||||
|
|
||||||
self.assertRaises(BatchExpiredError, se.save)
|
self.assertRaises(BatchExpiredError, se.save)
|
||||||
|
|
||||||
|
def test_audit_incorrect_stock_entries(self):
|
||||||
|
item_code = "Test Incorrect Valuation Rate Item - 001"
|
||||||
|
create_item(item_code=item_code, is_stock_item=1)
|
||||||
|
|
||||||
|
make_stock_entry(
|
||||||
|
item_code=item_code,
|
||||||
|
purpose="Material Receipt",
|
||||||
|
posting_date=add_days(nowdate(), -10),
|
||||||
|
qty=2,
|
||||||
|
rate=500,
|
||||||
|
to_warehouse="_Test Warehouse - _TC",
|
||||||
|
)
|
||||||
|
|
||||||
|
transfer_entry = make_stock_entry(
|
||||||
|
item_code=item_code,
|
||||||
|
purpose="Material Transfer",
|
||||||
|
qty=2,
|
||||||
|
rate=500,
|
||||||
|
from_warehouse="_Test Warehouse - _TC",
|
||||||
|
to_warehouse="_Test Warehouse 1 - _TC",
|
||||||
|
)
|
||||||
|
|
||||||
|
sle_name = frappe.db.get_value(
|
||||||
|
"Stock Ledger Entry", {"voucher_no": transfer_entry.name, "actual_qty": (">", 0)}, "name"
|
||||||
|
)
|
||||||
|
|
||||||
|
frappe.db.set_value(
|
||||||
|
"Stock Ledger Entry", sle_name, {"modified": add_days(now(), -1), "stock_value_difference": 10}
|
||||||
|
)
|
||||||
|
|
||||||
|
stock_entries = get_incorrect_stock_entries()
|
||||||
|
self.assertTrue(transfer_entry.name in stock_entries)
|
||||||
|
|
||||||
|
audit_incorrect_valuation_entries()
|
||||||
|
|
||||||
|
stock_entries = get_incorrect_stock_entries()
|
||||||
|
self.assertFalse(transfer_entry.name in stock_entries)
|
||||||
|
|
||||||
|
|
||||||
def make_serialized_item(**args):
|
def make_serialized_item(**args):
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
|
Loading…
Reference in New Issue
Block a user