mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-12 09:23:03 +00:00
Compare commits
215 Commits
fix/operat
...
v16.2.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6209d633c2 | ||
|
|
095fe65bef | ||
|
|
b285548a46 | ||
|
|
0b7684eccd | ||
|
|
574460c009 | ||
|
|
27fe754a7d | ||
|
|
531fe59a24 | ||
|
|
0a56647a61 | ||
|
|
c2f666b7a3 | ||
|
|
c1bbe1104e | ||
|
|
2c86327c7e | ||
|
|
31385a1f91 | ||
|
|
4f1695616a | ||
|
|
9ed3801d06 | ||
|
|
61ad67ec29 | ||
|
|
735b9da6b1 | ||
|
|
fe7a797156 | ||
|
|
f951dd180a | ||
|
|
8e871796d4 | ||
|
|
c88ee50c34 | ||
|
|
e49f6f4f09 | ||
|
|
72942e6b8c | ||
|
|
fdcf037f1b | ||
|
|
9e0c606b95 | ||
|
|
6b9f2ddf83 | ||
|
|
c1cc1dbd27 | ||
|
|
de584e2e8d | ||
|
|
75758610dd | ||
|
|
1927adbd2e | ||
|
|
7342b2551b | ||
|
|
6115f8fb9a | ||
|
|
53b73757ed | ||
|
|
dee3357da2 | ||
|
|
b1b1f25bb1 | ||
|
|
46e6096fe3 | ||
|
|
f486071cf6 | ||
|
|
b541fbbd60 | ||
|
|
41e6687b35 | ||
|
|
55ce40de37 | ||
|
|
6f21ab5d9a | ||
|
|
7c81672b36 | ||
|
|
d0faff09cb | ||
|
|
cff09b71cc | ||
|
|
b180e3b78c | ||
|
|
6ba2795043 | ||
|
|
1b9a93f90e | ||
|
|
1f1428f00a | ||
|
|
606ac2a91a | ||
|
|
9a175757ac | ||
|
|
22a8d483e1 | ||
|
|
7abaaed957 | ||
|
|
8946f12677 | ||
|
|
e9f3f0f445 | ||
|
|
ba38bc3eaf | ||
|
|
b4572978f9 | ||
|
|
bf53133f94 | ||
|
|
23c902c317 | ||
|
|
13e4849c43 | ||
|
|
f97b850077 | ||
|
|
b3e12f9acb | ||
|
|
fb3fb8ca5e | ||
|
|
e2232340dc | ||
|
|
881562fc37 | ||
|
|
dcd6279d47 | ||
|
|
041a7c5a57 | ||
|
|
27ffef41a7 | ||
|
|
9038f19fb6 | ||
|
|
264855e5e1 | ||
|
|
7120fbd14b | ||
|
|
b1716bfeef | ||
|
|
37a237dbb7 | ||
|
|
be9112b6fc | ||
|
|
2f240f3553 | ||
|
|
c7c7a55a58 | ||
|
|
30e6b5daac | ||
|
|
0b5cc039b6 | ||
|
|
6fa60d2f1a | ||
|
|
91199ea9c9 | ||
|
|
e23ba0e852 | ||
|
|
7c2bbe0d82 | ||
|
|
0a2234a814 | ||
|
|
504c84e28a | ||
|
|
bb2bada1fd | ||
|
|
ca85ee33f5 | ||
|
|
21c1189e24 | ||
|
|
7e7885b304 | ||
|
|
30238e3063 | ||
|
|
35b3045b72 | ||
|
|
cf130ff865 | ||
|
|
176096bc5b | ||
|
|
e854eafc0b | ||
|
|
72cdddbeda | ||
|
|
c9d7c6cd42 | ||
|
|
8393c3c32d | ||
|
|
5752d2e0a1 | ||
|
|
f25558b4d7 | ||
|
|
fef6df709d | ||
|
|
3ac431bd50 | ||
|
|
5d5d208a49 | ||
|
|
9535f3d583 | ||
|
|
673635e2c3 | ||
|
|
d067e37ab6 | ||
|
|
37e241ba15 | ||
|
|
fb669eb6f4 | ||
|
|
232225d753 | ||
|
|
80cbd851d1 | ||
|
|
5474ac298d | ||
|
|
7a9b10a05e | ||
|
|
621243c1d3 | ||
|
|
efa5173964 | ||
|
|
7b3f74609a | ||
|
|
775f6d07b1 | ||
|
|
e80ed14456 | ||
|
|
fe59ace285 | ||
|
|
2131c7aadb | ||
|
|
b7284c7717 | ||
|
|
6b9107c05c | ||
|
|
1ed8857d31 | ||
|
|
a195690bc8 | ||
|
|
0c546c9e5a | ||
|
|
11d9fd3dee | ||
|
|
3bdaab149b | ||
|
|
ad4ac4e53c | ||
|
|
9cc9fa59be | ||
|
|
ab2aedd9a2 | ||
|
|
686911546f | ||
|
|
4f3078ab1a | ||
|
|
a950adab79 | ||
|
|
ae6b3af013 | ||
|
|
1da8ed202b | ||
|
|
a3d860eabf | ||
|
|
adc9dc82ca | ||
|
|
79e04ea1fe | ||
|
|
0981b894dd | ||
|
|
380564a677 | ||
|
|
75deb180fb | ||
|
|
839315752b | ||
|
|
2b4a547e23 | ||
|
|
3c533d04f5 | ||
|
|
1c214eec98 | ||
|
|
aeb2b60450 | ||
|
|
1b3f5e1c96 | ||
|
|
c830bf6fc7 | ||
|
|
e2b95da24d | ||
|
|
89b44c41a2 | ||
|
|
181141b56a | ||
|
|
5742a5d86a | ||
|
|
68c8dfb24c | ||
|
|
7f54de7926 | ||
|
|
cb2d4550af | ||
|
|
c22d7e16d1 | ||
|
|
9d5a0e56a0 | ||
|
|
fcea7603a8 | ||
|
|
42ebb7446a | ||
|
|
49760e4542 | ||
|
|
6e1f4d84b6 | ||
|
|
ab482caac9 | ||
|
|
d8506fb2c0 | ||
|
|
d3dfed909e | ||
|
|
ac31c5ca19 | ||
|
|
ccab91b9ed | ||
|
|
541a8b135a | ||
|
|
c0a30a5302 | ||
|
|
accce1fe59 | ||
|
|
f04221417e | ||
|
|
c4c2d35565 | ||
|
|
f1e41f4a4f | ||
|
|
d9326d80de | ||
|
|
5c93bf5798 | ||
|
|
f62ad83d6f | ||
|
|
876e2d4e6e | ||
|
|
4977e06c50 | ||
|
|
e64ae9a8a9 | ||
|
|
6ddf4eee15 | ||
|
|
d27a09cb9f | ||
|
|
86d5939d91 | ||
|
|
768c131073 | ||
|
|
8f77223057 | ||
|
|
8ba470160d | ||
|
|
1a6264d831 | ||
|
|
19a90c0980 | ||
|
|
d57fc49896 | ||
|
|
fe0431a6d0 | ||
|
|
bfd6375508 | ||
|
|
6dade11d8f | ||
|
|
ce421bb1d4 | ||
|
|
84a749e3d0 | ||
|
|
65a1c7086b | ||
|
|
a04da71182 | ||
|
|
cbfc13728b | ||
|
|
9b88275312 | ||
|
|
332673f260 | ||
|
|
e49add20b7 | ||
|
|
c3b0633eda | ||
|
|
a660ed061b | ||
|
|
0b1c0c36b5 | ||
|
|
d316ef2306 | ||
|
|
af3a7903b3 | ||
|
|
a66e114a71 | ||
|
|
631b9d3bb0 | ||
|
|
eb03781718 | ||
|
|
eb7cebac91 | ||
|
|
3420e21d45 | ||
|
|
211832104c | ||
|
|
4b85d51257 | ||
|
|
0363b01ab7 | ||
|
|
fc517f7fa2 | ||
|
|
18451b69e6 | ||
|
|
50ce61ae02 | ||
|
|
294fb27dc8 | ||
|
|
c3fdb191b9 | ||
|
|
93db2ebd6f | ||
|
|
2925f9a04e | ||
|
|
c7bf103c0c | ||
|
|
6dead8fd85 |
2
.github/workflows/initiate_release.yml
vendored
2
.github/workflows/initiate_release.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
version: ["14", "15"]
|
||||
version: ["14", "15", "16"]
|
||||
|
||||
steps:
|
||||
- uses: octokit/request-action@v2.x
|
||||
|
||||
5
.github/workflows/patch.yml
vendored
5
.github/workflows/patch.yml
vendored
@@ -113,8 +113,8 @@ jobs:
|
||||
jq 'del(.install_apps)' ~/frappe-bench/sites/test_site/site_config.json > tmp.json
|
||||
mv tmp.json ~/frappe-bench/sites/test_site/site_config.json
|
||||
|
||||
wget https://erpnext.com/files/v13-erpnext.sql.gz
|
||||
bench --site test_site --force restore ~/frappe-bench/v13-erpnext.sql.gz
|
||||
wget https://frappe.io/files/erpnext-v14.sql.gz
|
||||
bench --site test_site --force restore ~/frappe-bench/erpnext-v14.sql.gz
|
||||
|
||||
git -C "apps/frappe" remote set-url upstream https://github.com/frappe/frappe.git
|
||||
git -C "apps/erpnext" remote set-url upstream https://github.com/frappe/erpnext.git
|
||||
@@ -142,7 +142,6 @@ jobs:
|
||||
bench --site test_site migrate
|
||||
}
|
||||
|
||||
update_to_version 14 3.11
|
||||
update_to_version 15 3.13
|
||||
|
||||
echo "Updating to latest version"
|
||||
|
||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -2,7 +2,7 @@ name: Generate Semantic Release
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- version-13
|
||||
- version-16
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"branches": ["version-13"],
|
||||
"branches": ["version-16"],
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer", {
|
||||
"preset": "angular",
|
||||
@@ -21,4 +21,4 @@
|
||||
],
|
||||
"@semantic-release/github"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils.user import is_website_user
|
||||
|
||||
__version__ = "16.0.0-dev"
|
||||
__version__ = "16.2.0"
|
||||
|
||||
|
||||
def get_default_company(user=None):
|
||||
|
||||
50
erpnext/accounts/accounts_dashboard/payments/payments.json
Normal file
50
erpnext/accounts/accounts_dashboard/payments/payments.json
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"cards": [
|
||||
{
|
||||
"card": "Total Outgoing Bills"
|
||||
},
|
||||
{
|
||||
"card": "Total Incoming Bills"
|
||||
},
|
||||
{
|
||||
"card": "Total Incoming Payment"
|
||||
},
|
||||
{
|
||||
"card": "Total Outgoing Payment"
|
||||
}
|
||||
],
|
||||
"charts": [
|
||||
{
|
||||
"chart": "Incoming Bills (Purchase Invoice)",
|
||||
"width": "Half"
|
||||
},
|
||||
{
|
||||
"chart": "Outgoing Bills (Sales Invoice)",
|
||||
"width": "Half"
|
||||
},
|
||||
{
|
||||
"chart": "Accounts Receivable Ageing",
|
||||
"width": "Half"
|
||||
},
|
||||
{
|
||||
"chart": "Accounts Payable Ageing",
|
||||
"width": "Half"
|
||||
},
|
||||
{
|
||||
"chart": "Bank Balance",
|
||||
"width": "Full"
|
||||
}
|
||||
],
|
||||
"creation": "2026-01-26 21:25:12.793893",
|
||||
"dashboard_name": "Payments",
|
||||
"docstatus": 0,
|
||||
"doctype": "Dashboard",
|
||||
"idx": 0,
|
||||
"is_default": 0,
|
||||
"is_standard": 1,
|
||||
"modified": "2026-01-26 21:25:12.793893",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Payments",
|
||||
"owner": "Administrator"
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -281,7 +281,7 @@
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"description": "Learn about <a href=\"https://docs.erpnext.com/docs/v13/user/manual/en/accounts/articles/common_party_accounting#:~:text=Common%20Party%20Accounting%20in%20ERPNext,Invoice%20against%20a%20primary%20Supplier.\">Common Party</a>",
|
||||
"description": "Learn about <a href=\"https://docs.frappe.io/erpnext/user/manual/en/common_party_accounting\">Common Party</a>",
|
||||
"fieldname": "enable_common_party_accounting",
|
||||
"fieldtype": "Check",
|
||||
"label": "Enable Common Party Accounting"
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
frappe.provide("erpnext.integrations");
|
||||
|
||||
frappe.ui.form.on("Bank", {
|
||||
onload: function (frm) {
|
||||
add_fields_to_mapping_table(frm);
|
||||
},
|
||||
refresh: function (frm) {
|
||||
add_fields_to_mapping_table(frm);
|
||||
frm.toggle_display(["address_html", "contact_html"], !frm.doc.__islocal);
|
||||
@@ -37,11 +34,11 @@ let add_fields_to_mapping_table = function (frm) {
|
||||
});
|
||||
});
|
||||
|
||||
frm.fields_dict.bank_transaction_mapping.grid.update_docfield_property(
|
||||
"bank_transaction_field",
|
||||
"options",
|
||||
options
|
||||
);
|
||||
const grid = frm.fields_dict.bank_transaction_mapping?.grid;
|
||||
|
||||
if (grid) {
|
||||
grid.update_docfield_property("bank_transaction_field", "options", options);
|
||||
}
|
||||
};
|
||||
|
||||
erpnext.integrations.refreshPlaidLink = class refreshPlaidLink {
|
||||
@@ -116,7 +113,7 @@ erpnext.integrations.refreshPlaidLink = class refreshPlaidLink {
|
||||
"There was an issue connecting to Plaid's authentication server. Check browser console for more information"
|
||||
)
|
||||
);
|
||||
console.log(error);
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
plaid_success(token, response) {
|
||||
|
||||
@@ -42,8 +42,4 @@ frappe.ui.form.on("Bank Account", {
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
is_company_account: function (frm) {
|
||||
frm.set_df_property("account", "reqd", frm.doc.is_company_account);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Company Account",
|
||||
"mandatory_depends_on": "is_company_account",
|
||||
"options": "Account"
|
||||
},
|
||||
{
|
||||
@@ -98,6 +99,7 @@
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Company",
|
||||
"mandatory_depends_on": "is_company_account",
|
||||
"options": "Company"
|
||||
},
|
||||
{
|
||||
@@ -252,7 +254,7 @@
|
||||
"link_fieldname": "default_bank_account"
|
||||
}
|
||||
],
|
||||
"modified": "2025-08-29 12:32:01.081687",
|
||||
"modified": "2026-01-20 00:46:16.633364",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Bank Account",
|
||||
|
||||
@@ -51,25 +51,29 @@ class BankAccount(Document):
|
||||
delete_contact_and_address("Bank Account", self.name)
|
||||
|
||||
def validate(self):
|
||||
self.validate_company()
|
||||
self.validate_account()
|
||||
self.validate_is_company_account()
|
||||
self.update_default_bank_account()
|
||||
|
||||
def validate_account(self):
|
||||
if self.account:
|
||||
if accounts := frappe.db.get_all(
|
||||
"Bank Account", filters={"account": self.account, "name": ["!=", self.name]}, as_list=1
|
||||
):
|
||||
frappe.throw(
|
||||
_("'{0}' account is already used by {1}. Use another account.").format(
|
||||
frappe.bold(self.account),
|
||||
frappe.bold(comma_and([get_link_to_form(self.doctype, x[0]) for x in accounts])),
|
||||
)
|
||||
)
|
||||
def validate_is_company_account(self):
|
||||
if self.is_company_account:
|
||||
if not self.company:
|
||||
frappe.throw(_("Company is mandatory for company account"))
|
||||
|
||||
def validate_company(self):
|
||||
if self.is_company_account and not self.company:
|
||||
frappe.throw(_("Company is mandatory for company account"))
|
||||
if not self.account:
|
||||
frappe.throw(_("Company Account is mandatory"))
|
||||
|
||||
self.validate_account()
|
||||
|
||||
def validate_account(self):
|
||||
if accounts := frappe.db.get_all(
|
||||
"Bank Account", filters={"account": self.account, "name": ["!=", self.name]}, as_list=1
|
||||
):
|
||||
frappe.throw(
|
||||
_("'{0}' account is already used by {1}. Use another account.").format(
|
||||
frappe.bold(self.account),
|
||||
frappe.bold(comma_and([get_link_to_form(self.doctype, x[0]) for x in accounts])),
|
||||
)
|
||||
)
|
||||
|
||||
def update_default_bank_account(self):
|
||||
if self.is_default and not self.disabled:
|
||||
|
||||
@@ -179,11 +179,14 @@ class JournalEntry(AccountsController):
|
||||
validate_docs_for_deferred_accounting([self.name], [])
|
||||
|
||||
def submit(self):
|
||||
if len(self.accounts) > 100:
|
||||
if len(self.accounts) > 100 and not self.meta.queue_in_background:
|
||||
queue_submission(self, "_submit")
|
||||
else:
|
||||
return self._submit()
|
||||
|
||||
def before_cancel(self):
|
||||
self.has_asset_adjustment_entry()
|
||||
|
||||
def cancel(self):
|
||||
if len(self.accounts) > 100:
|
||||
queue_submission(self, "_cancel")
|
||||
@@ -554,12 +557,27 @@ class JournalEntry(AccountsController):
|
||||
)
|
||||
frappe.db.set_value("Journal Entry", self.name, "inter_company_journal_entry_reference", "")
|
||||
|
||||
def unlink_asset_adjustment_entry(self):
|
||||
frappe.db.sql(
|
||||
""" update `tabAsset Value Adjustment`
|
||||
set journal_entry = null where journal_entry = %s""",
|
||||
self.name,
|
||||
def has_asset_adjustment_entry(self):
|
||||
if self.flags.get("via_asset_value_adjustment"):
|
||||
return
|
||||
|
||||
asset_value_adjustment = frappe.db.get_value(
|
||||
"Asset Value Adjustment", {"docstatus": 1, "journal_entry": self.name}, "name"
|
||||
)
|
||||
if asset_value_adjustment:
|
||||
frappe.throw(
|
||||
_(
|
||||
"Cannot cancel this document as it is linked with the submitted Asset Value Adjustment <b>{0}</b>. Please cancel the Asset Value Adjustment to continue."
|
||||
).format(frappe.utils.get_link_to_form("Asset Value Adjustment", asset_value_adjustment))
|
||||
)
|
||||
|
||||
def unlink_asset_adjustment_entry(self):
|
||||
AssetValueAdjustment = frappe.qb.DocType("Asset Value Adjustment")
|
||||
(
|
||||
frappe.qb.update(AssetValueAdjustment)
|
||||
.set(AssetValueAdjustment.journal_entry, None)
|
||||
.where(AssetValueAdjustment.journal_entry == self.name)
|
||||
).run()
|
||||
|
||||
def validate_party(self):
|
||||
for d in self.get("accounts"):
|
||||
|
||||
@@ -400,6 +400,16 @@ frappe.ui.form.on("Payment Entry", {
|
||||
);
|
||||
|
||||
frm.refresh_fields();
|
||||
|
||||
const party_currency =
|
||||
frm.doc.payment_type === "Receive" ? "paid_from_account_currency" : "paid_to_account_currency";
|
||||
|
||||
var reference_grid = frm.fields_dict["references"].grid;
|
||||
["total_amount", "outstanding_amount", "allocated_amount"].forEach((fieldname) => {
|
||||
reference_grid.update_docfield_property(fieldname, "options", party_currency);
|
||||
});
|
||||
|
||||
reference_grid.refresh();
|
||||
},
|
||||
|
||||
show_general_ledger: function (frm) {
|
||||
@@ -1104,7 +1114,7 @@ frappe.ui.form.on("Payment Entry", {
|
||||
|
||||
allocate_party_amount_against_ref_docs: async function (frm, paid_amount, paid_amount_change) {
|
||||
await frm.call("allocate_amount_to_references", {
|
||||
paid_amount: paid_amount,
|
||||
paid_amount: flt(paid_amount),
|
||||
paid_amount_change: paid_amount_change,
|
||||
allocate_payment_amount: frappe.flags.allocate_payment_amount ?? false,
|
||||
});
|
||||
|
||||
@@ -132,6 +132,12 @@
|
||||
"fieldtype": "Link",
|
||||
"label": "Cost Center",
|
||||
"options": "Cost Center"
|
||||
},
|
||||
{
|
||||
"fieldname": "project",
|
||||
"fieldtype": "Link",
|
||||
"label": "Project",
|
||||
"options": "Project"
|
||||
},
|
||||
{
|
||||
"fieldname": "due_date",
|
||||
|
||||
@@ -38,6 +38,7 @@ class PaymentLedgerEntry(Document):
|
||||
amount_in_account_currency: DF.Currency
|
||||
company: DF.Link | None
|
||||
cost_center: DF.Link | None
|
||||
project: DF.Link | None
|
||||
delinked: DF.Check
|
||||
due_date: DF.Date | None
|
||||
finance_book: DF.Link | None
|
||||
|
||||
@@ -746,7 +746,7 @@ class PaymentReconciliation(Document):
|
||||
ple = qb.DocType("Payment Ledger Entry")
|
||||
for x in self.dimensions:
|
||||
dimension = x.fieldname
|
||||
if self.get(dimension):
|
||||
if self.get(dimension) and frappe.db.has_column("Payment Ledger Entry", dimension):
|
||||
self.accounting_dimension_filter_conditions.append(ple[dimension] == self.get(dimension))
|
||||
|
||||
def build_qb_filter_conditions(self, get_invoices=False, get_return_invoices=False):
|
||||
|
||||
@@ -115,18 +115,21 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
|
||||
}
|
||||
|
||||
if (cint(doc.update_stock) != 1) {
|
||||
// show Make Delivery Note button only if Sales Invoice is not created from Delivery Note
|
||||
var from_delivery_note = false;
|
||||
from_delivery_note = this.frm.doc.items.some(function (item) {
|
||||
return item.delivery_note ? true : false;
|
||||
});
|
||||
|
||||
if (!from_delivery_note && !is_delivered_by_supplier) {
|
||||
this.frm.add_custom_button(
|
||||
__("Delivery"),
|
||||
this.frm.cscript["Make Delivery Note"],
|
||||
__("Create")
|
||||
if (!is_delivered_by_supplier) {
|
||||
const should_create_delivery_note = doc.items.some(
|
||||
(item) =>
|
||||
item.qty - item.delivered_qty > 0 &&
|
||||
!item.scio_detail &&
|
||||
!item.dn_detail &&
|
||||
!item.delivered_by_supplier
|
||||
);
|
||||
if (should_create_delivery_note) {
|
||||
this.frm.add_custom_button(
|
||||
__("Delivery Note"),
|
||||
this.frm.cscript["Make Delivery Note"],
|
||||
__("Create")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -778,8 +778,7 @@
|
||||
},
|
||||
{
|
||||
"collapsible": 1,
|
||||
"collapsible_depends_on": "eval:doc.total_billing_amount > 0",
|
||||
"depends_on": "eval:!doc.is_return",
|
||||
"collapsible_depends_on": "eval:doc.total_billing_amount > 0 || doc.total_billing_hours > 0",
|
||||
"fieldname": "time_sheet_list",
|
||||
"fieldtype": "Section Break",
|
||||
"hide_border": 1,
|
||||
@@ -793,7 +792,6 @@
|
||||
"hide_days": 1,
|
||||
"hide_seconds": 1,
|
||||
"label": "Time Sheets",
|
||||
"no_copy": 1,
|
||||
"options": "Sales Invoice Timesheet",
|
||||
"print_hide": 1
|
||||
},
|
||||
@@ -2092,7 +2090,7 @@
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:(!doc.is_return && doc.total_billing_amount > 0)",
|
||||
"depends_on": "eval:doc.total_billing_amount > 0 || doc.total_billing_hours > 0",
|
||||
"fieldname": "section_break_104",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
@@ -2306,7 +2304,7 @@
|
||||
"link_fieldname": "consolidated_invoice"
|
||||
}
|
||||
],
|
||||
"modified": "2025-10-09 14:48:59.472826",
|
||||
"modified": "2025-12-24 18:29:50.242618",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Sales Invoice",
|
||||
|
||||
@@ -352,10 +352,22 @@ class SalesInvoice(SellingController):
|
||||
self.is_opening = "No"
|
||||
|
||||
self.set_against_income_account()
|
||||
self.validate_time_sheets_are_submitted()
|
||||
|
||||
if self.is_return and not self.return_against and self.timesheets:
|
||||
frappe.throw(_("Direct return is not allowed for Timesheet."))
|
||||
|
||||
if not self.is_return:
|
||||
self.validate_time_sheets_are_submitted()
|
||||
|
||||
self.validate_multiple_billing("Delivery Note", "dn_detail", "amount")
|
||||
if self.is_return:
|
||||
self.timesheets = []
|
||||
|
||||
if self.is_return and self.return_against:
|
||||
for row in self.timesheets:
|
||||
if row.billing_hours:
|
||||
row.billing_hours = -abs(row.billing_hours)
|
||||
if row.billing_amount:
|
||||
row.billing_amount = -abs(row.billing_amount)
|
||||
|
||||
self.update_packing_list()
|
||||
self.set_billing_hours_and_amount()
|
||||
self.update_timesheet_billing_for_project()
|
||||
@@ -484,7 +496,7 @@ class SalesInvoice(SellingController):
|
||||
if cint(self.is_pos) != 1 and not self.is_return:
|
||||
self.update_against_document_in_jv()
|
||||
|
||||
self.update_time_sheet(self.name)
|
||||
self.update_time_sheet(None if (self.is_return and self.return_against) else self.name)
|
||||
|
||||
if frappe.get_single_value("Selling Settings", "sales_update_frequency") == "Each Transaction":
|
||||
update_company_current_month_sales(self.company)
|
||||
@@ -564,7 +576,7 @@ class SalesInvoice(SellingController):
|
||||
self.check_if_consolidated_invoice()
|
||||
|
||||
super().before_cancel()
|
||||
self.update_time_sheet(None)
|
||||
self.update_time_sheet(self.return_against if (self.is_return and self.return_against) else None)
|
||||
|
||||
def on_cancel(self):
|
||||
check_if_return_invoice_linked_with_payment_entry(self)
|
||||
@@ -804,8 +816,20 @@ class SalesInvoice(SellingController):
|
||||
for data in timesheet.time_logs:
|
||||
if (
|
||||
(self.project and args.timesheet_detail == data.name)
|
||||
or (not self.project and not data.sales_invoice)
|
||||
or (not sales_invoice and data.sales_invoice == self.name)
|
||||
or (not self.project and not data.sales_invoice and args.timesheet_detail == data.name)
|
||||
or (
|
||||
not sales_invoice
|
||||
and data.sales_invoice == self.name
|
||||
and args.timesheet_detail == data.name
|
||||
)
|
||||
or (
|
||||
self.is_return
|
||||
and self.return_against
|
||||
and data.sales_invoice
|
||||
and data.sales_invoice == self.return_against
|
||||
and not sales_invoice
|
||||
and args.timesheet_detail == data.name
|
||||
)
|
||||
):
|
||||
data.sales_invoice = sales_invoice
|
||||
|
||||
@@ -845,11 +869,26 @@ class SalesInvoice(SellingController):
|
||||
payment.account = get_bank_cash_account(payment.mode_of_payment, self.company).get("account")
|
||||
|
||||
def validate_time_sheets_are_submitted(self):
|
||||
# Note: This validation is skipped for return invoices
|
||||
# to allow returns to reference already-billed timesheet details
|
||||
for data in self.timesheets:
|
||||
# Handle invoice duplication
|
||||
if data.time_sheet and data.timesheet_detail:
|
||||
if sales_invoice := frappe.db.get_value(
|
||||
"Timesheet Detail", data.timesheet_detail, "sales_invoice"
|
||||
):
|
||||
frappe.throw(
|
||||
_("Row {0}: Sales Invoice {1} is already created for {2}").format(
|
||||
data.idx, frappe.bold(sales_invoice), frappe.bold(data.time_sheet)
|
||||
)
|
||||
)
|
||||
|
||||
if data.time_sheet:
|
||||
status = frappe.db.get_value("Timesheet", data.time_sheet, "status")
|
||||
if status not in ["Submitted", "Payslip"]:
|
||||
frappe.throw(_("Timesheet {0} is already completed or cancelled").format(data.time_sheet))
|
||||
if status not in ["Submitted", "Payslip", "Partially Billed"]:
|
||||
frappe.throw(
|
||||
_("Timesheet {0} cannot be invoiced in its current state").format(data.time_sheet)
|
||||
)
|
||||
|
||||
def set_pos_fields(self, for_validate=False):
|
||||
"""Set retail related fields from POS Profiles"""
|
||||
@@ -1283,7 +1322,12 @@ class SalesInvoice(SellingController):
|
||||
timesheet.billing_amount = ts_doc.total_billable_amount
|
||||
|
||||
def update_timesheet_billing_for_project(self):
|
||||
if not self.timesheets and self.project and self.is_auto_fetch_timesheet_enabled():
|
||||
if (
|
||||
not self.is_return
|
||||
and not self.timesheets
|
||||
and self.project
|
||||
and self.is_auto_fetch_timesheet_enabled()
|
||||
):
|
||||
self.add_timesheet_data()
|
||||
else:
|
||||
self.calculate_billing_amount_for_timesheet()
|
||||
@@ -2378,7 +2422,10 @@ def make_delivery_note(source_name, target_doc=None):
|
||||
"cost_center": "cost_center",
|
||||
},
|
||||
"postprocess": update_item,
|
||||
"condition": lambda doc: doc.delivered_by_supplier != 1 and not doc.scio_detail,
|
||||
"condition": lambda doc: doc.delivered_by_supplier != 1
|
||||
and not doc.scio_detail
|
||||
and not doc.dn_detail
|
||||
and doc.qty - doc.delivered_qty > 0,
|
||||
},
|
||||
"Sales Taxes and Charges": {"doctype": "Sales Taxes and Charges", "reset_value": True},
|
||||
"Sales Team": {
|
||||
|
||||
@@ -2951,6 +2951,60 @@ class TestSalesInvoice(ERPNextTestSuite):
|
||||
self.assertEqual(sales_invoice.items[0].item_tax_template, "_Test Account Excise Duty @ 10 - _TC")
|
||||
self.assertEqual(sales_invoice.items[0].item_tax_rate, item_tax_map)
|
||||
|
||||
def test_item_tax_template_change_with_grand_total_discount(self):
|
||||
"""
|
||||
Test that when item tax template changes due to discount on Grand Total,
|
||||
the tax calculations are consistent.
|
||||
"""
|
||||
item = create_item("Test Item With Multiple Tax Templates")
|
||||
|
||||
item.set("taxes", [])
|
||||
item.append(
|
||||
"taxes",
|
||||
{
|
||||
"item_tax_template": "_Test Account Excise Duty @ 10 - _TC",
|
||||
"minimum_net_rate": 0,
|
||||
"maximum_net_rate": 500,
|
||||
},
|
||||
)
|
||||
|
||||
item.append(
|
||||
"taxes",
|
||||
{
|
||||
"item_tax_template": "_Test Account Excise Duty @ 12 - _TC",
|
||||
"minimum_net_rate": 501,
|
||||
"maximum_net_rate": 1000,
|
||||
},
|
||||
)
|
||||
|
||||
item.save()
|
||||
|
||||
si = create_sales_invoice(item=item.name, rate=700, do_not_save=True)
|
||||
si.append(
|
||||
"taxes",
|
||||
{
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": "_Test Account Excise Duty - _TC",
|
||||
"cost_center": "_Test Cost Center - _TC",
|
||||
"description": "Excise Duty",
|
||||
"rate": 0,
|
||||
},
|
||||
)
|
||||
si.insert()
|
||||
|
||||
self.assertEqual(si.items[0].item_tax_template, "_Test Account Excise Duty @ 12 - _TC")
|
||||
|
||||
si.apply_discount_on = "Grand Total"
|
||||
si.discount_amount = 300
|
||||
si.save()
|
||||
|
||||
# Verify template changed to 10%
|
||||
self.assertEqual(si.items[0].item_tax_template, "_Test Account Excise Duty @ 10 - _TC")
|
||||
self.assertEqual(si.taxes[0].tax_amount, 70) # 10% of 700
|
||||
self.assertEqual(si.grand_total, 470) # 700 + 70 - 300
|
||||
|
||||
si.submit()
|
||||
|
||||
@IntegrationTestCase.change_settings("Selling Settings", {"enable_discount_accounting": 1})
|
||||
def test_sales_invoice_with_discount_accounting_enabled(self):
|
||||
discount_account = create_account(
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"label": "Timesheet Detail",
|
||||
"no_copy": 1,
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
@@ -117,15 +116,16 @@
|
||||
],
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2024-03-27 13:10:36.562795",
|
||||
"modified": "2025-12-23 13:54:17.677187",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Sales Invoice Timesheet",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"quick_entry": 1,
|
||||
"row_format": "Dynamic",
|
||||
"sort_field": "creation",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"track_changes": 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,7 +415,6 @@ class TestTaxWithholdingCategory(IntegrationTestCase):
|
||||
"cost_center": "Main - _TC",
|
||||
"tax_amount": 500,
|
||||
"description": "Test",
|
||||
"add_deduct_tax": "Add",
|
||||
},
|
||||
)
|
||||
pi.save()
|
||||
@@ -506,7 +505,6 @@ class TestTaxWithholdingCategory(IntegrationTestCase):
|
||||
"cost_center": "Main - _TC",
|
||||
"tax_amount": 200,
|
||||
"description": "Test Gross Tax",
|
||||
"add_deduct_tax": "Add",
|
||||
},
|
||||
)
|
||||
si.save()
|
||||
@@ -541,10 +539,10 @@ class TestTaxWithholdingCategory(IntegrationTestCase):
|
||||
"cost_center": "Main - _TC",
|
||||
"tax_amount": 400,
|
||||
"description": "Test Gross Tax",
|
||||
"add_deduct_tax": "Add",
|
||||
},
|
||||
)
|
||||
si.save()
|
||||
si.reload()
|
||||
si.submit()
|
||||
invoices.append(si)
|
||||
# For amount before threshold (first 8000 + VAT): TCS entry with amount zero
|
||||
@@ -594,7 +592,6 @@ class TestTaxWithholdingCategory(IntegrationTestCase):
|
||||
"cost_center": "Main - _TC",
|
||||
"tax_amount": 500,
|
||||
"description": "VAT added to test TDS calculation on gross amount",
|
||||
"add_deduct_tax": "Add",
|
||||
},
|
||||
)
|
||||
si.save()
|
||||
@@ -1024,7 +1021,6 @@ class TestTaxWithholdingCategory(IntegrationTestCase):
|
||||
"cost_center": "Main - _TC",
|
||||
"tax_amount": 1000,
|
||||
"description": "VAT added to test TDS calculation on gross amount",
|
||||
"add_deduct_tax": "Add",
|
||||
},
|
||||
)
|
||||
pi.save()
|
||||
@@ -1162,7 +1158,6 @@ class TestTaxWithholdingCategory(IntegrationTestCase):
|
||||
"cost_center": "Main - _TC",
|
||||
"tax_amount": 8000,
|
||||
"description": "Test",
|
||||
"add_deduct_tax": "Add",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -708,6 +708,10 @@ class TaxWithholdingController:
|
||||
existing_taxes = {row.account_head: row for row in self.doc.taxes if row.is_tax_withholding_account}
|
||||
precision = self.doc.precision("tax_amount", "taxes")
|
||||
conversion_rate = self.get_conversion_rate()
|
||||
add_deduct_tax = "Deduct"
|
||||
|
||||
if self.party_type == "Customer":
|
||||
add_deduct_tax = "Add"
|
||||
|
||||
for account_head, base_amount in account_amount_map.items():
|
||||
tax_amount = flt(base_amount / conversion_rate, precision)
|
||||
@@ -724,6 +728,7 @@ class TaxWithholdingController:
|
||||
tax_row = self._create_tax_row(account_head, tax_amount)
|
||||
for_update = False
|
||||
|
||||
tax_row.add_deduct_tax = add_deduct_tax
|
||||
# Set item-wise tax breakup for this tax row
|
||||
self._set_item_wise_tax_for_tds(
|
||||
tax_row, account_head, category_withholding_map, for_update=for_update
|
||||
@@ -743,7 +748,6 @@ class TaxWithholdingController:
|
||||
"account_head": account_head,
|
||||
"description": account_head,
|
||||
"cost_center": cost_center,
|
||||
"add_deduct_tax": "Deduct",
|
||||
"tax_amount": tax_amount,
|
||||
"dont_recompute_tax": 1,
|
||||
},
|
||||
@@ -807,12 +811,14 @@ class TaxWithholdingController:
|
||||
else:
|
||||
item_tax_amount = 0
|
||||
|
||||
multiplier = -1 if tax_row.add_deduct_tax == "Deduct" else 1
|
||||
|
||||
self.doc._item_wise_tax_details.append(
|
||||
frappe._dict(
|
||||
item=item,
|
||||
tax=tax_row,
|
||||
rate=category.tax_rate,
|
||||
amount=item_tax_amount * -1, # Negative because it's a deduction
|
||||
amount=item_tax_amount * multiplier,
|
||||
taxable_amount=item_base_taxable,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -877,11 +877,15 @@ class ReceivablePayableReport:
|
||||
else:
|
||||
entry_date = row.posting_date
|
||||
|
||||
row.range0 = 0.0
|
||||
|
||||
self.get_ageing_data(entry_date, row)
|
||||
|
||||
# ageing buckets should not have amounts if due date is not reached
|
||||
if getdate(entry_date) > getdate(self.age_as_on):
|
||||
row.range0 = row.outstanding
|
||||
[setattr(row, f"range{i}", 0.0) for i in self.range_numbers]
|
||||
row.total_due = 0
|
||||
return
|
||||
|
||||
row.total_due = sum(row[f"range{i}"] for i in self.range_numbers)
|
||||
|
||||
@@ -1281,6 +1285,8 @@ class ReceivablePayableReport:
|
||||
ranges = [*self.ranges, _("Above")]
|
||||
|
||||
prev_range_value = 0
|
||||
self.add_column(label=_("<0"), fieldname="range0", fieldtype="Currency")
|
||||
self.ageing_column_labels.append(_("<0"))
|
||||
for idx, curr_range_value in enumerate(ranges):
|
||||
label = f"{prev_range_value}-{curr_range_value}"
|
||||
self.add_column(label=label, fieldname="range" + str(idx + 1))
|
||||
@@ -1296,7 +1302,9 @@ class ReceivablePayableReport:
|
||||
for row in self.data:
|
||||
row = frappe._dict(row)
|
||||
if not cint(row.bold):
|
||||
values = [flt(row.get(f"range{i}", None), precision) for i in self.range_numbers]
|
||||
values = [flt(row.get("range0", 0), precision)] + [
|
||||
flt(row.get(f"range{i}", 0), precision) for i in self.range_numbers
|
||||
]
|
||||
rows.append({"values": values})
|
||||
|
||||
self.chart = {
|
||||
|
||||
@@ -18,6 +18,8 @@ def execute(filters=None):
|
||||
dimensions = filters.get("budget_against_filter")
|
||||
else:
|
||||
dimensions = get_budget_dimensions(filters)
|
||||
if not dimensions:
|
||||
return columns, [], None, None
|
||||
|
||||
budget_records = get_budget_records(filters, dimensions)
|
||||
budget_map = build_budget_map(budget_records, filters)
|
||||
|
||||
@@ -219,13 +219,18 @@ def get_net_profit(
|
||||
|
||||
has_value = False
|
||||
|
||||
gross_income_roots = [row for row in (gross_income or []) if not flt(row.get("indent"))]
|
||||
non_gross_income_roots = [row for row in (non_gross_income or []) if not flt(row.get("indent"))]
|
||||
gross_expense_roots = [row for row in (gross_expense or []) if not flt(row.get("indent"))]
|
||||
non_gross_expense_roots = [row for row in (non_gross_expense or []) if not flt(row.get("indent"))]
|
||||
|
||||
for period in period_list:
|
||||
key = period if consolidated else period.key
|
||||
gross_income_for_period = flt(gross_income[0].get(key, 0)) if gross_income else 0
|
||||
non_gross_income_for_period = flt(non_gross_income[0].get(key, 0)) if non_gross_income else 0
|
||||
|
||||
gross_expense_for_period = flt(gross_expense[0].get(key, 0)) if gross_expense else 0
|
||||
non_gross_expense_for_period = flt(non_gross_expense[0].get(key, 0)) if non_gross_expense else 0
|
||||
gross_income_for_period = sum(flt(row.get(key, 0)) for row in gross_income_roots)
|
||||
non_gross_income_for_period = sum(flt(row.get(key, 0)) for row in non_gross_income_roots)
|
||||
gross_expense_for_period = sum(flt(row.get(key, 0)) for row in gross_expense_roots)
|
||||
non_gross_expense_for_period = sum(flt(row.get(key, 0)) for row in non_gross_expense_roots)
|
||||
|
||||
total_income = gross_income_for_period + non_gross_income_for_period
|
||||
total_expense = gross_expense_for_period + non_gross_expense_for_period
|
||||
|
||||
@@ -105,7 +105,7 @@ def _execute(filters=None, additional_table_columns=None, additional_conditions=
|
||||
{
|
||||
"total_tax": total_tax,
|
||||
"total_other_charges": total_other_charges,
|
||||
"total": d.base_net_amount + total_tax,
|
||||
"total": d.base_net_amount + total_tax + total_other_charges,
|
||||
"currency": company_currency,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -547,6 +547,7 @@ def reconcile_against_document(
|
||||
doc.make_advance_gl_entries(entry=row)
|
||||
else:
|
||||
_delete_pl_entries(voucher_type, voucher_no)
|
||||
_delete_adv_pl_entries(voucher_type, voucher_no)
|
||||
gl_map = doc.build_gl_map()
|
||||
# Make sure there is no overallocation
|
||||
from erpnext.accounts.general_ledger import process_debit_credit_difference
|
||||
@@ -1946,6 +1947,7 @@ def get_payment_ledger_entries(gl_entries, cancel=0):
|
||||
account=gle.account,
|
||||
party_type=gle.party_type,
|
||||
party=gle.party,
|
||||
project=gle.project,
|
||||
cost_center=gle.cost_center,
|
||||
finance_book=gle.finance_book,
|
||||
due_date=gle.due_date,
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
"for_user": "",
|
||||
"hide_custom": 0,
|
||||
"icon": "accounting",
|
||||
"idx": 3,
|
||||
"idx": 4,
|
||||
"indicator_color": "",
|
||||
"is_hidden": 0,
|
||||
"label": "Accounting",
|
||||
"label": "Invoicing",
|
||||
"links": [
|
||||
{
|
||||
"hidden": 0,
|
||||
@@ -587,10 +587,10 @@
|
||||
"type": "Link"
|
||||
}
|
||||
],
|
||||
"modified": "2025-12-24 13:20:34.857205",
|
||||
"modified": "2026-01-23 11:05:47.246213",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Accounting",
|
||||
"name": "Invoicing",
|
||||
"number_cards": [
|
||||
{
|
||||
"label": "Outgoing Bills",
|
||||
@@ -617,6 +617,6 @@
|
||||
"roles": [],
|
||||
"sequence_id": 2.0,
|
||||
"shortcuts": [],
|
||||
"title": "Accounting",
|
||||
"title": "Invoicing",
|
||||
"type": "Workspace"
|
||||
}
|
||||
@@ -116,14 +116,6 @@ frappe.ui.form.on("Asset", {
|
||||
__("Manage")
|
||||
);
|
||||
|
||||
frm.add_custom_button(
|
||||
__("Repair Asset"),
|
||||
function () {
|
||||
frm.trigger("create_asset_repair");
|
||||
},
|
||||
__("Manage")
|
||||
);
|
||||
|
||||
frm.add_custom_button(
|
||||
__("Split Asset"),
|
||||
function () {
|
||||
@@ -155,6 +147,14 @@ frappe.ui.form.on("Asset", {
|
||||
},
|
||||
__("Manage")
|
||||
);
|
||||
|
||||
frm.add_custom_button(
|
||||
__("Repair Asset"),
|
||||
function () {
|
||||
frm.trigger("create_asset_repair");
|
||||
},
|
||||
__("Manage")
|
||||
);
|
||||
}
|
||||
|
||||
if (!frm.doc.calculate_depreciation) {
|
||||
|
||||
@@ -244,6 +244,8 @@ class Asset(AccountsController):
|
||||
|
||||
def before_submit(self):
|
||||
if self.is_composite_asset and not has_active_capitalization(self.name):
|
||||
if self.split_from and has_active_capitalization(self.split_from):
|
||||
return
|
||||
frappe.throw(_("Please capitalize this asset before submitting."))
|
||||
|
||||
def on_submit(self):
|
||||
|
||||
@@ -1691,6 +1691,71 @@ class TestDepreciationBasics(AssetSetup):
|
||||
pr.submit()
|
||||
self.assertTrue(get_gl_entries("Purchase Receipt", pr.name))
|
||||
|
||||
def test_split_asset_created_via_capitalization(self):
|
||||
"""Test that assets created via Asset Capitalization can be split without capitalization error"""
|
||||
from erpnext.assets.doctype.asset_capitalization.test_asset_capitalization import (
|
||||
create_asset_capitalization,
|
||||
create_asset_capitalization_data,
|
||||
)
|
||||
|
||||
# Ensure test data exists
|
||||
create_asset_capitalization_data()
|
||||
|
||||
company = "_Test Company with perpetual inventory"
|
||||
set_depreciation_settings_in_company(company=company)
|
||||
name = frappe.db.get_value(
|
||||
"Asset Category Account",
|
||||
filters={"parent": "Computers", "company_name": company},
|
||||
fieldname=["name"],
|
||||
)
|
||||
frappe.db.set_value("Asset Category Account", name, "capital_work_in_progress_account", "")
|
||||
|
||||
stock_rate = 1000
|
||||
stock_qty = 2
|
||||
total_amount = 2000
|
||||
|
||||
# Create composite asset
|
||||
wip_composite_asset = create_asset(
|
||||
asset_name="Asset Capitalization WIP Composite Asset for Split",
|
||||
is_composite_asset=1,
|
||||
warehouse="Stores - TCP1",
|
||||
company=company,
|
||||
asset_quantity=2, # Set quantity > 1 to allow splitting
|
||||
)
|
||||
|
||||
# Create and submit Asset Capitalization
|
||||
asset_capitalization = create_asset_capitalization(
|
||||
target_asset=wip_composite_asset.name,
|
||||
stock_qty=stock_qty,
|
||||
stock_rate=stock_rate,
|
||||
company=company,
|
||||
submit=1,
|
||||
)
|
||||
|
||||
# Verify asset was capitalized
|
||||
target_asset = frappe.get_doc("Asset", asset_capitalization.target_asset)
|
||||
self.assertEqual(target_asset.net_purchase_amount, total_amount)
|
||||
self.assertEqual(target_asset.status, "Work In Progress")
|
||||
|
||||
# Submit the capitalized asset
|
||||
target_asset.submit()
|
||||
self.assertEqual(target_asset.status, "Submitted")
|
||||
|
||||
# Split the asset - this should work without capitalization error
|
||||
split_qty = 1
|
||||
splitted_asset = split_asset(target_asset.name, split_qty)
|
||||
|
||||
# Verify split asset was created and submitted successfully
|
||||
self.assertIsNotNone(splitted_asset)
|
||||
self.assertEqual(splitted_asset.asset_quantity, split_qty)
|
||||
self.assertEqual(splitted_asset.split_from, target_asset.name)
|
||||
self.assertEqual(splitted_asset.docstatus, 1) # Should be submitted
|
||||
self.assertEqual(splitted_asset.status, "Submitted")
|
||||
|
||||
# Verify original asset was updated
|
||||
target_asset.reload()
|
||||
self.assertEqual(target_asset.asset_quantity, 1) # Remaining quantity
|
||||
|
||||
|
||||
def get_gl_entries(doctype, docname):
|
||||
gl_entry = frappe.qb.DocType("GL Entry")
|
||||
|
||||
@@ -574,13 +574,19 @@ class AssetCapitalization(StockController):
|
||||
if self.docstatus == 2:
|
||||
net_purchase_amount = asset_doc.net_purchase_amount - total_target_asset_value
|
||||
purchase_amount = asset_doc.purchase_amount - total_target_asset_value
|
||||
asset_doc.db_set("total_asset_cost", asset_doc.total_asset_cost - total_target_asset_value)
|
||||
total_asset_cost = asset_doc.total_asset_cost - total_target_asset_value
|
||||
else:
|
||||
net_purchase_amount = asset_doc.net_purchase_amount + total_target_asset_value
|
||||
purchase_amount = asset_doc.purchase_amount + total_target_asset_value
|
||||
total_asset_cost = asset_doc.total_asset_cost + total_target_asset_value
|
||||
|
||||
asset_doc.db_set("net_purchase_amount", net_purchase_amount)
|
||||
asset_doc.db_set("purchase_amount", purchase_amount)
|
||||
asset_doc.db_set(
|
||||
{
|
||||
"net_purchase_amount": net_purchase_amount,
|
||||
"purchase_amount": purchase_amount,
|
||||
"total_asset_cost": total_asset_cost,
|
||||
}
|
||||
)
|
||||
|
||||
frappe.msgprint(
|
||||
_("Asset {0} has been updated. Please set the depreciation details if any and submit it.").format(
|
||||
|
||||
@@ -74,7 +74,7 @@ class AssetValueAdjustment(Document):
|
||||
)
|
||||
|
||||
def on_cancel(self):
|
||||
frappe.get_doc("Journal Entry", self.journal_entry).cancel()
|
||||
self.cancel_asset_revaluation_entry()
|
||||
self.update_asset()
|
||||
add_asset_activity(
|
||||
self.asset,
|
||||
@@ -167,6 +167,17 @@ class AssetValueAdjustment(Document):
|
||||
if dimension.get("mandatory_for_pl"):
|
||||
debit_entry.update({dimension["fieldname"]: dimension_value})
|
||||
|
||||
def cancel_asset_revaluation_entry(self):
|
||||
if not self.journal_entry:
|
||||
return
|
||||
|
||||
revaluation_entry = frappe.get_doc("Journal Entry", self.journal_entry)
|
||||
if revaluation_entry.docstatus == 1:
|
||||
# Ignore permissions to match Journal Entry submission behavior
|
||||
revaluation_entry.flags.ignore_permissions = True
|
||||
revaluation_entry.flags.via_asset_value_adjustment = True
|
||||
revaluation_entry.cancel()
|
||||
|
||||
def update_asset(self):
|
||||
asset = self.update_asset_value_after_depreciation()
|
||||
note = self.get_adjustment_note()
|
||||
|
||||
@@ -1330,6 +1330,55 @@ class TestPurchaseOrder(IntegrationTestCase):
|
||||
pi = make_pi_from_po(po.name)
|
||||
self.assertEqual(pi.items[0].qty, 50)
|
||||
|
||||
def test_multiple_advances_against_purchase_order_are_allocated_across_partial_purchase_invoices(self):
|
||||
# step - 1: create PO
|
||||
po = create_purchase_order(qty=10, rate=10)
|
||||
|
||||
# step - 2: create first partial advance payment
|
||||
pe1 = get_payment_entry("Purchase Order", po.name, bank_account="_Test Bank - _TC")
|
||||
pe1.reference_no = "1"
|
||||
pe1.reference_date = nowdate()
|
||||
pe1.paid_amount = 50
|
||||
pe1.references[0].allocated_amount = 50
|
||||
pe1.save(ignore_permissions=True).submit()
|
||||
|
||||
# check first advance paid against PO
|
||||
po.reload()
|
||||
self.assertEqual(po.advance_paid, 50)
|
||||
|
||||
# step - 3: create first PI for partial qty and allocate first advance
|
||||
pi_1 = make_pi_from_po(po.name)
|
||||
pi_1.update_stock = 1
|
||||
pi_1.allocate_advances_automatically = 1
|
||||
pi_1.items[0].qty = 5
|
||||
pi_1.save(ignore_permissions=True).submit()
|
||||
|
||||
# step - 4: create second advance payment for remaining
|
||||
pe2 = get_payment_entry("Purchase Order", po.name, bank_account="_Test Bank - _TC")
|
||||
pe2.reference_no = "2"
|
||||
pe2.reference_date = nowdate()
|
||||
pe2.paid_amount = 50
|
||||
pe2.references[0].allocated_amount = 50
|
||||
pe2.save(ignore_permissions=True).submit()
|
||||
|
||||
# check second advance paid against PO
|
||||
po.reload()
|
||||
self.assertEqual(po.advance_paid, 100)
|
||||
|
||||
# step - 5: create second PI for remaining qty and allocate second advance
|
||||
pi_2 = make_pi_from_po(po.name)
|
||||
pi_2.update_stock = 1
|
||||
pi_2.allocate_advances_automatically = 1
|
||||
pi_2.save(ignore_permissions=True).submit()
|
||||
|
||||
# check PO and PI status
|
||||
po.reload()
|
||||
pi_1.reload()
|
||||
pi_2.reload()
|
||||
self.assertEqual(pi_1.status, "Paid")
|
||||
self.assertEqual(pi_2.status, "Paid")
|
||||
self.assertEqual(po.status, "Completed")
|
||||
|
||||
|
||||
def create_po_for_sc_testing():
|
||||
from erpnext.controllers.tests.test_subcontracting_controller import (
|
||||
|
||||
@@ -383,7 +383,7 @@
|
||||
},
|
||||
{
|
||||
"fieldname": "primary_address",
|
||||
"fieldtype": "Text",
|
||||
"fieldtype": "Text Editor",
|
||||
"label": "Primary Address",
|
||||
"read_only": 1
|
||||
},
|
||||
@@ -500,7 +500,7 @@
|
||||
"link_fieldname": "party"
|
||||
}
|
||||
],
|
||||
"modified": "2025-06-29 05:30:50.398653",
|
||||
"modified": "2026-01-16 15:56:31.139206",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "Supplier",
|
||||
|
||||
@@ -62,7 +62,7 @@ class Supplier(TransactionBase):
|
||||
portal_users: DF.Table[PortalUser]
|
||||
prevent_pos: DF.Check
|
||||
prevent_rfqs: DF.Check
|
||||
primary_address: DF.Text | None
|
||||
primary_address: DF.TextEditor | None
|
||||
release_date: DF.Date | None
|
||||
represents_company: DF.Link | None
|
||||
supplier_details: DF.Text | None
|
||||
|
||||
@@ -16,6 +16,14 @@ erpnext.buying.SupplierQuotationController = class SupplierQuotationController e
|
||||
return !doc.qty && me.frm.doc.has_unit_price_items ? "yellow" : "";
|
||||
});
|
||||
|
||||
this.frm.set_query("warehouse", "items", (doc, cdt, cdn) => {
|
||||
return {
|
||||
filters: {
|
||||
company: doc.company,
|
||||
is_group: 0,
|
||||
},
|
||||
};
|
||||
});
|
||||
super.setup();
|
||||
}
|
||||
|
||||
|
||||
@@ -187,9 +187,8 @@ class AccountsController(TransactionBase):
|
||||
|
||||
msg = ""
|
||||
if self.get("update_outstanding_for_self"):
|
||||
msg = (
|
||||
"We can see {0} is made against {1}. If you want {1}'s outstanding to be updated, "
|
||||
"uncheck '{2}' checkbox. <br><br>Or"
|
||||
msg = _(
|
||||
"We can see {0} is made against {1}. If you want {1}'s outstanding to be updated, uncheck the '{2}' checkbox."
|
||||
).format(
|
||||
frappe.bold(document_type),
|
||||
get_link_to_form(self.doctype, self.get("return_against")),
|
||||
@@ -200,8 +199,8 @@ class AccountsController(TransactionBase):
|
||||
abs(flt(self.rounded_total) or flt(self.grand_total)) > flt(against_voucher_outstanding)
|
||||
):
|
||||
self.update_outstanding_for_self = 1
|
||||
msg = (
|
||||
"The outstanding amount {} in {} is lesser than {}. Updating the outstanding to this invoice. <br><br>And"
|
||||
msg = _(
|
||||
"The outstanding amount {0} in {1} is lesser than {2}. Updating the outstanding to this invoice."
|
||||
).format(
|
||||
against_voucher_outstanding,
|
||||
get_link_to_form(self.doctype, self.get("return_against")),
|
||||
@@ -209,11 +208,11 @@ class AccountsController(TransactionBase):
|
||||
)
|
||||
|
||||
if msg:
|
||||
msg += " you can use {} tool to reconcile against {} later.".format(
|
||||
msg += "<br><br>" + _("You can use {0} to reconcile against {1} later.").format(
|
||||
get_link_to_form("Payment Reconciliation"),
|
||||
get_link_to_form(self.doctype, self.get("return_against")),
|
||||
)
|
||||
frappe.msgprint(_(msg))
|
||||
frappe.msgprint(msg)
|
||||
|
||||
def validate(self):
|
||||
if not self.get("is_return") and not self.get("is_debit_note"):
|
||||
|
||||
@@ -212,7 +212,10 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
|
||||
party = filters.get("customer") or filters.get("supplier")
|
||||
item_rules_list = frappe.get_all(
|
||||
"Party Specific Item",
|
||||
filters={"party": party},
|
||||
filters={
|
||||
"party": ["!=", party],
|
||||
"party_type": "Customer" if filters.get("customer") else "Supplier",
|
||||
},
|
||||
fields=["restrict_based_on", "based_on_value"],
|
||||
)
|
||||
|
||||
@@ -226,7 +229,7 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
|
||||
filters_dict[rule.restrict_based_on].append(rule.based_on_value)
|
||||
|
||||
for filter in filters_dict:
|
||||
filters[scrub(filter)] = ["in", filters_dict[filter]]
|
||||
filters[scrub(filter)] = ["not in", filters_dict[filter]]
|
||||
|
||||
if filters.get("customer"):
|
||||
del filters["customer"]
|
||||
|
||||
@@ -552,7 +552,7 @@ class StockController(AccountsController):
|
||||
if is_rejected:
|
||||
serial_nos = row.get("rejected_serial_no")
|
||||
type_of_transaction = "Inward" if not self.is_return else "Outward"
|
||||
qty = row.get("rejected_qty")
|
||||
qty = row.get("rejected_qty") * row.get("conversion_factor", 1.0)
|
||||
warehouse = row.get("rejected_warehouse")
|
||||
|
||||
if (
|
||||
|
||||
@@ -166,29 +166,46 @@ class SubcontractingController(StockController):
|
||||
_("Row {0}: Item {1} must be a subcontracted item.").format(item.idx, item.item_name)
|
||||
)
|
||||
|
||||
if self.doctype != "Subcontracting Receipt" and item.qty > flt(
|
||||
get_pending_subcontracted_quantity(
|
||||
self.doctype,
|
||||
self.purchase_order if self.doctype == "Subcontracting Order" else self.sales_order,
|
||||
).get(
|
||||
item.purchase_order_item
|
||||
if self.doctype == "Subcontracting Order"
|
||||
else item.sales_order_item
|
||||
)
|
||||
/ item.subcontracting_conversion_factor,
|
||||
frappe.get_precision(
|
||||
if self.doctype != "Subcontracting Receipt":
|
||||
order_item_doctype = (
|
||||
"Purchase Order Item"
|
||||
if self.doctype == "Subcontracting Order"
|
||||
else "Sales Order Item",
|
||||
"qty",
|
||||
),
|
||||
):
|
||||
frappe.throw(
|
||||
_(
|
||||
"Row {0}: Item {1}'s quantity cannot be higher than the available quantity."
|
||||
).format(item.idx, item.item_name)
|
||||
else "Sales Order Item"
|
||||
)
|
||||
|
||||
order_name = (
|
||||
self.purchase_order if self.doctype == "Subcontracting Order" else self.sales_order
|
||||
)
|
||||
order_item_field = frappe.scrub(order_item_doctype)
|
||||
|
||||
if not item.get(order_item_field):
|
||||
frappe.throw(
|
||||
_("Row {0}: Item {1} must be linked to a {2}.").format(
|
||||
item.idx, item.item_name, order_item_doctype
|
||||
)
|
||||
)
|
||||
|
||||
pending_qty = flt(
|
||||
flt(
|
||||
get_pending_subcontracted_quantity(
|
||||
order_item_doctype,
|
||||
order_name,
|
||||
).get(item.get(order_item_field))
|
||||
)
|
||||
/ item.subcontracting_conversion_factor,
|
||||
frappe.get_precision(
|
||||
order_item_doctype,
|
||||
"qty",
|
||||
),
|
||||
)
|
||||
|
||||
if item.qty > pending_qty:
|
||||
frappe.throw(
|
||||
_(
|
||||
"Row {0}: Item {1}'s quantity cannot be higher than the available quantity."
|
||||
).format(item.idx, item.item_name)
|
||||
)
|
||||
|
||||
if self.doctype != "Subcontracting Inward Order":
|
||||
item.amount = item.qty * item.rate
|
||||
|
||||
@@ -610,7 +627,9 @@ class SubcontractingController(StockController):
|
||||
and self.doctype != "Subcontracting Inward Order"
|
||||
):
|
||||
row.reserve_warehouse = self.set_reserve_warehouse or item.warehouse
|
||||
elif frappe.get_cached_value("Item", row.rm_item_code, "is_customer_provided_item"):
|
||||
elif frappe.get_cached_value("Item", row.rm_item_code, "is_customer_provided_item") and self.get(
|
||||
"customer_warehouse"
|
||||
):
|
||||
row.warehouse = self.customer_warehouse
|
||||
|
||||
def __set_alternative_item(self, bom_item):
|
||||
@@ -1331,9 +1350,7 @@ def get_item_details(items):
|
||||
|
||||
|
||||
def get_pending_subcontracted_quantity(doctype, name):
|
||||
table = frappe.qb.DocType(
|
||||
"Purchase Order Item" if doctype == "Subcontracting Order" else "Sales Order Item"
|
||||
)
|
||||
table = frappe.qb.DocType(doctype)
|
||||
query = (
|
||||
frappe.qb.from_(table)
|
||||
.select(table.name, table.stock_qty, table.subcontracted_qty)
|
||||
|
||||
@@ -720,6 +720,7 @@ class SubcontractingInwardController:
|
||||
item.db_set("scio_detail", scio_rm.name)
|
||||
|
||||
if data:
|
||||
precision = self.precision("customer_provided_item_cost", "items")
|
||||
result = frappe.get_all(
|
||||
"Subcontracting Inward Order Received Item",
|
||||
filters={
|
||||
@@ -734,10 +735,17 @@ class SubcontractingInwardController:
|
||||
table = frappe.qb.DocType("Subcontracting Inward Order Received Item")
|
||||
case_expr_qty, case_expr_rate = Case(), Case()
|
||||
for d in result:
|
||||
d.received_qty += (
|
||||
data[d.name].transfer_qty if self._action == "submit" else -data[d.name].transfer_qty
|
||||
current_qty = flt(data[d.name].transfer_qty) * (1 if self._action == "submit" else -1)
|
||||
current_rate = flt(data[d.name].rate)
|
||||
|
||||
# Calculate weighted average rate
|
||||
old_total = d.rate * d.received_qty
|
||||
current_total = current_rate * current_qty
|
||||
|
||||
d.received_qty = d.received_qty + current_qty
|
||||
d.rate = (
|
||||
flt((old_total + current_total) / d.received_qty, precision) if d.received_qty else 0.0
|
||||
)
|
||||
d.rate += data[d.name].rate if self._action == "submit" else -data[d.name].rate
|
||||
|
||||
if not d.required_qty and not d.received_qty:
|
||||
deleted_docs.append(d.name)
|
||||
|
||||
@@ -39,17 +39,23 @@ class calculate_taxes_and_totals:
|
||||
items = list(filter(lambda item: not item.get("is_alternative"), self.doc.get("items")))
|
||||
return items
|
||||
|
||||
def calculate(self):
|
||||
def calculate(self, ignore_tax_template_validation=False):
|
||||
if not len(self.doc.items):
|
||||
return
|
||||
|
||||
self.discount_amount_applied = False
|
||||
self.need_recomputation = False
|
||||
self.ignore_tax_template_validation = ignore_tax_template_validation
|
||||
|
||||
self._calculate()
|
||||
|
||||
if self.doc.meta.get_field("discount_amount"):
|
||||
self.set_discount_amount()
|
||||
self.apply_discount_amount()
|
||||
|
||||
if not ignore_tax_template_validation and self.need_recomputation:
|
||||
return self.calculate(ignore_tax_template_validation=True)
|
||||
|
||||
# Update grand total as per cash and non trade discount
|
||||
if self.doc.apply_discount_on == "Grand Total" and self.doc.get("is_cash_or_non_trade_discount"):
|
||||
self.doc.grand_total -= self.doc.discount_amount
|
||||
@@ -79,6 +85,9 @@ class calculate_taxes_and_totals:
|
||||
self.calculate_total_net_weight()
|
||||
|
||||
def validate_item_tax_template(self):
|
||||
if self.ignore_tax_template_validation:
|
||||
return
|
||||
|
||||
if self.doc.get("is_return") and self.doc.get("return_against"):
|
||||
return
|
||||
|
||||
@@ -122,6 +131,10 @@ class calculate_taxes_and_totals:
|
||||
)
|
||||
)
|
||||
|
||||
# For correct tax_amount calculation re-computation is required
|
||||
if self.discount_amount_applied and self.doc.apply_discount_on == "Grand Total":
|
||||
self.need_recomputation = True
|
||||
|
||||
def update_item_tax_map(self):
|
||||
for item in self.doc.items:
|
||||
item.item_tax_rate = get_item_tax_map(
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
{
|
||||
"app": "erpnext",
|
||||
"creation": "2025-11-17 20:55:11.854086",
|
||||
"creation": "2026-01-27 17:02:43.440221",
|
||||
"docstatus": 0,
|
||||
"doctype": "Desktop Icon",
|
||||
"hidden": 0,
|
||||
"icon": "accounting",
|
||||
"icon_type": "Link",
|
||||
"icon_type": "Folder",
|
||||
"idx": 1,
|
||||
"label": "Accounting",
|
||||
"link_to": "Accounting",
|
||||
"link_to": "",
|
||||
"link_type": "Workspace Sidebar",
|
||||
"modified": "2026-01-01 20:07:01.203651",
|
||||
"modified": "2026-01-27 17:04:04.351402",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Accounting",
|
||||
"owner": "Administrator",
|
||||
"parent_icon": "Accounts",
|
||||
"parent_icon": "",
|
||||
"restrict_removal": 0,
|
||||
"roles": [],
|
||||
"standard": 1
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"app": "erpnext",
|
||||
"creation": "2025-11-12 13:07:51.988728",
|
||||
"docstatus": 0,
|
||||
"doctype": "Desktop Icon",
|
||||
"hidden": 0,
|
||||
"icon_type": "Folder",
|
||||
"idx": 1,
|
||||
"label": "Accounts",
|
||||
"link_type": "DocType",
|
||||
"logo_url": "",
|
||||
"modified": "2025-11-17 17:39:36.915358",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Accounts",
|
||||
"owner": "Administrator",
|
||||
"roles": [],
|
||||
"standard": 1
|
||||
}
|
||||
21
erpnext/desktop_icon/accounts_setup.json
Normal file
21
erpnext/desktop_icon/accounts_setup.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"app": "erpnext",
|
||||
"bg_color": "blue",
|
||||
"creation": "2026-01-27 17:37:55.824821",
|
||||
"docstatus": 0,
|
||||
"doctype": "Desktop Icon",
|
||||
"hidden": 0,
|
||||
"icon_type": "Link",
|
||||
"idx": 3,
|
||||
"label": "Accounts Setup",
|
||||
"link_to": "Accounts Setup",
|
||||
"link_type": "Workspace Sidebar",
|
||||
"modified": "2026-01-27 18:34:57.092350",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Accounts Setup",
|
||||
"owner": "Administrator",
|
||||
"parent_icon": "Accounting",
|
||||
"restrict_removal": 0,
|
||||
"roles": [],
|
||||
"standard": 1
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
"modified_by": "Administrator",
|
||||
"name": "Banking",
|
||||
"owner": "Administrator",
|
||||
"parent_icon": "Accounts",
|
||||
"parent_icon": "Accounting",
|
||||
"restrict_removal": 0,
|
||||
"roles": [],
|
||||
"standard": 1
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
{
|
||||
"app": "erpnext",
|
||||
"creation": "2025-11-10 16:54:04.780644",
|
||||
"creation": "2026-01-23 11:00:23.272751",
|
||||
"docstatus": 0,
|
||||
"doctype": "Desktop Icon",
|
||||
"hidden": 0,
|
||||
"icon": "expenses",
|
||||
"icon_type": "Link",
|
||||
"idx": 4,
|
||||
"idx": 6,
|
||||
"label": "Budget",
|
||||
"link_to": "Budget",
|
||||
"link_type": "Workspace Sidebar",
|
||||
"modified": "2026-01-01 20:07:01.449176",
|
||||
"modified": "2026-01-23 14:39:30.839274",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Budget",
|
||||
"owner": "Administrator",
|
||||
"parent_icon": "Accounts",
|
||||
"parent_icon": "Accounting",
|
||||
"restrict_removal": 0,
|
||||
"roles": [],
|
||||
"standard": 1
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
{
|
||||
"app": "erpnext",
|
||||
"creation": "2025-11-17 20:55:11.772622",
|
||||
"creation": "2026-01-23 11:00:23.250819",
|
||||
"docstatus": 0,
|
||||
"doctype": "Desktop Icon",
|
||||
"hidden": 0,
|
||||
"icon": "file",
|
||||
"icon_type": "Link",
|
||||
"idx": 0,
|
||||
"idx": 2,
|
||||
"label": "Financial Reports",
|
||||
"link_to": "Financial Reports",
|
||||
"link_type": "Workspace Sidebar",
|
||||
"modified": "2026-01-01 20:07:01.253367",
|
||||
"modified": "2026-01-23 14:38:46.479759",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Financial Reports",
|
||||
"owner": "Administrator",
|
||||
"parent_icon": "Accounts",
|
||||
"parent_icon": "Accounting",
|
||||
"restrict_removal": 0,
|
||||
"roles": [],
|
||||
"sidebar": "",
|
||||
|
||||
21
erpnext/desktop_icon/invoicing.json
Normal file
21
erpnext/desktop_icon/invoicing.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"app": "erpnext",
|
||||
"creation": "2026-01-23 10:51:05.799725",
|
||||
"docstatus": 0,
|
||||
"doctype": "Desktop Icon",
|
||||
"hidden": 0,
|
||||
"icon": "accounting",
|
||||
"icon_type": "Link",
|
||||
"idx": 0,
|
||||
"label": "Invoicing",
|
||||
"link_to": "Invoicing",
|
||||
"link_type": "Workspace Sidebar",
|
||||
"modified": "2026-01-23 15:17:23.564795",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Invoicing",
|
||||
"owner": "Administrator",
|
||||
"parent_icon": "Accounting",
|
||||
"restrict_removal": 0,
|
||||
"roles": [],
|
||||
"standard": 1
|
||||
}
|
||||
22
erpnext/desktop_icon/payments.json
Normal file
22
erpnext/desktop_icon/payments.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"app": "erpnext",
|
||||
"bg_color": "blue",
|
||||
"creation": "2026-01-27 17:37:55.866525",
|
||||
"docstatus": 0,
|
||||
"doctype": "Desktop Icon",
|
||||
"hidden": 0,
|
||||
"icon": "receipt-text",
|
||||
"icon_type": "Link",
|
||||
"idx": 1,
|
||||
"label": "Payments",
|
||||
"link_to": "Payments",
|
||||
"link_type": "Workspace Sidebar",
|
||||
"modified": "2026-01-27 18:31:59.617181",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Payments",
|
||||
"owner": "Administrator",
|
||||
"parent_icon": "Accounting",
|
||||
"restrict_removal": 0,
|
||||
"roles": [],
|
||||
"standard": 1
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
{
|
||||
"app": "erpnext",
|
||||
"creation": "2026-01-12 12:31:53.444807",
|
||||
"creation": "2026-01-23 11:00:23.303554",
|
||||
"docstatus": 0,
|
||||
"doctype": "Desktop Icon",
|
||||
"hidden": 0,
|
||||
"icon_type": "Link",
|
||||
"idx": 8,
|
||||
"idx": 7,
|
||||
"label": "Share Management",
|
||||
"link_to": "Share Management",
|
||||
"link_type": "Workspace Sidebar",
|
||||
"modified": "2026-01-12 12:31:53.444807",
|
||||
"modified": "2026-01-23 14:39:34.128991",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Share Management",
|
||||
"owner": "Administrator",
|
||||
"parent_icon": "Accounts",
|
||||
"parent_icon": "Accounting",
|
||||
"restrict_removal": 0,
|
||||
"roles": [],
|
||||
"standard": 1
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
{
|
||||
"app": "erpnext",
|
||||
"creation": "2025-11-10 16:14:25.976756",
|
||||
"creation": "2026-01-23 11:00:23.344237",
|
||||
"docstatus": 0,
|
||||
"doctype": "Desktop Icon",
|
||||
"hidden": 0,
|
||||
"icon": "monitor-check",
|
||||
"icon_type": "Link",
|
||||
"idx": 99,
|
||||
"idx": 8,
|
||||
"label": "Subscription",
|
||||
"link_to": "Subscription",
|
||||
"link_type": "Workspace Sidebar",
|
||||
"modified": "2026-01-01 20:07:01.548581",
|
||||
"modified": "2026-01-23 14:39:37.830722",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Subscription",
|
||||
"owner": "Administrator",
|
||||
"parent_icon": "Accounts",
|
||||
"parent_icon": "Accounting",
|
||||
"restrict_removal": 0,
|
||||
"roles": [],
|
||||
"standard": 1
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
{
|
||||
"app": "erpnext",
|
||||
"creation": "2025-11-12 15:05:54.474218",
|
||||
"creation": "2026-01-23 11:00:23.262357",
|
||||
"docstatus": 0,
|
||||
"doctype": "Desktop Icon",
|
||||
"hidden": 0,
|
||||
"icon": "book-text",
|
||||
"icon_type": "Link",
|
||||
"idx": 3,
|
||||
"idx": 4,
|
||||
"label": "Taxes",
|
||||
"link_to": "Taxes",
|
||||
"link_type": "Workspace Sidebar",
|
||||
"modified": "2026-01-01 20:07:01.356333",
|
||||
"modified": "2026-01-23 14:39:25.636166",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Taxes",
|
||||
"owner": "Administrator",
|
||||
"parent_icon": "Accounts",
|
||||
"parent_icon": "Accounting",
|
||||
"restrict_removal": 0,
|
||||
"roles": [],
|
||||
"sidebar": "",
|
||||
|
||||
@@ -8,7 +8,7 @@ app_email = "hello@frappe.io"
|
||||
app_license = "GNU General Public License (v3)"
|
||||
source_link = "https://github.com/frappe/erpnext"
|
||||
app_logo_url = "/assets/erpnext/images/erpnext-logo.svg"
|
||||
app_home = "/app/home"
|
||||
app_home = "/desk"
|
||||
|
||||
add_to_apps_screen = [
|
||||
{
|
||||
@@ -569,6 +569,7 @@ accounting_dimension_doctypes = [
|
||||
"Payment Request",
|
||||
"Asset Movement Item",
|
||||
"Asset Depreciation Schedule",
|
||||
"Advance Taxes and Charges",
|
||||
]
|
||||
|
||||
get_matching_queries = (
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -92,6 +92,10 @@ frappe.ui.form.on("BOM", {
|
||||
};
|
||||
});
|
||||
|
||||
frm.events.set_company_filters(frm, "project");
|
||||
frm.events.set_company_filters(frm, "default_source_warehouse");
|
||||
frm.events.set_company_filters(frm, "default_target_warehouse");
|
||||
|
||||
frm.trigger("toggle_fields_for_semi_finished_goods");
|
||||
},
|
||||
|
||||
@@ -104,6 +108,16 @@ frappe.ui.form.on("BOM", {
|
||||
}
|
||||
},
|
||||
|
||||
set_company_filters: function (frm, fieldname) {
|
||||
frm.set_query(fieldname, () => {
|
||||
return {
|
||||
filters: {
|
||||
company: frm.doc.company,
|
||||
},
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
track_semi_finished_goods(frm) {
|
||||
frm.trigger("toggle_fields_for_semi_finished_goods");
|
||||
},
|
||||
@@ -683,8 +697,6 @@ var get_bom_material_detail = function (doc, cdt, cdn, scrap_items) {
|
||||
do_not_explode: d.do_not_explode,
|
||||
},
|
||||
callback: function (r) {
|
||||
d = locals[cdt][cdn];
|
||||
|
||||
$.extend(d, r.message);
|
||||
refresh_field("items");
|
||||
refresh_field("scrap_items");
|
||||
|
||||
@@ -1547,6 +1547,9 @@ def add_operating_cost_component_wise(
|
||||
if job_card and job_card.operation_id != row.name:
|
||||
continue
|
||||
|
||||
if not row.actual_operation_time:
|
||||
continue
|
||||
|
||||
workstation_cost = frappe.get_all(
|
||||
"Workstation Cost",
|
||||
fields=["operating_component", "operating_cost"],
|
||||
@@ -1609,7 +1612,7 @@ def add_operations_cost(stock_entry, work_order=None, expense_account=None, job_
|
||||
job_card=job_card,
|
||||
)
|
||||
|
||||
if not cost_added:
|
||||
if not cost_added and not job_card:
|
||||
stock_entry.append(
|
||||
"additional_costs",
|
||||
{
|
||||
|
||||
@@ -3725,6 +3725,53 @@ class TestWorkOrder(IntegrationTestCase):
|
||||
wo = make_wo_order_test_record(item="Top Level Parent")
|
||||
self.assertEqual([item.item_code for item in wo.required_items], expected)
|
||||
|
||||
def test_reserved_qty_for_pp_with_extra_material_transfer(self):
|
||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import (
|
||||
make_stock_entry as make_stock_entry_test_record,
|
||||
)
|
||||
|
||||
rm_item_code = make_item(
|
||||
"_Test Reserved Qty PP Item",
|
||||
{
|
||||
"is_stock_item": 1,
|
||||
},
|
||||
).name
|
||||
|
||||
fg_item_code = make_item(
|
||||
"_Test Reserved Qty PP FG Item",
|
||||
{
|
||||
"is_stock_item": 1,
|
||||
},
|
||||
).name
|
||||
|
||||
make_stock_entry_test_record(
|
||||
item_code=rm_item_code, target="_Test Warehouse - _TC", qty=10, basic_rate=100
|
||||
)
|
||||
|
||||
make_bom(
|
||||
item=fg_item_code,
|
||||
raw_materials=[rm_item_code],
|
||||
)
|
||||
|
||||
wo_order = make_wo_order_test_record(
|
||||
item=fg_item_code,
|
||||
qty=1,
|
||||
source_warehouse="_Test Warehouse - _TC",
|
||||
skip_transfer=0,
|
||||
target_warehouse="_Test Warehouse - _TC",
|
||||
)
|
||||
|
||||
bin1_at_completion = get_bin(rm_item_code, "_Test Warehouse - _TC")
|
||||
self.assertEqual(bin1_at_completion.reserved_qty_for_production, 1)
|
||||
|
||||
s = frappe.get_doc(make_stock_entry(wo_order.name, "Material Transfer for Manufacture", 1))
|
||||
s.items[0].qty += 2 # extra material transfer
|
||||
s.submit()
|
||||
|
||||
bin1_at_completion = get_bin(rm_item_code, "_Test Warehouse - _TC")
|
||||
|
||||
self.assertEqual(bin1_at_completion.reserved_qty_for_production, 0)
|
||||
|
||||
|
||||
def get_reserved_entries(voucher_no, warehouse=None):
|
||||
doctype = frappe.qb.DocType("Stock Reservation Entry")
|
||||
|
||||
@@ -829,7 +829,7 @@ erpnext.work_order = {
|
||||
}
|
||||
}
|
||||
if (counter > 0) {
|
||||
var consumption_btn = frm.add_custom_button(
|
||||
frm.add_custom_button(
|
||||
__("Material Consumption"),
|
||||
function () {
|
||||
const backflush_raw_materials_based_on =
|
||||
|
||||
@@ -502,8 +502,8 @@ class WorkOrder(Document):
|
||||
def validate_work_order_against_so(self):
|
||||
# already ordered qty
|
||||
ordered_qty_against_so = frappe.db.sql(
|
||||
"""select sum(qty) from `tabWork Order`
|
||||
where production_item = %s and sales_order = %s and docstatus < 2 and status != 'Closed' and name != %s""",
|
||||
"""select sum(qty - process_loss_qty) from `tabWork Order`
|
||||
where production_item = %s and sales_order = %s and docstatus = 1 and status != 'Closed' and name != %s""",
|
||||
(self.production_item, self.sales_order, self.name),
|
||||
)[0][0]
|
||||
|
||||
@@ -512,13 +512,13 @@ class WorkOrder(Document):
|
||||
# get qty from Sales Order Item table
|
||||
so_item_qty = frappe.db.sql(
|
||||
"""select sum(stock_qty) from `tabSales Order Item`
|
||||
where parent = %s and item_code = %s""",
|
||||
where parent = %s and item_code = %s and docstatus = 1""",
|
||||
(self.sales_order, self.production_item),
|
||||
)[0][0]
|
||||
# get qty from Packing Item table
|
||||
dnpi_qty = frappe.db.sql(
|
||||
"""select sum(qty) from `tabPacked Item`
|
||||
where parent = %s and parenttype = 'Sales Order' and item_code = %s""",
|
||||
where parent = %s and parenttype = 'Sales Order' and item_code = %s and docstatus = 1""",
|
||||
(self.sales_order, self.production_item),
|
||||
)[0][0]
|
||||
# total qty in SO
|
||||
@@ -530,8 +530,10 @@ class WorkOrder(Document):
|
||||
|
||||
if total_qty > so_qty + (allowance_percentage / 100 * so_qty):
|
||||
frappe.throw(
|
||||
_("Cannot produce more Item {0} than Sales Order quantity {1}").format(
|
||||
self.production_item, so_qty
|
||||
_("Cannot produce more Item {0} than Sales Order quantity {1} {2}").format(
|
||||
get_link_to_form("Item", self.production_item),
|
||||
frappe.bold(so_qty),
|
||||
frappe.bold(frappe.get_value("Item", self.production_item, "stock_uom")),
|
||||
),
|
||||
OverProductionError,
|
||||
)
|
||||
@@ -768,6 +770,7 @@ class WorkOrder(Document):
|
||||
self.db_set("status", "Cancelled")
|
||||
|
||||
self.on_close_or_cancel()
|
||||
self.delete_job_card()
|
||||
|
||||
def on_close_or_cancel(self):
|
||||
if self.production_plan and frappe.db.exists(
|
||||
@@ -777,7 +780,6 @@ class WorkOrder(Document):
|
||||
else:
|
||||
self.update_work_order_qty_in_so()
|
||||
|
||||
self.delete_job_card()
|
||||
self.update_completed_qty_in_material_request()
|
||||
self.update_planned_qty()
|
||||
self.update_ordered_qty()
|
||||
@@ -2652,6 +2654,9 @@ def get_reserved_qty_for_production(
|
||||
qty_field = wo_item.required_qty
|
||||
else:
|
||||
qty_field = Case()
|
||||
qty_field = qty_field.when(
|
||||
((wo.skip_transfer == 0) & (wo_item.transferred_qty > wo_item.required_qty)), 0.0
|
||||
)
|
||||
qty_field = qty_field.when(wo.skip_transfer == 0, wo_item.required_qty - wo_item.transferred_qty)
|
||||
qty_field = qty_field.else_(wo_item.required_qty - wo_item.consumed_qty)
|
||||
|
||||
|
||||
@@ -458,3 +458,4 @@ erpnext.patches.v16_0.update_corrected_cancelled_status
|
||||
erpnext.patches.v16_0.fix_barcode_typo
|
||||
erpnext.patches.v16_0.set_post_change_gl_entries_on_pos_settings
|
||||
execute:frappe.delete_doc_if_exists("Workspace Sidebar", "Opening & Closing")
|
||||
erpnext.patches.v15_0.create_accounting_dimensions_in_advance_taxes_and_charges
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
|
||||
create_accounting_dimensions_for_doctype,
|
||||
)
|
||||
|
||||
|
||||
def execute():
|
||||
create_accounting_dimensions_for_doctype(doctype="Advance Taxes and Charges")
|
||||
@@ -603,7 +603,7 @@ def send_project_update_email_to_users(project):
|
||||
"sent": 0,
|
||||
"date": today(),
|
||||
"time": nowtime(),
|
||||
"naming_series": "UPDATE-.project.-.YY.MM.DD.-",
|
||||
"naming_series": "UPDATE-.project.-.YY.MM.DD.-.####",
|
||||
}
|
||||
).insert()
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import frappe
|
||||
from frappe.tests import IntegrationTestCase
|
||||
from frappe.utils import add_to_date, now_datetime, nowdate
|
||||
|
||||
from erpnext.accounts.doctype.sales_invoice.sales_invoice import make_sales_return
|
||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
|
||||
from erpnext.projects.doctype.task.test_task import create_task
|
||||
from erpnext.projects.doctype.timesheet.timesheet import OverlapError, make_sales_invoice
|
||||
@@ -272,6 +273,60 @@ class TestTimesheet(ERPNextTestSuite):
|
||||
ts.calculate_percentage_billed()
|
||||
self.assertEqual(ts.per_billed, 100)
|
||||
|
||||
def test_partial_billing_and_return(self):
|
||||
"""
|
||||
Test Timesheet status transitions during partial billing, full billing,
|
||||
sales return, and return cancellation.
|
||||
|
||||
Scenario:
|
||||
1. Create a Timesheet with two billable time logs.
|
||||
2. Create a Sales Invoice billing only one time log → Timesheet becomes Partially Billed.
|
||||
3. Create another Sales Invoice billing the remaining time log → Timesheet becomes Billed.
|
||||
4. Create a Sales Return against the second invoice → Timesheet reverts to Partially Billed.
|
||||
5. Cancel the Sales Return → Timesheet returns to Billed status.
|
||||
|
||||
This test ensures Timesheet status is recalculated correctly
|
||||
across billing and return lifecycle events.
|
||||
"""
|
||||
emp = make_employee("test_employee_6@salary.com")
|
||||
|
||||
timesheet = make_timesheet(emp, simulate=True, is_billable=1, do_not_submit=True)
|
||||
timesheet_detail = timesheet.append("time_logs", {})
|
||||
timesheet_detail.is_billable = 1
|
||||
timesheet_detail.activity_type = "_Test Activity Type"
|
||||
timesheet_detail.from_time = timesheet.time_logs[0].to_time + datetime.timedelta(minutes=1)
|
||||
timesheet_detail.hours = 2
|
||||
timesheet_detail.to_time = timesheet_detail.from_time + datetime.timedelta(
|
||||
hours=timesheet_detail.hours
|
||||
)
|
||||
timesheet.save().submit()
|
||||
|
||||
sales_invoice = make_sales_invoice(timesheet.name, "_Test Item", "_Test Customer", currency="INR")
|
||||
sales_invoice.due_date = nowdate()
|
||||
sales_invoice.timesheets.pop()
|
||||
sales_invoice.submit()
|
||||
|
||||
timesheet_status = frappe.get_value("Timesheet", timesheet.name, "status")
|
||||
self.assertEqual(timesheet_status, "Partially Billed")
|
||||
|
||||
sales_invoice2 = make_sales_invoice(timesheet.name, "_Test Item", "_Test Customer", currency="INR")
|
||||
sales_invoice2.due_date = nowdate()
|
||||
sales_invoice2.submit()
|
||||
|
||||
timesheet_status = frappe.get_value("Timesheet", timesheet.name, "status")
|
||||
self.assertEqual(timesheet_status, "Billed")
|
||||
|
||||
sales_return = make_sales_return(sales_invoice2.name).submit()
|
||||
timesheet_status = frappe.get_value("Timesheet", timesheet.name, "status")
|
||||
self.assertEqual(timesheet_status, "Partially Billed")
|
||||
|
||||
sales_return.load_from_db()
|
||||
sales_return.cancel()
|
||||
|
||||
timesheet.load_from_db()
|
||||
self.assertEqual(timesheet.time_logs[1].sales_invoice, sales_invoice2.name)
|
||||
self.assertEqual(timesheet.status, "Billed")
|
||||
|
||||
|
||||
def make_timesheet(
|
||||
employee,
|
||||
@@ -283,6 +338,7 @@ def make_timesheet(
|
||||
company=None,
|
||||
currency=None,
|
||||
exchange_rate=None,
|
||||
do_not_submit=False,
|
||||
):
|
||||
update_activity_type(activity_type)
|
||||
timesheet = frappe.new_doc("Timesheet")
|
||||
@@ -311,7 +367,8 @@ def make_timesheet(
|
||||
else:
|
||||
timesheet.save(ignore_permissions=True)
|
||||
|
||||
timesheet.submit()
|
||||
if not do_not_submit:
|
||||
timesheet.submit()
|
||||
|
||||
return timesheet
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
"in_standard_filter": 1,
|
||||
"label": "Status",
|
||||
"no_copy": 1,
|
||||
"options": "Draft\nSubmitted\nBilled\nPayslip\nCompleted\nCancelled",
|
||||
"options": "Draft\nSubmitted\nPartially Billed\nBilled\nPayslip\nCompleted\nCancelled",
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
@@ -310,7 +310,7 @@
|
||||
"idx": 1,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2024-03-27 13:10:53.551907",
|
||||
"modified": "2025-12-19 13:48:23.453636",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Projects",
|
||||
"name": "Timesheet",
|
||||
@@ -386,8 +386,9 @@
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"row_format": "Dynamic",
|
||||
"sort_field": "creation",
|
||||
"sort_order": "ASC",
|
||||
"states": [],
|
||||
"title_field": "title"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,9 @@ class Timesheet(Document):
|
||||
per_billed: DF.Percent
|
||||
sales_invoice: DF.Link | None
|
||||
start_date: DF.Date | None
|
||||
status: DF.Literal["Draft", "Submitted", "Billed", "Payslip", "Completed", "Cancelled"]
|
||||
status: DF.Literal[
|
||||
"Draft", "Submitted", "Partially Billed", "Billed", "Payslip", "Completed", "Cancelled"
|
||||
]
|
||||
time_logs: DF.Table[TimesheetDetail]
|
||||
title: DF.Data | None
|
||||
total_billable_amount: DF.Currency
|
||||
@@ -128,6 +130,9 @@ class Timesheet(Document):
|
||||
if flt(self.per_billed, self.precision("per_billed")) >= 100.0:
|
||||
self.status = "Billed"
|
||||
|
||||
if 0.0 < flt(self.per_billed, self.precision("per_billed")) < 100.0:
|
||||
self.status = "Partially Billed"
|
||||
|
||||
if self.sales_invoice:
|
||||
self.status = "Completed"
|
||||
|
||||
@@ -433,7 +438,7 @@ def make_sales_invoice(source_name, item_code=None, customer=None, currency=None
|
||||
target.append("items", {"item_code": item_code, "qty": hours, "rate": billing_rate})
|
||||
|
||||
for time_log in timesheet.time_logs:
|
||||
if time_log.is_billable:
|
||||
if time_log.is_billable and not time_log.sales_invoice:
|
||||
target.append(
|
||||
"timesheets",
|
||||
{
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
frappe.listview_settings["Timesheet"] = {
|
||||
add_fields: ["status", "total_hours", "start_date", "end_date"],
|
||||
get_indicator: function (doc) {
|
||||
if (doc.status == "Partially Billed") {
|
||||
return [__("Partially Billed"), "orange", "status,=," + "Partially Billed"];
|
||||
}
|
||||
|
||||
if (doc.status == "Billed") {
|
||||
return [__("Billed"), "green", "status,=," + "Billed"];
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 928 B After Width: | Height: | Size: 928 B |
@@ -637,6 +637,12 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
||||
tax_count ? this.frm.doc["taxes"][tax_count - 1].total + grand_total_diff : this.frm.doc.net_total
|
||||
);
|
||||
|
||||
// total taxes and charges is calculated before adjusting base grand total
|
||||
this.frm.doc.total_taxes_and_charges = flt(
|
||||
this.frm.doc.grand_total - this.frm.doc.net_total - grand_total_diff,
|
||||
precision("total_taxes_and_charges")
|
||||
);
|
||||
|
||||
if (
|
||||
["Quotation", "Sales Order", "Delivery Note", "Sales Invoice", "POS Invoice"].includes(
|
||||
this.frm.doc.doctype
|
||||
@@ -679,11 +685,6 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
||||
]);
|
||||
}
|
||||
|
||||
this.frm.doc.total_taxes_and_charges = flt(
|
||||
this.frm.doc.grand_total - this.frm.doc.net_total - grand_total_diff,
|
||||
precision("total_taxes_and_charges")
|
||||
);
|
||||
|
||||
this.set_in_company_currency(this.frm.doc, ["total_taxes_and_charges"]);
|
||||
|
||||
// Round grand total as per precision
|
||||
|
||||
@@ -518,7 +518,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
|
||||
barcode(doc, cdt, cdn) {
|
||||
let row = locals[cdt][cdn];
|
||||
if (row.barcode) {
|
||||
if (row.barcode && !frappe.flags.trigger_from_barcode_scanner) {
|
||||
erpnext.stock.utils.set_item_details_using_barcode(this.frm, row, (r) => {
|
||||
frappe.model.set_value(cdt, cdn, {
|
||||
item_code: r.message.item_code,
|
||||
@@ -945,11 +945,10 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
// Replace all occurences of comma with line feed
|
||||
item.serial_no = item.serial_no.replace(/,/g, "\n");
|
||||
item.conversion_factor = item.conversion_factor || 1;
|
||||
refresh_field("serial_no", item.name, item.parentfield);
|
||||
if (!doc.is_return) {
|
||||
setTimeout(() => {
|
||||
me.update_qty(cdt, cdn);
|
||||
}, 3000);
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1530,8 +1529,8 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
} else if (
|
||||
this.frm.doc.price_list_currency === this.frm.doc.currency &&
|
||||
this.frm.doc.plc_conversion_rate &&
|
||||
cint(this.frm.doc.plc_conversion_rate) != 1 &&
|
||||
cint(this.frm.doc.plc_conversion_rate) != cint(this.frm.doc.conversion_rate)
|
||||
flt(this.frm.doc.plc_conversion_rate) != 1 &&
|
||||
flt(this.frm.doc.plc_conversion_rate) != flt(this.frm.doc.conversion_rate)
|
||||
) {
|
||||
this.frm.set_value("conversion_rate", this.frm.doc.plc_conversion_rate);
|
||||
}
|
||||
@@ -3132,10 +3131,16 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
|
||||
set_warehouse() {
|
||||
this.autofill_warehouse(this.frm.doc.items, "warehouse", this.frm.doc.set_warehouse);
|
||||
this.autofill_warehouse(this.frm.doc.packed_items, "warehouse", this.frm.doc.set_warehouse);
|
||||
}
|
||||
|
||||
set_target_warehouse() {
|
||||
this.autofill_warehouse(this.frm.doc.items, "target_warehouse", this.frm.doc.set_target_warehouse);
|
||||
this.autofill_warehouse(
|
||||
this.frm.doc.packed_items,
|
||||
"target_warehouse",
|
||||
this.frm.doc.set_target_warehouse
|
||||
);
|
||||
}
|
||||
|
||||
set_from_warehouse() {
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
frappe.provide("erpnext.financial_statements");
|
||||
|
||||
function get_filter_value(filter_name) {
|
||||
// not warn when the filter is missing
|
||||
return frappe.query_report.get_filter_value(filter_name, false);
|
||||
}
|
||||
|
||||
erpnext.financial_statements = {
|
||||
filters: get_filters(),
|
||||
baseData: null,
|
||||
|
||||
get_pdf_format: function (report, custom_format) {
|
||||
// If report template is selected, use default pdf formatting
|
||||
return report.get_filter_value("report_template") ? null : custom_format;
|
||||
return get_filter_value("report_template") ? null : custom_format;
|
||||
},
|
||||
|
||||
formatter: function (value, row, column, data, default_formatter, filter) {
|
||||
@@ -15,14 +20,14 @@ erpnext.financial_statements = {
|
||||
if (erpnext.financial_statements._is_special_view(column, data))
|
||||
return erpnext.financial_statements._format_special_view(...report_params);
|
||||
|
||||
if (frappe.query_report.get_filter_value("report_template"))
|
||||
if (get_filter_value("report_template"))
|
||||
return erpnext.financial_statements._format_custom_report(...report_params);
|
||||
else return erpnext.financial_statements._format_standard_report(...report_params);
|
||||
},
|
||||
|
||||
_is_special_view: function (column, data) {
|
||||
if (!data) return false;
|
||||
const view = frappe.query_report.get_filter_value("selected_view");
|
||||
const view = get_filter_value("selected_view");
|
||||
return (view === "Growth" && column.colIndex >= 3) || (view === "Margin" && column.colIndex >= 2);
|
||||
},
|
||||
|
||||
@@ -100,7 +105,7 @@ erpnext.financial_statements = {
|
||||
from_date: formatting.from_date || formatting.period_start_date,
|
||||
to_date: formatting.to_date || formatting.period_end_date,
|
||||
account_type: formatting.account_type,
|
||||
company: frappe.query_report.get_filter_value("company"),
|
||||
company: get_filter_value("company"),
|
||||
};
|
||||
|
||||
column.link_onclick =
|
||||
@@ -177,7 +182,7 @@ erpnext.financial_statements = {
|
||||
},
|
||||
|
||||
_format_special_view: function (value, row, column, data, default_formatter) {
|
||||
const selectedView = frappe.query_report.get_filter_value("selected_view");
|
||||
const selectedView = get_filter_value("selected_view");
|
||||
|
||||
if (selectedView === "Growth") {
|
||||
const growthPercent = data[column.fieldname];
|
||||
@@ -252,7 +257,7 @@ erpnext.financial_statements = {
|
||||
|
||||
frappe.route_options = {
|
||||
account: data.account || data.accounts,
|
||||
company: frappe.query_report.get_filter_value("company"),
|
||||
company: get_filter_value("company"),
|
||||
from_date: data.from_date || data.year_start_date,
|
||||
to_date: data.to_date || data.year_end_date,
|
||||
project: project && project.length > 0 ? project[0].get_value() : "",
|
||||
@@ -305,17 +310,49 @@ erpnext.financial_statements = {
|
||||
|
||||
report.page.add_custom_menu_item(views_menu, __("Balance Sheet"), function () {
|
||||
var filters = report.get_values();
|
||||
frappe.set_route("query-report", "Balance Sheet", { company: filters.company });
|
||||
frappe.set_route("query-report", "Balance Sheet", {
|
||||
company: filters.company,
|
||||
filter_based_on: filters.filter_based_on,
|
||||
period_start_date: filters.period_start_date,
|
||||
period_end_date: filters.period_end_date,
|
||||
from_fiscal_year: filters.from_fiscal_year,
|
||||
to_fiscal_year: filters.to_fiscal_year,
|
||||
periodicity: filters.periodicity,
|
||||
presentation_currency: filters.presentation_currency,
|
||||
cost_center: filters.cost_center,
|
||||
project: filters.project,
|
||||
});
|
||||
});
|
||||
|
||||
report.page.add_custom_menu_item(views_menu, __("Profit and Loss"), function () {
|
||||
var filters = report.get_values();
|
||||
frappe.set_route("query-report", "Profit and Loss Statement", { company: filters.company });
|
||||
frappe.set_route("query-report", "Profit and Loss Statement", {
|
||||
company: filters.company,
|
||||
filter_based_on: filters.filter_based_on,
|
||||
period_start_date: filters.period_start_date,
|
||||
period_end_date: filters.period_end_date,
|
||||
from_fiscal_year: filters.from_fiscal_year,
|
||||
to_fiscal_year: filters.to_fiscal_year,
|
||||
periodicity: filters.periodicity,
|
||||
presentation_currency: filters.presentation_currency,
|
||||
cost_center: filters.cost_center,
|
||||
project: filters.project,
|
||||
});
|
||||
});
|
||||
|
||||
report.page.add_custom_menu_item(views_menu, __("Cash Flow Statement"), function () {
|
||||
var filters = report.get_values();
|
||||
frappe.set_route("query-report", "Cash Flow", { company: filters.company });
|
||||
frappe.set_route("query-report", "Cash Flow", {
|
||||
company: filters.company,
|
||||
filter_based_on: filters.filter_based_on,
|
||||
period_start_date: filters.period_start_date,
|
||||
period_end_date: filters.period_end_date,
|
||||
from_fiscal_year: filters.from_fiscal_year,
|
||||
to_fiscal_year: filters.to_fiscal_year,
|
||||
periodicity: filters.periodicity,
|
||||
cost_center: filters.cost_center,
|
||||
project: filters.project,
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -345,7 +382,7 @@ function get_filters() {
|
||||
default: ["Fiscal Year"],
|
||||
reqd: 1,
|
||||
on_change: function () {
|
||||
let filter_based_on = frappe.query_report.get_filter_value("filter_based_on");
|
||||
let filter_based_on = get_filter_value("filter_based_on");
|
||||
frappe.query_report.toggle_filter_display(
|
||||
"from_fiscal_year",
|
||||
filter_based_on === "Date Range"
|
||||
@@ -422,7 +459,7 @@ function get_filters() {
|
||||
fieldtype: "MultiSelectList",
|
||||
get_data: function (txt) {
|
||||
return frappe.db.get_link_options("Cost Center", txt, {
|
||||
company: frappe.query_report.get_filter_value("company"),
|
||||
company: get_filter_value("company"),
|
||||
});
|
||||
},
|
||||
options: "Cost Center",
|
||||
@@ -433,7 +470,7 @@ function get_filters() {
|
||||
fieldtype: "MultiSelectList",
|
||||
get_data: function (txt) {
|
||||
return frappe.db.get_link_options("Project", txt, {
|
||||
company: frappe.query_report.get_filter_value("company"),
|
||||
company: get_filter_value("company"),
|
||||
});
|
||||
},
|
||||
options: "Project",
|
||||
|
||||
@@ -735,6 +735,7 @@ erpnext.utils.update_child_items = function (opts) {
|
||||
fieldname: "item_name",
|
||||
label: __("Item Name"),
|
||||
read_only: 1,
|
||||
in_list_view: 1,
|
||||
},
|
||||
{
|
||||
fieldtype: "Link",
|
||||
@@ -792,7 +793,7 @@ erpnext.utils.update_child_items = function (opts) {
|
||||
];
|
||||
|
||||
if (frm.doc.doctype == "Sales Order" || frm.doc.doctype == "Purchase Order") {
|
||||
fields.splice(2, 0, {
|
||||
fields.splice(3, 0, {
|
||||
fieldtype: "Date",
|
||||
fieldname: frm.doc.doctype == "Sales Order" ? "delivery_date" : "schedule_date",
|
||||
in_list_view: 1,
|
||||
@@ -800,7 +801,7 @@ erpnext.utils.update_child_items = function (opts) {
|
||||
default: frm.doc.doctype == "Sales Order" ? frm.doc.delivery_date : frm.doc.schedule_date,
|
||||
reqd: 1,
|
||||
});
|
||||
fields.splice(3, 0, {
|
||||
fields.splice(4, 0, {
|
||||
fieldtype: "Float",
|
||||
fieldname: "conversion_factor",
|
||||
label: __("Conversion Factor"),
|
||||
|
||||
@@ -138,7 +138,6 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
||||
|
||||
frappe.run_serially([
|
||||
() => this.set_selector_trigger_flag(data),
|
||||
() => this.set_barcode_uom(row, uom),
|
||||
() => this.set_serial_no(row, serial_no),
|
||||
() => this.set_batch_no(row, batch_no),
|
||||
() => this.set_barcode(row, barcode),
|
||||
@@ -148,6 +147,7 @@ erpnext.utils.BarcodeScanner = class BarcodeScanner {
|
||||
this.show_scan_message(row.idx, !is_new_row, qty);
|
||||
}),
|
||||
() => this.clean_up(),
|
||||
() => this.set_barcode_uom(row, uom),
|
||||
() => this.revert_selector_flag(),
|
||||
() => resolve(row),
|
||||
]);
|
||||
|
||||
@@ -157,7 +157,7 @@ erpnext.utils.get_address_display = function (frm, address_field, display_field,
|
||||
args: { address_dict: frm.doc[address_field] },
|
||||
callback: function (r) {
|
||||
if (r.message) {
|
||||
frm.set_value(display_field, frappe.utils.html2text(r.message));
|
||||
frm.set_value(display_field, r.message);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -495,7 +495,30 @@ erpnext.sales_common = {
|
||||
}
|
||||
}
|
||||
|
||||
project() {
|
||||
project(doc, cdt, cdn) {
|
||||
if (!cdt || !cdn) {
|
||||
if (this.frm.doc.project) {
|
||||
$.each(this.frm.doc["items"] || [], function (i, item) {
|
||||
if (!item.project) {
|
||||
frappe.model.set_value(item.doctype, item.name, "project", doc.project);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const item = frappe.get_doc(cdt, cdn);
|
||||
if (item.project) {
|
||||
$.each(this.frm.doc["items"] || [], function (i, other_item) {
|
||||
if (!other_item.project) {
|
||||
frappe.model.set_value(
|
||||
other_item.doctype,
|
||||
other_item.name,
|
||||
"project",
|
||||
item.project
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
let me = this;
|
||||
if (["Delivery Note", "Sales Invoice", "Sales Order"].includes(this.frm.doc.doctype)) {
|
||||
if (this.frm.doc.project) {
|
||||
|
||||
4
erpnext/regional/address_template/templates/sweden.html
Normal file
4
erpnext/regional/address_template/templates/sweden.html
Normal file
@@ -0,0 +1,4 @@
|
||||
{{ address_line1 }}<br>
|
||||
{% if address_line2 %}{{ address_line2 }}<br>{% endif -%}
|
||||
{{ pincode }} {{ city | upper }}<br>
|
||||
{{ country | upper }}
|
||||
@@ -183,6 +183,7 @@
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Customer Group",
|
||||
"link_filters": "[[\"Customer Group\", \"is_group\", \"=\", 0]]",
|
||||
"oldfieldname": "customer_group",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Customer Group",
|
||||
@@ -335,7 +336,7 @@
|
||||
},
|
||||
{
|
||||
"fieldname": "primary_address",
|
||||
"fieldtype": "Text",
|
||||
"fieldtype": "Text Editor",
|
||||
"label": "Primary Address",
|
||||
"read_only": 1
|
||||
},
|
||||
@@ -625,7 +626,7 @@
|
||||
"link_fieldname": "party"
|
||||
}
|
||||
],
|
||||
"modified": "2025-11-25 09:35:56.772949",
|
||||
"modified": "2026-01-21 17:23:42.151114",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Selling",
|
||||
"name": "Customer",
|
||||
|
||||
@@ -83,7 +83,7 @@ class Customer(TransactionBase):
|
||||
opportunity_name: DF.Link | None
|
||||
payment_terms: DF.Link | None
|
||||
portal_users: DF.Table[PortalUser]
|
||||
primary_address: DF.Text | None
|
||||
primary_address: DF.TextEditor | None
|
||||
prospect_name: DF.Link | None
|
||||
represents_company: DF.Link | None
|
||||
sales_team: DF.Table[SalesTeam]
|
||||
@@ -117,6 +117,7 @@ class Customer(TransactionBase):
|
||||
set_name_from_naming_options(frappe.get_meta(self.doctype).autoname, self)
|
||||
|
||||
def get_customer_name(self):
|
||||
self.customer_name = self.customer_name.strip()
|
||||
if frappe.db.get_value("Customer", self.customer_name) and not frappe.flags.in_import:
|
||||
count = frappe.db.sql(
|
||||
"""select ifnull(MAX(CAST(SUBSTRING_INDEX(name, ' ', -1) AS UNSIGNED)), 0) from tabCustomer
|
||||
|
||||
@@ -35,8 +35,7 @@ class TestPartySpecificItem(IntegrationTestCase):
|
||||
items = item_query(
|
||||
doctype="Item", txt="", searchfield="name", start=0, page_len=20, filters=filters, as_dict=False
|
||||
)
|
||||
for item in items:
|
||||
self.assertEqual(item[0], self.item.name)
|
||||
self.assertTrue(self.item.name in flatten(items))
|
||||
|
||||
def test_item_query_for_supplier(self):
|
||||
create_party_specific_item(
|
||||
@@ -49,5 +48,14 @@ class TestPartySpecificItem(IntegrationTestCase):
|
||||
items = item_query(
|
||||
doctype="Item", txt="", searchfield="name", start=0, page_len=20, filters=filters, as_dict=False
|
||||
)
|
||||
for item in items:
|
||||
self.assertEqual(item[2], self.item.item_group)
|
||||
self.assertTrue(self.item.item_group in flatten(items))
|
||||
|
||||
|
||||
def flatten(lst):
|
||||
result = []
|
||||
for item in lst:
|
||||
if isinstance(item, tuple):
|
||||
result.extend(flatten(item))
|
||||
else:
|
||||
result.append(item)
|
||||
return result
|
||||
|
||||
@@ -36,6 +36,15 @@ frappe.ui.form.on("Quotation", {
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query("warehouse", "items", (doc, cdt, cdn) => {
|
||||
return {
|
||||
filters: {
|
||||
company: doc.company,
|
||||
is_group: 0,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_indicator_formatter("item_code", function (doc) {
|
||||
return !doc.qty && frm.doc.has_unit_price_items ? "yellow" : "";
|
||||
});
|
||||
|
||||
@@ -1220,10 +1220,12 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex
|
||||
},
|
||||
freeze: true,
|
||||
callback: function (r) {
|
||||
if (!r.message) {
|
||||
if (r.message.length === 0) {
|
||||
frappe.msgprint({
|
||||
title: __("Work Order not created"),
|
||||
message: __("No Items with Bill of Materials to Manufacture"),
|
||||
message: __(
|
||||
"No Items with Bill of Materials to Manufacture or all items already manufactured"
|
||||
),
|
||||
indicator: "orange",
|
||||
});
|
||||
return;
|
||||
@@ -1233,19 +1235,24 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex
|
||||
label: __("Items"),
|
||||
fieldtype: "Table",
|
||||
fieldname: "items",
|
||||
cannot_add_rows: true,
|
||||
description: __("Select BOM and Qty for Production"),
|
||||
fields: [
|
||||
{
|
||||
fieldtype: "Read Only",
|
||||
fieldtype: "Link",
|
||||
fieldname: "item_code",
|
||||
options: "Item",
|
||||
label: __("Item Code"),
|
||||
in_list_view: 1,
|
||||
read_only: 1,
|
||||
},
|
||||
{
|
||||
fieldtype: "Read Only",
|
||||
fieldtype: "Data",
|
||||
fieldname: "item_name",
|
||||
label: __("Item Name"),
|
||||
in_list_view: 1,
|
||||
read_only: 1,
|
||||
fetch_from: "item_code.item_name",
|
||||
},
|
||||
{
|
||||
fieldtype: "Link",
|
||||
@@ -1271,6 +1278,7 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex
|
||||
reqd: 1,
|
||||
label: __("Sales Order Item"),
|
||||
hidden: 1,
|
||||
read_only: 1,
|
||||
},
|
||||
],
|
||||
data: r.message,
|
||||
|
||||
@@ -1981,6 +1981,10 @@ def get_work_order_items(sales_order, for_raw_material_request=0):
|
||||
)
|
||||
]
|
||||
|
||||
overproduction_percentage_for_sales_order = (
|
||||
frappe.get_single_value("Manufacturing Settings", "overproduction_percentage_for_sales_order")
|
||||
/ 100
|
||||
)
|
||||
for table in [so.items, so.packed_items]:
|
||||
for i in table:
|
||||
bom = get_default_bom(i.item_code)
|
||||
@@ -1989,12 +1993,12 @@ def get_work_order_items(sales_order, for_raw_material_request=0):
|
||||
if not for_raw_material_request:
|
||||
total_work_order_qty = flt(
|
||||
qb.from_(wo)
|
||||
.select(Sum(wo.qty))
|
||||
.select(Sum(wo.qty - wo.process_loss_qty))
|
||||
.where(
|
||||
(wo.production_item == i.item_code)
|
||||
& (wo.sales_order == so.name)
|
||||
& (wo.sales_order_item == i.name)
|
||||
& (wo.docstatus.lt(2))
|
||||
& (wo.docstatus == 1)
|
||||
& (wo.status != "Closed")
|
||||
)
|
||||
.run()[0][0]
|
||||
@@ -2003,7 +2007,10 @@ def get_work_order_items(sales_order, for_raw_material_request=0):
|
||||
else:
|
||||
pending_qty = stock_qty
|
||||
|
||||
if pending_qty and i.item_code not in product_bundle_parents:
|
||||
if not pending_qty:
|
||||
pending_qty = stock_qty * overproduction_percentage_for_sales_order
|
||||
|
||||
if pending_qty > 0 and i.item_code not in product_bundle_parents:
|
||||
items.append(
|
||||
dict(
|
||||
name=i.name,
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Default Customer Group",
|
||||
"link_filters": "[[\"Customer Group\", \"is_group\", \"=\", 0]]",
|
||||
"options": "Customer Group"
|
||||
},
|
||||
{
|
||||
@@ -297,7 +298,7 @@
|
||||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2026-01-02 18:17:05.734945",
|
||||
"modified": "2026-01-21 17:28:37.027837",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Selling",
|
||||
"name": "Selling Settings",
|
||||
|
||||
@@ -651,6 +651,9 @@ erpnext.PointOfSale.Controller = class {
|
||||
|
||||
async on_cart_update(args) {
|
||||
frappe.dom.freeze();
|
||||
if (this.frm.doc.set_warehouse !== this.settings.warehouse) {
|
||||
this.frm.set_value("set_warehouse", this.settings.warehouse);
|
||||
}
|
||||
let item_row = undefined;
|
||||
try {
|
||||
let { field, value, item } = args;
|
||||
|
||||
@@ -11,7 +11,16 @@ from frappe.cache_manager import clear_defaults_cache
|
||||
from frappe.contacts.address_and_contact import load_address_and_contact
|
||||
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
|
||||
from frappe.desk.page.setup_wizard.setup_wizard import make_records
|
||||
from frappe.utils import add_months, cint, formatdate, get_first_day, get_link_to_form, get_timestamp, today
|
||||
from frappe.utils import (
|
||||
add_months,
|
||||
cint,
|
||||
formatdate,
|
||||
get_first_day,
|
||||
get_last_day,
|
||||
get_link_to_form,
|
||||
get_timestamp,
|
||||
today,
|
||||
)
|
||||
from frappe.utils.nestedset import NestedSet, rebuild_tree
|
||||
|
||||
from erpnext.accounts.doctype.account.account import get_account_currency
|
||||
@@ -866,31 +875,41 @@ def install_country_fixtures(company, country):
|
||||
|
||||
|
||||
def update_company_current_month_sales(company):
|
||||
from_date = get_first_day(today())
|
||||
to_date = get_first_day(add_months(from_date, 1))
|
||||
"""Update Company's Total Monthly Sales.
|
||||
|
||||
results = frappe.db.sql(
|
||||
"""
|
||||
SELECT
|
||||
SUM(base_grand_total) AS total,
|
||||
DATE_FORMAT(posting_date, '%%m-%%Y') AS month_year
|
||||
FROM
|
||||
`tabSales Invoice`
|
||||
WHERE
|
||||
posting_date >= %s
|
||||
AND posting_date < %s
|
||||
AND docstatus = 1
|
||||
AND company = %s
|
||||
GROUP BY
|
||||
month_year
|
||||
""",
|
||||
(from_date, to_date, company),
|
||||
as_dict=True,
|
||||
Postgres compatibility:
|
||||
- Avoid MariaDB-only DATE_FORMAT().
|
||||
- Use a date range for the current month instead (portable + index-friendly).
|
||||
"""
|
||||
|
||||
# Local imports so you don't have to touch file-level imports
|
||||
from frappe.query_builder.functions import Sum
|
||||
|
||||
start_date = get_first_day(today())
|
||||
end_date = get_last_day(today())
|
||||
|
||||
si = frappe.qb.DocType("Sales Invoice")
|
||||
|
||||
total_monthly_sales = (
|
||||
frappe.qb.from_(si)
|
||||
.select(Sum(si.base_grand_total))
|
||||
.where(
|
||||
(si.docstatus == 1)
|
||||
& (si.company == company)
|
||||
& (si.posting_date >= start_date)
|
||||
& (si.posting_date <= end_date)
|
||||
)
|
||||
).run(pluck=True)[0] or 0
|
||||
|
||||
# Fieldname in standard ERPNext is `total_monthly_sales`
|
||||
frappe.db.set_value(
|
||||
"Company",
|
||||
company,
|
||||
"total_monthly_sales",
|
||||
total_monthly_sales,
|
||||
update_modified=False,
|
||||
)
|
||||
|
||||
monthly_total = results[0]["total"] if len(results) > 0 else 0
|
||||
frappe.db.set_value("Company", company, "total_monthly_sales", monthly_total)
|
||||
|
||||
|
||||
def update_company_monthly_sales(company):
|
||||
"""Cache past year monthly sales of every company based on sales invoices"""
|
||||
|
||||
@@ -1,7 +1,2 @@
|
||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
//--------- ONLOAD -------------
|
||||
cur_frm.cscript.onload = function (doc, cdt, cdn) {};
|
||||
|
||||
cur_frm.cscript.refresh = function (doc, cdt, cdn) {};
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
}
|
||||
},
|
||||
"Algeria": {
|
||||
"Algeria VAT 17%": {
|
||||
"account_name": "VAT 17%",
|
||||
"tax_rate": 17.00,
|
||||
"Algeria TVA 19%": {
|
||||
"account_name": "TVA 19%",
|
||||
"tax_rate": 19.00,
|
||||
"default": 1
|
||||
},
|
||||
"Algeria VAT 7%": {
|
||||
"account_name": "VAT 7%",
|
||||
"tax_rate": 7.00
|
||||
"Algeria TVA 9%": {
|
||||
"account_name": "TVA 9%",
|
||||
"tax_rate": 9.00
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -53,12 +53,14 @@ def get_stock_value_by_item_group(company):
|
||||
.inner_join(item_doctype)
|
||||
.on(doctype.item_code == item_doctype.name)
|
||||
.select(item_doctype.item_group, stock_value.as_("stock_value"))
|
||||
.where(doctype.warehouse.isin(warehouses))
|
||||
.groupby(item_doctype.item_group)
|
||||
.orderby(stock_value, order=frappe.qb.desc)
|
||||
.limit(10)
|
||||
)
|
||||
|
||||
if warehouses:
|
||||
query = query.where(doctype.warehouse.isin(warehouses))
|
||||
|
||||
results = query.run(as_dict=True)
|
||||
|
||||
labels = []
|
||||
|
||||
@@ -97,7 +97,6 @@ class DeprecatedBatchNoValuation:
|
||||
for ledger in entries:
|
||||
self.stock_value_differece[ledger.batch_no] += flt(ledger.batch_value)
|
||||
self.available_qty[ledger.batch_no] += flt(ledger.batch_qty)
|
||||
self.total_qty[ledger.batch_no] += flt(ledger.batch_qty)
|
||||
|
||||
@deprecated(
|
||||
"erpnext.stock.serial_batch_bundle.BatchNoValuation.get_sle_for_batches",
|
||||
@@ -271,7 +270,6 @@ class DeprecatedBatchNoValuation:
|
||||
batch_data = query.run(as_dict=True)
|
||||
for d in batch_data:
|
||||
self.available_qty[d.batch_no] += flt(d.batch_qty)
|
||||
self.total_qty[d.batch_no] += flt(d.batch_qty)
|
||||
|
||||
for d in batch_data:
|
||||
if self.available_qty.get(d.batch_no):
|
||||
@@ -383,7 +381,6 @@ class DeprecatedBatchNoValuation:
|
||||
batch_data = query.run(as_dict=True)
|
||||
for d in batch_data:
|
||||
self.available_qty[d.batch_no] += flt(d.batch_qty)
|
||||
self.total_qty[d.batch_no] += flt(d.batch_qty)
|
||||
|
||||
if not self.last_sle:
|
||||
return
|
||||
|
||||
@@ -116,6 +116,11 @@ frappe.ui.form.on("Item", {
|
||||
},
|
||||
__("View")
|
||||
);
|
||||
|
||||
frm.toggle_display(
|
||||
["opening_stock"],
|
||||
frappe.model.can_create("Stock Entry") && frappe.model.can_write("Stock Entry")
|
||||
);
|
||||
}
|
||||
|
||||
if (frm.doc.is_fixed_asset) {
|
||||
@@ -239,6 +244,8 @@ frappe.ui.form.on("Item", {
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
frm.toggle_display(["standard_rate"], frappe.model.can_create("Item Price"));
|
||||
},
|
||||
|
||||
validate: function (frm) {
|
||||
@@ -1063,7 +1070,7 @@ frappe.tour["Item"] = [
|
||||
fieldname: "valuation_rate",
|
||||
title: "Valuation Rate",
|
||||
description: __(
|
||||
"There are two options to maintain valuation of stock. FIFO (first in - first out) and Moving Average. To understand this topic in detail please visit <a href='https://docs.erpnext.com/docs/v13/user/manual/en/stock/articles/item-valuation-fifo-and-moving-average' target='_blank'>Item Valuation, FIFO and Moving Average.</a>"
|
||||
"There are two options to maintain valuation of stock. FIFO (first in - first out) and Moving Average. To understand this topic in detail please visit <a href='https://docs.frappe.io/erpnext/user/manual/en/calculation-of-valuation-rate-in-fifo-and-moving-average' target='_blank'>Item Valuation, FIFO and Moving Average.</a>"
|
||||
),
|
||||
},
|
||||
{
|
||||
|
||||
@@ -232,8 +232,25 @@ class Item(Document):
|
||||
cint(frappe.get_single_value("Stock Settings", "clean_description_html"))
|
||||
and self.description != self.item_name # perf: Avoid cleaning up a fallback
|
||||
):
|
||||
old_desc = self.description
|
||||
self.description = clean_html(self.description)
|
||||
|
||||
if (
|
||||
old_desc
|
||||
and self.description
|
||||
and "<img src" in old_desc
|
||||
and "<img src" not in self.description
|
||||
):
|
||||
frappe.msgprint(
|
||||
_(
|
||||
'Image in the description has been removed. To disable this behavior, uncheck "{0}" in {1}.'
|
||||
).format(
|
||||
frappe.get_meta("Stock Settings").get_label("clean_description_html"),
|
||||
get_link_to_form("Stock Settings"),
|
||||
),
|
||||
alert=True,
|
||||
)
|
||||
|
||||
def validate_customer_provided_part(self):
|
||||
if self.is_customer_provided_item:
|
||||
if self.is_purchase_item:
|
||||
|
||||
@@ -437,7 +437,7 @@ def get_vendor_invoices(doctype, txt, searchfield, start, page_len, filters):
|
||||
query = get_vendor_invoice_query(filters)
|
||||
|
||||
if txt:
|
||||
query = query.where(doctype.name.like(f"%{txt}%"))
|
||||
query = query.where(frappe.qb.DocType(doctype).name.like(f"%{txt}%"))
|
||||
|
||||
if start:
|
||||
query = query.limit(page_len).offset(start)
|
||||
|
||||
@@ -282,7 +282,6 @@
|
||||
{
|
||||
"fieldname": "set_warehouse",
|
||||
"fieldtype": "Link",
|
||||
"ignore_user_permissions": 1,
|
||||
"in_list_view": 1,
|
||||
"label": "Set Target Warehouse",
|
||||
"options": "Warehouse"
|
||||
@@ -378,7 +377,7 @@
|
||||
"idx": 70,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2026-01-10 15:34:59.000603",
|
||||
"modified": "2026-01-21 12:48:40.792323",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Material Request",
|
||||
|
||||
@@ -266,7 +266,7 @@ erpnext.stock.PurchaseReceiptController = class PurchaseReceiptController extend
|
||||
);
|
||||
}
|
||||
cur_frm.add_custom_button(
|
||||
__("Retention Stock Entry"),
|
||||
__("Sample Retention Stock Entry"),
|
||||
this.make_retention_stock_entry,
|
||||
__("Create")
|
||||
);
|
||||
|
||||
@@ -4849,6 +4849,193 @@ class TestPurchaseReceipt(IntegrationTestCase):
|
||||
self.assertEqual(return_entry.items[0].qty, -2)
|
||||
self.assertEqual(return_entry.items[0].rejected_qty, 0) # 3-3=0
|
||||
|
||||
def test_do_not_use_batchwise_valuation_with_fifo(self):
|
||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
||||
|
||||
item_code = make_item(
|
||||
"Test Item Do Not Use Batchwise Valuation with FIFO",
|
||||
{
|
||||
"is_stock_item": 1,
|
||||
"has_batch_no": 1,
|
||||
"batch_number_series": "BN-TESTDNUBVWF-.#####",
|
||||
"valuation_method": "FIFO",
|
||||
},
|
||||
).name
|
||||
|
||||
doc = frappe.new_doc("Batch")
|
||||
doc.update(
|
||||
{
|
||||
"batch_id": "BN-TESTDNUBVWF-00001",
|
||||
"item": item_code,
|
||||
}
|
||||
).insert()
|
||||
|
||||
doc.db_set("use_batchwise_valuation", 0)
|
||||
doc.reload()
|
||||
|
||||
self.assertTrue(doc.use_batchwise_valuation == 0)
|
||||
|
||||
doc = frappe.new_doc("Batch")
|
||||
doc.update(
|
||||
{
|
||||
"batch_id": "BN-TESTDNUBVWF-00002",
|
||||
"item": item_code,
|
||||
}
|
||||
).insert()
|
||||
|
||||
self.assertTrue(doc.use_batchwise_valuation == 1)
|
||||
|
||||
warehouse = "_Test Warehouse - _TC"
|
||||
make_stock_entry(
|
||||
item_code=item_code,
|
||||
qty=10,
|
||||
rate=100,
|
||||
target=warehouse,
|
||||
batch_no="BN-TESTDNUBVWF-00001",
|
||||
use_serial_batch_fields=1,
|
||||
)
|
||||
|
||||
se1 = make_stock_entry(
|
||||
item_code=item_code,
|
||||
qty=10,
|
||||
rate=200,
|
||||
target=warehouse,
|
||||
batch_no="BN-TESTDNUBVWF-00001",
|
||||
use_serial_batch_fields=1,
|
||||
)
|
||||
|
||||
stock_queue = frappe.db.get_value(
|
||||
"Stock Ledger Entry",
|
||||
{
|
||||
"item_code": item_code,
|
||||
"warehouse": warehouse,
|
||||
"is_cancelled": 0,
|
||||
"voucher_type": "Stock Entry",
|
||||
"voucher_no": se1.name,
|
||||
},
|
||||
"stock_queue",
|
||||
)
|
||||
|
||||
stock_queue = frappe.parse_json(stock_queue)
|
||||
|
||||
self.assertEqual(stock_queue, [[10, 100.0], [10, 200.0]])
|
||||
|
||||
se2 = make_stock_entry(
|
||||
item_code=item_code,
|
||||
qty=10,
|
||||
rate=2,
|
||||
target=warehouse,
|
||||
batch_no="BN-TESTDNUBVWF-00002",
|
||||
use_serial_batch_fields=1,
|
||||
)
|
||||
|
||||
stock_queue = frappe.db.get_value(
|
||||
"Stock Ledger Entry",
|
||||
{
|
||||
"item_code": item_code,
|
||||
"warehouse": warehouse,
|
||||
"is_cancelled": 0,
|
||||
"voucher_type": "Stock Entry",
|
||||
"voucher_no": se2.name,
|
||||
},
|
||||
"stock_queue",
|
||||
)
|
||||
|
||||
stock_queue = frappe.parse_json(stock_queue)
|
||||
self.assertEqual(stock_queue, [[10, 100.0], [10, 200.0]])
|
||||
|
||||
se3 = make_stock_entry(
|
||||
item_code=item_code,
|
||||
qty=20,
|
||||
source=warehouse,
|
||||
batch_no="BN-TESTDNUBVWF-00001",
|
||||
use_serial_batch_fields=1,
|
||||
)
|
||||
|
||||
ste_details = frappe.db.get_value(
|
||||
"Stock Ledger Entry",
|
||||
{
|
||||
"item_code": item_code,
|
||||
"warehouse": warehouse,
|
||||
"is_cancelled": 0,
|
||||
"voucher_type": "Stock Entry",
|
||||
"voucher_no": se3.name,
|
||||
},
|
||||
["stock_queue", "stock_value_difference"],
|
||||
as_dict=1,
|
||||
)
|
||||
|
||||
stock_queue = frappe.parse_json(ste_details.stock_queue)
|
||||
self.assertEqual(stock_queue, [])
|
||||
self.assertEqual(ste_details.stock_value_difference, 3000 * -1)
|
||||
|
||||
se4 = make_stock_entry(
|
||||
item_code=item_code,
|
||||
qty=20,
|
||||
rate=0,
|
||||
target=warehouse,
|
||||
batch_no="BN-TESTDNUBVWF-00001",
|
||||
use_serial_batch_fields=1,
|
||||
do_not_submit=1,
|
||||
)
|
||||
|
||||
se4.items[0].basic_rate = 0.0
|
||||
se4.items[0].allow_zero_valuation_rate = 1
|
||||
se4.submit()
|
||||
|
||||
stock_queue = frappe.db.get_value(
|
||||
"Stock Ledger Entry",
|
||||
{
|
||||
"item_code": item_code,
|
||||
"warehouse": warehouse,
|
||||
"is_cancelled": 0,
|
||||
"voucher_type": "Stock Entry",
|
||||
"voucher_no": se4.name,
|
||||
},
|
||||
"stock_queue",
|
||||
)
|
||||
|
||||
self.assertEqual(frappe.parse_json(stock_queue), [[20, 0.0]])
|
||||
|
||||
def test_negative_stock_error_for_purchase_return(self):
|
||||
from erpnext.controllers.sales_and_purchase_return import make_return_doc
|
||||
from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
|
||||
|
||||
item_code = make_item(
|
||||
"Test Negative Stock for Purchase Return Item",
|
||||
{"has_batch_no": 1, "create_new_batch": 1, "batch_number_series": "TNSFPRI.#####"},
|
||||
).name
|
||||
|
||||
pr = make_purchase_receipt(
|
||||
item_code=item_code,
|
||||
posting_date=add_days(today(), -3),
|
||||
qty=10,
|
||||
rate=100,
|
||||
warehouse="_Test Warehouse - _TC",
|
||||
)
|
||||
|
||||
batch_no = get_batch_from_bundle(pr.items[0].serial_and_batch_bundle)
|
||||
|
||||
make_purchase_receipt(
|
||||
item_code=item_code,
|
||||
posting_date=add_days(today(), -4),
|
||||
qty=10,
|
||||
rate=100,
|
||||
warehouse="_Test Warehouse - _TC",
|
||||
)
|
||||
|
||||
make_stock_entry(
|
||||
item_code=item_code,
|
||||
qty=10,
|
||||
source="_Test Warehouse - _TC",
|
||||
target="_Test Warehouse 1 - _TC",
|
||||
batch_no=batch_no,
|
||||
use_serial_batch_fields=1,
|
||||
)
|
||||
|
||||
return_pr = make_return_doc("Purchase Receipt", pr.name)
|
||||
self.assertRaises(frappe.ValidationError, return_pr.submit)
|
||||
|
||||
|
||||
def prepare_data_for_internal_transfer():
|
||||
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_internal_supplier
|
||||
|
||||
@@ -12,7 +12,7 @@ import frappe.query_builder.functions
|
||||
from frappe import _, _dict, bold
|
||||
from frappe.model.document import Document
|
||||
from frappe.model.naming import make_autoname
|
||||
from frappe.query_builder.functions import Sum
|
||||
from frappe.query_builder.functions import Concat_ws, Locate, Sum
|
||||
from frappe.utils import (
|
||||
cint,
|
||||
cstr,
|
||||
@@ -576,14 +576,12 @@ class SerialandBatchBundle(Document):
|
||||
d.incoming_rate = abs(flt(sn_obj.batch_avg_rate.get(d.batch_no)))
|
||||
|
||||
precision = d.precision("qty")
|
||||
for field in ["available_qty", "total_qty"]:
|
||||
value = getattr(sn_obj, field)
|
||||
available_qty = flt(value.get(d.batch_no), precision)
|
||||
if self.docstatus == 1:
|
||||
available_qty += flt(d.qty, precision)
|
||||
available_qty = flt(sn_obj.available_qty.get(d.batch_no), precision)
|
||||
if self.docstatus == 1:
|
||||
available_qty += flt(d.qty, precision)
|
||||
|
||||
if not allow_negative_stock:
|
||||
self.validate_negative_batch(d.batch_no, available_qty, field)
|
||||
if not allow_negative_stock:
|
||||
self.validate_negative_batch(d.batch_no, available_qty)
|
||||
|
||||
d.stock_value_difference = flt(d.qty) * flt(d.incoming_rate)
|
||||
|
||||
@@ -596,8 +594,8 @@ class SerialandBatchBundle(Document):
|
||||
}
|
||||
)
|
||||
|
||||
def validate_negative_batch(self, batch_no, available_qty, field=None):
|
||||
if available_qty < 0 and not self.is_stock_reco_for_valuation_adjustment(available_qty, field=field):
|
||||
def validate_negative_batch(self, batch_no, available_qty):
|
||||
if available_qty < 0 and not self.is_stock_reco_for_valuation_adjustment(available_qty):
|
||||
msg = f"""Batch No {bold(batch_no)} of an Item {bold(self.item_code)}
|
||||
has negative stock
|
||||
of quantity {bold(available_qty)} in the
|
||||
@@ -605,7 +603,7 @@ class SerialandBatchBundle(Document):
|
||||
|
||||
frappe.throw(_(msg), BatchNegativeStockError)
|
||||
|
||||
def is_stock_reco_for_valuation_adjustment(self, available_qty, field=None):
|
||||
def is_stock_reco_for_valuation_adjustment(self, available_qty):
|
||||
if (
|
||||
self.voucher_type == "Stock Reconciliation"
|
||||
and self.type_of_transaction == "Outward"
|
||||
@@ -613,7 +611,6 @@ class SerialandBatchBundle(Document):
|
||||
and (
|
||||
abs(frappe.db.get_value("Stock Reconciliation Item", self.voucher_detail_no, "qty"))
|
||||
== abs(available_qty)
|
||||
or field == "total_qty"
|
||||
)
|
||||
):
|
||||
return True
|
||||
@@ -712,17 +709,16 @@ class SerialandBatchBundle(Document):
|
||||
is_packed_item = True
|
||||
|
||||
stock_queue = []
|
||||
batches = []
|
||||
if prev_sle and prev_sle.stock_queue:
|
||||
batches = frappe.get_all(
|
||||
"Batch",
|
||||
filters={
|
||||
"name": ("in", [d.batch_no for d in self.entries if d.batch_no]),
|
||||
"use_batchwise_valuation": 0,
|
||||
},
|
||||
pluck="name",
|
||||
)
|
||||
batches = frappe.get_all(
|
||||
"Batch",
|
||||
filters={
|
||||
"name": ("in", [d.batch_no for d in self.entries if d.batch_no]),
|
||||
"use_batchwise_valuation": 0,
|
||||
},
|
||||
pluck="name",
|
||||
)
|
||||
|
||||
if prev_sle and prev_sle.stock_queue and parse_json(prev_sle.stock_queue):
|
||||
if batches and valuation_method == "FIFO":
|
||||
stock_queue = parse_json(prev_sle.stock_queue)
|
||||
|
||||
@@ -749,7 +745,7 @@ class SerialandBatchBundle(Document):
|
||||
if d.qty:
|
||||
d.stock_value_difference = flt(d.qty) * d.incoming_rate
|
||||
|
||||
if stock_queue and valuation_method == "FIFO" and d.batch_no in batches:
|
||||
if valuation_method == "FIFO" and d.batch_no in batches and d.incoming_rate is not None:
|
||||
stock_queue.append([d.qty, d.incoming_rate])
|
||||
d.stock_queue = json.dumps(stock_queue)
|
||||
|
||||
@@ -1345,6 +1341,7 @@ class SerialandBatchBundle(Document):
|
||||
def on_submit(self):
|
||||
self.validate_docstatus()
|
||||
self.validate_serial_nos_inventory()
|
||||
self.validate_batch_quantity()
|
||||
|
||||
def validate_docstatus(self):
|
||||
for row in self.entries:
|
||||
@@ -1438,6 +1435,106 @@ class SerialandBatchBundle(Document):
|
||||
|
||||
def on_cancel(self):
|
||||
self.validate_voucher_no_docstatus()
|
||||
self.validate_batch_quantity()
|
||||
|
||||
def validate_batch_quantity(self):
|
||||
if not self.has_batch_no:
|
||||
return
|
||||
|
||||
if self.type_of_transaction != "Outward" or (
|
||||
self.voucher_type == "Stock Reconciliation" and self.type_of_transaction == "Outward"
|
||||
):
|
||||
return
|
||||
|
||||
batch_wise_available_qty = self.get_batchwise_available_qty()
|
||||
precision = frappe.get_precision("Serial and Batch Entry", "qty")
|
||||
|
||||
for d in self.entries:
|
||||
available_qty = batch_wise_available_qty.get(d.batch_no, 0)
|
||||
if flt(available_qty, precision) < 0:
|
||||
frappe.throw(
|
||||
_(
|
||||
"""
|
||||
The Batch {0} of an item {1} has negative stock in the warehouse {2}. Please add a stock quantity of {3} to proceed with this entry."""
|
||||
).format(
|
||||
bold(d.batch_no),
|
||||
bold(self.item_code),
|
||||
bold(self.warehouse),
|
||||
bold(abs(flt(available_qty, precision))),
|
||||
),
|
||||
title=_("Negative Stock Error"),
|
||||
)
|
||||
|
||||
def get_batchwise_available_qty(self):
|
||||
available_qty = self.get_available_qty_from_sabb()
|
||||
available_qty_from_ledger = self.get_available_qty_from_stock_ledger()
|
||||
|
||||
if not available_qty_from_ledger:
|
||||
return available_qty
|
||||
|
||||
for batch_no, qty in available_qty_from_ledger.items():
|
||||
if batch_no in available_qty:
|
||||
available_qty[batch_no] += qty
|
||||
else:
|
||||
available_qty[batch_no] = qty
|
||||
|
||||
return available_qty
|
||||
|
||||
def get_available_qty_from_stock_ledger(self):
|
||||
batches = [d.batch_no for d in self.entries if d.batch_no]
|
||||
|
||||
sle = frappe.qb.DocType("Stock Ledger Entry")
|
||||
|
||||
query = (
|
||||
frappe.qb.from_(sle)
|
||||
.select(
|
||||
sle.batch_no,
|
||||
Sum(sle.actual_qty).as_("available_qty"),
|
||||
)
|
||||
.where(
|
||||
(sle.item_code == self.item_code)
|
||||
& (sle.warehouse == self.warehouse)
|
||||
& (sle.is_cancelled == 0)
|
||||
& (sle.batch_no.isin(batches))
|
||||
& (sle.docstatus == 1)
|
||||
& (sle.serial_and_batch_bundle.isnull())
|
||||
& (sle.batch_no.isnotnull())
|
||||
)
|
||||
.for_update()
|
||||
.groupby(sle.batch_no)
|
||||
)
|
||||
|
||||
res = query.run(as_list=True)
|
||||
|
||||
return frappe._dict(res) if res else frappe._dict()
|
||||
|
||||
def get_available_qty_from_sabb(self):
|
||||
batches = [d.batch_no for d in self.entries if d.batch_no]
|
||||
|
||||
child = frappe.qb.DocType("Serial and Batch Entry")
|
||||
|
||||
query = (
|
||||
frappe.qb.from_(child)
|
||||
.select(
|
||||
child.batch_no,
|
||||
Sum(child.qty).as_("available_qty"),
|
||||
)
|
||||
.where(
|
||||
(child.item_code == self.item_code)
|
||||
& (child.warehouse == self.warehouse)
|
||||
& (child.is_cancelled == 0)
|
||||
& (child.batch_no.isin(batches))
|
||||
& (child.docstatus == 1)
|
||||
& (child.type_of_transaction.isin(["Inward", "Outward"]))
|
||||
)
|
||||
.for_update()
|
||||
.groupby(child.batch_no)
|
||||
)
|
||||
query = query.where(child.voucher_type != "Pick List")
|
||||
|
||||
res = query.run(as_list=True)
|
||||
|
||||
return frappe._dict(res) if res else frappe._dict()
|
||||
|
||||
def validate_voucher_no_docstatus(self):
|
||||
if self.voucher_type == "POS Invoice":
|
||||
@@ -2986,7 +3083,15 @@ def get_ledgers_from_serial_batch_bundle(**kwargs) -> list[frappe._dict]:
|
||||
|
||||
|
||||
def get_stock_ledgers_for_serial_nos(kwargs):
|
||||
"""
|
||||
Fetch stock ledger entries based on various filters.
|
||||
:param kwargs: Filters including posting_datetime, creation, warehouse, item_code, serial_nos, ignore_voucher_detail_no, voucher_no. Joins with Serial and Batch Entry table to filter based on serial numbers.
|
||||
:return: List of stock ledger entries as dictionaries.
|
||||
:rtype: list[dict]
|
||||
"""
|
||||
|
||||
stock_ledger_entry = frappe.qb.DocType("Stock Ledger Entry")
|
||||
serial_batch_entry = frappe.qb.DocType("Serial and Batch Entry")
|
||||
|
||||
query = (
|
||||
frappe.qb.from_(stock_ledger_entry)
|
||||
@@ -3013,7 +3118,7 @@ def get_stock_ledgers_for_serial_nos(kwargs):
|
||||
|
||||
query = query.where(timestamp_condition)
|
||||
|
||||
for field in ["warehouse", "item_code", "serial_no"]:
|
||||
for field in ["warehouse", "item_code"]:
|
||||
if not kwargs.get(field):
|
||||
continue
|
||||
|
||||
@@ -3022,6 +3127,27 @@ def get_stock_ledgers_for_serial_nos(kwargs):
|
||||
else:
|
||||
query = query.where(stock_ledger_entry[field] == kwargs.get(field))
|
||||
|
||||
serial_nos = kwargs.get("serial_nos") or kwargs.get("serial_no")
|
||||
if serial_nos and not isinstance(serial_nos, list):
|
||||
serial_nos = [serial_nos]
|
||||
|
||||
if serial_nos:
|
||||
query = (
|
||||
query.left_join(serial_batch_entry)
|
||||
.on(stock_ledger_entry.serial_and_batch_bundle == serial_batch_entry.parent)
|
||||
.distinct()
|
||||
)
|
||||
|
||||
bundle_match = serial_batch_entry.serial_no.isin(serial_nos)
|
||||
|
||||
padded_serial_no = Concat_ws("", "\n", stock_ledger_entry.serial_no, "\n")
|
||||
direct_match = None
|
||||
for sn in serial_nos:
|
||||
cond = Locate(f"\n{sn}\n", padded_serial_no) > 0
|
||||
direct_match = cond if direct_match is None else (direct_match | cond)
|
||||
|
||||
query = query.where(bundle_match | direct_match)
|
||||
|
||||
if kwargs.ignore_voucher_detail_no:
|
||||
query = query.where(stock_ledger_entry.voucher_detail_no != kwargs.ignore_voucher_detail_no)
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user