mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-03 21:48:27 +00:00
Merge pull request #45567 from frappe/version-14-hotfix
chore: release v14
This commit is contained in:
6
.github/workflows/patch.yml
vendored
6
.github/workflows/patch.yml
vendored
@@ -59,7 +59,7 @@ jobs:
|
||||
run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts
|
||||
|
||||
- name: Cache pip
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml') }}
|
||||
@@ -68,7 +68,7 @@ jobs:
|
||||
${{ runner.os }}-
|
||||
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v4
|
||||
env:
|
||||
cache-name: cache-node-modules
|
||||
with:
|
||||
@@ -83,7 +83,7 @@ jobs:
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
|
||||
- uses: actions/cache@v2
|
||||
- uses: actions/cache@v4
|
||||
id: yarn-cache
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
|
||||
6
.github/workflows/server-tests-mariadb.yml
vendored
6
.github/workflows/server-tests-mariadb.yml
vendored
@@ -79,7 +79,7 @@ jobs:
|
||||
run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts
|
||||
|
||||
- name: Cache pip
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml') }}
|
||||
@@ -88,7 +88,7 @@ jobs:
|
||||
${{ runner.os }}-
|
||||
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v4
|
||||
env:
|
||||
cache-name: cache-node-modules
|
||||
with:
|
||||
@@ -103,7 +103,7 @@ jobs:
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
|
||||
- uses: actions/cache@v2
|
||||
- uses: actions/cache@v4
|
||||
id: yarn-cache
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
|
||||
6
.github/workflows/server-tests-postgres.yml
vendored
6
.github/workflows/server-tests-postgres.yml
vendored
@@ -66,7 +66,7 @@ jobs:
|
||||
run: echo "127.0.0.1 test_site" | sudo tee -a /etc/hosts
|
||||
|
||||
- name: Cache pip
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt', '**/pyproject.toml') }}
|
||||
@@ -75,7 +75,7 @@ jobs:
|
||||
${{ runner.os }}-
|
||||
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v4
|
||||
env:
|
||||
cache-name: cache-node-modules
|
||||
with:
|
||||
@@ -90,7 +90,7 @@ jobs:
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
|
||||
- uses: actions/cache@v2
|
||||
- uses: actions/cache@v4
|
||||
id: yarn-cache
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
"label": "Reference Document Type",
|
||||
"options": "DocType",
|
||||
"read_only_depends_on": "eval:!doc.__islocal",
|
||||
"reqd": 1
|
||||
"reqd": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
|
||||
@@ -45,42 +45,41 @@ class AutoMatchbyAccountIBAN:
|
||||
if not (self.bank_party_account_number or self.bank_party_iban):
|
||||
return None
|
||||
|
||||
result = self.match_account_in_party()
|
||||
return result
|
||||
return self.match_account_in_party()
|
||||
|
||||
def match_account_in_party(self) -> tuple | None:
|
||||
"""Check if there is a IBAN/Account No. match in Customer/Supplier/Employee"""
|
||||
result = None
|
||||
parties = get_parties_in_order(self.deposit)
|
||||
or_filters = self.get_or_filters()
|
||||
"""
|
||||
Returns (Party Type, Party) if a matching account is found in Bank Account or Employee:
|
||||
1. Get party from a matching (iban/account no) Bank Account
|
||||
2. If not found, get party from Employee with matching bank account details (iban/account no)
|
||||
"""
|
||||
if not (self.bank_party_account_number or self.bank_party_iban):
|
||||
# Nothing to match
|
||||
return None
|
||||
|
||||
for party in parties:
|
||||
party_result = frappe.db.get_all(
|
||||
"Bank Account", or_filters=or_filters, pluck="party", limit_page_length=1
|
||||
)
|
||||
# Search for a matching Bank Account that has party set
|
||||
party_result = frappe.db.get_all(
|
||||
"Bank Account",
|
||||
or_filters=self.get_or_filters(),
|
||||
filters={"party_type": ("is", "set"), "party": ("is", "set")},
|
||||
fields=["party", "party_type"],
|
||||
limit_page_length=1,
|
||||
)
|
||||
if result := party_result[0] if party_result else None:
|
||||
return (result["party_type"], result["party"])
|
||||
|
||||
if party == "Employee" and not party_result:
|
||||
# Search in Bank Accounts first for Employee, and then Employee record
|
||||
if "bank_account_no" in or_filters:
|
||||
or_filters["bank_ac_no"] = or_filters.pop("bank_account_no")
|
||||
# If no party is found, search in Employee (since it has bank account details)
|
||||
if employee_result := frappe.db.get_all(
|
||||
"Employee", or_filters=self.get_or_filters("Employee"), pluck="name", limit_page_length=1
|
||||
):
|
||||
return ("Employee", employee_result[0])
|
||||
|
||||
party_result = frappe.db.get_all(
|
||||
party, or_filters=or_filters, pluck="name", limit_page_length=1
|
||||
)
|
||||
|
||||
if party_result:
|
||||
result = (
|
||||
party,
|
||||
party_result[0],
|
||||
)
|
||||
break
|
||||
|
||||
return result
|
||||
|
||||
def get_or_filters(self) -> dict:
|
||||
def get_or_filters(self, party: str | None = None) -> dict:
|
||||
"""Return OR filters for Bank Account and IBAN"""
|
||||
or_filters = {}
|
||||
if self.bank_party_account_number:
|
||||
or_filters["bank_account_no"] = self.bank_party_account_number
|
||||
bank_ac_field = "bank_ac_no" if party == "Employee" else "bank_account_no"
|
||||
or_filters[bank_ac_field] = self.bank_party_account_number
|
||||
|
||||
if self.bank_party_iban:
|
||||
or_filters["iban"] = self.bank_party_iban
|
||||
@@ -100,8 +99,7 @@ class AutoMatchbyPartyNameDescription:
|
||||
if not (self.bank_party_name or self.description):
|
||||
return None
|
||||
|
||||
result = self.match_party_name_desc_in_party()
|
||||
return result
|
||||
return self.match_party_name_desc_in_party()
|
||||
|
||||
def match_party_name_desc_in_party(self) -> tuple | None:
|
||||
"""Fuzzy search party name and/or description against parties in the system"""
|
||||
@@ -110,7 +108,7 @@ class AutoMatchbyPartyNameDescription:
|
||||
|
||||
for party in parties:
|
||||
filters = {"status": "Active"} if party == "Employee" else {"disabled": 0}
|
||||
field = party.lower() + "_name"
|
||||
field = f"{party.lower()}_name"
|
||||
names = frappe.get_all(party, filters=filters, fields=[f"{field} as party_name", "name"])
|
||||
|
||||
for field in ["bank_party_name", "description"]:
|
||||
@@ -137,13 +135,7 @@ class AutoMatchbyPartyNameDescription:
|
||||
)
|
||||
party_name, skip = self.process_fuzzy_result(result)
|
||||
|
||||
if not party_name:
|
||||
return None, skip
|
||||
|
||||
return (
|
||||
party,
|
||||
party_name,
|
||||
), skip
|
||||
return ((party, party_name), skip) if party_name else (None, skip)
|
||||
|
||||
def process_fuzzy_result(self, result: list | None):
|
||||
"""
|
||||
@@ -161,8 +153,8 @@ class AutoMatchbyPartyNameDescription:
|
||||
if len(result) == 1:
|
||||
return (first_result[PARTY_ID] if first_result[SCORE] > CUTOFF else None), True
|
||||
|
||||
second_result = result[1]
|
||||
if first_result[SCORE] > CUTOFF:
|
||||
second_result = result[1]
|
||||
# If multiple matches with the same score, return None but discontinue matching
|
||||
# Matches were found but were too close to distinguish between
|
||||
if first_result[SCORE] == second_result[SCORE]:
|
||||
@@ -174,8 +166,8 @@ class AutoMatchbyPartyNameDescription:
|
||||
|
||||
|
||||
def get_parties_in_order(deposit: float) -> list:
|
||||
parties = ["Supplier", "Employee", "Customer"] # most -> least likely to receive
|
||||
if flt(deposit) > 0:
|
||||
parties = ["Customer", "Supplier", "Employee"] # most -> least likely to pay
|
||||
|
||||
return parties
|
||||
return (
|
||||
["Customer", "Supplier", "Employee"] # most -> least likely to pay us
|
||||
if flt(deposit) > 0
|
||||
else ["Supplier", "Employee", "Customer"] # most -> least likely to receive from us
|
||||
)
|
||||
|
||||
@@ -328,8 +328,6 @@ def get_pricing_rule_for_item(args, doc=None, for_validate=False):
|
||||
"parent": args.parent,
|
||||
"parenttype": args.parenttype,
|
||||
"child_docname": args.get("child_docname"),
|
||||
"discount_percentage": 0.0,
|
||||
"discount_amount": 0,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ from frappe.utils import cint, cstr, flt, formatdate, get_link_to_form, getdate,
|
||||
|
||||
import erpnext
|
||||
from erpnext.accounts.deferred_revenue import validate_service_stop_date
|
||||
from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt
|
||||
from erpnext.accounts.doctype.repost_accounting_ledger.repost_accounting_ledger import (
|
||||
validate_docs_for_deferred_accounting,
|
||||
validate_docs_for_voucher_types,
|
||||
@@ -33,7 +32,7 @@ from erpnext.accounts.general_ledger import (
|
||||
merge_similar_entries,
|
||||
)
|
||||
from erpnext.accounts.party import get_due_date, get_party_account
|
||||
from erpnext.accounts.utils import get_account_currency, get_fiscal_year
|
||||
from erpnext.accounts.utils import get_account_currency, get_fiscal_year, update_voucher_outstanding
|
||||
from erpnext.assets.doctype.asset.asset import is_cwip_accounting_enabled
|
||||
from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account
|
||||
from erpnext.buying.utils import check_on_hold_or_closed_status
|
||||
@@ -661,12 +660,12 @@ class PurchaseInvoice(BuyingController):
|
||||
|
||||
def update_supplier_outstanding(self, update_outstanding):
|
||||
if update_outstanding == "No":
|
||||
update_outstanding_amt(
|
||||
self.credit_to,
|
||||
"Supplier",
|
||||
self.supplier,
|
||||
self.doctype,
|
||||
self.return_against if cint(self.is_return) and self.return_against else self.name,
|
||||
update_voucher_outstanding(
|
||||
voucher_type=self.doctype,
|
||||
voucher_no=self.return_against if cint(self.is_return) and self.return_against else self.name,
|
||||
account=self.credit_to,
|
||||
party_type="Supplier",
|
||||
party=self.supplier,
|
||||
)
|
||||
|
||||
def get_gl_entries(self, warehouse_account=None):
|
||||
|
||||
@@ -45,12 +45,16 @@ frappe.listview_settings["Purchase Invoice"] = {
|
||||
},
|
||||
|
||||
onload: function (listview) {
|
||||
listview.page.add_action_item(__("Purchase Receipt"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Purchase Invoice", "Purchase Receipt");
|
||||
});
|
||||
if (frappe.model.can_create("Purchase Receipt")) {
|
||||
listview.page.add_action_item(__("Purchase Receipt"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Purchase Invoice", "Purchase Receipt");
|
||||
});
|
||||
}
|
||||
|
||||
listview.page.add_action_item(__("Payment"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Purchase Invoice", "Payment Entry");
|
||||
});
|
||||
if (frappe.model.can_create("Payment Entry")) {
|
||||
listview.page.add_action_item(__("Payment"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Purchase Invoice", "Payment Entry");
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -9,6 +9,10 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e
|
||||
setup(doc) {
|
||||
this.setup_posting_date_time_check();
|
||||
super.setup(doc);
|
||||
this.frm.make_methods = {
|
||||
Dunning: this.make_dunning.bind(this),
|
||||
"Invoice Discounting": this.make_invoice_discounting.bind(this),
|
||||
};
|
||||
}
|
||||
company() {
|
||||
super.company();
|
||||
@@ -94,26 +98,35 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e
|
||||
}
|
||||
}
|
||||
|
||||
if (doc.outstanding_amount>0) {
|
||||
cur_frm.add_custom_button(__('Payment Request'), function() {
|
||||
me.make_payment_request();
|
||||
}, __('Create'));
|
||||
if (doc.outstanding_amount > 0) {
|
||||
this.frm.add_custom_button(
|
||||
__("Payment Request"),
|
||||
function () {
|
||||
me.make_payment_request();
|
||||
},
|
||||
__("Create")
|
||||
);
|
||||
this.frm.add_custom_button(
|
||||
__("Invoice Discounting"),
|
||||
this.make_invoice_discounting.bind(this),
|
||||
__("Create")
|
||||
);
|
||||
|
||||
cur_frm.add_custom_button(__('Invoice Discounting'), function() {
|
||||
cur_frm.events.create_invoice_discounting(cur_frm);
|
||||
}, __('Create'));
|
||||
const payment_is_overdue = doc.payment_schedule
|
||||
.map((row) => Date.parse(row.due_date) < Date.now())
|
||||
.reduce((prev, current) => prev || current, false);
|
||||
|
||||
if (doc.due_date < frappe.datetime.get_today()) {
|
||||
cur_frm.add_custom_button(__('Dunning'), function() {
|
||||
cur_frm.events.create_dunning(cur_frm);
|
||||
}, __('Create'));
|
||||
if (payment_is_overdue) {
|
||||
this.frm.add_custom_button(__("Dunning"), this.make_dunning.bind(this), __("Create"));
|
||||
}
|
||||
}
|
||||
|
||||
if (doc.docstatus === 1) {
|
||||
cur_frm.add_custom_button(__('Maintenance Schedule'), function () {
|
||||
cur_frm.cscript.make_maintenance_schedule();
|
||||
}, __('Create'));
|
||||
this.frm.add_custom_button(
|
||||
__("Maintenance Schedule"),
|
||||
this.make_maintenance_schedule.bind(this),
|
||||
__("Create")
|
||||
);
|
||||
}
|
||||
|
||||
if(!doc.auto_repeat) {
|
||||
@@ -146,6 +159,20 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e
|
||||
erpnext.accounts.unreconcile_payment.add_unreconcile_btn(me.frm);
|
||||
}
|
||||
|
||||
make_invoice_discounting() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_invoice_discounting",
|
||||
frm: this.frm,
|
||||
});
|
||||
}
|
||||
|
||||
make_dunning() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_dunning",
|
||||
frm: this.frm,
|
||||
});
|
||||
}
|
||||
|
||||
make_maintenance_schedule() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_maintenance_schedule",
|
||||
@@ -948,20 +975,6 @@ frappe.ui.form.on('Sales Invoice', {
|
||||
frm.set_df_property('return_against', 'label', __('Adjustment Against'));
|
||||
}
|
||||
},
|
||||
|
||||
create_invoice_discounting: function(frm) {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_invoice_discounting",
|
||||
frm: frm
|
||||
});
|
||||
},
|
||||
|
||||
create_dunning: function(frm) {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_dunning",
|
||||
frm: frm
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
frappe.ui.form.on("Sales Invoice Timesheet", {
|
||||
|
||||
@@ -24,7 +24,11 @@ from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category
|
||||
)
|
||||
from erpnext.accounts.general_ledger import get_round_off_account_and_cost_center
|
||||
from erpnext.accounts.party import get_due_date, get_party_account, get_party_details
|
||||
from erpnext.accounts.utils import cancel_exchange_gain_loss_journal, get_account_currency
|
||||
from erpnext.accounts.utils import (
|
||||
cancel_exchange_gain_loss_journal,
|
||||
get_account_currency,
|
||||
update_voucher_outstanding,
|
||||
)
|
||||
from erpnext.assets.doctype.asset.depreciation import (
|
||||
depreciate_asset,
|
||||
get_disposal_account_and_cost_center,
|
||||
@@ -1019,14 +1023,14 @@ class SalesInvoice(SellingController):
|
||||
make_reverse_gl_entries(voucher_type=self.doctype, voucher_no=self.name)
|
||||
|
||||
if update_outstanding == "No":
|
||||
from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt
|
||||
|
||||
update_outstanding_amt(
|
||||
self.debit_to,
|
||||
"Customer",
|
||||
self.customer,
|
||||
self.doctype,
|
||||
self.return_against if cint(self.is_return) and self.return_against else self.name,
|
||||
update_voucher_outstanding(
|
||||
voucher_type=self.doctype,
|
||||
voucher_no=self.return_against
|
||||
if cint(self.is_return) and self.return_against
|
||||
else self.name,
|
||||
account=self.debit_to,
|
||||
party_type="Customer",
|
||||
party=self.customer,
|
||||
)
|
||||
|
||||
elif self.docstatus == 2 and cint(self.update_stock) and cint(auto_accounting_for_stock):
|
||||
|
||||
@@ -32,12 +32,16 @@ frappe.listview_settings["Sales Invoice"] = {
|
||||
right_column: "grand_total",
|
||||
|
||||
onload: function (listview) {
|
||||
listview.page.add_action_item(__("Delivery Note"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Sales Invoice", "Delivery Note");
|
||||
});
|
||||
if (frappe.model.can_create("Delivery Note")) {
|
||||
listview.page.add_action_item(__("Delivery Note"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Sales Invoice", "Delivery Note");
|
||||
});
|
||||
}
|
||||
|
||||
listview.page.add_action_item(__("Payment"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Sales Invoice", "Payment Entry");
|
||||
});
|
||||
if (frappe.model.can_create("Payment Entry")) {
|
||||
listview.page.add_action_item(__("Payment"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Sales Invoice", "Payment Entry");
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -3860,6 +3860,7 @@ class TestSalesInvoice(FrappeTestCase):
|
||||
si = create_sales_invoice(do_not_submit=True)
|
||||
|
||||
project = frappe.new_doc("Project")
|
||||
project.company = "_Test Company"
|
||||
project.project_name = "Test Total Billed Amount"
|
||||
project.save()
|
||||
|
||||
|
||||
@@ -1587,7 +1587,7 @@ def get_stock_and_account_balance(account=None, posting_date=None, company=None)
|
||||
if wh_details.account == account and not wh_details.is_group
|
||||
]
|
||||
|
||||
total_stock_value = get_stock_value_on(related_warehouses, posting_date)
|
||||
total_stock_value = get_stock_value_on(related_warehouses, posting_date, company=company)
|
||||
|
||||
precision = frappe.get_precision("Journal Entry Account", "debit_in_account_currency")
|
||||
return flt(account_balance, precision), flt(total_stock_value, precision), related_warehouses
|
||||
|
||||
@@ -51,16 +51,22 @@ frappe.listview_settings["Purchase Order"] = {
|
||||
listview.call_for_selected_items(method, { status: "Submitted" });
|
||||
});
|
||||
|
||||
listview.page.add_action_item(__("Purchase Invoice"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Purchase Order", "Purchase Invoice");
|
||||
});
|
||||
if (frappe.model.can_create("Purchase Invoice")) {
|
||||
listview.page.add_action_item(__("Purchase Invoice"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Purchase Order", "Purchase Invoice");
|
||||
});
|
||||
}
|
||||
|
||||
listview.page.add_action_item(__("Purchase Receipt"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Purchase Order", "Purchase Receipt");
|
||||
});
|
||||
if (frappe.model.can_create("Purchase Receipt")) {
|
||||
listview.page.add_action_item(__("Purchase Receipt"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Purchase Order", "Purchase Receipt");
|
||||
});
|
||||
}
|
||||
|
||||
listview.page.add_action_item(__("Advance Payment"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Purchase Order", "Payment Entry");
|
||||
});
|
||||
if (frappe.model.can_create("Payment Entry")) {
|
||||
listview.page.add_action_item(__("Advance Payment"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Purchase Order", "Payment Entry");
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@ from frappe.model.naming import set_name_by_naming_series, set_name_from_naming_
|
||||
|
||||
from erpnext.accounts.party import (
|
||||
get_dashboard_info,
|
||||
get_timeline_data,
|
||||
validate_party_accounts,
|
||||
)
|
||||
from erpnext.utilities.transaction_base import TransactionBase
|
||||
|
||||
@@ -11,12 +11,20 @@ frappe.listview_settings["Supplier Quotation"] = {
|
||||
},
|
||||
|
||||
onload: function (listview) {
|
||||
listview.page.add_action_item(__("Purchase Order"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Supplier Quotation", "Purchase Order");
|
||||
});
|
||||
if (frappe.model.can_create("Purchase Order")) {
|
||||
listview.page.add_action_item(__("Purchase Order"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Supplier Quotation", "Purchase Order");
|
||||
});
|
||||
}
|
||||
|
||||
listview.page.add_action_item(__("Purchase Invoice"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Supplier Quotation", "Purchase Invoice");
|
||||
});
|
||||
if (frappe.model.can_create("Purchase Invoice")) {
|
||||
listview.page.add_action_item(__("Purchase Invoice"), () => {
|
||||
erpnext.bulk_transaction_processing.create(
|
||||
listview,
|
||||
"Supplier Quotation",
|
||||
"Purchase Invoice"
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ from collections import defaultdict
|
||||
import frappe
|
||||
from frappe import _, bold, qb, throw
|
||||
from frappe.model.workflow import get_workflow_name, is_transition_condition_satisfied
|
||||
from frappe.query_builder import Criterion
|
||||
from frappe.query_builder import Criterion, DocType
|
||||
from frappe.query_builder.custom import ConstantColumn
|
||||
from frappe.query_builder.functions import Abs, Sum
|
||||
from frappe.utils import (
|
||||
@@ -250,6 +250,7 @@ class AccountsController(TransactionBase):
|
||||
apply_pricing_rule_on_transaction(self)
|
||||
|
||||
self.set_total_in_words()
|
||||
self.validate_company_in_accounting_dimension()
|
||||
|
||||
def init_internal_values(self):
|
||||
# init all the internal values as 0 on sa
|
||||
@@ -355,6 +356,39 @@ class AccountsController(TransactionBase):
|
||||
(sle.voucher_type == self.doctype) & (sle.voucher_no == self.name)
|
||||
).run()
|
||||
|
||||
def validate_company_in_accounting_dimension(self):
|
||||
doc_field = DocType("DocField")
|
||||
accounting_dimension = DocType("Accounting Dimension")
|
||||
dimension_list = (
|
||||
frappe.qb.from_(accounting_dimension)
|
||||
.select(accounting_dimension.document_type)
|
||||
.join(doc_field)
|
||||
.on(doc_field.parent == accounting_dimension.document_type)
|
||||
.where(doc_field.fieldname == "company")
|
||||
).run(as_list=True)
|
||||
|
||||
dimension_list = sum(dimension_list, ["Project"])
|
||||
self.validate_company(dimension_list)
|
||||
|
||||
for child in self.get_all_children() or []:
|
||||
self.validate_company(dimension_list, child)
|
||||
|
||||
def validate_company(self, dimension_list, child=None):
|
||||
for dimension in dimension_list:
|
||||
if not child:
|
||||
dimension_value = self.get(frappe.scrub(dimension))
|
||||
else:
|
||||
dimension_value = child.get(frappe.scrub(dimension))
|
||||
|
||||
if dimension_value:
|
||||
company = frappe.get_cached_value(dimension, dimension_value, "company")
|
||||
if company and company != self.company:
|
||||
frappe.throw(
|
||||
_("{0}: {1} does not belong to the Company: {2}").format(
|
||||
dimension, frappe.bold(dimension_value), self.company
|
||||
)
|
||||
)
|
||||
|
||||
def validate_return_against_account(self):
|
||||
if self.doctype in ["Sales Invoice", "Purchase Invoice"] and self.is_return and self.return_against:
|
||||
cr_dr_account_field = "debit_to" if self.doctype == "Sales Invoice" else "credit_to"
|
||||
|
||||
@@ -75,7 +75,11 @@ def validate_returned_items(doc):
|
||||
if doc.doctype != "Purchase Invoice":
|
||||
select_fields += ",serial_no, batch_no"
|
||||
|
||||
if doc.doctype in ["Purchase Invoice", "Purchase Receipt", "Subcontracting Receipt"]:
|
||||
if doc.doctype in [
|
||||
"Purchase Invoice",
|
||||
"Purchase Receipt",
|
||||
"Subcontracting Receipt",
|
||||
]:
|
||||
select_fields += ",rejected_qty, received_qty"
|
||||
|
||||
for d in frappe.db.sql(
|
||||
@@ -105,7 +109,12 @@ def validate_returned_items(doc):
|
||||
for d in doc.get("items"):
|
||||
key = d.item_code
|
||||
raise_exception = False
|
||||
if doc.doctype in ["Purchase Receipt", "Purchase Invoice", "Sales Invoice", "POS Invoice"]:
|
||||
if doc.doctype in [
|
||||
"Purchase Receipt",
|
||||
"Purchase Invoice",
|
||||
"Sales Invoice",
|
||||
"POS Invoice",
|
||||
]:
|
||||
field = frappe.scrub(doc.doctype) + "_item"
|
||||
if d.get(field):
|
||||
key = (d.item_code, d.get(field))
|
||||
@@ -175,7 +184,11 @@ def validate_returned_items(doc):
|
||||
|
||||
def validate_quantity(doc, key, args, ref, valid_items, already_returned_items):
|
||||
fields = ["stock_qty"]
|
||||
if doc.doctype in ["Purchase Receipt", "Purchase Invoice", "Subcontracting Receipt"]:
|
||||
if doc.doctype in [
|
||||
"Purchase Receipt",
|
||||
"Purchase Invoice",
|
||||
"Subcontracting Receipt",
|
||||
]:
|
||||
fields.extend(["received_qty", "rejected_qty"])
|
||||
|
||||
already_returned_data = already_returned_items.get(key) or {}
|
||||
@@ -203,7 +216,8 @@ def validate_quantity(doc, key, args, ref, valid_items, already_returned_items):
|
||||
frappe.throw(_("{0} must be negative in return document").format(label))
|
||||
elif returned_qty >= reference_qty and args.get(column):
|
||||
frappe.throw(
|
||||
_("Item {0} has already been returned").format(args.item_code), StockOverReturnError
|
||||
_("Item {0} has already been returned").format(args.item_code),
|
||||
StockOverReturnError,
|
||||
)
|
||||
elif abs(flt(current_stock_qty, stock_qty_precision)) > max_returnable_qty:
|
||||
frappe.throw(
|
||||
@@ -242,7 +256,11 @@ def get_ref_item_dict(valid_items, ref_item_row):
|
||||
if ref_item_row.get("rate", 0) > item_dict["rate"]:
|
||||
item_dict["rate"] = ref_item_row.get("rate", 0)
|
||||
|
||||
if ref_item_row.parenttype in ["Purchase Invoice", "Purchase Receipt", "Subcontracting Receipt"]:
|
||||
if ref_item_row.parenttype in [
|
||||
"Purchase Invoice",
|
||||
"Purchase Receipt",
|
||||
"Subcontracting Receipt",
|
||||
]:
|
||||
item_dict["received_qty"] += ref_item_row.received_qty
|
||||
item_dict["rejected_qty"] += ref_item_row.rejected_qty
|
||||
|
||||
@@ -257,7 +275,11 @@ def get_ref_item_dict(valid_items, ref_item_row):
|
||||
|
||||
def get_already_returned_items(doc):
|
||||
column = "child.item_code, sum(abs(child.qty)) as qty, sum(abs(child.stock_qty)) as stock_qty"
|
||||
if doc.doctype in ["Purchase Invoice", "Purchase Receipt", "Subcontracting Receipt"]:
|
||||
if doc.doctype in [
|
||||
"Purchase Invoice",
|
||||
"Purchase Receipt",
|
||||
"Subcontracting Receipt",
|
||||
]:
|
||||
column += """, sum(abs(child.rejected_qty) * child.conversion_factor) as rejected_qty,
|
||||
sum(abs(child.received_qty) * child.conversion_factor) as received_qty"""
|
||||
|
||||
@@ -384,7 +406,8 @@ def make_return_doc(doctype: str, source_name: str, target_doc=None):
|
||||
paid_amount = 0.00
|
||||
base_paid_amount = 0.00
|
||||
data.base_amount = flt(
|
||||
data.amount * source.conversion_rate, source.precision("base_paid_amount")
|
||||
data.amount * source.conversion_rate,
|
||||
source.precision("base_paid_amount"),
|
||||
)
|
||||
paid_amount += data.amount
|
||||
base_paid_amount += data.base_amount
|
||||
@@ -544,10 +567,17 @@ def make_return_doc(doctype: str, source_name: str, target_doc=None):
|
||||
},
|
||||
doctype + " Item": {
|
||||
"doctype": doctype + " Item",
|
||||
"field_map": {"serial_no": "serial_no", "batch_no": "batch_no", "bom": "bom"},
|
||||
"field_map": {
|
||||
"serial_no": "serial_no",
|
||||
"batch_no": "batch_no",
|
||||
"bom": "bom",
|
||||
},
|
||||
"postprocess": update_item,
|
||||
},
|
||||
"Payment Schedule": {"doctype": "Payment Schedule", "postprocess": update_terms},
|
||||
"Payment Schedule": {
|
||||
"doctype": "Payment Schedule",
|
||||
"postprocess": update_terms,
|
||||
},
|
||||
},
|
||||
target_doc,
|
||||
set_missing_values,
|
||||
@@ -580,13 +610,20 @@ def get_rate_for_return(
|
||||
item_row,
|
||||
)
|
||||
|
||||
if voucher_type in ("Purchase Receipt", "Purchase Invoice", "Subcontracting Receipt"):
|
||||
if voucher_type in (
|
||||
"Purchase Receipt",
|
||||
"Purchase Invoice",
|
||||
"Subcontracting Receipt",
|
||||
):
|
||||
select_field = "incoming_rate"
|
||||
else:
|
||||
select_field = "abs(stock_value_difference / actual_qty)"
|
||||
|
||||
rate = flt(frappe.db.get_value("Stock Ledger Entry", filters, select_field))
|
||||
if not (rate and return_against) and voucher_type in ["Sales Invoice", "Delivery Note"]:
|
||||
if not (rate and return_against) and voucher_type in [
|
||||
"Sales Invoice",
|
||||
"Delivery Note",
|
||||
]:
|
||||
rate = frappe.db.get_value(f"{voucher_type} Item", voucher_detail_no, "incoming_rate")
|
||||
|
||||
if not rate and sle:
|
||||
@@ -629,7 +666,11 @@ def get_filters(
|
||||
return_against_item_field,
|
||||
item_row,
|
||||
):
|
||||
filters = {"voucher_type": voucher_type, "voucher_no": return_against, "item_code": item_code}
|
||||
filters = {
|
||||
"voucher_type": voucher_type,
|
||||
"voucher_no": return_against,
|
||||
"item_code": item_code,
|
||||
}
|
||||
|
||||
if item_row:
|
||||
reference_voucher_detail_no = item_row.get(return_against_item_field)
|
||||
@@ -669,3 +710,9 @@ def get_returned_serial_nos(child_doc, parent_doc, serial_no_field="serial_no"):
|
||||
serial_nos.extend(get_serial_nos(row.get(serial_no_field)))
|
||||
|
||||
return serial_nos
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_payment_data(invoice):
|
||||
payment = frappe.db.get_all("Sales Invoice Payment", {"parent": invoice}, ["mode_of_payment", "amount"])
|
||||
return payment
|
||||
|
||||
@@ -1344,32 +1344,32 @@ class TestAccountsController(FrappeTestCase):
|
||||
|
||||
# Invoices
|
||||
si1 = self.create_sales_invoice(qty=1, rate=rate_in_account_currency, do_not_submit=True)
|
||||
si1.department = "Management"
|
||||
si1.department = "Management - _TC"
|
||||
si1.save().submit()
|
||||
|
||||
si2 = self.create_sales_invoice(qty=1, rate=rate_in_account_currency, do_not_submit=True)
|
||||
si2.department = "Operations"
|
||||
si2.department = "Operations - _TC"
|
||||
si2.save().submit()
|
||||
|
||||
# Payments
|
||||
cr_note1 = self.create_sales_invoice(qty=-1, conversion_rate=75, rate=1, do_not_save=True)
|
||||
cr_note1.department = "Management"
|
||||
cr_note1.department = "Management - _TC"
|
||||
cr_note1.is_return = 1
|
||||
cr_note1.save().submit()
|
||||
|
||||
cr_note2 = self.create_sales_invoice(qty=-1, conversion_rate=75, rate=1, do_not_save=True)
|
||||
cr_note2.department = "Legal"
|
||||
cr_note2.department = "Legal - _TC"
|
||||
cr_note2.is_return = 1
|
||||
cr_note2.save().submit()
|
||||
|
||||
pe1 = get_payment_entry(si1.doctype, si1.name)
|
||||
pe1.references = []
|
||||
pe1.department = "Research & Development"
|
||||
pe1.department = "Research & Development - _TC"
|
||||
pe1.save().submit()
|
||||
|
||||
pe2 = get_payment_entry(si1.doctype, si1.name)
|
||||
pe2.references = []
|
||||
pe2.department = "Management"
|
||||
pe2.department = "Management - _TC"
|
||||
pe2.save().submit()
|
||||
|
||||
je1 = self.create_journal_entry(
|
||||
@@ -1382,7 +1382,7 @@ class TestAccountsController(FrappeTestCase):
|
||||
)
|
||||
je1.accounts[0].party_type = "Customer"
|
||||
je1.accounts[0].party = self.customer
|
||||
je1.accounts[0].department = "Management"
|
||||
je1.accounts[0].department = "Management - _TC"
|
||||
je1.save().submit()
|
||||
|
||||
# assert dimension filter's result
|
||||
@@ -1391,17 +1391,17 @@ class TestAccountsController(FrappeTestCase):
|
||||
self.assertEqual(len(pr.invoices), 2)
|
||||
self.assertEqual(len(pr.payments), 5)
|
||||
|
||||
pr.department = "Legal"
|
||||
pr.department = "Legal - _TC"
|
||||
pr.get_unreconciled_entries()
|
||||
self.assertEqual(len(pr.invoices), 0)
|
||||
self.assertEqual(len(pr.payments), 1)
|
||||
|
||||
pr.department = "Management"
|
||||
pr.department = "Management - _TC"
|
||||
pr.get_unreconciled_entries()
|
||||
self.assertEqual(len(pr.invoices), 1)
|
||||
self.assertEqual(len(pr.payments), 3)
|
||||
|
||||
pr.department = "Research & Development"
|
||||
pr.department = "Research & Development - _TC"
|
||||
pr.get_unreconciled_entries()
|
||||
self.assertEqual(len(pr.invoices), 0)
|
||||
self.assertEqual(len(pr.payments), 1)
|
||||
@@ -1413,17 +1413,17 @@ class TestAccountsController(FrappeTestCase):
|
||||
|
||||
# Invoice
|
||||
si = self.create_sales_invoice(qty=1, rate=rate_in_account_currency, do_not_submit=True)
|
||||
si.department = "Management"
|
||||
si.department = "Management - _TC"
|
||||
si.save().submit()
|
||||
|
||||
# Payment
|
||||
cr_note = self.create_sales_invoice(qty=-1, conversion_rate=75, rate=1, do_not_save=True)
|
||||
cr_note.department = "Management"
|
||||
cr_note.department = "Management - _TC"
|
||||
cr_note.is_return = 1
|
||||
cr_note.save().submit()
|
||||
|
||||
pr = self.create_payment_reconciliation()
|
||||
pr.department = "Management"
|
||||
pr.department = "Management - _TC"
|
||||
pr.get_unreconciled_entries()
|
||||
self.assertEqual(len(pr.invoices), 1)
|
||||
self.assertEqual(len(pr.payments), 1)
|
||||
@@ -1456,7 +1456,7 @@ class TestAccountsController(FrappeTestCase):
|
||||
# Sales Invoice in Foreign Currency
|
||||
self.setup_dimensions()
|
||||
rate_in_account_currency = 1
|
||||
dpt = "Research & Development"
|
||||
dpt = "Research & Development - _TC"
|
||||
|
||||
si = self.create_sales_invoice(qty=1, rate=rate_in_account_currency, do_not_save=True)
|
||||
si.department = dpt
|
||||
@@ -1492,7 +1492,7 @@ class TestAccountsController(FrappeTestCase):
|
||||
|
||||
def test_93_dimension_inheritance_on_advance(self):
|
||||
self.setup_dimensions()
|
||||
dpt = "Research & Development"
|
||||
dpt = "Research & Development - _TC"
|
||||
|
||||
adv = self.create_payment_entry(amount=1, source_exc_rate=85)
|
||||
adv.department = dpt
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[
|
||||
{
|
||||
"project_name": "_Test Project",
|
||||
"status": "Open"
|
||||
"status": "Open",
|
||||
"company": "_Test Company"
|
||||
}
|
||||
]
|
||||
@@ -806,7 +806,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
||||
}
|
||||
}
|
||||
|
||||
set_total_amount_to_default_mop() {
|
||||
async set_total_amount_to_default_mop() {
|
||||
let grand_total = this.frm.doc.rounded_total || this.frm.doc.grand_total;
|
||||
let base_grand_total = this.frm.doc.base_rounded_total || this.frm.doc.base_grand_total;
|
||||
|
||||
@@ -828,6 +828,45 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments {
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
During returns, if an user select mode of payment other than
|
||||
default mode of payment, it should retain the user selection
|
||||
instead resetting it to default mode of payment.
|
||||
*/
|
||||
|
||||
let payment_amount = 0;
|
||||
this.frm.doc.payments.forEach(payment => {
|
||||
payment_amount += payment.amount
|
||||
});
|
||||
|
||||
if (payment_amount == total_amount_to_pay) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
For partial return, if the payment was made using single mode of payment
|
||||
it should set the return to that mode of payment only.
|
||||
*/
|
||||
|
||||
let return_against_mop = await frappe.call({
|
||||
method: 'erpnext.controllers.sales_and_purchase_return.get_payment_data',
|
||||
args: {
|
||||
invoice: this.frm.doc.return_against
|
||||
}
|
||||
});
|
||||
|
||||
if (return_against_mop.message.length === 1) {
|
||||
this.frm.doc.payments.forEach(payment => {
|
||||
if (payment.mode_of_payment == return_against_mop.message[0].mode_of_payment) {
|
||||
payment.amount = total_amount_to_pay;
|
||||
} else {
|
||||
payment.amount = 0;
|
||||
}
|
||||
});
|
||||
this.frm.refresh_fields();
|
||||
return;
|
||||
}
|
||||
|
||||
this.frm.doc.payments.find(payment => {
|
||||
if (payment.default) {
|
||||
payment.amount = total_amount_to_pay;
|
||||
|
||||
@@ -1527,7 +1527,7 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
"serial_no": d.serial_no,
|
||||
"batch_no": d.batch_no,
|
||||
"price_list_rate": d.price_list_rate,
|
||||
"conversion_factor": d.conversion_factor || 1.0
|
||||
"conversion_factor": d.conversion_factor || 1.0,
|
||||
});
|
||||
|
||||
// if doctype is Quotation Item / Sales Order Iten then add Margin Type and rate in item_list
|
||||
|
||||
@@ -628,6 +628,62 @@ erpnext.utils.update_child_items = function (opts) {
|
||||
filters: filters,
|
||||
};
|
||||
},
|
||||
onchange: function () {
|
||||
const me = this;
|
||||
|
||||
frm.call({
|
||||
method: "erpnext.stock.get_item_details.get_item_details",
|
||||
args: {
|
||||
doc: frm.doc,
|
||||
ctx: {
|
||||
item_code: this.value,
|
||||
set_warehouse: frm.doc.set_warehouse,
|
||||
customer: frm.doc.customer || frm.doc.party_name,
|
||||
quotation_to: frm.doc.quotation_to,
|
||||
supplier: frm.doc.supplier,
|
||||
currency: frm.doc.currency,
|
||||
is_internal_supplier: frm.doc.is_internal_supplier,
|
||||
is_internal_customer: frm.doc.is_internal_customer,
|
||||
conversion_rate: frm.doc.conversion_rate,
|
||||
price_list: frm.doc.selling_price_list || frm.doc.buying_price_list,
|
||||
price_list_currency: frm.doc.price_list_currency,
|
||||
plc_conversion_rate: frm.doc.plc_conversion_rate,
|
||||
company: frm.doc.company,
|
||||
order_type: frm.doc.order_type,
|
||||
is_pos: cint(frm.doc.is_pos),
|
||||
is_return: cint(frm.doc.is_return),
|
||||
is_subcontracted: frm.doc.is_subcontracted,
|
||||
ignore_pricing_rule: frm.doc.ignore_pricing_rule,
|
||||
doctype: frm.doc.doctype,
|
||||
name: frm.doc.name,
|
||||
qty: me.doc.qty || 1,
|
||||
uom: me.doc.uom,
|
||||
pos_profile: cint(frm.doc.is_pos) ? frm.doc.pos_profile : "",
|
||||
tax_category: frm.doc.tax_category,
|
||||
child_doctype: frm.doc.doctype + " Item",
|
||||
is_old_subcontracting_flow: frm.doc.is_old_subcontracting_flow,
|
||||
},
|
||||
},
|
||||
callback: function (r) {
|
||||
if (r.message) {
|
||||
const { qty, price_list_rate: rate, uom, conversion_factor } = r.message;
|
||||
|
||||
const row = dialog.fields_dict.trans_items.df.data.find(
|
||||
(doc) => doc.idx == me.doc.idx
|
||||
);
|
||||
if (row) {
|
||||
Object.assign(row, {
|
||||
conversion_factor: me.doc.conversion_factor || conversion_factor,
|
||||
uom: me.doc.uom || uom,
|
||||
qty: me.doc.qty || qty,
|
||||
rate: me.doc.rate || rate,
|
||||
});
|
||||
dialog.fields_dict.trans_items.grid.refresh();
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldtype: "Link",
|
||||
|
||||
@@ -20,6 +20,7 @@ from frappe.utils.user import get_users_with_role
|
||||
|
||||
from erpnext.accounts.party import (
|
||||
get_dashboard_info,
|
||||
get_timeline_data,
|
||||
validate_party_accounts,
|
||||
)
|
||||
from erpnext.utilities.transaction_base import TransactionBase
|
||||
|
||||
@@ -12,13 +12,17 @@ frappe.listview_settings["Quotation"] = {
|
||||
};
|
||||
}
|
||||
|
||||
listview.page.add_action_item(__("Sales Order"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Quotation", "Sales Order");
|
||||
});
|
||||
if (frappe.model.can_create("Sales Order")) {
|
||||
listview.page.add_action_item(__("Sales Order"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Quotation", "Sales Order");
|
||||
});
|
||||
}
|
||||
|
||||
listview.page.add_action_item(__("Sales Invoice"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Quotation", "Sales Invoice");
|
||||
});
|
||||
if (frappe.model.can_create("Sales Invoice")) {
|
||||
listview.page.add_action_item(__("Sales Invoice"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Quotation", "Sales Invoice");
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
get_indicator: function (doc) {
|
||||
|
||||
@@ -1044,7 +1044,8 @@ def make_purchase_order_for_default_supplier(source_name, selected_items=None, t
|
||||
"postprocess": update_item,
|
||||
"condition": lambda doc: doc.ordered_qty < doc.stock_qty
|
||||
and doc.supplier == supplier
|
||||
and doc.item_code in items_to_map,
|
||||
and doc.item_code in items_to_map
|
||||
and doc.delivered_by_supplier == 1,
|
||||
},
|
||||
},
|
||||
target_doc,
|
||||
|
||||
@@ -60,16 +60,22 @@ frappe.listview_settings["Sales Order"] = {
|
||||
listview.call_for_selected_items(method, { status: "Submitted" });
|
||||
});
|
||||
|
||||
listview.page.add_action_item(__("Sales Invoice"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Sales Order", "Sales Invoice");
|
||||
});
|
||||
if (frappe.model.can_create("Sales Invoice")) {
|
||||
listview.page.add_action_item(__("Sales Invoice"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Sales Order", "Sales Invoice");
|
||||
});
|
||||
}
|
||||
|
||||
listview.page.add_action_item(__("Delivery Note"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Sales Order", "Delivery Note");
|
||||
});
|
||||
if (frappe.model.can_create("Delivery Note")) {
|
||||
listview.page.add_action_item(__("Delivery Note"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Sales Order", "Delivery Note");
|
||||
});
|
||||
}
|
||||
|
||||
listview.page.add_action_item(__("Advance Payment"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Sales Order", "Payment Entry");
|
||||
});
|
||||
if (frappe.model.can_create("Payment Entry")) {
|
||||
listview.page.add_action_item(__("Advance Payment"), () => {
|
||||
erpnext.bulk_transaction_processing.create(listview, "Sales Order", "Payment Entry");
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -110,7 +110,7 @@ erpnext.PointOfSale.PastOrderList = class {
|
||||
</div>
|
||||
</div>
|
||||
<div class="invoice-total-status">
|
||||
<div class="invoice-total">${format_currency(invoice.grand_total, invoice.currency, 0) || 0}</div>
|
||||
<div class="invoice-total">${format_currency(invoice.grand_total, invoice.currency) || 0}</div>
|
||||
<div class="invoice-date">${posting_datetime}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -42,6 +42,7 @@ class Employee(NestedSet):
|
||||
self.validate_email()
|
||||
self.validate_status()
|
||||
self.validate_reports_to()
|
||||
self.set_preferred_email()
|
||||
self.validate_preferred_email()
|
||||
|
||||
if self.user_id:
|
||||
@@ -184,9 +185,7 @@ class Employee(NestedSet):
|
||||
|
||||
def set_preferred_email(self):
|
||||
preferred_email_field = frappe.scrub(self.prefered_contact_email)
|
||||
if preferred_email_field:
|
||||
preferred_email = self.get(preferred_email_field)
|
||||
self.prefered_email = preferred_email
|
||||
self.prefered_email = self.get(preferred_email_field) if preferred_email_field else None
|
||||
|
||||
def validate_status(self):
|
||||
if self.status == "Left":
|
||||
|
||||
@@ -63,16 +63,20 @@ frappe.listview_settings["Delivery Note"] = {
|
||||
}
|
||||
};
|
||||
|
||||
// doclist.page.add_actions_menu_item(__('Create Delivery Trip'), action, false);
|
||||
if (frappe.model.can_create("Delivery Trip")) {
|
||||
doclist.page.add_action_item(__("Create Delivery Trip"), action);
|
||||
}
|
||||
|
||||
doclist.page.add_action_item(__("Create Delivery Trip"), action);
|
||||
if (frappe.model.can_create("Sales Invoice")) {
|
||||
doclist.page.add_action_item(__("Sales Invoice"), () => {
|
||||
erpnext.bulk_transaction_processing.create(doclist, "Delivery Note", "Sales Invoice");
|
||||
});
|
||||
}
|
||||
|
||||
doclist.page.add_action_item(__("Sales Invoice"), () => {
|
||||
erpnext.bulk_transaction_processing.create(doclist, "Delivery Note", "Sales Invoice");
|
||||
});
|
||||
|
||||
doclist.page.add_action_item(__("Packaging Slip From Delivery Note"), () => {
|
||||
erpnext.bulk_transaction_processing.create(doclist, "Delivery Note", "Packing Slip");
|
||||
});
|
||||
if (frappe.model.can_create("Packing Slip")) {
|
||||
doclist.page.add_action_item(__("Packaging Slip From Delivery Note"), () => {
|
||||
erpnext.bulk_transaction_processing.create(doclist, "Delivery Note", "Packing Slip");
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -803,7 +803,12 @@ frappe.ui.form.on('Stock Entry Detail', {
|
||||
var d = locals[cdt][cdn];
|
||||
$.each(r.message, function(k, v) {
|
||||
if (v) {
|
||||
frappe.model.set_value(cdt, cdn, k, v); // qty and it's subsequent fields weren't triggered
|
||||
// set_value trigger barcode function and barcode set qty to 1 in stock_controller.js, to avoid this set value manually instead of set value.
|
||||
if (k != "barcode") {
|
||||
frappe.model.set_value(cdt, cdn, k, v); // qty and it's subsequent fields weren't triggered
|
||||
} else {
|
||||
d.barcode = v;
|
||||
}
|
||||
}
|
||||
});
|
||||
refresh_field("items");
|
||||
|
||||
@@ -54,7 +54,10 @@ def get_stock_value_from_bin(warehouse=None, item_code=None):
|
||||
|
||||
|
||||
def get_stock_value_on(
|
||||
warehouses: list | str | None = None, posting_date: str | None = None, item_code: str | None = None
|
||||
warehouses: list | str | None = None,
|
||||
posting_date: str | None = None,
|
||||
item_code: str | None = None,
|
||||
company: str | None = None,
|
||||
) -> float:
|
||||
if not posting_date:
|
||||
posting_date = nowdate()
|
||||
@@ -82,6 +85,9 @@ def get_stock_value_on(
|
||||
if item_code:
|
||||
query = query.where(sle.item_code == item_code)
|
||||
|
||||
if company:
|
||||
query = query.where(sle.company == company)
|
||||
|
||||
return query.run(as_list=True)[0][0]
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ from frappe.utils import get_link_to_form, today
|
||||
|
||||
@frappe.whitelist()
|
||||
def transaction_processing(data, from_doctype, to_doctype):
|
||||
frappe.has_permission(from_doctype, "read", throw=True)
|
||||
frappe.has_permission(to_doctype, "create", throw=True)
|
||||
|
||||
if isinstance(data, str):
|
||||
deserialized_data = json.loads(data)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user