mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-18 06:15:10 +00:00
Merge pull request #32893 from frappe/version-14-hotfix
chore: release v14
This commit is contained in:
@@ -12,6 +12,9 @@ frappe.ui.form.on("Bank Reconciliation Tool", {
|
||||
},
|
||||
};
|
||||
});
|
||||
let no_bank_transactions_text =
|
||||
`<div class="text-muted text-center">${__("No Matching Bank Transactions Found")}</div>`
|
||||
set_field_options("no_bank_transactions", no_bank_transactions_text);
|
||||
},
|
||||
|
||||
onload: function (frm) {
|
||||
|
||||
@@ -81,8 +81,7 @@
|
||||
},
|
||||
{
|
||||
"fieldname": "no_bank_transactions",
|
||||
"fieldtype": "HTML",
|
||||
"options": "<div class=\"text-muted text-center\">No Matching Bank Transactions Found</div>"
|
||||
"fieldtype": "HTML"
|
||||
}
|
||||
],
|
||||
"hide_toolbar": 1,
|
||||
@@ -109,4 +108,4 @@
|
||||
"quick_entry": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ frappe.ui.form.on("Bank Statement Import", {
|
||||
|
||||
if (frm.doc.status.includes("Success")) {
|
||||
frm.add_custom_button(
|
||||
__("Go to {0} List", [frm.doc.reference_doctype]),
|
||||
__("Go to {0} List", [__(frm.doc.reference_doctype)]),
|
||||
() => frappe.set_route("List", frm.doc.reference_doctype)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"barcode",
|
||||
"has_item_scanned",
|
||||
"item_code",
|
||||
"col_break1",
|
||||
"item_name",
|
||||
@@ -808,11 +809,19 @@
|
||||
"fieldtype": "Check",
|
||||
"label": "Grant Commission",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"depends_on": "barcode",
|
||||
"fieldname": "has_item_scanned",
|
||||
"fieldtype": "Check",
|
||||
"label": "Has Item Scanned",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2021-10-05 12:23:47.506290",
|
||||
"modified": "2022-11-02 12:52:39.125295",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "POS Invoice Item",
|
||||
@@ -820,5 +829,6 @@
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC"
|
||||
"sort_order": "DESC",
|
||||
"states": []
|
||||
}
|
||||
@@ -57,6 +57,8 @@
|
||||
"column_break_28",
|
||||
"total",
|
||||
"net_total",
|
||||
"tax_withholding_net_total",
|
||||
"base_tax_withholding_net_total",
|
||||
"taxes_section",
|
||||
"taxes_and_charges",
|
||||
"column_break_58",
|
||||
@@ -89,7 +91,6 @@
|
||||
"section_break_44",
|
||||
"apply_discount_on",
|
||||
"base_discount_amount",
|
||||
"additional_discount_account",
|
||||
"column_break_46",
|
||||
"additional_discount_percentage",
|
||||
"discount_amount",
|
||||
@@ -1421,6 +1422,26 @@
|
||||
"label": "Is Old Subcontracting Flow",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "tax_withholding_net_total",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 1,
|
||||
"label": "Tax Withholding Net Total",
|
||||
"no_copy": 1,
|
||||
"options": "currency",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "base_tax_withholding_net_total",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 1,
|
||||
"label": "Base Tax Withholding Net Total",
|
||||
"no_copy": 1,
|
||||
"options": "currency",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"collapsible_depends_on": "tax_withheld_vouchers",
|
||||
"fieldname": "tax_withheld_vouchers_section",
|
||||
@@ -1519,7 +1540,7 @@
|
||||
"idx": 204,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2022-10-11 13:04:44.304389",
|
||||
"modified": "2022-11-04 01:02:44.544878",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Purchase Invoice",
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
"discount_amount",
|
||||
"base_rate_with_margin",
|
||||
"sec_break2",
|
||||
"apply_tds",
|
||||
"rate",
|
||||
"amount",
|
||||
"item_tax_template",
|
||||
@@ -868,6 +869,12 @@
|
||||
"label": "Product Bundle",
|
||||
"options": "Product Bundle",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "1",
|
||||
"fieldname": "apply_tds",
|
||||
"fieldtype": "Check",
|
||||
"label": "Apply TDS"
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"barcode",
|
||||
"has_item_scanned",
|
||||
"item_code",
|
||||
"col_break1",
|
||||
"item_name",
|
||||
@@ -872,12 +873,20 @@
|
||||
"label": "Purchase Order Item",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"depends_on": "barcode",
|
||||
"fieldname": "has_item_scanned",
|
||||
"fieldtype": "Check",
|
||||
"label": "Has Item Scanned",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2022-10-26 11:38:36.119339",
|
||||
"modified": "2022-11-02 12:53:12.693217",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Sales Invoice Item",
|
||||
|
||||
@@ -61,6 +61,9 @@ def get_party_details(inv):
|
||||
|
||||
|
||||
def get_party_tax_withholding_details(inv, tax_withholding_category=None):
|
||||
if inv.doctype == "Payment Entry":
|
||||
inv.tax_withholding_net_total = inv.net_total
|
||||
|
||||
pan_no = ""
|
||||
parties = []
|
||||
party_type, party = get_party_details(inv)
|
||||
@@ -242,7 +245,7 @@ def get_tax_amount(party_type, parties, inv, tax_details, posting_date, pan_no=N
|
||||
if party_type == "Supplier":
|
||||
ldc = get_lower_deduction_certificate(tax_details, pan_no)
|
||||
if tax_deducted:
|
||||
net_total = inv.net_total
|
||||
net_total = inv.tax_withholding_net_total
|
||||
if ldc:
|
||||
tax_amount = get_tds_amount_from_ldc(
|
||||
ldc, parties, pan_no, tax_details, posting_date, net_total
|
||||
@@ -272,6 +275,11 @@ def get_tax_amount(party_type, parties, inv, tax_details, posting_date, pan_no=N
|
||||
|
||||
def get_invoice_vouchers(parties, tax_details, company, party_type="Supplier"):
|
||||
doctype = "Purchase Invoice" if party_type == "Supplier" else "Sales Invoice"
|
||||
field = (
|
||||
"base_tax_withholding_net_total as base_net_total"
|
||||
if party_type == "Supplier"
|
||||
else "base_net_total"
|
||||
)
|
||||
voucher_wise_amount = {}
|
||||
vouchers = []
|
||||
|
||||
@@ -288,7 +296,7 @@ def get_invoice_vouchers(parties, tax_details, company, party_type="Supplier"):
|
||||
{"apply_tds": 1, "tax_withholding_category": tax_details.get("tax_withholding_category")}
|
||||
)
|
||||
|
||||
invoices_details = frappe.get_all(doctype, filters=filters, fields=["name", "base_net_total"])
|
||||
invoices_details = frappe.get_all(doctype, filters=filters, fields=["name", field])
|
||||
|
||||
for d in invoices_details:
|
||||
vouchers.append(d.name)
|
||||
@@ -392,7 +400,7 @@ def get_tds_amount(ldc, parties, inv, tax_details, tax_deducted, vouchers):
|
||||
tds_amount = 0
|
||||
invoice_filters = {"name": ("in", vouchers), "docstatus": 1, "apply_tds": 1}
|
||||
|
||||
field = "sum(net_total)"
|
||||
field = "sum(tax_withholding_net_total)"
|
||||
|
||||
if cint(tax_details.consider_party_ledger_amount):
|
||||
invoice_filters.pop("apply_tds", None)
|
||||
@@ -415,12 +423,12 @@ def get_tds_amount(ldc, parties, inv, tax_details, tax_deducted, vouchers):
|
||||
)
|
||||
|
||||
supp_credit_amt += supp_jv_credit_amt
|
||||
supp_credit_amt += inv.net_total
|
||||
supp_credit_amt += inv.tax_withholding_net_total
|
||||
|
||||
threshold = tax_details.get("threshold", 0)
|
||||
cumulative_threshold = tax_details.get("cumulative_threshold", 0)
|
||||
|
||||
if (threshold and inv.net_total >= threshold) or (
|
||||
if (threshold and inv.tax_withholding_net_total >= threshold) or (
|
||||
cumulative_threshold and supp_credit_amt >= cumulative_threshold
|
||||
):
|
||||
if (cumulative_threshold and supp_credit_amt >= cumulative_threshold) and cint(
|
||||
@@ -428,11 +436,11 @@ def get_tds_amount(ldc, parties, inv, tax_details, tax_deducted, vouchers):
|
||||
):
|
||||
# Get net total again as TDS is calculated on net total
|
||||
# Grand is used to just check for threshold breach
|
||||
net_total = 0
|
||||
if vouchers:
|
||||
net_total = frappe.db.get_value("Purchase Invoice", invoice_filters, "sum(net_total)")
|
||||
|
||||
net_total += inv.net_total
|
||||
net_total = (
|
||||
frappe.db.get_value("Purchase Invoice", invoice_filters, "sum(tax_withholding_net_total)")
|
||||
or 0.0
|
||||
)
|
||||
net_total += inv.tax_withholding_net_total
|
||||
supp_credit_amt = net_total - cumulative_threshold
|
||||
|
||||
if ldc and is_valid_certificate(
|
||||
@@ -440,7 +448,7 @@ def get_tds_amount(ldc, parties, inv, tax_details, tax_deducted, vouchers):
|
||||
ldc.valid_upto,
|
||||
inv.get("posting_date") or inv.get("transaction_date"),
|
||||
tax_deducted,
|
||||
inv.net_total,
|
||||
inv.tax_withholding_net_total,
|
||||
ldc.certificate_limit,
|
||||
):
|
||||
tds_amount = get_ltds_amount(supp_credit_amt, 0, ldc.certificate_limit, ldc.rate, tax_details)
|
||||
@@ -523,7 +531,7 @@ def get_tds_amount_from_ldc(ldc, parties, pan_no, tax_details, posting_date, net
|
||||
limit_consumed = frappe.db.get_value(
|
||||
"Purchase Invoice",
|
||||
{"supplier": ("in", parties), "apply_tds": 1, "docstatus": 1},
|
||||
"sum(net_total)",
|
||||
"sum(tax_withholding_net_total)",
|
||||
)
|
||||
|
||||
if is_valid_certificate(
|
||||
|
||||
@@ -186,6 +186,46 @@ class TestTaxWithholdingCategory(unittest.TestCase):
|
||||
for d in reversed(invoices):
|
||||
d.cancel()
|
||||
|
||||
def test_tds_calculation_on_net_total_partial_tds(self):
|
||||
frappe.db.set_value(
|
||||
"Supplier", "Test TDS Supplier4", "tax_withholding_category", "Cumulative Threshold TDS"
|
||||
)
|
||||
invoices = []
|
||||
|
||||
pi = create_purchase_invoice(supplier="Test TDS Supplier4", rate=20000, do_not_save=True)
|
||||
pi.extend(
|
||||
"items",
|
||||
[
|
||||
{
|
||||
"doctype": "Purchase Invoice Item",
|
||||
"item_code": frappe.db.get_value("Item", {"item_name": "TDS Item"}, "name"),
|
||||
"qty": 1,
|
||||
"rate": 20000,
|
||||
"cost_center": "Main - _TC",
|
||||
"expense_account": "Stock Received But Not Billed - _TC",
|
||||
"apply_tds": 0,
|
||||
},
|
||||
{
|
||||
"doctype": "Purchase Invoice Item",
|
||||
"item_code": frappe.db.get_value("Item", {"item_name": "TDS Item"}, "name"),
|
||||
"qty": 1,
|
||||
"rate": 35000,
|
||||
"cost_center": "Main - _TC",
|
||||
"expense_account": "Stock Received But Not Billed - _TC",
|
||||
"apply_tds": 1,
|
||||
},
|
||||
],
|
||||
)
|
||||
pi.save()
|
||||
pi.submit()
|
||||
invoices.append(pi)
|
||||
|
||||
self.assertEqual(pi.taxes[0].tax_amount, 5500)
|
||||
|
||||
# cancel invoices to avoid clashing
|
||||
for d in reversed(invoices):
|
||||
d.cancel()
|
||||
|
||||
def test_multi_category_single_supplier(self):
|
||||
frappe.db.set_value(
|
||||
"Supplier", "Test TDS Supplier5", "tax_withholding_category", "Test Service Category"
|
||||
|
||||
@@ -1009,7 +1009,7 @@ class ReceivablePayableReport(object):
|
||||
"{range3}-{range4}".format(
|
||||
range3=cint(self.filters["range3"]) + 1, range4=self.filters["range4"]
|
||||
),
|
||||
"{range4}-{above}".format(range4=cint(self.filters["range4"]) + 1, above=_("Above")),
|
||||
_("{range4}-Above").format(range4=cint(self.filters["range4"]) + 1),
|
||||
]
|
||||
):
|
||||
self.add_column(label=label, fieldname="range" + str(i + 1))
|
||||
|
||||
@@ -75,7 +75,7 @@ frappe.query_reports["Budget Variance Report"] = {
|
||||
"formatter": function (value, row, column, data, default_formatter) {
|
||||
value = default_formatter(value, row, column, data);
|
||||
|
||||
if (column.fieldname.includes('variance')) {
|
||||
if (column.fieldname.includes(__("variance"))) {
|
||||
|
||||
if (data[column.fieldname] < 0) {
|
||||
value = "<span style='color:red'>" + value + "</span>";
|
||||
|
||||
@@ -383,8 +383,8 @@ def get_chart_data(filters, columns, data):
|
||||
"data": {
|
||||
"labels": labels,
|
||||
"datasets": [
|
||||
{"name": "Budget", "chartType": "bar", "values": budget_values},
|
||||
{"name": "Actual Expense", "chartType": "bar", "values": actual_values},
|
||||
{"name": _("Budget"), "chartType": "bar", "values": budget_values},
|
||||
{"name": _("Actual Expense"), "chartType": "bar", "values": actual_values},
|
||||
],
|
||||
},
|
||||
"type": "bar",
|
||||
|
||||
@@ -396,7 +396,7 @@ class Deferred_Revenue_and_Expense_Report(object):
|
||||
"labels": [period.label for period in self.period_list],
|
||||
"datasets": [
|
||||
{
|
||||
"name": "Actual Posting",
|
||||
"name": _("Actual Posting"),
|
||||
"chartType": "bar",
|
||||
"values": [x.actual for x in self.period_total],
|
||||
}
|
||||
@@ -410,7 +410,7 @@ class Deferred_Revenue_and_Expense_Report(object):
|
||||
|
||||
if self.filters.with_upcoming_postings:
|
||||
chart["data"]["datasets"].append(
|
||||
{"name": "Expected", "chartType": "line", "values": [x.total for x in self.period_total]}
|
||||
{"name": _("Expected"), "chartType": "line", "values": [x.total for x in self.period_total]}
|
||||
)
|
||||
|
||||
return chart
|
||||
|
||||
@@ -432,7 +432,11 @@ frappe.ui.form.on('Asset', {
|
||||
|
||||
set_values_from_purchase_doc: function(frm, doctype, purchase_doc) {
|
||||
frm.set_value('company', purchase_doc.company);
|
||||
frm.set_value('purchase_date', purchase_doc.posting_date);
|
||||
if (purchase_doc.bill_date) {
|
||||
frm.set_value('purchase_date', purchase_doc.bill_date);
|
||||
} else {
|
||||
frm.set_value('purchase_date', purchase_doc.posting_date);
|
||||
}
|
||||
const item = purchase_doc.items.find(item => item.item_code === frm.doc.item_code);
|
||||
if (!item) {
|
||||
doctype_field = frappe.scrub(doctype)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import json
|
||||
|
||||
import frappe
|
||||
from frappe.tests.utils import FrappeTestCase
|
||||
from frappe.tests.utils import FrappeTestCase, change_settings
|
||||
from frappe.utils import add_days, flt, getdate, nowdate
|
||||
from frappe.utils.data import today
|
||||
|
||||
@@ -709,13 +709,10 @@ class TestPurchaseOrder(FrappeTestCase):
|
||||
pi.insert()
|
||||
self.assertTrue(pi.get("payment_schedule"))
|
||||
|
||||
@change_settings("Accounts Settings", {"unlink_advance_payment_on_cancelation_of_order": 1})
|
||||
def test_advance_payment_entry_unlink_against_purchase_order(self):
|
||||
from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
|
||||
|
||||
frappe.db.set_value(
|
||||
"Accounts Settings", "Accounts Settings", "unlink_advance_payment_on_cancelation_of_order", 1
|
||||
)
|
||||
|
||||
po_doc = create_purchase_order()
|
||||
|
||||
pe = get_payment_entry("Purchase Order", po_doc.name, bank_account="_Test Bank - _TC")
|
||||
@@ -735,9 +732,31 @@ class TestPurchaseOrder(FrappeTestCase):
|
||||
pe_doc = frappe.get_doc("Payment Entry", pe.name)
|
||||
pe_doc.cancel()
|
||||
|
||||
frappe.db.set_value(
|
||||
"Accounts Settings", "Accounts Settings", "unlink_advance_payment_on_cancelation_of_order", 0
|
||||
)
|
||||
@change_settings("Accounts Settings", {"unlink_advance_payment_on_cancelation_of_order": 1})
|
||||
def test_advance_paid_upon_payment_entry_cancellation(self):
|
||||
from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
|
||||
|
||||
po_doc = create_purchase_order()
|
||||
|
||||
pe = get_payment_entry("Purchase Order", po_doc.name, bank_account="_Test Bank - _TC")
|
||||
pe.reference_no = "1"
|
||||
pe.reference_date = nowdate()
|
||||
pe.paid_from_account_currency = po_doc.currency
|
||||
pe.paid_to_account_currency = po_doc.currency
|
||||
pe.source_exchange_rate = 1
|
||||
pe.target_exchange_rate = 1
|
||||
pe.paid_amount = po_doc.grand_total
|
||||
pe.save(ignore_permissions=True)
|
||||
pe.submit()
|
||||
|
||||
po_doc.reload()
|
||||
self.assertEqual(po_doc.advance_paid, po_doc.base_grand_total)
|
||||
|
||||
pe_doc = frappe.get_doc("Payment Entry", pe.name)
|
||||
pe_doc.cancel()
|
||||
|
||||
po_doc.reload()
|
||||
self.assertEqual(po_doc.advance_paid, 0)
|
||||
|
||||
def test_schedule_date(self):
|
||||
po = create_purchase_order(do_not_submit=True)
|
||||
|
||||
@@ -7,7 +7,7 @@ import json
|
||||
import frappe
|
||||
from frappe import _, throw
|
||||
from frappe.model.workflow import get_workflow_name, is_transition_condition_satisfied
|
||||
from frappe.query_builder.functions import Sum
|
||||
from frappe.query_builder.functions import Abs, Sum
|
||||
from frappe.utils import (
|
||||
add_days,
|
||||
add_months,
|
||||
@@ -151,6 +151,7 @@ class AccountsController(TransactionBase):
|
||||
self.validate_inter_company_reference()
|
||||
|
||||
self.disable_pricing_rule_on_internal_transfer()
|
||||
self.disable_tax_included_prices_for_internal_transfer()
|
||||
self.set_incoming_rate()
|
||||
|
||||
if self.meta.get_field("currency"):
|
||||
@@ -226,7 +227,7 @@ class AccountsController(TransactionBase):
|
||||
for item in self.get("items"):
|
||||
if item.get("enable_deferred_revenue") or item.get("enable_deferred_expense"):
|
||||
if not item.get(field_map.get(self.doctype)):
|
||||
default_deferred_account = frappe.db.get_value(
|
||||
default_deferred_account = frappe.get_cached_value(
|
||||
"Company", self.company, "default_" + field_map.get(self.doctype)
|
||||
)
|
||||
if not default_deferred_account:
|
||||
@@ -398,6 +399,20 @@ class AccountsController(TransactionBase):
|
||||
alert=1,
|
||||
)
|
||||
|
||||
def disable_tax_included_prices_for_internal_transfer(self):
|
||||
if self.is_internal_transfer():
|
||||
tax_updated = False
|
||||
for tax in self.get("taxes"):
|
||||
if tax.get("included_in_print_rate"):
|
||||
tax.included_in_print_rate = 0
|
||||
tax_updated = True
|
||||
|
||||
if tax_updated:
|
||||
frappe.msgprint(
|
||||
_("Disabled tax included prices since this {} is an internal transfer").format(self.doctype),
|
||||
alert=1,
|
||||
)
|
||||
|
||||
def validate_due_date(self):
|
||||
if self.get("is_pos"):
|
||||
return
|
||||
@@ -661,7 +676,7 @@ class AccountsController(TransactionBase):
|
||||
|
||||
def validate_enabled_taxes_and_charges(self):
|
||||
taxes_and_charges_doctype = self.meta.get_options("taxes_and_charges")
|
||||
if frappe.db.get_value(taxes_and_charges_doctype, self.taxes_and_charges, "disabled"):
|
||||
if frappe.get_cached_value(taxes_and_charges_doctype, self.taxes_and_charges, "disabled"):
|
||||
frappe.throw(
|
||||
_("{0} '{1}' is disabled").format(taxes_and_charges_doctype, self.taxes_and_charges)
|
||||
)
|
||||
@@ -669,7 +684,7 @@ class AccountsController(TransactionBase):
|
||||
def validate_tax_account_company(self):
|
||||
for d in self.get("taxes"):
|
||||
if d.account_head:
|
||||
tax_account_company = frappe.db.get_value("Account", d.account_head, "company")
|
||||
tax_account_company = frappe.get_cached_value("Account", d.account_head, "company")
|
||||
if tax_account_company != self.company:
|
||||
frappe.throw(
|
||||
_("Row #{0}: Account {1} does not belong to company {2}").format(
|
||||
@@ -804,15 +819,12 @@ class AccountsController(TransactionBase):
|
||||
self.set("advances", [])
|
||||
advance_allocated = 0
|
||||
for d in res:
|
||||
if d.against_order:
|
||||
allocated_amount = flt(d.amount)
|
||||
if self.get("party_account_currency") == self.company_currency:
|
||||
amount = self.get("base_rounded_total") or self.base_grand_total
|
||||
else:
|
||||
if self.get("party_account_currency") == self.company_currency:
|
||||
amount = self.get("base_rounded_total") or self.base_grand_total
|
||||
else:
|
||||
amount = self.get("rounded_total") or self.grand_total
|
||||
amount = self.get("rounded_total") or self.grand_total
|
||||
|
||||
allocated_amount = min(amount - advance_allocated, d.amount)
|
||||
allocated_amount = min(amount - advance_allocated, d.amount)
|
||||
advance_allocated += flt(allocated_amount)
|
||||
|
||||
advance_row = {
|
||||
@@ -917,7 +929,9 @@ class AccountsController(TransactionBase):
|
||||
party_account = self.credit_to if is_purchase_invoice else self.debit_to
|
||||
party_type = "Supplier" if is_purchase_invoice else "Customer"
|
||||
|
||||
gain_loss_account = frappe.db.get_value("Company", self.company, "exchange_gain_loss_account")
|
||||
gain_loss_account = frappe.get_cached_value(
|
||||
"Company", self.company, "exchange_gain_loss_account"
|
||||
)
|
||||
if not gain_loss_account:
|
||||
frappe.throw(
|
||||
_("Please set default Exchange Gain/Loss Account in Company {}").format(self.get("company"))
|
||||
@@ -1014,7 +1028,7 @@ class AccountsController(TransactionBase):
|
||||
else self.grand_total
|
||||
),
|
||||
"outstanding_amount": self.outstanding_amount,
|
||||
"difference_account": frappe.db.get_value(
|
||||
"difference_account": frappe.get_cached_value(
|
||||
"Company", self.company, "exchange_gain_loss_account"
|
||||
),
|
||||
"exchange_gain_loss": flt(d.get("exchange_gain_loss")),
|
||||
@@ -1334,30 +1348,20 @@ class AccountsController(TransactionBase):
|
||||
return stock_items
|
||||
|
||||
def set_total_advance_paid(self):
|
||||
if self.doctype == "Sales Order":
|
||||
dr_or_cr = "credit_in_account_currency"
|
||||
rev_dr_or_cr = "debit_in_account_currency"
|
||||
party = self.customer
|
||||
else:
|
||||
dr_or_cr = "debit_in_account_currency"
|
||||
rev_dr_or_cr = "credit_in_account_currency"
|
||||
party = self.supplier
|
||||
|
||||
advance = frappe.db.sql(
|
||||
"""
|
||||
select
|
||||
account_currency, sum({dr_or_cr}) - sum({rev_dr_cr}) as amount
|
||||
from
|
||||
`tabGL Entry`
|
||||
where
|
||||
against_voucher_type = %s and against_voucher = %s and party=%s
|
||||
and docstatus = 1
|
||||
""".format(
|
||||
dr_or_cr=dr_or_cr, rev_dr_cr=rev_dr_or_cr
|
||||
),
|
||||
(self.doctype, self.name, party),
|
||||
as_dict=1,
|
||||
) # nosec
|
||||
ple = frappe.qb.DocType("Payment Ledger Entry")
|
||||
party = self.customer if self.doctype == "Sales Order" else self.supplier
|
||||
advance = (
|
||||
frappe.qb.from_(ple)
|
||||
.select(ple.account_currency, Abs(Sum(ple.amount)).as_("amount"))
|
||||
.where(
|
||||
(ple.against_voucher_type == self.doctype)
|
||||
& (ple.against_voucher_no == self.name)
|
||||
& (ple.party == party)
|
||||
& (ple.delinked == 0)
|
||||
& (ple.company == self.company)
|
||||
)
|
||||
.run(as_dict=True)
|
||||
)
|
||||
|
||||
if advance:
|
||||
advance = advance[0]
|
||||
@@ -1392,7 +1396,7 @@ class AccountsController(TransactionBase):
|
||||
@property
|
||||
def company_abbr(self):
|
||||
if not hasattr(self, "_abbr"):
|
||||
self._abbr = frappe.db.get_value("Company", self.company, "abbr")
|
||||
self._abbr = frappe.get_cached_value("Company", self.company, "abbr")
|
||||
|
||||
return self._abbr
|
||||
|
||||
@@ -1778,7 +1782,7 @@ class AccountsController(TransactionBase):
|
||||
"""
|
||||
|
||||
if self.is_internal_transfer() and not self.unrealized_profit_loss_account:
|
||||
unrealized_profit_loss_account = frappe.db.get_value(
|
||||
unrealized_profit_loss_account = frappe.get_cached_value(
|
||||
"Company", self.company, "unrealized_profit_loss_account"
|
||||
)
|
||||
|
||||
@@ -1893,7 +1897,9 @@ class AccountsController(TransactionBase):
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_tax_rate(account_head):
|
||||
return frappe.db.get_value("Account", account_head, ["tax_rate", "account_name"], as_dict=True)
|
||||
return frappe.get_cached_value(
|
||||
"Account", account_head, ["tax_rate", "account_name"], as_dict=True
|
||||
)
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
@@ -1902,7 +1908,7 @@ def get_default_taxes_and_charges(master_doctype, tax_template=None, company=Non
|
||||
return {}
|
||||
|
||||
if tax_template and company:
|
||||
tax_template_company = frappe.db.get_value(master_doctype, tax_template, "company")
|
||||
tax_template_company = frappe.get_cached_value(master_doctype, tax_template, "company")
|
||||
if tax_template_company == company:
|
||||
return
|
||||
|
||||
|
||||
@@ -326,7 +326,7 @@ def make_return_doc(doctype: str, source_name: str, target_doc=None):
|
||||
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
|
||||
|
||||
company = frappe.db.get_value("Delivery Note", source_name, "company")
|
||||
default_warehouse_for_sales_return = frappe.db.get_value(
|
||||
default_warehouse_for_sales_return = frappe.get_cached_value(
|
||||
"Company", company, "default_warehouse_for_sales_return"
|
||||
)
|
||||
|
||||
@@ -340,11 +340,11 @@ def make_return_doc(doctype: str, source_name: str, target_doc=None):
|
||||
|
||||
# look for Print Heading "Credit Note"
|
||||
if not doc.select_print_heading:
|
||||
doc.select_print_heading = frappe.db.get_value("Print Heading", _("Credit Note"))
|
||||
doc.select_print_heading = frappe.get_cached_value("Print Heading", _("Credit Note"))
|
||||
|
||||
elif doctype == "Purchase Invoice":
|
||||
# look for Print Heading "Debit Note"
|
||||
doc.select_print_heading = frappe.db.get_value("Print Heading", _("Debit Note"))
|
||||
doc.select_print_heading = frappe.get_cached_value("Print Heading", _("Debit Note"))
|
||||
|
||||
for tax in doc.get("taxes") or []:
|
||||
if tax.charge_type == "Actual":
|
||||
@@ -503,7 +503,7 @@ def make_return_doc(doctype: str, source_name: str, target_doc=None):
|
||||
doctype
|
||||
+ " Item": {
|
||||
"doctype": doctype + " Item",
|
||||
"field_map": {"serial_no": "serial_no", "batch_no": "batch_no"},
|
||||
"field_map": {"serial_no": "serial_no", "batch_no": "batch_no", "bom": "bom"},
|
||||
"postprocess": update_item,
|
||||
},
|
||||
"Payment Schedule": {"doctype": "Payment Schedule", "postprocess": update_terms},
|
||||
|
||||
@@ -57,7 +57,7 @@ class StockController(AccountsController):
|
||||
make_reverse_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
|
||||
|
||||
provisional_accounting_for_non_stock_items = cint(
|
||||
frappe.db.get_value(
|
||||
frappe.get_cached_value(
|
||||
"Company", self.company, "enable_provisional_accounting_for_non_stock_items"
|
||||
)
|
||||
)
|
||||
@@ -200,7 +200,7 @@ class StockController(AccountsController):
|
||||
elif self.get("is_internal_supplier"):
|
||||
warehouse_asset_account = warehouse_account[item_row.get("warehouse")]["account"]
|
||||
|
||||
expense_account = frappe.db.get_value("Company", self.company, "default_expense_account")
|
||||
expense_account = frappe.get_cached_value("Company", self.company, "default_expense_account")
|
||||
|
||||
gl_list.append(
|
||||
self.get_gl_dict(
|
||||
@@ -235,7 +235,7 @@ class StockController(AccountsController):
|
||||
|
||||
if warehouse_with_no_account:
|
||||
for wh in warehouse_with_no_account:
|
||||
if frappe.db.get_value("Warehouse", wh, "company"):
|
||||
if frappe.get_cached_value("Warehouse", wh, "company"):
|
||||
frappe.throw(
|
||||
_(
|
||||
"Warehouse {0} is not linked to any account, please mention the account in the warehouse record or set default inventory account in company {1}."
|
||||
@@ -449,15 +449,15 @@ class StockController(AccountsController):
|
||||
|
||||
# Get value based on doctype name
|
||||
if not sl_dict.get(dimension.target_fieldname):
|
||||
fieldname = frappe.get_cached_value(
|
||||
"DocField", {"parent": self.doctype, "options": dimension.fetch_from_parent}, "fieldname"
|
||||
fieldname = next(
|
||||
(
|
||||
field.fieldname
|
||||
for field in frappe.get_meta(self.doctype).fields
|
||||
if field.options == dimension.fetch_from_parent
|
||||
),
|
||||
None,
|
||||
)
|
||||
|
||||
if not fieldname:
|
||||
fieldname = frappe.get_cached_value(
|
||||
"Custom Field", {"dt": self.doctype, "options": dimension.fetch_from_parent}, "fieldname"
|
||||
)
|
||||
|
||||
if fieldname and self.get(fieldname):
|
||||
sl_dict[dimension.target_fieldname] = self.get(fieldname)
|
||||
|
||||
|
||||
@@ -89,6 +89,9 @@ class SubcontractingController(StockController):
|
||||
if bom.item != item.item_code:
|
||||
msg = f"Please select an valid BOM for Item {item.item_name}."
|
||||
frappe.throw(_(msg))
|
||||
else:
|
||||
msg = f"Please select a BOM for Item {item.item_name}."
|
||||
frappe.throw(_(msg))
|
||||
|
||||
def __get_data_before_save(self):
|
||||
item_dict = {}
|
||||
@@ -97,7 +100,7 @@ class SubcontractingController(StockController):
|
||||
and self._doc_before_save
|
||||
):
|
||||
for row in self._doc_before_save.get("items"):
|
||||
item_dict[row.name] = (row.item_code, row.qty)
|
||||
item_dict[row.name] = (row.item_code, row.received_qty or row.qty)
|
||||
|
||||
return item_dict
|
||||
|
||||
@@ -115,7 +118,9 @@ class SubcontractingController(StockController):
|
||||
|
||||
for row in self.items:
|
||||
self.__reference_name.append(row.name)
|
||||
if (row.name not in item_dict) or (row.item_code, row.qty) != item_dict[row.name]:
|
||||
if (row.name not in item_dict) or (row.item_code, row.received_qty or row.qty) != item_dict[
|
||||
row.name
|
||||
]:
|
||||
self.__changed_name.append(row.name)
|
||||
|
||||
if item_dict.get(row.name):
|
||||
@@ -458,12 +463,13 @@ class SubcontractingController(StockController):
|
||||
|
||||
def __get_qty_based_on_material_transfer(self, item_row, transfer_item):
|
||||
key = (item_row.item_code, item_row.get(self.subcontract_data.order_field))
|
||||
item_qty = item_row.received_qty or item_row.qty
|
||||
|
||||
if self.qty_to_be_received == item_row.qty:
|
||||
if self.qty_to_be_received.get(key) == item_qty:
|
||||
return transfer_item.qty
|
||||
|
||||
if self.qty_to_be_received:
|
||||
qty = (flt(item_row.qty) * flt(transfer_item.qty)) / flt(self.qty_to_be_received.get(key, 0))
|
||||
qty = (flt(item_qty) * flt(transfer_item.qty)) / flt(self.qty_to_be_received.get(key, 0))
|
||||
transfer_item.item_details.required_qty = transfer_item.qty
|
||||
|
||||
if transfer_item.serial_no or frappe.get_cached_value(
|
||||
@@ -488,7 +494,11 @@ class SubcontractingController(StockController):
|
||||
for bom_item in self.__get_materials_from_bom(
|
||||
row.item_code, row.bom, row.get("include_exploded_items")
|
||||
):
|
||||
qty = flt(bom_item.qty_consumed_per_unit) * flt(row.qty) * row.conversion_factor
|
||||
qty = (
|
||||
flt(bom_item.qty_consumed_per_unit)
|
||||
* flt(row.received_qty or row.qty)
|
||||
* row.conversion_factor
|
||||
)
|
||||
bom_item.main_item_code = row.item_code
|
||||
self.__update_reserve_warehouse(bom_item, row)
|
||||
self.__set_alternative_item(bom_item)
|
||||
|
||||
@@ -58,12 +58,25 @@ class calculate_taxes_and_totals(object):
|
||||
self.initialize_taxes()
|
||||
self.determine_exclusive_rate()
|
||||
self.calculate_net_total()
|
||||
self.calculate_tax_withholding_net_total()
|
||||
self.calculate_taxes()
|
||||
self.manipulate_grand_total_for_inclusive_tax()
|
||||
self.calculate_totals()
|
||||
self._cleanup()
|
||||
self.calculate_total_net_weight()
|
||||
|
||||
def calculate_tax_withholding_net_total(self):
|
||||
if hasattr(self.doc, "tax_withholding_net_total"):
|
||||
sum_net_amount = 0
|
||||
sum_base_net_amount = 0
|
||||
for item in self.doc.get("items"):
|
||||
if hasattr(item, "apply_tds") and item.apply_tds:
|
||||
sum_net_amount += item.net_amount
|
||||
sum_base_net_amount += item.base_net_amount
|
||||
|
||||
self.doc.tax_withholding_net_total = sum_net_amount
|
||||
self.doc.base_tax_withholding_net_total = sum_base_net_amount
|
||||
|
||||
def validate_item_tax_template(self):
|
||||
for item in self.doc.get("items"):
|
||||
if item.item_code and item.get("item_tax_template"):
|
||||
@@ -1043,7 +1056,7 @@ class init_landed_taxes_and_totals(object):
|
||||
company_currency = erpnext.get_company_currency(self.doc.company)
|
||||
for d in self.doc.get(self.tax_field):
|
||||
if not d.account_currency:
|
||||
account_currency = frappe.db.get_value("Account", d.expense_account, "account_currency")
|
||||
account_currency = frappe.get_cached_value("Account", d.expense_account, "account_currency")
|
||||
d.account_currency = account_currency or company_currency
|
||||
|
||||
def set_exchange_rate(self):
|
||||
|
||||
@@ -815,6 +815,7 @@ def add_second_row_in_scr(scr):
|
||||
"item_name",
|
||||
"qty",
|
||||
"uom",
|
||||
"bom",
|
||||
"warehouse",
|
||||
"stock_uom",
|
||||
"subcontracting_order",
|
||||
|
||||
@@ -80,7 +80,7 @@ def get_data(filters, conditions):
|
||||
if conditions.get("trans") == "Quotation" and filters.get("group_by") == "Customer":
|
||||
cond += " and t1.quotation_to = 'Customer'"
|
||||
|
||||
year_start_date, year_end_date = frappe.db.get_value(
|
||||
year_start_date, year_end_date = frappe.get_cached_value(
|
||||
"Fiscal Year", filters.get("fiscal_year"), ["year_start_date", "year_end_date"]
|
||||
)
|
||||
|
||||
@@ -275,7 +275,7 @@ def get_period_date_ranges(period, fiscal_year=None, year_start_date=None):
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
if not year_start_date:
|
||||
year_start_date, year_end_date = frappe.db.get_value(
|
||||
year_start_date, year_end_date = frappe.get_cached_value(
|
||||
"Fiscal Year", fiscal_year, ["year_start_date", "year_end_date"]
|
||||
)
|
||||
|
||||
|
||||
@@ -589,66 +589,69 @@ erpnext.work_order = {
|
||||
}
|
||||
}
|
||||
|
||||
if(!frm.doc.skip_transfer){
|
||||
if (frm.doc.status != 'Stopped') {
|
||||
// If "Material Consumption is check in Manufacturing Settings, allow Material Consumption
|
||||
if (flt(doc.material_transferred_for_manufacturing) > 0 && frm.doc.status != 'Stopped') {
|
||||
if ((flt(doc.produced_qty) < flt(doc.material_transferred_for_manufacturing))) {
|
||||
frm.has_finish_btn = true;
|
||||
|
||||
if (frm.doc.__onload && frm.doc.__onload.material_consumption == 1) {
|
||||
// Only show "Material Consumption" when required_qty > consumed_qty
|
||||
var counter = 0;
|
||||
var tbl = frm.doc.required_items || [];
|
||||
var tbl_lenght = tbl.length;
|
||||
for (var i = 0, len = tbl_lenght; i < len; i++) {
|
||||
let wo_item_qty = frm.doc.required_items[i].transferred_qty || frm.doc.required_items[i].required_qty;
|
||||
if (flt(wo_item_qty) > flt(frm.doc.required_items[i].consumed_qty)) {
|
||||
counter += 1;
|
||||
}
|
||||
}
|
||||
if (counter > 0) {
|
||||
var consumption_btn = frm.add_custom_button(__('Material Consumption'), function() {
|
||||
const backflush_raw_materials_based_on = frm.doc.__onload.backflush_raw_materials_based_on;
|
||||
erpnext.work_order.make_consumption_se(frm, backflush_raw_materials_based_on);
|
||||
});
|
||||
consumption_btn.addClass('btn-primary');
|
||||
if (frm.doc.__onload && frm.doc.__onload.material_consumption == 1) {
|
||||
if (flt(doc.material_transferred_for_manufacturing) > 0 || frm.doc.skip_transfer) {
|
||||
// Only show "Material Consumption" when required_qty > consumed_qty
|
||||
var counter = 0;
|
||||
var tbl = frm.doc.required_items || [];
|
||||
var tbl_lenght = tbl.length;
|
||||
for (var i = 0, len = tbl_lenght; i < len; i++) {
|
||||
let wo_item_qty = frm.doc.required_items[i].transferred_qty || frm.doc.required_items[i].required_qty;
|
||||
if (flt(wo_item_qty) > flt(frm.doc.required_items[i].consumed_qty)) {
|
||||
counter += 1;
|
||||
}
|
||||
}
|
||||
if (counter > 0) {
|
||||
var consumption_btn = frm.add_custom_button(__('Material Consumption'), function() {
|
||||
const backflush_raw_materials_based_on = frm.doc.__onload.backflush_raw_materials_based_on;
|
||||
erpnext.work_order.make_consumption_se(frm, backflush_raw_materials_based_on);
|
||||
});
|
||||
consumption_btn.addClass('btn-primary');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!frm.doc.skip_transfer){
|
||||
if (flt(doc.material_transferred_for_manufacturing) > 0) {
|
||||
if ((flt(doc.produced_qty) < flt(doc.material_transferred_for_manufacturing))) {
|
||||
frm.has_finish_btn = true;
|
||||
|
||||
var finish_btn = frm.add_custom_button(__('Finish'), function() {
|
||||
erpnext.work_order.make_se(frm, 'Manufacture');
|
||||
});
|
||||
|
||||
if(doc.material_transferred_for_manufacturing>=doc.qty) {
|
||||
// all materials transferred for manufacturing, make this primary
|
||||
finish_btn.addClass('btn-primary');
|
||||
}
|
||||
} else {
|
||||
frappe.db.get_doc("Manufacturing Settings").then((doc) => {
|
||||
let allowance_percentage = doc.overproduction_percentage_for_work_order;
|
||||
|
||||
if (allowance_percentage > 0) {
|
||||
let allowed_qty = frm.doc.qty + ((allowance_percentage / 100) * frm.doc.qty);
|
||||
|
||||
if ((flt(doc.produced_qty) < allowed_qty)) {
|
||||
frm.add_custom_button(__('Finish'), function() {
|
||||
erpnext.work_order.make_se(frm, 'Manufacture');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((flt(doc.produced_qty) < flt(doc.qty))) {
|
||||
var finish_btn = frm.add_custom_button(__('Finish'), function() {
|
||||
erpnext.work_order.make_se(frm, 'Manufacture');
|
||||
});
|
||||
|
||||
if(doc.material_transferred_for_manufacturing>=doc.qty) {
|
||||
// all materials transferred for manufacturing, make this primary
|
||||
finish_btn.addClass('btn-primary');
|
||||
}
|
||||
} else {
|
||||
frappe.db.get_doc("Manufacturing Settings").then((doc) => {
|
||||
let allowance_percentage = doc.overproduction_percentage_for_work_order;
|
||||
|
||||
if (allowance_percentage > 0) {
|
||||
let allowed_qty = frm.doc.qty + ((allowance_percentage / 100) * frm.doc.qty);
|
||||
|
||||
if ((flt(doc.produced_qty) < allowed_qty)) {
|
||||
frm.add_custom_button(__('Finish'), function() {
|
||||
erpnext.work_order.make_se(frm, 'Manufacture');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
finish_btn.addClass('btn-primary');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((flt(doc.produced_qty) < flt(doc.qty)) && frm.doc.status != 'Stopped') {
|
||||
var finish_btn = frm.add_custom_button(__('Finish'), function() {
|
||||
erpnext.work_order.make_se(frm, 'Manufacture');
|
||||
});
|
||||
finish_btn.addClass('btn-primary');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
calculate_cost: function(doc) {
|
||||
if (doc.operations){
|
||||
|
||||
@@ -317,4 +317,4 @@ erpnext.patches.v14_0.fix_subcontracting_receipt_gl_entries
|
||||
erpnext.patches.v14_0.migrate_remarks_from_gl_to_payment_ledger
|
||||
erpnext.patches.v14_0.create_accounting_dimensions_for_asset_capitalization
|
||||
erpnext.patches.v13_0.update_schedule_type_in_loans
|
||||
|
||||
erpnext.patches.v14_0.update_tds_fields
|
||||
29
erpnext/patches/v14_0/update_tds_fields.py
Normal file
29
erpnext/patches/v14_0/update_tds_fields.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import frappe
|
||||
from frappe.utils import nowdate
|
||||
|
||||
from erpnext.accounts.utils import FiscalYearError, get_fiscal_year
|
||||
|
||||
|
||||
def execute():
|
||||
# Only do for current fiscal year, no need to repost for all years
|
||||
for company in frappe.get_all("Company"):
|
||||
try:
|
||||
fiscal_year_details = get_fiscal_year(date=nowdate(), company=company.name, as_dict=True)
|
||||
|
||||
purchase_invoice = frappe.qb.DocType("Purchase Invoice")
|
||||
|
||||
frappe.qb.update(purchase_invoice).set(
|
||||
purchase_invoice.tax_withholding_net_total, purchase_invoice.net_total
|
||||
).set(
|
||||
purchase_invoice.base_tax_withholding_net_total, purchase_invoice.base_net_total
|
||||
).where(
|
||||
purchase_invoice.company == company.name
|
||||
).where(
|
||||
purchase_invoice.apply_tds == 1
|
||||
).where(
|
||||
purchase_invoice.posting_date >= fiscal_year_details.year_start_date
|
||||
).where(
|
||||
purchase_invoice.docstatus == 1
|
||||
).run()
|
||||
except FiscalYearError:
|
||||
pass
|
||||
@@ -30,28 +30,28 @@ erpnext.accounts.bank_reconciliation.DataTableManager = class DataTableManager {
|
||||
get_dt_columns() {
|
||||
this.columns = [
|
||||
{
|
||||
name: "Date",
|
||||
name: __("Date"),
|
||||
editable: false,
|
||||
width: 100,
|
||||
},
|
||||
|
||||
{
|
||||
name: "Party Type",
|
||||
name: __("Party Type"),
|
||||
editable: false,
|
||||
width: 95,
|
||||
},
|
||||
{
|
||||
name: "Party",
|
||||
name: __("Party"),
|
||||
editable: false,
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
name: "Description",
|
||||
name: __("Description"),
|
||||
editable: false,
|
||||
width: 350,
|
||||
},
|
||||
{
|
||||
name: "Deposit",
|
||||
name: __("Deposit"),
|
||||
editable: false,
|
||||
width: 100,
|
||||
format: (value) =>
|
||||
@@ -60,7 +60,7 @@ erpnext.accounts.bank_reconciliation.DataTableManager = class DataTableManager {
|
||||
"</span>",
|
||||
},
|
||||
{
|
||||
name: "Withdrawal",
|
||||
name: __("Withdrawal"),
|
||||
editable: false,
|
||||
width: 100,
|
||||
format: (value) =>
|
||||
@@ -69,26 +69,26 @@ erpnext.accounts.bank_reconciliation.DataTableManager = class DataTableManager {
|
||||
"</span>",
|
||||
},
|
||||
{
|
||||
name: "Unallocated Amount",
|
||||
name: __("Unallocated Amount"),
|
||||
editable: false,
|
||||
width: 100,
|
||||
format: (value) =>
|
||||
"<span style='color:blue;'>" +
|
||||
"<span style='color:var(--blue-500);'>" +
|
||||
format_currency(value, this.currency) +
|
||||
"</span>",
|
||||
},
|
||||
{
|
||||
name: "Reference Number",
|
||||
name: __("Reference Number"),
|
||||
editable: false,
|
||||
width: 140,
|
||||
},
|
||||
{
|
||||
name: "Actions",
|
||||
name: __("Actions"),
|
||||
editable: false,
|
||||
sortable: false,
|
||||
focusable: false,
|
||||
dropdown: false,
|
||||
width: 80,
|
||||
width: 100,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -118,7 +118,7 @@ erpnext.accounts.bank_reconciliation.DataTableManager = class DataTableManager {
|
||||
row["reference_number"],
|
||||
`
|
||||
<Button class="btn btn-primary btn-xs center" data-name = ${row["name"]} >
|
||||
Actions
|
||||
${__("Actions")}
|
||||
</a>
|
||||
`,
|
||||
];
|
||||
|
||||
@@ -87,33 +87,33 @@ erpnext.accounts.bank_reconciliation.DialogManager = class DialogManager {
|
||||
get_dt_columns() {
|
||||
this.columns = [
|
||||
{
|
||||
name: "Document Type",
|
||||
name: __("Document Type"),
|
||||
editable: false,
|
||||
width: 125,
|
||||
},
|
||||
{
|
||||
name: "Document Name",
|
||||
name: __("Document Name"),
|
||||
editable: false,
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
name: "Reference Date",
|
||||
name: __("Reference Date"),
|
||||
editable: false,
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
name: "Amount",
|
||||
name: __("Amount"),
|
||||
editable: false,
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
name: "Party",
|
||||
name: __("Party"),
|
||||
editable: false,
|
||||
width: 120,
|
||||
},
|
||||
|
||||
{
|
||||
name: "Reference Number",
|
||||
name: __("Reference Number"),
|
||||
editable: false,
|
||||
width: 140,
|
||||
},
|
||||
@@ -222,7 +222,7 @@ erpnext.accounts.bank_reconciliation.DialogManager = class DialogManager {
|
||||
{
|
||||
fieldtype: "HTML",
|
||||
fieldname: "no_matching_vouchers",
|
||||
options: "<div class=\"text-muted text-center\">No Matching Vouchers Found</div>"
|
||||
options: __("<div class=\"text-muted text-center\">{0}</div>", [__("No Matching Vouchers Found")])
|
||||
},
|
||||
{
|
||||
fieldtype: "Section Break",
|
||||
@@ -444,10 +444,7 @@ erpnext.accounts.bank_reconciliation.DialogManager = class DialogManager {
|
||||
vouchers: vouchers,
|
||||
},
|
||||
callback: (response) => {
|
||||
const alert_string =
|
||||
"Bank Transaction " +
|
||||
this.bank_transaction.name +
|
||||
" Matched";
|
||||
const alert_string = __("Bank Transaction {0} Matched", [this.bank_transaction.name]);
|
||||
frappe.show_alert(alert_string);
|
||||
this.update_dt_cards(response.message);
|
||||
this.dialog.hide();
|
||||
@@ -471,10 +468,7 @@ erpnext.accounts.bank_reconciliation.DialogManager = class DialogManager {
|
||||
cost_center: values.cost_center,
|
||||
},
|
||||
callback: (response) => {
|
||||
const alert_string =
|
||||
"Bank Transaction " +
|
||||
this.bank_transaction.name +
|
||||
" added as Payment Entry";
|
||||
const alert_string = __("Bank Transaction {0} added as Payment Entry", [this.bank_transaction.name]);
|
||||
frappe.show_alert(alert_string);
|
||||
this.update_dt_cards(response.message);
|
||||
this.dialog.hide();
|
||||
@@ -498,10 +492,7 @@ erpnext.accounts.bank_reconciliation.DialogManager = class DialogManager {
|
||||
second_account: values.second_account,
|
||||
},
|
||||
callback: (response) => {
|
||||
const alert_string =
|
||||
"Bank Transaction " +
|
||||
this.bank_transaction.name +
|
||||
" added as Journal Entry";
|
||||
const alert_string = __("Bank Transaction {0} added as Journal Entry", [this.bank_transaction.name]);
|
||||
frappe.show_alert(alert_string);
|
||||
this.update_dt_cards(response.message);
|
||||
this.dialog.hide();
|
||||
@@ -520,10 +511,7 @@ erpnext.accounts.bank_reconciliation.DialogManager = class DialogManager {
|
||||
party: values.party,
|
||||
},
|
||||
callback: (response) => {
|
||||
const alert_string =
|
||||
"Bank Transaction " +
|
||||
this.bank_transaction.name +
|
||||
" updated";
|
||||
const alert_string = __("Bank Transaction {0} updated", [this.bank_transaction.name]);
|
||||
frappe.show_alert(alert_string);
|
||||
this.update_dt_cards(response.message);
|
||||
this.dialog.hide();
|
||||
|
||||
@@ -15,20 +15,20 @@ erpnext.accounts.bank_reconciliation.NumberCardManager = class NumberCardManager
|
||||
var chart_data = [
|
||||
{
|
||||
value: this.bank_statement_closing_balance,
|
||||
label: "Closing Balance as per Bank Statement",
|
||||
label: __("Closing Balance as per Bank Statement"),
|
||||
datatype: "Currency",
|
||||
currency: this.currency,
|
||||
},
|
||||
{
|
||||
value: this.cleared_balance,
|
||||
label: "Closing Balance as per ERP",
|
||||
label: __("Closing Balance as per ERP"),
|
||||
datatype: "Currency",
|
||||
currency: this.currency,
|
||||
},
|
||||
{
|
||||
value:
|
||||
this.bank_statement_closing_balance - this.cleared_balance,
|
||||
label: "Difference",
|
||||
label: __("Difference"),
|
||||
datatype: "Currency",
|
||||
currency: this.currency,
|
||||
},
|
||||
|
||||
@@ -341,6 +341,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
this.set_dynamic_labels();
|
||||
this.setup_sms();
|
||||
this.setup_quality_inspection();
|
||||
this.validate_has_items();
|
||||
}
|
||||
|
||||
scan_barcode() {
|
||||
@@ -348,6 +349,12 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
barcode_scanner.process_scan();
|
||||
}
|
||||
|
||||
validate_has_items () {
|
||||
let table = this.frm.doc.items;
|
||||
this.frm.has_items = (table && table.length
|
||||
&& table[0].qty && table[0].item_code);
|
||||
}
|
||||
|
||||
apply_default_taxes() {
|
||||
var me = this;
|
||||
var taxes_and_charges_field = frappe.meta.get_docfield(me.frm.doc.doctype, "taxes_and_charges",
|
||||
@@ -1200,7 +1207,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
"base_rounding_adjustment"], company_currency);
|
||||
|
||||
this.frm.set_currency_labels(["total", "net_total", "total_taxes_and_charges", "discount_amount",
|
||||
"grand_total", "taxes_and_charges_added", "taxes_and_charges_deducted",
|
||||
"grand_total", "taxes_and_charges_added", "taxes_and_charges_deducted","tax_withholding_net_total",
|
||||
"rounded_total", "in_words", "paid_amount", "write_off_amount", "operating_cost",
|
||||
"scrap_material_cost", "rounding_adjustment", "raw_material_cost",
|
||||
"total_cost"], this.frm.doc.currency);
|
||||
@@ -1217,7 +1224,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
}
|
||||
|
||||
// toggle fields
|
||||
this.frm.toggle_display(["conversion_rate", "base_total", "base_net_total",
|
||||
this.frm.toggle_display(["conversion_rate", "base_total", "base_net_total", "base_tax_withholding_net_total",
|
||||
"base_total_taxes_and_charges", "base_taxes_and_charges_added", "base_taxes_and_charges_deducted",
|
||||
"base_grand_total", "base_rounded_total", "base_in_words", "base_discount_amount",
|
||||
"base_paid_amount", "base_write_off_amount", "base_operating_cost", "base_raw_material_cost",
|
||||
|
||||
@@ -21,6 +21,11 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
||||
this.items_table_name = opts.items_table_name || "items";
|
||||
this.items_table = this.frm.doc[this.items_table_name];
|
||||
|
||||
// optional sound name to play when scan either fails or passes.
|
||||
// see https://frappeframework.com/docs/v14/user/en/python-api/hooks#sounds
|
||||
this.success_sound = opts.play_success_sound;
|
||||
this.fail_sound = opts.play_fail_sound;
|
||||
|
||||
// any API that takes `search_value` as input and returns dictionary as follows
|
||||
// {
|
||||
// item_code: "HORSESHOE", // present if any item was found
|
||||
@@ -42,58 +47,74 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
||||
return;
|
||||
}
|
||||
|
||||
frappe
|
||||
.call({
|
||||
method: this.scan_api,
|
||||
args: {
|
||||
search_value: input,
|
||||
},
|
||||
})
|
||||
.then((r) => {
|
||||
const data = r && r.message;
|
||||
if (!data || Object.keys(data).length === 0) {
|
||||
this.show_alert(__("Cannot find Item with this Barcode"), "red");
|
||||
this.clean_up();
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
this.scan_api_call(input, (r) => {
|
||||
const data = r && r.message;
|
||||
if (!data || Object.keys(data).length === 0) {
|
||||
this.show_alert(__("Cannot find Item with this Barcode"), "red");
|
||||
this.clean_up();
|
||||
this.play_fail_sound();
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
|
||||
me.update_table(data).then(row => {
|
||||
row ? resolve(row) : reject();
|
||||
});
|
||||
me.update_table(data).then(row => {
|
||||
this.play_success_sound();
|
||||
resolve(row);
|
||||
}).catch(() => {
|
||||
this.play_fail_sound();
|
||||
reject();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
scan_api_call(input, callback) {
|
||||
frappe
|
||||
.call({
|
||||
method: this.scan_api,
|
||||
args: {
|
||||
search_value: input,
|
||||
},
|
||||
})
|
||||
.then((r) => {
|
||||
callback(r);
|
||||
});
|
||||
}
|
||||
|
||||
update_table(data) {
|
||||
return new Promise(resolve => {
|
||||
let cur_grid = this.frm.fields_dict[this.items_table_name].grid;
|
||||
|
||||
const {item_code, barcode, batch_no, serial_no, uom} = data;
|
||||
|
||||
let row = this.get_row_to_modify_on_scan(item_code, batch_no, uom);
|
||||
let row = this.get_row_to_modify_on_scan(item_code, batch_no, uom, barcode);
|
||||
|
||||
this.is_new_row = false;
|
||||
if (!row) {
|
||||
if (this.dont_allow_new_row) {
|
||||
this.show_alert(__("Maximum quantity scanned for item {0}.", [item_code]), "red");
|
||||
this.clean_up();
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
this.is_new_row = true;
|
||||
|
||||
// add new row if new item/batch is scanned
|
||||
row = frappe.model.add_child(this.frm.doc, cur_grid.doctype, this.items_table_name);
|
||||
// trigger any row add triggers defined on child table.
|
||||
this.frm.script_manager.trigger(`${this.items_table_name}_add`, row.doctype, row.name);
|
||||
this.frm.has_items = false;
|
||||
}
|
||||
|
||||
if (this.is_duplicate_serial_no(row, serial_no)) {
|
||||
this.clean_up();
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
|
||||
frappe.run_serially([
|
||||
() => this.set_selector_trigger_flag(data),
|
||||
() => this.set_item(row, item_code).then(qty => {
|
||||
() => this.set_item(row, item_code, barcode, batch_no, serial_no).then(qty => {
|
||||
this.show_scan_message(row.idx, row.item_code, qty);
|
||||
}),
|
||||
() => this.set_barcode_uom(row, uom),
|
||||
@@ -124,7 +145,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
||||
frappe.flags.hide_serial_batch_dialog = false;
|
||||
}
|
||||
|
||||
set_item(row, item_code) {
|
||||
set_item(row, item_code, barcode, batch_no, serial_no) {
|
||||
return new Promise(resolve => {
|
||||
const increment = async (value = 1) => {
|
||||
const item_data = {item_code: item_code};
|
||||
@@ -137,12 +158,186 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
||||
frappe.prompt(__("Please enter quantity for item {0}", [item_code]), ({value}) => {
|
||||
increment(value).then((value) => resolve(value));
|
||||
});
|
||||
} else if (this.frm.has_items) {
|
||||
this.prepare_item_for_scan(row, item_code, barcode, batch_no, serial_no);
|
||||
} else {
|
||||
increment().then((value) => resolve(value));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
prepare_item_for_scan(row, item_code, barcode, batch_no, serial_no) {
|
||||
var me = this;
|
||||
this.dialog = new frappe.ui.Dialog({
|
||||
title: __("Scan barcode for item {0}", [item_code]),
|
||||
fields: me.get_fields_for_dialog(row, item_code, barcode, batch_no, serial_no),
|
||||
})
|
||||
|
||||
this.dialog.set_primary_action(__("Update"), () => {
|
||||
const item_data = {item_code: item_code};
|
||||
item_data[this.qty_field] = this.dialog.get_value("scanned_qty");
|
||||
item_data["has_item_scanned"] = 1;
|
||||
|
||||
this.remaining_qty = flt(this.dialog.get_value("qty")) - flt(this.dialog.get_value("scanned_qty"));
|
||||
frappe.model.set_value(row.doctype, row.name, item_data);
|
||||
|
||||
frappe.run_serially([
|
||||
() => this.set_batch_no(row, this.dialog.get_value("batch_no")),
|
||||
() => this.set_barcode(row, this.dialog.get_value("barcode")),
|
||||
() => this.set_serial_no(row, this.dialog.get_value("serial_no")),
|
||||
() => this.add_child_for_remaining_qty(row),
|
||||
() => this.clean_up()
|
||||
]);
|
||||
|
||||
this.dialog.hide();
|
||||
});
|
||||
|
||||
this.dialog.show();
|
||||
|
||||
this.$scan_btn = this.dialog.$wrapper.find(".link-btn");
|
||||
this.$scan_btn.css("display", "inline");
|
||||
}
|
||||
|
||||
get_fields_for_dialog(row, item_code, barcode, batch_no, serial_no) {
|
||||
let fields = [
|
||||
{
|
||||
fieldtype: "Data",
|
||||
fieldname: "barcode_scanner",
|
||||
options: "Barcode",
|
||||
label: __("Scan Barcode"),
|
||||
onchange: (e) => {
|
||||
if (!e) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.target.value) {
|
||||
this.scan_api_call(e.target.value, (r) => {
|
||||
if (r.message) {
|
||||
this.update_dialog_values(item_code, r);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
fieldtype: "Section Break",
|
||||
},
|
||||
{
|
||||
fieldtype: "Float",
|
||||
fieldname: "qty",
|
||||
label: __("Quantity to Scan"),
|
||||
default: row[this.qty_field] || 1,
|
||||
},
|
||||
{
|
||||
fieldtype: "Column Break",
|
||||
fieldname: "column_break_1",
|
||||
},
|
||||
{
|
||||
fieldtype: "Float",
|
||||
read_only: 1,
|
||||
fieldname: "scanned_qty",
|
||||
label: __("Scanned Quantity"),
|
||||
default: 1,
|
||||
},
|
||||
{
|
||||
fieldtype: "Section Break",
|
||||
}
|
||||
]
|
||||
|
||||
if (batch_no) {
|
||||
fields.push({
|
||||
fieldtype: "Link",
|
||||
fieldname: "batch_no",
|
||||
options: "Batch No",
|
||||
label: __("Batch No"),
|
||||
default: batch_no,
|
||||
read_only: 1,
|
||||
hidden: 1
|
||||
});
|
||||
}
|
||||
|
||||
if (serial_no) {
|
||||
fields.push({
|
||||
fieldtype: "Small Text",
|
||||
fieldname: "serial_no",
|
||||
label: __("Serial Nos"),
|
||||
default: serial_no,
|
||||
read_only: 1,
|
||||
});
|
||||
}
|
||||
|
||||
if (barcode) {
|
||||
fields.push({
|
||||
fieldtype: "Data",
|
||||
fieldname: "barcode",
|
||||
options: "Barcode",
|
||||
label: __("Barcode"),
|
||||
default: barcode,
|
||||
read_only: 1,
|
||||
hidden: 1
|
||||
});
|
||||
}
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
update_dialog_values(scanned_item, r) {
|
||||
const {item_code, barcode, batch_no, serial_no} = r.message;
|
||||
|
||||
this.dialog.set_value("barcode_scanner", "");
|
||||
if (item_code === scanned_item &&
|
||||
(this.dialog.get_value("barcode") === barcode || batch_no || serial_no)) {
|
||||
|
||||
if (batch_no) {
|
||||
this.dialog.set_value("batch_no", batch_no);
|
||||
}
|
||||
|
||||
if (serial_no) {
|
||||
|
||||
this.validate_duplicate_serial_no(serial_no);
|
||||
let serial_nos = this.dialog.get_value("serial_no") + "\n" + serial_no;
|
||||
this.dialog.set_value("serial_no", serial_nos);
|
||||
}
|
||||
|
||||
let qty = flt(this.dialog.get_value("scanned_qty")) + 1.0;
|
||||
this.dialog.set_value("scanned_qty", qty);
|
||||
}
|
||||
}
|
||||
|
||||
validate_duplicate_serial_no(serial_no) {
|
||||
let serial_nos = this.dialog.get_value("serial_no") ?
|
||||
this.dialog.get_value("serial_no").split("\n") : [];
|
||||
|
||||
if (in_list(serial_nos, serial_no)) {
|
||||
frappe.throw(__("Serial No {0} already scanned", [serial_no]));
|
||||
}
|
||||
}
|
||||
|
||||
add_child_for_remaining_qty(prev_row) {
|
||||
if (this.remaining_qty && this.remaining_qty >0) {
|
||||
let cur_grid = this.frm.fields_dict[this.items_table_name].grid;
|
||||
let row = frappe.model.add_child(this.frm.doc, cur_grid.doctype, this.items_table_name);
|
||||
|
||||
let ignore_fields = ["name", "idx", "batch_no", "barcode",
|
||||
"received_qty", "serial_no", "has_item_scanned"];
|
||||
|
||||
for (let key in prev_row) {
|
||||
if (in_list(ignore_fields, key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
row[key] = prev_row[key];
|
||||
}
|
||||
|
||||
row[this.qty_field] = this.remaining_qty;
|
||||
if (this.qty_field == "qty" && frappe.meta.has_field(row.doctype, "stock_qty")) {
|
||||
row["stock_qty"] = this.remaining_qty * row.conversion_factor;
|
||||
}
|
||||
|
||||
this.frm.script_manager.trigger("item_code", row.doctype, row.name);
|
||||
}
|
||||
}
|
||||
|
||||
async set_serial_no(row, serial_no) {
|
||||
if (serial_no && frappe.meta.has_field(row.doctype, this.serial_no_field)) {
|
||||
const existing_serial_nos = row[this.serial_no_field];
|
||||
@@ -193,7 +388,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
||||
return is_duplicate;
|
||||
}
|
||||
|
||||
get_row_to_modify_on_scan(item_code, batch_no, uom) {
|
||||
get_row_to_modify_on_scan(item_code, batch_no, uom, barcode) {
|
||||
let cur_grid = this.frm.fields_dict[this.items_table_name].grid;
|
||||
|
||||
// Check if batch is scanned and table has batch no field
|
||||
@@ -202,12 +397,14 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
||||
|
||||
const matching_row = (row) => {
|
||||
const item_match = row.item_code == item_code;
|
||||
const batch_match = row[this.batch_no_field] == batch_no;
|
||||
const batch_match = (!row[this.batch_no_field] || row[this.batch_no_field] == batch_no);
|
||||
const uom_match = !uom || row[this.uom_field] == uom;
|
||||
const qty_in_limit = flt(row[this.qty_field]) < flt(row[this.max_qty_field]);
|
||||
const item_scanned = row.has_item_scanned;
|
||||
|
||||
return item_match
|
||||
&& uom_match
|
||||
&& !item_scanned
|
||||
&& (!is_batch_no_scan || batch_match)
|
||||
&& (!check_max_qty || qty_in_limit)
|
||||
}
|
||||
@@ -219,6 +416,14 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
||||
return this.items_table.find((d) => !d.item_code);
|
||||
}
|
||||
|
||||
play_success_sound() {
|
||||
this.success_sound && frappe.utils.play_sound(this.success_sound);
|
||||
}
|
||||
|
||||
play_fail_sound() {
|
||||
this.fail_sound && frappe.utils.play_sound(this.fail_sound);
|
||||
}
|
||||
|
||||
clean_up() {
|
||||
this.scan_barcode_field.set_value("");
|
||||
refresh_field(this.items_table_name);
|
||||
|
||||
@@ -6,7 +6,7 @@ import json
|
||||
import frappe
|
||||
import frappe.permissions
|
||||
from frappe.core.doctype.user_permission.test_user_permission import create_user
|
||||
from frappe.tests.utils import FrappeTestCase
|
||||
from frappe.tests.utils import FrappeTestCase, change_settings
|
||||
from frappe.utils import add_days, flt, getdate, nowdate, today
|
||||
|
||||
from erpnext.controllers.accounts_controller import update_child_qty_rate
|
||||
@@ -1346,6 +1346,33 @@ class TestSalesOrder(FrappeTestCase):
|
||||
|
||||
self.assertRaises(frappe.LinkExistsError, so_doc.cancel)
|
||||
|
||||
@change_settings("Accounts Settings", {"unlink_advance_payment_on_cancelation_of_order": 1})
|
||||
def test_advance_paid_upon_payment_cancellation(self):
|
||||
from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
|
||||
|
||||
so = make_sales_order()
|
||||
|
||||
pe = get_payment_entry("Sales Order", so.name, bank_account="_Test Bank - _TC")
|
||||
pe.reference_no = "1"
|
||||
pe.reference_date = nowdate()
|
||||
pe.paid_from_account_currency = so.currency
|
||||
pe.paid_to_account_currency = so.currency
|
||||
pe.source_exchange_rate = 1
|
||||
pe.target_exchange_rate = 1
|
||||
pe.paid_amount = so.grand_total
|
||||
pe.save(ignore_permissions=True)
|
||||
pe.submit()
|
||||
so.reload()
|
||||
|
||||
self.assertEqual(so.advance_paid, so.base_grand_total)
|
||||
|
||||
# cancel advance payment
|
||||
pe.reload()
|
||||
pe.cancel()
|
||||
|
||||
so.reload()
|
||||
self.assertEqual(so.advance_paid, 0)
|
||||
|
||||
def test_cancel_sales_order_after_cancel_payment_entry(self):
|
||||
from erpnext.accounts.doctype.payment_entry.test_payment_entry import get_payment_entry
|
||||
|
||||
@@ -1747,6 +1774,69 @@ class TestSalesOrder(FrappeTestCase):
|
||||
sales_order.save()
|
||||
self.assertEqual(sales_order.taxes[0].tax_amount, 0)
|
||||
|
||||
def test_sales_order_partial_advance_payment(self):
|
||||
from erpnext.accounts.doctype.payment_entry.test_payment_entry import (
|
||||
create_payment_entry,
|
||||
get_payment_entry,
|
||||
)
|
||||
from erpnext.selling.doctype.customer.test_customer import get_customer_dict
|
||||
|
||||
# Make a customer
|
||||
customer = get_customer_dict("QA Logistics")
|
||||
frappe.get_doc(customer).insert()
|
||||
|
||||
# Make a Sales Order
|
||||
so = make_sales_order(
|
||||
customer="QA Logistics",
|
||||
item_list=[
|
||||
{"item_code": "_Test Item", "qty": 1, "rate": 200},
|
||||
{"item_code": "_Test Item 2", "qty": 1, "rate": 300},
|
||||
],
|
||||
)
|
||||
|
||||
# Create a advance payment against that Sales Order
|
||||
pe = get_payment_entry("Sales Order", so.name, bank_account="_Test Bank - _TC")
|
||||
pe.reference_no = "1"
|
||||
pe.reference_date = nowdate()
|
||||
pe.paid_from_account_currency = so.currency
|
||||
pe.paid_to_account_currency = so.currency
|
||||
pe.source_exchange_rate = 1
|
||||
pe.target_exchange_rate = 1
|
||||
pe.paid_amount = so.grand_total
|
||||
pe.save(ignore_permissions=True)
|
||||
pe.submit()
|
||||
|
||||
# Make standalone advance payment entry
|
||||
create_payment_entry(
|
||||
payment_type="Receive",
|
||||
party_type="Customer",
|
||||
party="QA Logistics",
|
||||
paid_from="Debtors - _TC",
|
||||
paid_to="_Test Bank - _TC",
|
||||
save=1,
|
||||
submit=1,
|
||||
)
|
||||
|
||||
si = make_sales_invoice(so.name)
|
||||
|
||||
item = si.get("items")[1]
|
||||
si.remove(item)
|
||||
|
||||
si.allocate_advances_automatically = 1
|
||||
si.save()
|
||||
|
||||
self.assertEqual(len(si.get("advances")), 1)
|
||||
self.assertEqual(si.get("advances")[0].allocated_amount, 200)
|
||||
self.assertEqual(si.get("advances")[0].reference_name, pe.name)
|
||||
|
||||
si.submit()
|
||||
pe.load_from_db()
|
||||
|
||||
self.assertEqual(pe.references[0].reference_name, si.name)
|
||||
self.assertEqual(pe.references[0].allocated_amount, 200)
|
||||
self.assertEqual(pe.references[1].reference_name, so.name)
|
||||
self.assertEqual(pe.references[1].allocated_amount, 300)
|
||||
|
||||
|
||||
def automatically_fetch_payment_terms(enable=1):
|
||||
accounts_settings = frappe.get_doc("Accounts Settings")
|
||||
|
||||
@@ -67,7 +67,7 @@ erpnext.PointOfSale.Controller = class {
|
||||
{
|
||||
fieldtype: 'Link', label: __('POS Profile'),
|
||||
options: 'POS Profile', fieldname: 'pos_profile', reqd: 1,
|
||||
get_query: () => pos_profile_query,
|
||||
get_query: () => pos_profile_query(),
|
||||
onchange: () => fetch_pos_payment_methods()
|
||||
},
|
||||
{
|
||||
@@ -101,9 +101,11 @@ erpnext.PointOfSale.Controller = class {
|
||||
primary_action_label: __('Submit')
|
||||
});
|
||||
dialog.show();
|
||||
const pos_profile_query = {
|
||||
query: 'erpnext.accounts.doctype.pos_profile.pos_profile.pos_profile_query',
|
||||
filters: { company: dialog.fields_dict.company.get_value() }
|
||||
const pos_profile_query = () => {
|
||||
return {
|
||||
query: 'erpnext.accounts.doctype.pos_profile.pos_profile.pos_profile_query',
|
||||
filters: { company: dialog.fields_dict.company.get_value() }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -313,11 +313,13 @@ class Analytics(object):
|
||||
|
||||
def get_period(self, posting_date):
|
||||
if self.filters.range == "Weekly":
|
||||
period = "Week " + str(posting_date.isocalendar()[1]) + " " + str(posting_date.year)
|
||||
period = _("Week {0} {1}").format(str(posting_date.isocalendar()[1]), str(posting_date.year))
|
||||
elif self.filters.range == "Monthly":
|
||||
period = str(self.months[posting_date.month - 1]) + " " + str(posting_date.year)
|
||||
period = _(str(self.months[posting_date.month - 1])) + " " + str(posting_date.year)
|
||||
elif self.filters.range == "Quarterly":
|
||||
period = "Quarter " + str(((posting_date.month - 1) // 3) + 1) + " " + str(posting_date.year)
|
||||
period = _("Quarter {0} {1}").format(
|
||||
str(((posting_date.month - 1) // 3) + 1), str(posting_date.year)
|
||||
)
|
||||
else:
|
||||
year = get_fiscal_year(posting_date, company=self.filters.company)
|
||||
period = str(year[0])
|
||||
|
||||
@@ -291,7 +291,7 @@ def get_batch_no(item_code, warehouse, qty=1, throw=False, serial_no=None):
|
||||
batches = get_batches(item_code, warehouse, qty, throw, serial_no)
|
||||
|
||||
for batch in batches:
|
||||
if cint(qty) <= cint(batch.qty):
|
||||
if flt(qty) <= flt(batch.qty):
|
||||
batch_no = batch.batch_id
|
||||
break
|
||||
|
||||
|
||||
@@ -1050,9 +1050,22 @@ class TestDeliveryNote(FrappeTestCase):
|
||||
do_not_submit=True,
|
||||
)
|
||||
|
||||
dn.append(
|
||||
"taxes",
|
||||
{
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": "_Test Account Service Tax - _TC",
|
||||
"description": "Tax 1",
|
||||
"rate": 14,
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"included_in_print_rate": 1,
|
||||
},
|
||||
)
|
||||
|
||||
self.assertEqual(dn.items[0].rate, 500) # haven't saved yet
|
||||
dn.save()
|
||||
self.assertEqual(dn.ignore_pricing_rule, 1)
|
||||
self.assertEqual(dn.taxes[0].included_in_print_rate, 0)
|
||||
|
||||
# rate should reset to incoming rate
|
||||
self.assertEqual(dn.items[0].rate, rate)
|
||||
@@ -1063,6 +1076,7 @@ class TestDeliveryNote(FrappeTestCase):
|
||||
dn.save()
|
||||
|
||||
self.assertEqual(dn.items[0].rate, rate)
|
||||
self.assertEqual(dn.items[0].net_rate, rate)
|
||||
|
||||
def test_internal_transfer_precision_gle(self):
|
||||
from erpnext.selling.doctype.customer.test_customer import create_internal_customer
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"barcode",
|
||||
"has_item_scanned",
|
||||
"item_code",
|
||||
"item_name",
|
||||
"col_break1",
|
||||
@@ -809,13 +810,21 @@
|
||||
"label": "Purchase Order Item",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"depends_on": "barcode",
|
||||
"fieldname": "has_item_scanned",
|
||||
"fieldtype": "Check",
|
||||
"label": "Has Item Scanned",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
"index_web_pages_for_search": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2022-10-26 16:05:17.720768",
|
||||
"modified": "2022-11-02 12:54:07.225623",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Delivery Note Item",
|
||||
|
||||
@@ -590,6 +590,7 @@ class TestMaterialRequest(FrappeTestCase):
|
||||
mr = frappe.copy_doc(test_records[0])
|
||||
mr.material_request_type = "Material Issue"
|
||||
mr.submit()
|
||||
frappe.db.value_cache = {}
|
||||
|
||||
# testing bin value after material request is submitted
|
||||
self.assertEqual(_get_requested_qty(), existing_requested_qty - 54.0)
|
||||
|
||||
@@ -10,6 +10,8 @@ import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.model.mapper import map_child_doc
|
||||
from frappe.query_builder import Case
|
||||
from frappe.query_builder.functions import Locate
|
||||
from frappe.utils import cint, floor, flt, today
|
||||
from frappe.utils.nestedset import get_descendants_of
|
||||
|
||||
@@ -686,31 +688,22 @@ def create_stock_entry(pick_list):
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_pending_work_orders(doctype, txt, searchfield, start, page_length, filters, as_dict):
|
||||
return frappe.db.sql(
|
||||
"""
|
||||
SELECT
|
||||
`name`, `company`, `planned_start_date`
|
||||
FROM
|
||||
`tabWork Order`
|
||||
WHERE
|
||||
`status` not in ('Completed', 'Stopped')
|
||||
AND `qty` > `material_transferred_for_manufacturing`
|
||||
AND `docstatus` = 1
|
||||
AND `company` = %(company)s
|
||||
AND `name` like %(txt)s
|
||||
ORDER BY
|
||||
(case when locate(%(_txt)s, name) > 0 then locate(%(_txt)s, name) else 99999 end) name
|
||||
LIMIT
|
||||
%(start)s, %(page_length)s""",
|
||||
{
|
||||
"txt": "%%%s%%" % txt,
|
||||
"_txt": txt.replace("%", ""),
|
||||
"start": start,
|
||||
"page_length": frappe.utils.cint(page_length),
|
||||
"company": filters.get("company"),
|
||||
},
|
||||
as_dict=as_dict,
|
||||
)
|
||||
wo = frappe.qb.DocType("Work Order")
|
||||
return (
|
||||
frappe.qb.from_(wo)
|
||||
.select(wo.name, wo.company, wo.planned_start_date)
|
||||
.where(
|
||||
(wo.status.notin(["Completed", "Stopped"]))
|
||||
& (wo.qty > wo.material_transferred_for_manufacturing)
|
||||
& (wo.docstatus == 1)
|
||||
& (wo.company == filters.get("company"))
|
||||
& (wo.name.like("%{0}%".format(txt)))
|
||||
)
|
||||
.orderby(Case().when(Locate(txt, wo.name) > 0, Locate(txt, wo.name)).else_(99999))
|
||||
.orderby(wo.name)
|
||||
.limit(cint(page_length))
|
||||
.offset(start)
|
||||
).run(as_dict=as_dict)
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"barcode",
|
||||
"has_item_scanned",
|
||||
"section_break_2",
|
||||
"item_code",
|
||||
"product_bundle",
|
||||
@@ -996,12 +997,20 @@
|
||||
{
|
||||
"fieldname": "column_break_102",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"depends_on": "barcode",
|
||||
"fieldname": "has_item_scanned",
|
||||
"fieldtype": "Check",
|
||||
"label": "Has Item Scanned",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2022-10-26 16:06:02.524435",
|
||||
"modified": "2022-11-02 12:49:28.746701",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Purchase Receipt Item",
|
||||
|
||||
@@ -3,7 +3,6 @@ frappe.listview_settings['Stock Entry'] = {
|
||||
"`tabStock Entry`.`purpose`", "`tabStock Entry`.`work_order`", "`tabStock Entry`.`bom_no`",
|
||||
"`tabStock Entry`.`is_return`"],
|
||||
get_indicator: function (doc) {
|
||||
debugger
|
||||
if(doc.is_return===1 && doc.purpose === "Material Transfer for Manufacture") {
|
||||
return [__("Material Returned from WIP"), "orange",
|
||||
"is_return,=,1|purpose,=,Material Transfer for Manufacture|docstatus,<,2"];
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"barcode",
|
||||
"has_item_scanned",
|
||||
"section_break_2",
|
||||
"s_warehouse",
|
||||
"col_break1",
|
||||
@@ -498,14 +499,14 @@
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "sco_rm_detail",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"label": "SCO Supplied Item",
|
||||
"no_copy": 1,
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
"fieldname": "sco_rm_detail",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"label": "SCO Supplied Item",
|
||||
"no_copy": 1,
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"depends_on": "eval:parent.purpose===\"Repack\" && doc.t_warehouse",
|
||||
@@ -563,13 +564,21 @@
|
||||
"fieldname": "is_process_loss",
|
||||
"fieldtype": "Check",
|
||||
"label": "Is Process Loss"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"depends_on": "barcode",
|
||||
"fieldname": "has_item_scanned",
|
||||
"fieldtype": "Check",
|
||||
"label": "Has Item Scanned",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
"index_web_pages_for_search": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2022-06-17 05:06:33.621264",
|
||||
"modified": "2022-11-02 13:00:34.258828",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Stock Entry Detail",
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"barcode",
|
||||
"has_item_scanned",
|
||||
"item_code",
|
||||
"item_name",
|
||||
"warehouse",
|
||||
@@ -177,11 +178,18 @@
|
||||
"label": "Allow Zero Valuation Rate",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "barcode",
|
||||
"fieldname": "has_item_scanned",
|
||||
"fieldtype": "Data",
|
||||
"label": "Has Item Scanned",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2022-04-02 04:19:40.380587",
|
||||
"modified": "2022-11-02 13:01:23.580937",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Stock Reconciliation Item",
|
||||
|
||||
@@ -198,11 +198,11 @@ def setup_ageing_columns(filters: Filters, range_columns: List):
|
||||
f"0 - {filters['range1']}",
|
||||
f"{cint(filters['range1']) + 1} - {cint(filters['range2'])}",
|
||||
f"{cint(filters['range2']) + 1} - {cint(filters['range3'])}",
|
||||
f"{cint(filters['range3']) + 1} - {_('Above')}",
|
||||
_("{0} - Above").format(cint(filters["range3"]) + 1),
|
||||
]
|
||||
for i, label in enumerate(ranges):
|
||||
fieldname = "range" + str(i + 1)
|
||||
add_column(range_columns, label=f"Age ({label})", fieldname=fieldname)
|
||||
add_column(range_columns, label=_("Age ({0})").format(label), fieldname=fieldname)
|
||||
|
||||
|
||||
def add_column(
|
||||
|
||||
@@ -114,11 +114,13 @@ def get_period(posting_date, filters):
|
||||
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
||||
|
||||
if filters.range == "Weekly":
|
||||
period = "Week " + str(posting_date.isocalendar()[1]) + " " + str(posting_date.year)
|
||||
period = _("Week {0} {1}").format(str(posting_date.isocalendar()[1]), str(posting_date.year))
|
||||
elif filters.range == "Monthly":
|
||||
period = str(months[posting_date.month - 1]) + " " + str(posting_date.year)
|
||||
period = _(str(months[posting_date.month - 1])) + " " + str(posting_date.year)
|
||||
elif filters.range == "Quarterly":
|
||||
period = "Quarter " + str(((posting_date.month - 1) // 3) + 1) + " " + str(posting_date.year)
|
||||
period = _("Quarter {0} {1}").format(
|
||||
str(((posting_date.month - 1) // 3) + 1), str(posting_date.year)
|
||||
)
|
||||
else:
|
||||
year = get_fiscal_year(posting_date, company=filters.company)
|
||||
period = str(year[2])
|
||||
|
||||
@@ -91,8 +91,8 @@ def get_columns(filters):
|
||||
columns = [
|
||||
_("Item") + ":Link/Item:180",
|
||||
_("Item Group") + "::100",
|
||||
_("Value") + ":Currency:100",
|
||||
_("Age") + ":Float:60",
|
||||
_("Value") + ":Currency:120",
|
||||
_("Age") + ":Float:80",
|
||||
]
|
||||
return columns
|
||||
|
||||
@@ -123,7 +123,7 @@ def get_warehouse_list(filters):
|
||||
|
||||
def add_warehouse_column(columns, warehouse_list):
|
||||
if len(warehouse_list) > 1:
|
||||
columns += [_("Total Qty") + ":Int:50"]
|
||||
columns += [_("Total Qty") + ":Int:90"]
|
||||
|
||||
for wh in warehouse_list:
|
||||
columns += [_(wh.name) + ":Int:54"]
|
||||
columns += [_(wh.name) + ":Int:120"]
|
||||
|
||||
@@ -57,6 +57,18 @@ frappe.ui.form.on('Subcontracting Receipt', {
|
||||
filters: { 'company': frm.doc.company }
|
||||
};
|
||||
});
|
||||
|
||||
frappe.db.get_single_value('Buying Settings', 'backflush_raw_materials_of_subcontract_based_on').then(val => {
|
||||
if (val == 'Material Transferred for Subcontract') {
|
||||
frm.fields_dict['supplied_items'].grid.grid_rows.forEach((grid_row) => {
|
||||
grid_row.docfields.forEach((df) => {
|
||||
if (df.fieldname == 'consumed_qty') {
|
||||
df.read_only = 0;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
refresh: (frm) => {
|
||||
|
||||
@@ -57,6 +57,8 @@ class SubcontractingReceipt(SubcontractingController):
|
||||
|
||||
def before_validate(self):
|
||||
super(SubcontractingReceipt, self).before_validate()
|
||||
self.set_items_bom()
|
||||
self.set_received_qty()
|
||||
self.set_items_cost_center()
|
||||
self.set_items_expense_account()
|
||||
|
||||
@@ -193,6 +195,28 @@ class SubcontractingReceipt(SubcontractingController):
|
||||
).format(item.idx)
|
||||
)
|
||||
|
||||
def set_items_bom(self):
|
||||
if self.is_return:
|
||||
for item in self.items:
|
||||
if not item.bom:
|
||||
item.bom = frappe.db.get_value(
|
||||
"Subcontracting Receipt Item",
|
||||
{"name": item.subcontracting_receipt_item, "parent": self.return_against},
|
||||
"bom",
|
||||
)
|
||||
else:
|
||||
for item in self.items:
|
||||
if not item.bom:
|
||||
item.bom = frappe.db.get_value(
|
||||
"Subcontracting Order Item",
|
||||
{"name": item.subcontracting_order_item, "parent": item.subcontracting_order},
|
||||
"bom",
|
||||
)
|
||||
|
||||
def set_received_qty(self):
|
||||
for item in self.items:
|
||||
item.received_qty = flt(item.qty) + flt(item.rejected_qty)
|
||||
|
||||
def set_items_cost_center(self):
|
||||
if self.company:
|
||||
cost_center = frappe.get_cached_value("Company", self.company, "cost_center")
|
||||
|
||||
@@ -327,7 +327,7 @@ class TestSubcontractingReceipt(FrappeTestCase):
|
||||
for row in scr.supplied_items:
|
||||
self.assertEqual(transferred_batch.get(row.batch_no), row.consumed_qty)
|
||||
|
||||
def test_subcontracting_order_partial_return(self):
|
||||
def test_subcontracting_receipt_partial_return(self):
|
||||
sco = get_subcontracting_order()
|
||||
rm_items = get_rm_items(sco.supplied_items)
|
||||
itemwise_details = make_stock_in_entry(rm_items=rm_items)
|
||||
@@ -343,15 +343,17 @@ class TestSubcontractingReceipt(FrappeTestCase):
|
||||
scr1_return = make_return_subcontracting_receipt(scr_name=scr1.name, qty=-3)
|
||||
scr1.load_from_db()
|
||||
self.assertEqual(scr1_return.status, "Return")
|
||||
self.assertIsNotNone(scr1_return.items[0].bom)
|
||||
self.assertEqual(scr1.items[0].returned_qty, 3)
|
||||
|
||||
scr2_return = make_return_subcontracting_receipt(scr_name=scr1.name, qty=-7)
|
||||
scr1.load_from_db()
|
||||
self.assertEqual(scr2_return.status, "Return")
|
||||
self.assertIsNotNone(scr2_return.items[0].bom)
|
||||
self.assertEqual(scr1.status, "Return Issued")
|
||||
self.assertEqual(scr1.items[0].returned_qty, 10)
|
||||
|
||||
def test_subcontracting_order_over_return(self):
|
||||
def test_subcontracting_receipt_over_return(self):
|
||||
sco = get_subcontracting_order()
|
||||
rm_items = get_rm_items(sco.supplied_items)
|
||||
itemwise_details = make_stock_in_entry(rm_items=rm_items)
|
||||
@@ -402,8 +404,8 @@ class TestSubcontractingReceipt(FrappeTestCase):
|
||||
"stock_value_difference",
|
||||
)
|
||||
|
||||
# Service Cost(100 * 10) + Raw Materials Cost(50 * 10) + Additional Costs(100) = 1600
|
||||
self.assertEqual(stock_value_difference, 1600)
|
||||
# Service Cost(100 * 10) + Raw Materials Cost(100 * 10) + Additional Costs(10 * 10) = 2100
|
||||
self.assertEqual(stock_value_difference, 2100)
|
||||
self.assertFalse(get_gl_entries("Subcontracting Receipt", scr.name))
|
||||
|
||||
def test_subcontracting_receipt_gl_entry(self):
|
||||
@@ -466,6 +468,65 @@ class TestSubcontractingReceipt(FrappeTestCase):
|
||||
scr.cancel()
|
||||
self.assertTrue(get_gl_entries("Subcontracting Receipt", scr.name))
|
||||
|
||||
def test_supplied_items_consumed_qty(self):
|
||||
# Set Backflush Based On as "Material Transferred for Subcontracting" to transfer RM's more than the required qty
|
||||
set_backflush_based_on("Material Transferred for Subcontract")
|
||||
|
||||
# Create Material Receipt for RM's
|
||||
make_stock_entry(
|
||||
item_code="_Test Item", qty=100, target="_Test Warehouse 1 - _TC", basic_rate=100
|
||||
)
|
||||
make_stock_entry(
|
||||
item_code="_Test Item Home Desktop 100",
|
||||
qty=100,
|
||||
target="_Test Warehouse 1 - _TC",
|
||||
basic_rate=100,
|
||||
)
|
||||
|
||||
service_items = [
|
||||
{
|
||||
"warehouse": "_Test Warehouse - _TC",
|
||||
"item_code": "Subcontracted Service Item 1",
|
||||
"qty": 10,
|
||||
"rate": 100,
|
||||
"fg_item": "_Test FG Item",
|
||||
"fg_item_qty": 10,
|
||||
},
|
||||
]
|
||||
|
||||
# Create Subcontracting Order
|
||||
sco = get_subcontracting_order(service_items=service_items)
|
||||
|
||||
# Transfer RM's
|
||||
rm_items = get_rm_items(sco.supplied_items)
|
||||
rm_items[0]["qty"] = 20 # Extra 10 Qty
|
||||
itemwise_details = make_stock_in_entry(rm_items=rm_items)
|
||||
make_stock_transfer_entry(
|
||||
sco_no=sco.name,
|
||||
rm_items=rm_items,
|
||||
itemwise_details=copy.deepcopy(itemwise_details),
|
||||
)
|
||||
|
||||
# Create Subcontracting Receipt
|
||||
scr = make_subcontracting_receipt(sco.name)
|
||||
scr.rejected_warehouse = "_Test Warehouse 1 - _TC"
|
||||
|
||||
scr.items[0].qty = 5 # Accepted Qty
|
||||
scr.items[0].rejected_qty = 3
|
||||
scr.save()
|
||||
|
||||
# consumed_qty should be ((received_qty) * (transfered_qty / qty)) = ((5 + 3) * (20 / 10)) = 16
|
||||
self.assertEqual(scr.supplied_items[0].consumed_qty, 16)
|
||||
|
||||
# Set Backflush Based On as "BOM"
|
||||
set_backflush_based_on("BOM")
|
||||
|
||||
scr.items[0].rejected_qty = 4
|
||||
scr.save()
|
||||
|
||||
# consumed_qty should be ((received_qty) * (qty_consumed_per_unit)) = ((5 + 4) * (1)) = 9
|
||||
self.assertEqual(scr.supplied_items[0].consumed_qty, 9)
|
||||
|
||||
|
||||
def make_return_subcontracting_receipt(**args):
|
||||
args = frappe._dict(args)
|
||||
|
||||
@@ -1,207 +1,208 @@
|
||||
{
|
||||
"actions": [],
|
||||
"creation": "2022-04-18 10:45:16.538479",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"main_item_code",
|
||||
"rm_item_code",
|
||||
"item_name",
|
||||
"bom_detail_no",
|
||||
"col_break1",
|
||||
"description",
|
||||
"stock_uom",
|
||||
"conversion_factor",
|
||||
"reference_name",
|
||||
"secbreak_1",
|
||||
"rate",
|
||||
"col_break2",
|
||||
"amount",
|
||||
"secbreak_2",
|
||||
"available_qty_for_consumption",
|
||||
"required_qty",
|
||||
"col_break3",
|
||||
"consumed_qty",
|
||||
"current_stock",
|
||||
"secbreak_3",
|
||||
"batch_no",
|
||||
"col_break4",
|
||||
"serial_no",
|
||||
"subcontracting_order"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "main_item_code",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Item Code",
|
||||
"options": "Item",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "rm_item_code",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Raw Material Item Code",
|
||||
"options": "Item",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Text Editor",
|
||||
"in_global_search": 1,
|
||||
"label": "Description",
|
||||
"print_width": "300px",
|
||||
"read_only": 1,
|
||||
"width": "300px"
|
||||
},
|
||||
{
|
||||
"fieldname": "batch_no",
|
||||
"fieldtype": "Link",
|
||||
"label": "Batch No",
|
||||
"no_copy": 1,
|
||||
"options": "Batch"
|
||||
},
|
||||
{
|
||||
"fieldname": "serial_no",
|
||||
"fieldtype": "Text",
|
||||
"label": "Serial No",
|
||||
"no_copy": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "col_break1",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "required_qty",
|
||||
"fieldtype": "Float",
|
||||
"label": "Required Qty",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"columns": 2,
|
||||
"fieldname": "consumed_qty",
|
||||
"fieldtype": "Float",
|
||||
"in_list_view": 1,
|
||||
"label": "Consumed Qty",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "stock_uom",
|
||||
"fieldtype": "Link",
|
||||
"label": "Stock Uom",
|
||||
"options": "UOM",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "rate",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Rate",
|
||||
"options": "Company:company:default_currency",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "amount",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Amount",
|
||||
"options": "Company:company:default_currency",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "1",
|
||||
"fieldname": "conversion_factor",
|
||||
"fieldtype": "Float",
|
||||
"hidden": 1,
|
||||
"label": "Conversion Factor",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "current_stock",
|
||||
"fieldtype": "Float",
|
||||
"in_list_view": 1,
|
||||
"label": "Current Stock",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "reference_name",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"in_list_view": 1,
|
||||
"label": "Reference Name",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "bom_detail_no",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"in_list_view": 1,
|
||||
"label": "BOM Detail No",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "secbreak_1",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "col_break2",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "secbreak_2",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "col_break3",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "secbreak_3",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "col_break4",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "item_name",
|
||||
"fieldtype": "Data",
|
||||
"label": "Item Name",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "subcontracting_order",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 1,
|
||||
"label": "Subcontracting Order",
|
||||
"no_copy": 1,
|
||||
"options": "Subcontracting Order",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "available_qty_for_consumption",
|
||||
"fieldtype": "Float",
|
||||
"in_list_view": 1,
|
||||
"label": "Available Qty For Consumption",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2022-09-02 22:28:53.392381",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Subcontracting",
|
||||
"name": "Subcontracting Receipt Supplied Item",
|
||||
"naming_rule": "Autoincrement",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"track_changes": 1
|
||||
"actions": [],
|
||||
"creation": "2022-04-18 10:45:16.538479",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"main_item_code",
|
||||
"rm_item_code",
|
||||
"item_name",
|
||||
"bom_detail_no",
|
||||
"col_break1",
|
||||
"description",
|
||||
"stock_uom",
|
||||
"conversion_factor",
|
||||
"reference_name",
|
||||
"secbreak_1",
|
||||
"rate",
|
||||
"col_break2",
|
||||
"amount",
|
||||
"secbreak_2",
|
||||
"available_qty_for_consumption",
|
||||
"required_qty",
|
||||
"col_break3",
|
||||
"consumed_qty",
|
||||
"current_stock",
|
||||
"secbreak_3",
|
||||
"batch_no",
|
||||
"col_break4",
|
||||
"serial_no",
|
||||
"subcontracting_order"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "main_item_code",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Item Code",
|
||||
"options": "Item",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "rm_item_code",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Raw Material Item Code",
|
||||
"options": "Item",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Text Editor",
|
||||
"in_global_search": 1,
|
||||
"label": "Description",
|
||||
"print_width": "300px",
|
||||
"read_only": 1,
|
||||
"width": "300px"
|
||||
},
|
||||
{
|
||||
"fieldname": "batch_no",
|
||||
"fieldtype": "Link",
|
||||
"label": "Batch No",
|
||||
"no_copy": 1,
|
||||
"options": "Batch"
|
||||
},
|
||||
{
|
||||
"fieldname": "serial_no",
|
||||
"fieldtype": "Text",
|
||||
"label": "Serial No",
|
||||
"no_copy": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "col_break1",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "required_qty",
|
||||
"fieldtype": "Float",
|
||||
"label": "Required Qty",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"columns": 2,
|
||||
"fieldname": "consumed_qty",
|
||||
"fieldtype": "Float",
|
||||
"in_list_view": 1,
|
||||
"label": "Consumed Qty",
|
||||
"read_only": 1,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "stock_uom",
|
||||
"fieldtype": "Link",
|
||||
"label": "Stock Uom",
|
||||
"options": "UOM",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "rate",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Rate",
|
||||
"options": "Company:company:default_currency",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "amount",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Amount",
|
||||
"options": "Company:company:default_currency",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "1",
|
||||
"fieldname": "conversion_factor",
|
||||
"fieldtype": "Float",
|
||||
"hidden": 1,
|
||||
"label": "Conversion Factor",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "current_stock",
|
||||
"fieldtype": "Float",
|
||||
"in_list_view": 1,
|
||||
"label": "Current Stock",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "reference_name",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"in_list_view": 1,
|
||||
"label": "Reference Name",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "bom_detail_no",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"in_list_view": 1,
|
||||
"label": "BOM Detail No",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "secbreak_1",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "col_break2",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "secbreak_2",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "col_break3",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "secbreak_3",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "col_break4",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "item_name",
|
||||
"fieldtype": "Data",
|
||||
"label": "Item Name",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "subcontracting_order",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 1,
|
||||
"label": "Subcontracting Order",
|
||||
"no_copy": 1,
|
||||
"options": "Subcontracting Order",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "available_qty_for_consumption",
|
||||
"fieldtype": "Float",
|
||||
"in_list_view": 1,
|
||||
"label": "Available Qty For Consumption",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2022-11-07 17:17:21.670761",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Subcontracting",
|
||||
"name": "Subcontracting Receipt Supplied Item",
|
||||
"naming_rule": "Autoincrement",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"track_changes": 1
|
||||
}
|
||||
@@ -9873,3 +9873,35 @@ Leave Type Allocation,Zuordnung Abwesenheitsarten,
|
||||
From Lead,Aus Lead,
|
||||
From Opportunity,Aus Chance,
|
||||
Publish in Website,Auf Webseite veröffentlichen,
|
||||
Total Allocated Leave(s),Gesamte zugewiesene Urlaubstage,
|
||||
Expired Leave(s),Verfallene Urlaubstage,
|
||||
Used Leave(s),Verbrauchte Urlaubstage,
|
||||
Leave(s) Pending Approval,Urlaubstage zur Genehmigung ausstehend,
|
||||
Available Leave(s),Verfügbare Urlaubstage,
|
||||
Party Specific Item,Parteispezifischer Artikel,
|
||||
Active Customers,Aktive Kunden,
|
||||
Annual Sales,Jährlicher Umsatz,
|
||||
Total Outgoing Bills,Ausgangsrechnungen insgesamt,
|
||||
Total Incoming Bills,Eingangsrechnungen insgesamt,
|
||||
Total Incoming Payment,Zahlungseingang insgesamt,
|
||||
Total Outgoing Payment,Zahlungsausgang insgesamt,
|
||||
Incoming Bills (Purchase Invoice),Eingehende Rechnungen (Eingangsrechnung),
|
||||
Outgoing Bills (Sales Invoice),Ausgehende Rechnungen (Ausgangsrechnung),
|
||||
Accounts Receivable Ageing,Fälligkeit Forderungen,
|
||||
Accounts Payable Ageing,Fälligkeit Verbindlichkeiten,
|
||||
Budget Variance,Budgetabweichung,
|
||||
Based On Value,Basierend auf Wert,
|
||||
Restrict Items Based On,Artikel einschränken auf Basis von,
|
||||
Earnings & Deductions,Erträge & Abzüge,
|
||||
Is Process Loss,Ist Prozessverlust,
|
||||
Is Finished Item,Ist fertiger Artikel,
|
||||
Is Scrap Item,Ist Schrott,
|
||||
Issue a debit note with 0 qty against an existing Sales Invoice,Lastschrift mit Menge 0 gegen eine bestehende Ausgangsrechnung ausstellen,
|
||||
Show Remarks,Bemerkungen anzeigen,
|
||||
Website Item,Webseiten-Artikel,
|
||||
Update Property,Eigenschaft aktualisieren,
|
||||
Recurring Sales Invoice,Wiederkehrende Ausgangsrechnung,
|
||||
Total Asset,Aktiva,
|
||||
Total Liability,Verbindlichkeiten,
|
||||
Total Equity,Eigenkapital,
|
||||
Warehouse wise Stock Value,Warenwert nach Lager,
|
||||
|
||||
|
Can't render this file because it is too large.
|
Reference in New Issue
Block a user