Merge pull request #37690 from deepeshgarg007/plaid_fixes
fix(plaid): Do not sync pending transactions
diff --git a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py
index 9a7a9a3..7e2f763 100644
--- a/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py
+++ b/erpnext/accounts/doctype/bank_reconciliation_tool/bank_reconciliation_tool.py
@@ -18,6 +18,7 @@
get_entries,
)
from erpnext.accounts.utils import get_account_currency, get_balance_on
+from erpnext.setup.utils import get_exchange_rate
class BankReconciliationTool(Document):
@@ -130,7 +131,7 @@
bank_transaction = frappe.db.get_values(
"Bank Transaction",
bank_transaction_name,
- fieldname=["name", "deposit", "withdrawal", "bank_account"],
+ fieldname=["name", "deposit", "withdrawal", "bank_account", "currency"],
as_dict=True,
)[0]
company_account = frappe.get_value("Bank Account", bank_transaction.bank_account, "account")
@@ -144,29 +145,94 @@
)
company = frappe.get_value("Account", company_account, "company")
+ company_default_currency = frappe.get_cached_value("Company", company, "default_currency")
+ company_account_currency = frappe.get_cached_value("Account", company_account, "account_currency")
+ second_account_currency = frappe.get_cached_value("Account", second_account, "account_currency")
+
+ # determine if multi-currency Journal or not
+ is_multi_currency = (
+ True
+ if company_default_currency != company_account_currency
+ or company_default_currency != second_account_currency
+ or company_default_currency != bank_transaction.currency
+ else False
+ )
accounts = []
- # Multi Currency?
- accounts.append(
- {
- "account": second_account,
- "credit_in_account_currency": bank_transaction.deposit,
- "debit_in_account_currency": bank_transaction.withdrawal,
- "party_type": party_type,
- "party": party,
- "cost_center": get_default_cost_center(company),
- }
- )
+ second_account_dict = {
+ "account": second_account,
+ "account_currency": second_account_currency,
+ "credit_in_account_currency": bank_transaction.deposit,
+ "debit_in_account_currency": bank_transaction.withdrawal,
+ "party_type": party_type,
+ "party": party,
+ "cost_center": get_default_cost_center(company),
+ }
- accounts.append(
- {
- "account": company_account,
- "bank_account": bank_transaction.bank_account,
- "credit_in_account_currency": bank_transaction.withdrawal,
- "debit_in_account_currency": bank_transaction.deposit,
- "cost_center": get_default_cost_center(company),
- }
- )
+ company_account_dict = {
+ "account": company_account,
+ "account_currency": company_account_currency,
+ "bank_account": bank_transaction.bank_account,
+ "credit_in_account_currency": bank_transaction.withdrawal,
+ "debit_in_account_currency": bank_transaction.deposit,
+ "cost_center": get_default_cost_center(company),
+ }
+
+ # convert transaction amount to company currency
+ if is_multi_currency:
+ exc_rate = get_exchange_rate(bank_transaction.currency, company_default_currency, posting_date)
+ withdrawal_in_company_currency = flt(exc_rate * abs(bank_transaction.withdrawal))
+ deposit_in_company_currency = flt(exc_rate * abs(bank_transaction.deposit))
+ else:
+ withdrawal_in_company_currency = bank_transaction.withdrawal
+ deposit_in_company_currency = bank_transaction.deposit
+
+ # if second account is of foreign currency, convert and set debit and credit fields.
+ if second_account_currency != company_default_currency:
+ exc_rate = get_exchange_rate(second_account_currency, company_default_currency, posting_date)
+ second_account_dict.update(
+ {
+ "exchange_rate": exc_rate,
+ "credit": deposit_in_company_currency,
+ "debit": withdrawal_in_company_currency,
+ "credit_in_account_currency": flt(deposit_in_company_currency / exc_rate) or 0,
+ "debit_in_account_currency": flt(withdrawal_in_company_currency / exc_rate) or 0,
+ }
+ )
+ else:
+ second_account_dict.update(
+ {
+ "exchange_rate": 1,
+ "credit": deposit_in_company_currency,
+ "debit": withdrawal_in_company_currency,
+ "credit_in_account_currency": deposit_in_company_currency,
+ "debit_in_account_currency": withdrawal_in_company_currency,
+ }
+ )
+
+ # if company account is of foreign currency, convert and set debit and credit fields.
+ if company_account_currency != company_default_currency:
+ exc_rate = get_exchange_rate(company_account_currency, company_default_currency, posting_date)
+ company_account_dict.update(
+ {
+ "exchange_rate": exc_rate,
+ "credit": withdrawal_in_company_currency,
+ "debit": deposit_in_company_currency,
+ }
+ )
+ else:
+ company_account_dict.update(
+ {
+ "exchange_rate": 1,
+ "credit": withdrawal_in_company_currency,
+ "debit": deposit_in_company_currency,
+ "credit_in_account_currency": withdrawal_in_company_currency,
+ "debit_in_account_currency": deposit_in_company_currency,
+ }
+ )
+
+ accounts.append(second_account_dict)
+ accounts.append(company_account_dict)
journal_entry_dict = {
"voucher_type": entry_type,
@@ -176,6 +242,9 @@
"cheque_no": reference_number,
"mode_of_payment": mode_of_payment,
}
+ if is_multi_currency:
+ journal_entry_dict.update({"multi_currency": True})
+
journal_entry = frappe.new_doc("Journal Entry")
journal_entry.update(journal_entry_dict)
journal_entry.set("accounts", accounts)
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index 231b3bf..21cc253 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -2539,6 +2539,37 @@
frappe.local.enable_perpetual_inventory["_Test Company 1"] = old_perpetual_inventory
frappe.db.set_single_value("Stock Settings", "allow_negative_stock", old_negative_stock)
+ def test_sle_for_target_warehouse(self):
+ se = make_stock_entry(
+ item_code="138-CMS Shoe",
+ target="Finished Goods - _TC",
+ company="_Test Company",
+ qty=1,
+ basic_rate=500,
+ )
+
+ si = frappe.copy_doc(test_records[0])
+ si.customer = "_Test Internal Customer 3"
+ si.update_stock = 1
+ si.set_warehouse = "Finished Goods - _TC"
+ si.set_target_warehouse = "Stores - _TC"
+ si.get("items")[0].warehouse = "Finished Goods - _TC"
+ si.get("items")[0].target_warehouse = "Stores - _TC"
+ si.insert()
+ si.submit()
+
+ sles = frappe.get_all(
+ "Stock Ledger Entry", filters={"voucher_no": si.name}, fields=["name", "actual_qty"]
+ )
+
+ # check if both SLEs are created
+ self.assertEqual(len(sles), 2)
+ self.assertEqual(sum(d.actual_qty for d in sles), 0.0)
+
+ # tear down
+ si.cancel()
+ se.cancel()
+
def test_internal_transfer_gl_entry(self):
si = create_sales_invoice(
company="_Test Company with perpetual inventory",
@@ -3662,6 +3693,20 @@
allowed_to_interact_with="_Test Company with perpetual inventory",
)
+ create_internal_customer(
+ customer_name="_Test Internal Customer 3",
+ represents_company="_Test Company",
+ allowed_to_interact_with="_Test Company",
+ )
+
+ account = create_account(
+ account_name="Unrealized Profit",
+ parent_account="Current Liabilities - _TC",
+ company="_Test Company",
+ )
+
+ frappe.db.set_value("Company", "_Test Company", "unrealized_profit_loss_account", account)
+
create_internal_supplier(
supplier_name="_Test Internal Supplier",
represents_company="Wind Power LLC",
diff --git a/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py b/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py
index f2ec31c..eac5426 100644
--- a/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py
+++ b/erpnext/accounts/report/tax_withholding_details/tax_withholding_details.py
@@ -68,7 +68,7 @@
tax_amount += entry.credit - entry.debit
if net_total_map.get(name):
- if voucher_type == "Journal Entry":
+ if voucher_type == "Journal Entry" and tax_amount and rate:
# back calcalute total amount from rate and tax_amount
total_amount = grand_total = base_total = tax_amount / (rate / 100)
else:
diff --git a/erpnext/buying/doctype/buying_settings/buying_settings.json b/erpnext/buying/doctype/buying_settings/buying_settings.json
index 71cb01b..0599992 100644
--- a/erpnext/buying/doctype/buying_settings/buying_settings.json
+++ b/erpnext/buying/doctype/buying_settings/buying_settings.json
@@ -16,7 +16,7 @@
"transaction_settings_section",
"po_required",
"pr_required",
- "over_order_allowance",
+ "blanket_order_allowance",
"column_break_12",
"maintain_same_rate",
"set_landed_cost_based_on_purchase_invoice_rate",
@@ -161,17 +161,17 @@
},
{
"default": "0",
- "description": "Percentage you are allowed to order more against the Blanket Order Quantity. For example: If you have a Blanket Order of Quantity 100 units. and your Allowance is 10% then you are allowed to order 110 units.",
- "fieldname": "over_order_allowance",
- "fieldtype": "Float",
- "label": "Over Order Allowance (%)"
- },
- {
- "default": "0",
"description": "While making Purchase Invoice from Purchase Order, use Exchange Rate on Invoice's transaction date rather than inheriting it from Purchase Order. Only applies for Purchase Invoice.",
"fieldname": "use_transaction_date_exchange_rate",
"fieldtype": "Check",
"label": "Use Transaction Date Exchange Rate"
+ },
+ {
+ "default": "0",
+ "description": "Percentage you are allowed to order beyond the Blanket Order quantity.",
+ "fieldname": "blanket_order_allowance",
+ "fieldtype": "Float",
+ "label": "Blanket Order Allowance (%)"
}
],
"icon": "fa fa-cog",
@@ -179,7 +179,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
- "modified": "2023-10-16 16:22:03.201078",
+ "modified": "2023-10-25 14:03:32.520418",
"modified_by": "Administrator",
"module": "Buying",
"name": "Buying Settings",
diff --git a/erpnext/manufacturing/doctype/blanket_order/blanket_order.py b/erpnext/manufacturing/doctype/blanket_order/blanket_order.py
index 32f1c36..0135a4f 100644
--- a/erpnext/manufacturing/doctype/blanket_order/blanket_order.py
+++ b/erpnext/manufacturing/doctype/blanket_order/blanket_order.py
@@ -107,7 +107,7 @@
allowance = flt(
frappe.db.get_single_value(
"Selling Settings" if order_doc.doctype == "Sales Order" else "Buying Settings",
- "over_order_allowance",
+ "blanket_order_allowance",
)
)
for bo_name, item_data in order_data.items():
diff --git a/erpnext/manufacturing/doctype/blanket_order/test_blanket_order.py b/erpnext/manufacturing/doctype/blanket_order/test_blanket_order.py
index 58f3c95..e9fc25b 100644
--- a/erpnext/manufacturing/doctype/blanket_order/test_blanket_order.py
+++ b/erpnext/manufacturing/doctype/blanket_order/test_blanket_order.py
@@ -63,7 +63,7 @@
po1.currency = get_company_currency(po1.company)
self.assertEqual(po1.items[0].qty, (bo.items[0].qty - bo.items[0].ordered_qty))
- def test_over_order_allowance(self):
+ def test_blanket_order_allowance(self):
# Sales Order
bo = make_blanket_order(blanket_order_type="Selling", quantity=100)
@@ -74,7 +74,7 @@
so.items[0].qty = 110
self.assertRaises(frappe.ValidationError, so.submit)
- frappe.db.set_single_value("Selling Settings", "over_order_allowance", 10)
+ frappe.db.set_single_value("Selling Settings", "blanket_order_allowance", 10)
so.submit()
# Purchase Order
@@ -87,7 +87,7 @@
po.items[0].qty = 110
self.assertRaises(frappe.ValidationError, po.submit)
- frappe.db.set_single_value("Buying Settings", "over_order_allowance", 10)
+ frappe.db.set_single_value("Buying Settings", "blanket_order_allowance", 10)
po.submit()
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 53bddb5..d7f33ad 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -316,7 +316,7 @@
execute:frappe.db.set_single_value("Accounts Settings", "merge_similar_account_heads", 0)
erpnext.patches.v14_0.update_reference_type_in_journal_entry_accounts
erpnext.patches.v14_0.update_subscription_details
-execute:frappe.delete_doc_if_exists("Report", "Tax Detail")
+execute:frappe.delete_doc("Report", "Tax Detail", force=True)
erpnext.patches.v15_0.enable_all_leads
erpnext.patches.v14_0.update_company_in_ldc
erpnext.patches.v14_0.set_packed_qty_in_draft_delivery_notes
@@ -341,5 +341,7 @@
erpnext.patches.v15_0.delete_payment_gateway_doctypes
erpnext.patches.v14_0.create_accounting_dimensions_in_sales_order_item
erpnext.patches.v15_0.update_sre_from_voucher_details
+erpnext.patches.v14_0.rename_over_order_allowance_field
+erpnext.patches.v14_0.migrate_delivery_stop_lock_field
# below migration patch should always run last
-erpnext.patches.v14_0.migrate_gl_to_payment_ledger
\ No newline at end of file
+erpnext.patches.v14_0.migrate_gl_to_payment_ledger
diff --git a/erpnext/patches/v14_0/migrate_delivery_stop_lock_field.py b/erpnext/patches/v14_0/migrate_delivery_stop_lock_field.py
new file mode 100644
index 0000000..c9ec1e1
--- /dev/null
+++ b/erpnext/patches/v14_0/migrate_delivery_stop_lock_field.py
@@ -0,0 +1,7 @@
+import frappe
+from frappe.model.utils.rename_field import rename_field
+
+
+def execute():
+ if frappe.db.has_column("Delivery Stop", "lock"):
+ rename_field("Delivery Stop", "lock", "locked")
diff --git a/erpnext/patches/v14_0/rename_over_order_allowance_field.py b/erpnext/patches/v14_0/rename_over_order_allowance_field.py
new file mode 100644
index 0000000..a81fe88
--- /dev/null
+++ b/erpnext/patches/v14_0/rename_over_order_allowance_field.py
@@ -0,0 +1,15 @@
+from frappe.model.utils.rename_field import rename_field
+
+
+def execute():
+ rename_field(
+ "Buying Settings",
+ "over_order_allowance",
+ "blanket_order_allowance",
+ )
+
+ rename_field(
+ "Selling Settings",
+ "over_order_allowance",
+ "blanket_order_allowance",
+ )
diff --git a/erpnext/selling/doctype/selling_settings/selling_settings.json b/erpnext/selling/doctype/selling_settings/selling_settings.json
index 6855012..d6829ce 100644
--- a/erpnext/selling/doctype/selling_settings/selling_settings.json
+++ b/erpnext/selling/doctype/selling_settings/selling_settings.json
@@ -25,7 +25,7 @@
"so_required",
"dn_required",
"sales_update_frequency",
- "over_order_allowance",
+ "blanket_order_allowance",
"column_break_5",
"allow_multiple_items",
"allow_against_multiple_purchase_orders",
@@ -184,12 +184,6 @@
"label": "Allow Sales Order Creation For Expired Quotation"
},
{
- "description": "Percentage you are allowed to order more against the Blanket Order Quantity. For example: If you have a Blanket Order of Quantity 100 units. and your Allowance is 10% then you are allowed to order 110 units.",
- "fieldname": "over_order_allowance",
- "fieldtype": "Float",
- "label": "Over Order Allowance (%)"
- },
- {
"default": "0",
"fieldname": "dont_reserve_sales_order_qty_on_sales_return",
"fieldtype": "Check",
@@ -200,6 +194,12 @@
"fieldname": "allow_negative_rates_for_items",
"fieldtype": "Check",
"label": "Allow Negative rates for Items"
+ },
+ {
+ "description": "Percentage you are allowed to sell beyond the Blanket Order quantity.",
+ "fieldname": "blanket_order_allowance",
+ "fieldtype": "Float",
+ "label": "Blanket Order Allowance (%)"
}
],
"icon": "fa fa-cog",
@@ -207,7 +207,7 @@
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
- "modified": "2023-08-14 20:33:05.693667",
+ "modified": "2023-10-25 14:03:03.966701",
"modified_by": "Administrator",
"module": "Selling",
"name": "Selling Settings",
diff --git a/erpnext/stock/doctype/delivery_note/test_delivery_note.py b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
index d068192..1eecf6d 100644
--- a/erpnext/stock/doctype/delivery_note/test_delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/test_delivery_note.py
@@ -1230,16 +1230,16 @@
frappe.db.rollback()
frappe.db.set_single_value("Selling Settings", "dont_reserve_sales_order_qty_on_sales_return", 0)
- def non_internal_transfer_delivery_note(self):
+ def test_non_internal_transfer_delivery_note(self):
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse
dn = create_delivery_note(do_not_submit=True)
- warehouse = create_warehouse("Internal Transfer Warehouse", dn.company)
- dn.items[0].db_set("target_warehouse", "warehouse")
+ warehouse = create_warehouse("Internal Transfer Warehouse", company=dn.company)
+ dn.items[0].db_set("target_warehouse", warehouse)
dn.reload()
- self.assertEqual(dn.items[0].target_warehouse, warehouse.name)
+ self.assertEqual(dn.items[0].target_warehouse, warehouse)
dn.save()
dn.reload()
diff --git a/erpnext/stock/doctype/delivery_stop/delivery_stop.json b/erpnext/stock/doctype/delivery_stop/delivery_stop.json
index 5610a81..42560e6 100644
--- a/erpnext/stock/doctype/delivery_stop/delivery_stop.json
+++ b/erpnext/stock/doctype/delivery_stop/delivery_stop.json
@@ -1,815 +1,197 @@
{
- "allow_copy": 0,
- "allow_events_in_timeline": 0,
- "allow_guest_to_view": 0,
- "allow_import": 0,
- "allow_rename": 0,
- "beta": 0,
- "creation": "2017-10-16 16:46:28.166950",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "",
- "editable_grid": 1,
- "engine": "InnoDB",
+ "actions": [],
+ "creation": "2017-10-16 16:46:28.166950",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+ "customer",
+ "address",
+ "locked",
+ "column_break_6",
+ "customer_address",
+ "visited",
+ "order_information_section",
+ "delivery_note",
+ "cb_order",
+ "grand_total",
+ "section_break_7",
+ "contact",
+ "email_sent_to",
+ "column_break_7",
+ "customer_contact",
+ "section_break_9",
+ "distance",
+ "estimated_arrival",
+ "lat",
+ "column_break_19",
+ "uom",
+ "lng",
+ "more_information_section",
+ "details"
+ ],
"fields": [
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 2,
- "fieldname": "customer",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Customer",
- "length": 0,
- "no_copy": 0,
- "options": "Customer",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "columns": 2,
+ "fieldname": "customer",
+ "fieldtype": "Link",
+ "in_list_view": 1,
+ "label": "Customer",
+ "options": "Customer"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "address",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Address Name",
- "length": 0,
- "no_copy": 0,
- "options": "Address",
- "permlevel": 0,
- "precision": "",
- "print_hide": 1,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "address",
+ "fieldtype": "Link",
+ "in_list_view": 1,
+ "label": "Address Name",
+ "options": "Address",
+ "print_hide": 1,
+ "reqd": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "lock",
- "fieldtype": "Check",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Lock",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "default": "0",
+ "fieldname": "locked",
+ "fieldtype": "Check",
+ "in_list_view": 1,
+ "label": "Locked"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "column_break_6",
- "fieldtype": "Column Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "column_break_6",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "customer_address",
- "fieldtype": "Small Text",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Customer Address",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "customer_address",
+ "fieldtype": "Small Text",
+ "label": "Customer Address",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 1,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "depends_on": "eval:doc.docstatus==1",
- "fieldname": "visited",
- "fieldtype": "Check",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Visited",
- "length": 0,
- "no_copy": 1,
- "permlevel": 0,
- "precision": "",
- "print_hide": 1,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "allow_on_submit": 1,
+ "default": "0",
+ "depends_on": "eval:doc.docstatus==1",
+ "fieldname": "visited",
+ "fieldtype": "Check",
+ "label": "Visited",
+ "no_copy": 1,
+ "print_hide": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "order_information_section",
- "fieldtype": "Section Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Order Information",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "order_information_section",
+ "fieldtype": "Section Break",
+ "label": "Order Information"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "delivery_note",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Delivery Note",
- "length": 0,
- "no_copy": 1,
- "options": "Delivery Note",
- "permlevel": 0,
- "precision": "",
- "print_hide": 1,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "delivery_note",
+ "fieldtype": "Link",
+ "in_list_view": 1,
+ "label": "Delivery Note",
+ "no_copy": 1,
+ "options": "Delivery Note",
+ "print_hide": 1,
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "cb_order",
- "fieldtype": "Column Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "cb_order",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "grand_total",
- "fieldtype": "Currency",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Grand Total",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "grand_total",
+ "fieldtype": "Currency",
+ "label": "Grand Total",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "section_break_7",
- "fieldtype": "Section Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Contact Information",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "section_break_7",
+ "fieldtype": "Section Break",
+ "label": "Contact Information"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "contact",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Contact Name",
- "length": 0,
- "no_copy": 0,
- "options": "Contact",
- "permlevel": 0,
- "precision": "",
- "print_hide": 1,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "contact",
+ "fieldtype": "Link",
+ "label": "Contact Name",
+ "options": "Contact",
+ "print_hide": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "email_sent_to",
- "fieldtype": "Data",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Email sent to",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "email_sent_to",
+ "fieldtype": "Data",
+ "label": "Email sent to",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "column_break_7",
- "fieldtype": "Column Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "column_break_7",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "customer_contact",
- "fieldtype": "Small Text",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Customer Contact",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "customer_contact",
+ "fieldtype": "Small Text",
+ "label": "Customer Contact",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "section_break_9",
- "fieldtype": "Section Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Dispatch Information",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "section_break_9",
+ "fieldtype": "Section Break",
+ "label": "Dispatch Information"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "distance",
- "fieldtype": "Float",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Distance",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "2",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "distance",
+ "fieldtype": "Float",
+ "label": "Distance",
+ "precision": "2",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "estimated_arrival",
- "fieldtype": "Datetime",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 1,
- "in_standard_filter": 0,
- "label": "Estimated Arrival",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "estimated_arrival",
+ "fieldtype": "Datetime",
+ "in_list_view": 1,
+ "label": "Estimated Arrival"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "lat",
- "fieldtype": "Float",
- "hidden": 1,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Latitude",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "lat",
+ "fieldtype": "Float",
+ "hidden": 1,
+ "label": "Latitude"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "column_break_19",
- "fieldtype": "Column Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "column_break_19",
+ "fieldtype": "Column Break"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "default": "",
- "depends_on": "eval:doc.distance",
- "fieldname": "uom",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "UOM",
- "length": 0,
- "no_copy": 0,
- "options": "UOM",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 1,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "depends_on": "eval:doc.distance",
+ "fieldname": "uom",
+ "fieldtype": "Link",
+ "label": "UOM",
+ "options": "UOM",
+ "read_only": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "lng",
- "fieldtype": "Float",
- "hidden": 1,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Longitude",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "lng",
+ "fieldtype": "Float",
+ "hidden": 1,
+ "label": "Longitude"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "more_information_section",
- "fieldtype": "Section Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "More Information",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
- },
+ "fieldname": "more_information_section",
+ "fieldtype": "Section Break",
+ "label": "More Information"
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "details",
- "fieldtype": "Text Editor",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 0,
- "in_global_search": 0,
- "in_list_view": 0,
- "in_standard_filter": 0,
- "label": "Details",
- "length": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "remember_last_selected_value": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "translatable": 0,
- "unique": 0
+ "fieldname": "details",
+ "fieldtype": "Text Editor",
+ "label": "Details"
}
- ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "idx": 0,
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 1,
- "max_attachments": 0,
- "modified": "2018-10-16 05:23:25.661542",
- "modified_by": "Administrator",
- "module": "Stock",
- "name": "Delivery Stop",
- "name_case": "",
- "owner": "Administrator",
- "permissions": [],
- "quick_entry": 1,
- "read_only": 0,
- "read_only_onload": 0,
- "show_name_in_global_search": 0,
- "sort_field": "modified",
- "sort_order": "DESC",
- "track_changes": 1,
- "track_seen": 0,
- "track_views": 0
+ ],
+ "istable": 1,
+ "links": [],
+ "modified": "2023-09-29 09:22:53.435161",
+ "modified_by": "Administrator",
+ "module": "Stock",
+ "name": "Delivery Stop",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 1,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "states": [],
+ "track_changes": 1
}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/delivery_trip/delivery_trip.js b/erpnext/stock/doctype/delivery_trip/delivery_trip.js
index 4a72d77..158bd0c 100755
--- a/erpnext/stock/doctype/delivery_trip/delivery_trip.js
+++ b/erpnext/stock/doctype/delivery_trip/delivery_trip.js
@@ -64,6 +64,11 @@
})
}, __("Get stops from"));
}
+ frm.add_custom_button(__("Delivery Notes"), function () {
+ frappe.set_route("List", "Delivery Note",
+ {'name': ["in", frm.doc.delivery_stops.map((stop) => {return stop.delivery_note;})]}
+ );
+ }, __("View"));
},
calculate_arrival_time: function (frm) {
diff --git a/erpnext/stock/doctype/delivery_trip/delivery_trip.py b/erpnext/stock/doctype/delivery_trip/delivery_trip.py
index af2f411..c531a87 100644
--- a/erpnext/stock/doctype/delivery_trip/delivery_trip.py
+++ b/erpnext/stock/doctype/delivery_trip/delivery_trip.py
@@ -170,7 +170,7 @@
for stop in self.delivery_stops:
leg.append(stop.customer_address)
- if optimize and stop.lock:
+ if optimize and stop.locked:
route_list.append(leg)
leg = [stop.customer_address]
diff --git a/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py b/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py
index ed699e3..9b8b46e 100644
--- a/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py
+++ b/erpnext/stock/doctype/delivery_trip/test_delivery_trip.py
@@ -46,7 +46,7 @@
self.assertEqual(len(route_list[0]), 4)
def test_unoptimized_route_list_with_locks(self):
- self.delivery_trip.delivery_stops[0].lock = 1
+ self.delivery_trip.delivery_stops[0].locked = 1
self.delivery_trip.save()
route_list = self.delivery_trip.form_route_list(optimize=False)
@@ -65,7 +65,7 @@
self.assertEqual(len(route_list[0]), 4)
def test_optimized_route_list_with_locks(self):
- self.delivery_trip.delivery_stops[0].lock = 1
+ self.delivery_trip.delivery_stops[0].locked = 1
self.delivery_trip.save()
route_list = self.delivery_trip.form_route_list(optimize=True)
diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
index e998b84..146cbff 100644
--- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
@@ -957,6 +957,119 @@
pr1.reload()
pr1.cancel()
+ def test_stock_transfer_from_purchase_receipt(self):
+ from erpnext.stock.doctype.delivery_note.delivery_note import make_inter_company_purchase_receipt
+ from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note
+
+ prepare_data_for_internal_transfer()
+
+ customer = "_Test Internal Customer 2"
+ company = "_Test Company with perpetual inventory"
+
+ pr1 = make_purchase_receipt(
+ warehouse="Stores - TCP1", company="_Test Company with perpetual inventory"
+ )
+
+ dn1 = create_delivery_note(
+ item_code=pr1.items[0].item_code,
+ company=company,
+ customer=customer,
+ cost_center="Main - TCP1",
+ expense_account="Cost of Goods Sold - TCP1",
+ qty=5,
+ rate=500,
+ warehouse="Stores - TCP1",
+ target_warehouse="Work In Progress - TCP1",
+ )
+
+ pr = make_inter_company_purchase_receipt(dn1.name)
+ pr.items[0].from_warehouse = "Work In Progress - TCP1"
+ pr.items[0].warehouse = "Stores - TCP1"
+ pr.submit()
+
+ gl_entries = get_gl_entries("Purchase Receipt", pr.name)
+ sl_entries = get_sl_entries("Purchase Receipt", pr.name)
+
+ self.assertFalse(gl_entries)
+
+ expected_sle = {"Work In Progress - TCP1": -5, "Stores - TCP1": 5}
+
+ for sle in sl_entries:
+ self.assertEqual(expected_sle[sle.warehouse], sle.actual_qty)
+
+ pr.cancel()
+
+ def test_stock_transfer_from_purchase_receipt_with_valuation(self):
+ from erpnext.stock.doctype.delivery_note.delivery_note import make_inter_company_purchase_receipt
+ from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note
+
+ prepare_data_for_internal_transfer()
+
+ create_warehouse(
+ "_Test Warehouse for Valuation",
+ company="_Test Company with perpetual inventory",
+ properties={"account": "_Test Account Stock In Hand - TCP1"},
+ )
+
+ pr1 = make_purchase_receipt(
+ warehouse="Stores - TCP1",
+ company="_Test Company with perpetual inventory",
+ )
+
+ customer = "_Test Internal Customer 2"
+ company = "_Test Company with perpetual inventory"
+
+ dn1 = create_delivery_note(
+ item_code=pr1.items[0].item_code,
+ company=company,
+ customer=customer,
+ cost_center="Main - TCP1",
+ expense_account="Cost of Goods Sold - TCP1",
+ qty=5,
+ rate=50,
+ warehouse="Stores - TCP1",
+ target_warehouse="_Test Warehouse for Valuation - TCP1",
+ )
+
+ pr = make_inter_company_purchase_receipt(dn1.name)
+ pr.items[0].from_warehouse = "_Test Warehouse for Valuation - TCP1"
+ pr.items[0].warehouse = "Stores - TCP1"
+
+ pr.append(
+ "taxes",
+ {
+ "charge_type": "On Net Total",
+ "account_head": "_Test Account Shipping Charges - TCP1",
+ "category": "Valuation and Total",
+ "cost_center": "Main - TCP1",
+ "description": "Test",
+ "rate": 9,
+ },
+ )
+
+ pr.submit()
+
+ gl_entries = get_gl_entries("Purchase Receipt", pr.name)
+ sl_entries = get_sl_entries("Purchase Receipt", pr.name)
+
+ expected_gle = [
+ ["Stock In Hand - TCP1", 272.5, 0.0],
+ ["_Test Account Stock In Hand - TCP1", 0.0, 250.0],
+ ["_Test Account Shipping Charges - TCP1", 0.0, 22.5],
+ ]
+
+ expected_sle = {"_Test Warehouse for Valuation - TCP1": -5, "Stores - TCP1": 5}
+
+ for sle in sl_entries:
+ self.assertEqual(expected_sle[sle.warehouse], sle.actual_qty)
+
+ for i, gle in enumerate(gl_entries):
+ self.assertEqual(gle.account, expected_gle[i][0])
+ self.assertEqual(gle.debit, expected_gle[i][1])
+ self.assertEqual(gle.credit, expected_gle[i][2])
+
+ pr.cancel()
+
def test_po_to_pi_and_po_to_pr_worflow_full(self):
"""Test following behaviour:
- Create PO
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 35f6230..c41349f 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -1020,14 +1020,34 @@
& (se.docstatus == 1)
& (se_detail.item_code == se_item.item_code)
& (
- (se.purchase_order == self.purchase_order)
+ ((se.purchase_order == self.purchase_order) & (se_detail.po_detail == se_item.po_detail))
if self.subcontract_data.order_doctype == "Purchase Order"
- else (se.subcontracting_order == self.subcontracting_order)
+ else (
+ (se.subcontracting_order == self.subcontracting_order)
+ & (se_detail.sco_rm_detail == se_item.sco_rm_detail)
+ )
)
)
- ).run()[0][0]
+ ).run()[0][0] or 0
- if flt(total_supplied, precision) > flt(total_allowed, precision):
+ total_returned = 0
+ if self.subcontract_data.order_doctype == "Subcontracting Order":
+ total_returned = (
+ frappe.qb.from_(se)
+ .inner_join(se_detail)
+ .on(se.name == se_detail.parent)
+ .select(Sum(se_detail.transfer_qty))
+ .where(
+ (se.purpose == "Material Transfer")
+ & (se.docstatus == 1)
+ & (se.is_return == 1)
+ & (se_detail.item_code == se_item.item_code)
+ & (se_detail.sco_rm_detail == se_item.sco_rm_detail)
+ & (se.subcontracting_order == self.subcontracting_order)
+ )
+ ).run()[0][0] or 0
+
+ if flt(total_supplied - total_returned, precision) > flt(total_allowed, precision):
frappe.throw(
_("Row {0}# Item {1} cannot be transferred more than {2} against {3} {4}").format(
se_item.idx,
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 8c6fd84..a8eb777 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -330,8 +330,12 @@
),
"expense_account": expense_account
or get_default_expense_account(args, item_defaults, item_group_defaults, brand_defaults),
- "discount_account": get_default_discount_account(args, item_defaults),
- "provisional_expense_account": get_provisional_account(args, item_defaults),
+ "discount_account": get_default_discount_account(
+ args, item_defaults, item_group_defaults, brand_defaults
+ ),
+ "provisional_expense_account": get_provisional_account(
+ args, item_defaults, item_group_defaults, brand_defaults
+ ),
"cost_center": get_default_cost_center(
args, item_defaults, item_group_defaults, brand_defaults
),
@@ -686,12 +690,22 @@
)
-def get_provisional_account(args, item):
- return item.get("default_provisional_account") or args.default_provisional_account
+def get_provisional_account(args, item, item_group, brand):
+ return (
+ item.get("default_provisional_account")
+ or item_group.get("default_provisional_account")
+ or brand.get("default_provisional_account")
+ or args.default_provisional_account
+ )
-def get_default_discount_account(args, item):
- return item.get("default_discount_account") or args.discount_account
+def get_default_discount_account(args, item, item_group, brand):
+ return (
+ item.get("default_discount_account")
+ or item_group.get("default_discount_account")
+ or brand.get("default_discount_account")
+ or args.discount_account
+ )
def get_default_deferred_account(args, item, fieldname=None):
diff --git a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js
index f2b395a..587a3b4 100644
--- a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js
+++ b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.js
@@ -107,7 +107,7 @@
get_materials_from_supplier: function (frm) {
let sco_rm_details = [];
- if (frm.doc.status != "Closed" && frm.doc.supplied_items && frm.doc.per_received > 0) {
+ if (frm.doc.status != "Closed" && frm.doc.supplied_items) {
frm.doc.supplied_items.forEach(d => {
if (d.total_supplied_qty > 0 && d.total_supplied_qty != d.consumed_qty) {
sco_rm_details.push(d.name);
@@ -193,7 +193,7 @@
}
has_unsupplied_items() {
- return this.frm.doc['supplied_items'].some(item => item.required_qty > item.supplied_qty);
+ return this.frm.doc['supplied_items'].some(item => item.required_qty > (item.supplied_qty - item.returned_qty));
}
make_subcontracting_receipt() {