fix: merge conflicts
This commit is contained in:
parent
0f23a304bc
commit
21f5680914
@ -193,7 +193,7 @@ def get_dimension_with_children(doctype, dimension):
|
||||
|
||||
all_dimensions = []
|
||||
lft, rgt = frappe.db.get_value(doctype, dimension, ["lft", "rgt"])
|
||||
children = frappe.get_all(doctype, filters={"lft": [">=", lft], "rgt": ["<=", rgt]})
|
||||
children = frappe.get_all(doctype, filters={"lft": [">=", lft], "rgt": ["<=", rgt]}, order_by="lft")
|
||||
all_dimensions += [c.name for c in children]
|
||||
|
||||
return all_dimensions
|
||||
|
@ -30,18 +30,10 @@ frappe.ui.form.on('Exchange Rate Revaluation', {
|
||||
frm.doc.accounts.forEach(d=> {
|
||||
total_amt = total_amt + d['new_balance_in_base_currency'];
|
||||
});
|
||||
if(total_amt === r.sum) {
|
||||
frm.add_custom_button(__("Journal Entry"), function(){
|
||||
frappe.route_options = {
|
||||
'reference_type': 'Exchange Rate Revaluation',
|
||||
'reference_name': frm.doc.name
|
||||
};
|
||||
frappe.set_route("List", "Journal Entry");
|
||||
}, __("View"));
|
||||
} else {
|
||||
frm.add_custom_button(__('Create Journal Entry'), function() {
|
||||
if(total_amt !== r.sum) {
|
||||
frm.add_custom_button(__('Journal Entry'), function() {
|
||||
return frm.events.make_jv(frm);
|
||||
});
|
||||
}, __('Create'));
|
||||
}
|
||||
}, 'Journal Entry');
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
def get_data():
|
||||
return {
|
||||
'fieldname': 'reference_name',
|
||||
'transactions': [
|
||||
{
|
||||
'items': ['Journal Entry']
|
||||
}
|
||||
]
|
||||
}
|
@ -81,8 +81,13 @@ class PaymentEntry(AccountsController):
|
||||
self.update_advance_paid()
|
||||
self.update_expense_claim()
|
||||
self.delink_advance_entry_references()
|
||||
self.set_payment_req_status()
|
||||
self.set_status()
|
||||
|
||||
def set_payment_req_status(self):
|
||||
from erpnext.accounts.doctype.payment_request.payment_request import update_payment_req_status
|
||||
update_payment_req_status(self, None)
|
||||
|
||||
def update_outstanding_amounts(self):
|
||||
self.set_missing_ref_details(force=True)
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -66,6 +66,8 @@ class PaymentRequest(Document):
|
||||
if self.payment_request_type == 'Outward':
|
||||
self.db_set('status', 'Initiated')
|
||||
return
|
||||
elif self.payment_request_type == 'Inward':
|
||||
self.db_set('status', 'Requested')
|
||||
|
||||
send_mail = self.payment_gateway_validation()
|
||||
ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)
|
||||
@ -88,6 +90,7 @@ class PaymentRequest(Document):
|
||||
if (hasattr(ref_doc, "order_type") and getattr(ref_doc, "order_type") == "Shopping Cart"):
|
||||
from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice
|
||||
si = make_sales_invoice(self.reference_name, ignore_permissions=True)
|
||||
si.allocate_advances_automatically = True
|
||||
si = si.insert(ignore_permissions=True)
|
||||
si.submit()
|
||||
|
||||
@ -415,16 +418,30 @@ def make_payment_entry(docname):
|
||||
doc = frappe.get_doc("Payment Request", docname)
|
||||
return doc.create_payment_entry(submit=False).as_dict()
|
||||
|
||||
def make_status_as_paid(doc, method):
|
||||
def update_payment_req_status(doc, method):
|
||||
from erpnext.accounts.doctype.payment_entry.payment_entry import get_reference_details
|
||||
|
||||
for ref in doc.references:
|
||||
payment_request_name = frappe.db.get_value("Payment Request",
|
||||
{"reference_doctype": ref.reference_doctype, "reference_name": ref.reference_name,
|
||||
"docstatus": 1})
|
||||
|
||||
if payment_request_name:
|
||||
doc = frappe.get_doc("Payment Request", payment_request_name)
|
||||
if doc.status != "Paid":
|
||||
doc.db_set('status', 'Paid')
|
||||
ref_details = get_reference_details(ref.reference_doctype, ref.reference_name, doc.party_account_currency)
|
||||
pay_req_doc = frappe.get_doc('Payment Request', payment_request_name)
|
||||
status = pay_req_doc.status
|
||||
|
||||
if status != "Paid" and not ref_details.outstanding_amount:
|
||||
status = 'Paid'
|
||||
elif status != "Partially Paid" and ref_details.outstanding_amount != ref_details.total_amount:
|
||||
status = 'Partially Paid'
|
||||
elif ref_details.outstanding_amount == ref_details.total_amount:
|
||||
if pay_req_doc.payment_request_type == 'Outward':
|
||||
status = 'Initiated'
|
||||
elif pay_req_doc.payment_request_type == 'Inward':
|
||||
status = 'Requested'
|
||||
|
||||
pay_req_doc.db_set('status', status)
|
||||
frappe.db.commit()
|
||||
|
||||
def get_dummy_message(doc):
|
||||
|
@ -4,14 +4,20 @@ frappe.listview_settings['Payment Request'] = {
|
||||
if(doc.status == "Draft") {
|
||||
return [__("Draft"), "darkgrey", "status,=,Draft"];
|
||||
}
|
||||
if(doc.status == "Requested") {
|
||||
return [__("Requested"), "green", "status,=,Requested"];
|
||||
}
|
||||
else if(doc.status == "Initiated") {
|
||||
return [__("Initiated"), "green", "status,=,Initiated"];
|
||||
}
|
||||
else if(doc.status == "Partially Paid") {
|
||||
return [__("Partially Paid"), "orange", "status,=,Partially Paid"];
|
||||
}
|
||||
else if(doc.status == "Paid") {
|
||||
return [__("Paid"), "blue", "status,=,Paid"];
|
||||
}
|
||||
else if(doc.status == "Cancelled") {
|
||||
return [__("Cancelled"), "orange", "status,=,Cancelled"];
|
||||
return [__("Cancelled"), "red", "status,=,Cancelled"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,6 +101,23 @@ class TestPaymentRequest(unittest.TestCase):
|
||||
self.assertEqual(expected_gle[gle.account][2], gle.credit)
|
||||
self.assertEqual(expected_gle[gle.account][3], gle.against_voucher)
|
||||
|
||||
def test_status(self):
|
||||
si_usd = create_sales_invoice(customer="_Test Customer USD", debit_to="_Test Receivable USD - _TC",
|
||||
currency="USD", conversion_rate=50)
|
||||
|
||||
pr = make_payment_request(dt="Sales Invoice", dn=si_usd.name, recipient_id="saurabh@erpnext.com",
|
||||
mute_email=1, payment_gateway="_Test Gateway - USD", submit_doc=1, return_doc=1)
|
||||
|
||||
pe = pr.create_payment_entry()
|
||||
pr.load_from_db()
|
||||
|
||||
self.assertEqual(pr.status, 'Paid')
|
||||
|
||||
pe.cancel()
|
||||
pr.load_from_db()
|
||||
|
||||
self.assertEqual(pr.status, 'Requested')
|
||||
|
||||
def test_multiple_payment_entries_against_sales_order(self):
|
||||
# Make Sales Order, grand_total = 1000
|
||||
so = make_sales_order()
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe, erpnext
|
||||
from frappe.utils import cint, cstr, formatdate, flt, getdate, nowdate
|
||||
from frappe.utils import cint, cstr, formatdate, flt, getdate, nowdate, get_link_to_form
|
||||
from frappe import _, throw
|
||||
import frappe.defaults
|
||||
|
||||
@ -146,10 +146,14 @@ class PurchaseInvoice(BuyingController):
|
||||
["account_type", "report_type", "account_currency"], as_dict=True)
|
||||
|
||||
if account.report_type != "Balance Sheet":
|
||||
frappe.throw(_("Credit To account must be a Balance Sheet account"))
|
||||
frappe.throw(_("Please ensure {} account is a Balance Sheet account. \
|
||||
You can change the parent account to a Balance Sheet account or select a different account.")
|
||||
.format(frappe.bold("Credit To")), title=_("Invalid Account"))
|
||||
|
||||
if self.supplier and account.account_type != "Payable":
|
||||
frappe.throw(_("Credit To account must be a Payable account"))
|
||||
frappe.throw(_("Please ensure {} account is a Payable account. \
|
||||
Change the account type to Payable or select a different account.")
|
||||
.format(frappe.bold("Credit To")), title=_("Invalid Account"))
|
||||
|
||||
self.party_account_currency = account.account_currency
|
||||
|
||||
@ -267,16 +271,30 @@ class PurchaseInvoice(BuyingController):
|
||||
|
||||
def po_required(self):
|
||||
if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes':
|
||||
|
||||
if frappe.get_value('Supplier', self.supplier, 'allow_purchase_invoice_creation_without_purchase_order'):
|
||||
return
|
||||
|
||||
for d in self.get('items'):
|
||||
if not d.purchase_order:
|
||||
throw(_("As per the Buying Settings if Purchase Order Required == 'YES', then for creating Purchase Invoice, user need to create Purchase Order first for item {0}").format(d.item_code))
|
||||
throw(_("""Purchase Order Required for item {0}
|
||||
To submit the invoice without purchase order please set
|
||||
{1} as {2} in {3}""").format(frappe.bold(d.item_code), frappe.bold(_('Purchase Order Required')),
|
||||
frappe.bold('No'), get_link_to_form('Buying Settings', 'Buying Settings', 'Buying Settings')))
|
||||
|
||||
def pr_required(self):
|
||||
stock_items = self.get_stock_items()
|
||||
if frappe.db.get_value("Buying Settings", None, "pr_required") == 'Yes':
|
||||
|
||||
if frappe.get_value('Supplier', self.supplier, 'allow_purchase_invoice_creation_without_purchase_receipt'):
|
||||
return
|
||||
|
||||
for d in self.get('items'):
|
||||
if not d.purchase_receipt and d.item_code in stock_items:
|
||||
throw(_("As per the Buying Settings if Purchase Reciept Required == 'YES', then for creating Purchase Invoice, user need to create Purchase Receipt first for item {0}").format(d.item_code))
|
||||
throw(_("""Purchase Receipt Required for item {0}
|
||||
To submit the invoice without purchase receipt please set
|
||||
{1} as {2} in {3}""").format(frappe.bold(d.item_code), frappe.bold(_('Purchase Receipt Required')),
|
||||
frappe.bold('No'), get_link_to_form('Buying Settings', 'Buying Settings', 'Buying Settings')))
|
||||
|
||||
def validate_write_off_account(self):
|
||||
if self.write_off_amount and not self.write_off_account:
|
||||
|
@ -761,7 +761,7 @@
|
||||
"depends_on": "is_fixed_asset",
|
||||
"fetch_from": "item_code.asset_category",
|
||||
"fieldname": "asset_category",
|
||||
"fieldtype": "Data",
|
||||
"fieldtype": "Link",
|
||||
"label": "Asset Category",
|
||||
"options": "Asset Category",
|
||||
"read_only": 1
|
||||
@ -777,7 +777,7 @@
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2020-03-11 14:20:17.297284",
|
||||
"modified": "2020-04-01 14:20:17.297284",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Accounts",
|
||||
"name": "Purchase Invoice Item",
|
||||
|
@ -437,13 +437,17 @@ class SalesInvoice(SellingController):
|
||||
if (not for_validate) or (for_validate and not self.get(fieldname)):
|
||||
self.set(fieldname, pos.get(fieldname))
|
||||
|
||||
customer_price_list = frappe.get_value("Customer", self.customer, 'default_price_list')
|
||||
|
||||
if pos.get("company_address"):
|
||||
self.company_address = pos.get("company_address")
|
||||
|
||||
if not customer_price_list:
|
||||
self.set('selling_price_list', pos.get('selling_price_list'))
|
||||
customer_price_list, customer_group = frappe.get_value("Customer", self.customer, ['default_price_list', 'customer_group'])
|
||||
|
||||
customer_group_price_list = frappe.get_value("Customer Group", customer_group, 'default_price_list')
|
||||
|
||||
selling_price_list = customer_price_list or customer_group_price_list or pos.get('selling_price_list')
|
||||
|
||||
if selling_price_list:
|
||||
self.set('selling_price_list', selling_price_list)
|
||||
|
||||
if not for_validate:
|
||||
self.update_stock = cint(pos.get("update_stock"))
|
||||
@ -474,13 +478,17 @@ class SalesInvoice(SellingController):
|
||||
["account_type", "report_type", "account_currency"], as_dict=True)
|
||||
|
||||
if not account:
|
||||
frappe.throw(_("Debit To is required"))
|
||||
frappe.throw(_("Debit To is required"), title=_("Account Missing"))
|
||||
|
||||
if account.report_type != "Balance Sheet":
|
||||
frappe.throw(_("Debit To account must be a Balance Sheet account"))
|
||||
frappe.throw(_("Please ensure {} account is a Balance Sheet account. \
|
||||
You can change the parent account to a Balance Sheet account or select a different account.")
|
||||
.format(frappe.bold("Debit To")), title=_("Invalid Account"))
|
||||
|
||||
if self.customer and account.account_type != "Receivable":
|
||||
frappe.throw(_("Debit To account must be a Receivable account"))
|
||||
frappe.throw(_("Please ensure {} account is a Receivable account. \
|
||||
Change the account type to Receivable or select a different account.")
|
||||
.format(frappe.bold("Debit To")), title=_("Invalid Account"))
|
||||
|
||||
self.party_account_currency = account.account_currency
|
||||
|
||||
@ -542,12 +550,17 @@ class SalesInvoice(SellingController):
|
||||
"""check in manage account if sales order / delivery note required or not."""
|
||||
if self.is_return:
|
||||
return
|
||||
dic = {'Sales Order':['so_required', 'is_pos'],'Delivery Note':['dn_required', 'update_stock']}
|
||||
for i in dic:
|
||||
if frappe.db.get_single_value('Selling Settings', dic[i][0]) == 'Yes':
|
||||
|
||||
prev_doc_field_map = {'Sales Order': ['so_required', 'is_pos'],'Delivery Note': ['dn_required', 'update_stock']}
|
||||
for key, value in iteritems(prev_doc_field_map):
|
||||
if frappe.db.get_single_value('Selling Settings', value[0]) == 'Yes':
|
||||
|
||||
if frappe.get_value('Customer', self.customer, value[0]):
|
||||
continue
|
||||
|
||||
for d in self.get('items'):
|
||||
if (d.item_code and not d.get(i.lower().replace(' ','_')) and not self.get(dic[i][1])):
|
||||
msgprint(_("{0} is mandatory for Item {1}").format(i,d.item_code), raise_exception=1)
|
||||
if (d.item_code and not d.get(key.lower().replace(' ', '_')) and not self.get(value[1])):
|
||||
msgprint(_("{0} is mandatory for Item {1}").format(key, d.item_code), raise_exception=1)
|
||||
|
||||
|
||||
def validate_proj_cust(self):
|
||||
|
@ -11,7 +11,7 @@ from frappe.utils import (add_days, getdate, formatdate, date_diff,
|
||||
add_years, get_timestamp, nowdate, flt, cstr, add_months, get_last_day)
|
||||
from frappe.contacts.doctype.address.address import (get_address_display,
|
||||
get_default_address, get_company_address)
|
||||
from frappe.contacts.doctype.contact.contact import get_contact_details, get_default_contact
|
||||
from frappe.contacts.doctype.contact.contact import get_contact_details
|
||||
from erpnext.exceptions import PartyFrozen, PartyDisabled, InvalidAccountCurrency
|
||||
from erpnext.accounts.utils import get_fiscal_year
|
||||
from erpnext import get_company_currency
|
||||
@ -613,3 +613,26 @@ def get_partywise_advanced_payment_amount(party_type, posting_date = None):
|
||||
|
||||
if data:
|
||||
return frappe._dict(data)
|
||||
|
||||
def get_default_contact(doctype, name):
|
||||
"""
|
||||
Returns default contact for the given doctype and name.
|
||||
Can be ordered by `contact_type` to either is_primary_contact or is_billing_contact.
|
||||
"""
|
||||
out = frappe.db.sql("""
|
||||
SELECT dl.parent, c.is_primary_contact, c.is_billing_contact
|
||||
FROM `tabDynamic Link` dl
|
||||
INNER JOIN tabContact c ON c.name = dl.parent
|
||||
WHERE
|
||||
dl.link_doctype=%s AND
|
||||
dl.link_name=%s AND
|
||||
dl.parenttype = "Contact"
|
||||
ORDER BY is_primary_contact DESC, is_billing_contact DESC
|
||||
""", (doctype, name))
|
||||
if out:
|
||||
try:
|
||||
return out[0][0]
|
||||
except:
|
||||
return None
|
||||
else:
|
||||
return None
|
@ -9,6 +9,7 @@ from erpnext.accounts.report.financial_statements import (get_period_list, get_c
|
||||
|
||||
def execute(filters=None):
|
||||
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
|
||||
filters.period_start_date, filters.period_end_date, filters.filter_based_on,
|
||||
filters.periodicity, company=filters.company)
|
||||
|
||||
currency = filters.presentation_currency or frappe.get_cached_value('Company', filters.company, "default_currency")
|
||||
@ -58,7 +59,10 @@ def execute(filters=None):
|
||||
|
||||
chart = get_chart_data(filters, columns, asset, liability, equity)
|
||||
|
||||
return columns, data, message, chart
|
||||
report_summary = get_report_summary(period_list, asset, liability, equity, provisional_profit_loss,
|
||||
total_credit, currency, filters)
|
||||
|
||||
return columns, data, message, chart, report_summary
|
||||
|
||||
def get_provisional_profit_loss(asset, liability, equity, period_list, company, currency=None, consolidated=False):
|
||||
provisional_profit_loss = {}
|
||||
@ -120,6 +124,56 @@ def check_opening_balance(asset, liability, equity):
|
||||
return _("Previous Financial Year is not closed"),opening_balance
|
||||
return None,None
|
||||
|
||||
def get_report_summary(period_list, asset, liability, equity, provisional_profit_loss, total_credit, currency,
|
||||
filters, consolidated=False):
|
||||
|
||||
net_asset, net_liability, net_equity, net_provisional_profit_loss = 0.0, 0.0, 0.0, 0.0
|
||||
|
||||
if filters.get('accumulated_values'):
|
||||
period_list = [period_list[-1]]
|
||||
|
||||
for period in period_list:
|
||||
key = period if consolidated else period.key
|
||||
if asset:
|
||||
net_asset += asset[-2].get(key)
|
||||
if liability:
|
||||
net_liability += liability[-2].get(key)
|
||||
if equity:
|
||||
net_equity += equity[-2].get(key)
|
||||
if provisional_profit_loss:
|
||||
net_provisional_profit_loss += provisional_profit_loss.get(key)
|
||||
|
||||
return [
|
||||
{
|
||||
"value": net_asset,
|
||||
"label": "Total Asset",
|
||||
"indicator": "Green",
|
||||
"datatype": "Currency",
|
||||
"currency": currency
|
||||
},
|
||||
{
|
||||
"value": net_liability,
|
||||
"label": "Total Liability",
|
||||
"datatype": "Currency",
|
||||
"indicator": "Red",
|
||||
"currency": currency
|
||||
},
|
||||
{
|
||||
"value": net_equity,
|
||||
"label": "Total Equity",
|
||||
"datatype": "Currency",
|
||||
"indicator": "Blue",
|
||||
"currency": currency
|
||||
},
|
||||
{
|
||||
"value": net_provisional_profit_loss,
|
||||
"label": "Provisional Profit / Loss (Credit)",
|
||||
"indicator": "Green" if net_provisional_profit_loss > 0 else "Red",
|
||||
"datatype": "Currency",
|
||||
"currency": currency
|
||||
}
|
||||
]
|
||||
|
||||
def get_chart_data(filters, columns, asset, liability, equity):
|
||||
labels = [d.get("label") for d in columns[2:]]
|
||||
|
||||
|
@ -9,14 +9,9 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
||||
// filter. It won't be used in cash flow for now so we pop it. Please take
|
||||
// of this if you are working here.
|
||||
|
||||
frappe.query_reports["Cash Flow"]["filters"].splice(5, 1);
|
||||
frappe.query_reports["Cash Flow"]["filters"].splice(8, 1);
|
||||
|
||||
frappe.query_reports["Cash Flow"]["filters"].push(
|
||||
{
|
||||
"fieldname": "accumulated_values",
|
||||
"label": __("Accumulated Values"),
|
||||
"fieldtype": "Check"
|
||||
},
|
||||
{
|
||||
"fieldname": "include_default_book_entries",
|
||||
"label": __("Include Default Book Entries"),
|
||||
|
@ -8,6 +8,7 @@ from frappe.utils import cint, cstr
|
||||
from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data)
|
||||
from erpnext.accounts.report.profit_and_loss_statement.profit_and_loss_statement import get_net_profit_loss
|
||||
from erpnext.accounts.utils import get_fiscal_year
|
||||
from six import iteritems
|
||||
|
||||
|
||||
def execute(filters=None):
|
||||
@ -16,7 +17,8 @@ def execute(filters=None):
|
||||
return execute_custom(filters=filters)
|
||||
|
||||
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
|
||||
filters.periodicity, filters.accumulated_values, filters.company)
|
||||
filters.period_start_date, filters.period_end_date, filters.filter_based_on,
|
||||
filters.periodicity, company=filters.company)
|
||||
|
||||
cash_flow_accounts = get_cash_flow_accounts()
|
||||
|
||||
@ -29,6 +31,7 @@ def execute(filters=None):
|
||||
net_profit_loss = get_net_profit_loss(income, expense, period_list, filters.company)
|
||||
|
||||
data = []
|
||||
summary_data = {}
|
||||
company_currency = frappe.get_cached_value('Company', filters.company, "default_currency")
|
||||
|
||||
for cash_flow_account in cash_flow_accounts:
|
||||
@ -64,14 +67,16 @@ def execute(filters=None):
|
||||
section_data.append(account_data)
|
||||
|
||||
add_total_row_account(data, section_data, cash_flow_account['section_footer'],
|
||||
period_list, company_currency)
|
||||
period_list, company_currency, summary_data)
|
||||
|
||||
add_total_row_account(data, data, _("Net Change in Cash"), period_list, company_currency)
|
||||
add_total_row_account(data, data, _("Net Change in Cash"), period_list, company_currency, summary_data)
|
||||
columns = get_columns(filters.periodicity, period_list, filters.accumulated_values, filters.company)
|
||||
|
||||
chart = get_chart_data(columns, data)
|
||||
|
||||
return columns, data, None, chart
|
||||
report_summary = get_report_summary(summary_data, company_currency)
|
||||
|
||||
return columns, data, None, chart, report_summary
|
||||
|
||||
def get_cash_flow_accounts():
|
||||
operation_accounts = {
|
||||
@ -157,7 +162,7 @@ def get_start_date(period, accumulated_values, company):
|
||||
|
||||
return start_date
|
||||
|
||||
def add_total_row_account(out, data, label, period_list, currency, consolidated = False):
|
||||
def add_total_row_account(out, data, label, period_list, currency, summary_data, consolidated = False):
|
||||
total_row = {
|
||||
"account_name": "'" + _("{0}").format(label) + "'",
|
||||
"account": "'" + _("{0}").format(label) + "'",
|
||||
@ -176,6 +181,24 @@ def add_total_row_account(out, data, label, period_list, currency, consolidated
|
||||
out.append(total_row)
|
||||
out.append({})
|
||||
|
||||
summary_data[label] = total_row["total"]
|
||||
|
||||
def get_report_summary(summary_data, currency):
|
||||
report_summary = []
|
||||
|
||||
for label, value in iteritems(summary_data):
|
||||
report_summary.append(
|
||||
{
|
||||
"value": value,
|
||||
"label": label,
|
||||
"datatype": "Currency",
|
||||
"currency": currency
|
||||
}
|
||||
)
|
||||
|
||||
return report_summary
|
||||
|
||||
|
||||
def get_chart_data(columns, data):
|
||||
labels = [d.get("label") for d in columns[2:]]
|
||||
datasets = [{'name':account.get('account').replace("'", ""), 'values': [account.get('total')]} for account in data if account.get('parent_account') == None and account.get('currency')]
|
||||
|
@ -12,6 +12,39 @@ frappe.query_reports["Consolidated Financial Statement"] = {
|
||||
"default": frappe.defaults.get_user_default("Company"),
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname":"filter_based_on",
|
||||
"label": __("Filter Based On"),
|
||||
"fieldtype": "Select",
|
||||
"options": ["Fiscal Year", "Date Range"],
|
||||
"default": ["Fiscal Year"],
|
||||
"reqd": 1,
|
||||
on_change: function() {
|
||||
let filter_based_on = frappe.query_report.get_filter_value('filter_based_on');
|
||||
frappe.query_report.toggle_filter_display('from_fiscal_year', filter_based_on === 'Date Range');
|
||||
frappe.query_report.toggle_filter_display('to_fiscal_year', filter_based_on === 'Date Range');
|
||||
frappe.query_report.toggle_filter_display('period_start_date', filter_based_on === 'Fiscal Year');
|
||||
frappe.query_report.toggle_filter_display('period_end_date', filter_based_on === 'Fiscal Year');
|
||||
|
||||
frappe.query_report.refresh();
|
||||
}
|
||||
},
|
||||
{
|
||||
"fieldname":"period_start_date",
|
||||
"label": __("Start Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": frappe.datetime.nowdate(),
|
||||
"hidden": 1,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname":"period_end_date",
|
||||
"label": __("End Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": frappe.datetime.add_months(frappe.datetime.nowdate(), 12),
|
||||
"hidden": 1,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname":"from_fiscal_year",
|
||||
"label": __("Start Year"),
|
||||
@ -61,5 +94,17 @@ frappe.query_reports["Consolidated Financial Statement"] = {
|
||||
"fieldtype": "Check",
|
||||
"default": 1
|
||||
}
|
||||
]
|
||||
],
|
||||
"formatter": function(value, row, column, data, default_formatter) {
|
||||
value = default_formatter(value, row, column, data);
|
||||
|
||||
if (!data.parent_account) {
|
||||
value = $(`<span>${value}</span>`);
|
||||
|
||||
var $value = $(value).css("font-weight", "bold");
|
||||
|
||||
value = $value.wrap("<p></p>").parent().html();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
@ -4,15 +4,15 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe, erpnext
|
||||
from frappe import _
|
||||
from frappe.utils import flt, cint
|
||||
from frappe.utils import flt, cint, getdate
|
||||
from erpnext.accounts.report.utils import get_currency, convert_to_presentation_currency
|
||||
from erpnext.accounts.report.financial_statements import get_fiscal_year_data, sort_accounts
|
||||
from erpnext.accounts.report.balance_sheet.balance_sheet import (get_provisional_profit_loss,
|
||||
check_opening_balance, get_chart_data)
|
||||
check_opening_balance, get_chart_data, get_report_summary as get_bs_summary)
|
||||
from erpnext.accounts.report.profit_and_loss_statement.profit_and_loss_statement import (get_net_profit_loss,
|
||||
get_chart_data as get_pl_chart_data)
|
||||
get_chart_data as get_pl_chart_data, get_report_summary as get_pl_summary)
|
||||
from erpnext.accounts.report.cash_flow.cash_flow import (get_cash_flow_accounts, get_account_type_based_gl_data,
|
||||
add_total_row_account)
|
||||
add_total_row_account, get_report_summary as get_cash_flow_summary)
|
||||
|
||||
def execute(filters=None):
|
||||
columns, data, message, chart = [], [], [], []
|
||||
@ -25,17 +25,17 @@ def execute(filters=None):
|
||||
columns = get_columns(companies_column)
|
||||
|
||||
if filters.get('report') == "Balance Sheet":
|
||||
data, message, chart = get_balance_sheet_data(fiscal_year, companies, columns, filters)
|
||||
data, message, chart, report_summary = get_balance_sheet_data(fiscal_year, companies, columns, filters)
|
||||
elif filters.get('report') == "Profit and Loss Statement":
|
||||
data, message, chart = get_profit_loss_data(fiscal_year, companies, columns, filters)
|
||||
data, message, chart, report_summary = get_profit_loss_data(fiscal_year, companies, columns, filters)
|
||||
else:
|
||||
if cint(frappe.db.get_single_value('Accounts Settings', 'use_custom_cash_flow')):
|
||||
from erpnext.accounts.report.cash_flow.custom_cash_flow import execute as execute_custom
|
||||
return execute_custom(filters=filters)
|
||||
|
||||
data = get_cash_flow_data(fiscal_year, companies, filters)
|
||||
data, report_summary = get_cash_flow_data(fiscal_year, companies, filters)
|
||||
|
||||
return columns, data, message, chart
|
||||
return columns, data, message, chart, report_summary
|
||||
|
||||
def get_balance_sheet_data(fiscal_year, companies, columns, filters):
|
||||
asset = get_data(companies, "Asset", "Debit", fiscal_year, filters=filters)
|
||||
@ -75,9 +75,12 @@ def get_balance_sheet_data(fiscal_year, companies, columns, filters):
|
||||
if total_credit:
|
||||
data.append(total_credit)
|
||||
|
||||
report_summary = get_bs_summary(companies, asset, liability, equity, provisional_profit_loss, total_credit,
|
||||
company_currency, filters, True)
|
||||
|
||||
chart = get_chart_data(filters, columns, asset, liability, equity)
|
||||
|
||||
return data, message, chart
|
||||
return data, message, chart, report_summary
|
||||
|
||||
def get_profit_loss_data(fiscal_year, companies, columns, filters):
|
||||
income, expense, net_profit_loss = get_income_expense_data(companies, fiscal_year, filters)
|
||||
@ -90,7 +93,9 @@ def get_profit_loss_data(fiscal_year, companies, columns, filters):
|
||||
|
||||
chart = get_pl_chart_data(filters, columns, income, expense, net_profit_loss)
|
||||
|
||||
return data, None, chart
|
||||
report_summary = get_pl_summary(companies, '', income, expense, net_profit_loss, True)
|
||||
|
||||
return data, None, chart, report_summary
|
||||
|
||||
def get_income_expense_data(companies, fiscal_year, filters):
|
||||
company_currency = get_company_currency(filters)
|
||||
@ -108,6 +113,7 @@ def get_cash_flow_data(fiscal_year, companies, filters):
|
||||
income, expense, net_profit_loss = get_income_expense_data(companies, fiscal_year, filters)
|
||||
|
||||
data = []
|
||||
summary_data = {}
|
||||
company_currency = get_company_currency(filters)
|
||||
|
||||
for cash_flow_account in cash_flow_accounts:
|
||||
@ -142,11 +148,13 @@ def get_cash_flow_data(fiscal_year, companies, filters):
|
||||
section_data.append(account_data)
|
||||
|
||||
add_total_row_account(data, section_data, cash_flow_account['section_footer'],
|
||||
companies, company_currency, True)
|
||||
companies, company_currency, summary_data, True)
|
||||
|
||||
add_total_row_account(data, data, _("Net Change in Cash"), companies, company_currency, True)
|
||||
add_total_row_account(data, data, _("Net Change in Cash"), companies, company_currency, summary_data, True)
|
||||
|
||||
return data
|
||||
report_summary = get_cash_flow_summary(summary_data, company_currency)
|
||||
|
||||
return data, report_summary
|
||||
|
||||
def get_account_type_based_data(account_type, companies, fiscal_year, filters):
|
||||
data = {}
|
||||
@ -200,17 +208,24 @@ def get_data(companies, root_type, balance_must_be, fiscal_year, filters=None, i
|
||||
|
||||
company_currency = get_company_currency(filters)
|
||||
|
||||
if filters.filter_based_on == 'Fiscal Year':
|
||||
start_date = fiscal_year.year_start_date
|
||||
end_date = fiscal_year.year_end_date
|
||||
else:
|
||||
start_date = filters.period_start_date
|
||||
end_date = filters.period_end_date
|
||||
|
||||
gl_entries_by_account = {}
|
||||
for root in frappe.db.sql("""select lft, rgt from tabAccount
|
||||
where root_type=%s and ifnull(parent_account, '') = ''""", root_type, as_dict=1):
|
||||
|
||||
set_gl_entries_by_account(fiscal_year.year_start_date,
|
||||
fiscal_year.year_end_date, root.lft, root.rgt, filters,
|
||||
set_gl_entries_by_account(start_date,
|
||||
end_date, root.lft, root.rgt, filters,
|
||||
gl_entries_by_account, accounts_by_name, ignore_closing_entries=False)
|
||||
|
||||
calculate_values(accounts_by_name, gl_entries_by_account, companies, fiscal_year, filters)
|
||||
calculate_values(accounts_by_name, gl_entries_by_account, companies, start_date, filters)
|
||||
accumulate_values_into_parents(accounts, accounts_by_name, companies)
|
||||
out = prepare_data(accounts, fiscal_year, balance_must_be, companies, company_currency)
|
||||
out = prepare_data(accounts, start_date, end_date, balance_must_be, companies, company_currency)
|
||||
|
||||
if out:
|
||||
add_total_row(out, root_type, balance_must_be, companies, company_currency)
|
||||
@ -221,7 +236,7 @@ def get_company_currency(filters=None):
|
||||
return (filters.get('presentation_currency')
|
||||
or frappe.get_cached_value('Company', filters.company, "default_currency"))
|
||||
|
||||
def calculate_values(accounts_by_name, gl_entries_by_account, companies, fiscal_year, filters):
|
||||
def calculate_values(accounts_by_name, gl_entries_by_account, companies, start_date, filters):
|
||||
for entries in gl_entries_by_account.values():
|
||||
for entry in entries:
|
||||
key = entry.account_number or entry.account_name
|
||||
@ -233,7 +248,7 @@ def calculate_values(accounts_by_name, gl_entries_by_account, companies, fiscal_
|
||||
and entry.company in companies.get(company)):
|
||||
d[company] = d.get(company, 0.0) + flt(entry.debit) - flt(entry.credit)
|
||||
|
||||
if entry.posting_date < fiscal_year.year_start_date:
|
||||
if entry.posting_date < getdate(start_date):
|
||||
d["opening_balance"] = d.get("opening_balance", 0.0) + flt(entry.debit) - flt(entry.credit)
|
||||
|
||||
def accumulate_values_into_parents(accounts, accounts_by_name, companies):
|
||||
@ -287,10 +302,8 @@ def get_accounts(root_type, filters):
|
||||
`tabAccount` where company = %s and root_type = %s
|
||||
""" , (filters.get('company'), root_type), as_dict=1)
|
||||
|
||||
def prepare_data(accounts, fiscal_year, balance_must_be, companies, company_currency):
|
||||
def prepare_data(accounts, start_date, end_date, balance_must_be, companies, company_currency):
|
||||
data = []
|
||||
year_start_date = fiscal_year.year_start_date
|
||||
year_end_date = fiscal_year.year_end_date
|
||||
|
||||
for d in accounts:
|
||||
# add to output
|
||||
@ -301,8 +314,8 @@ def prepare_data(accounts, fiscal_year, balance_must_be, companies, company_curr
|
||||
"account": _(d.account_name),
|
||||
"parent_account": _(d.parent_account),
|
||||
"indent": flt(d.indent),
|
||||
"year_start_date": year_start_date,
|
||||
"year_end_date": year_end_date,
|
||||
"year_start_date": start_date,
|
||||
"year_end_date": end_date,
|
||||
"currency": company_currency,
|
||||
"opening_balance": d.get("opening_balance", 0.0) * (1 if balance_must_be == "Debit" else -1)
|
||||
})
|
||||
|
@ -18,17 +18,20 @@ from frappe.utils import (flt, getdate, get_first_day, add_months, add_days, for
|
||||
from six import itervalues
|
||||
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions, get_dimension_with_children
|
||||
|
||||
def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_values=False,
|
||||
def get_period_list(from_fiscal_year, to_fiscal_year, period_start_date, period_end_date, filter_based_on, periodicity, accumulated_values=False,
|
||||
company=None, reset_period_on_fy_change=True):
|
||||
"""Get a list of dict {"from_date": from_date, "to_date": to_date, "key": key, "label": label}
|
||||
Periodicity can be (Yearly, Quarterly, Monthly)"""
|
||||
|
||||
if filter_based_on == 'Fiscal Year':
|
||||
fiscal_year = get_fiscal_year_data(from_fiscal_year, to_fiscal_year)
|
||||
validate_fiscal_year(fiscal_year, from_fiscal_year, to_fiscal_year)
|
||||
|
||||
# start with first day, so as to avoid year to_dates like 2-April if ever they occur]
|
||||
year_start_date = getdate(fiscal_year.year_start_date)
|
||||
year_end_date = getdate(fiscal_year.year_end_date)
|
||||
else:
|
||||
validate_dates(period_start_date, period_end_date)
|
||||
year_start_date = getdate(period_start_date)
|
||||
year_end_date = getdate(period_end_date)
|
||||
|
||||
months_to_add = {
|
||||
"Yearly": 12,
|
||||
@ -42,6 +45,9 @@ def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, accumulated_v
|
||||
start_date = year_start_date
|
||||
months = get_months(year_start_date, year_end_date)
|
||||
|
||||
if (months // months_to_add) != (months / months_to_add):
|
||||
months += months_to_add
|
||||
|
||||
for i in range(months // months_to_add):
|
||||
period = frappe._dict({
|
||||
"from_date": start_date
|
||||
@ -103,9 +109,18 @@ def get_fiscal_year_data(from_fiscal_year, to_fiscal_year):
|
||||
|
||||
|
||||
def validate_fiscal_year(fiscal_year, from_fiscal_year, to_fiscal_year):
|
||||
if not fiscal_year.get('year_start_date') and not fiscal_year.get('year_end_date'):
|
||||
if not fiscal_year.get('year_start_date') or not fiscal_year.get('year_end_date'):
|
||||
frappe.throw(_("Start Year and End Year are mandatory"))
|
||||
|
||||
if getdate(fiscal_year.get('year_end_date')) < getdate(fiscal_year.get('year_start_date')):
|
||||
frappe.throw(_("End Year cannot be before Start Year"))
|
||||
|
||||
def validate_dates(from_date, to_date):
|
||||
if not from_date or not to_date:
|
||||
frappe.throw("From Date and To Date are mandatory")
|
||||
|
||||
if to_date < from_date:
|
||||
frappe.throw("To Date cannot be less than From Date")
|
||||
|
||||
def get_months(start_date, end_date):
|
||||
diff = (12 * end_date.year + end_date.month) - (12 * start_date.year + start_date.month)
|
||||
@ -151,7 +166,7 @@ def get_data(
|
||||
|
||||
calculate_values(
|
||||
accounts_by_name, gl_entries_by_account, period_list, accumulated_values, ignore_accumulated_values_for_fy)
|
||||
accumulate_values_into_parents(accounts, accounts_by_name, period_list, accumulated_values)
|
||||
accumulate_values_into_parents(accounts, accounts_by_name, period_list)
|
||||
out = prepare_data(accounts, balance_must_be, period_list, company_currency)
|
||||
out = filter_out_zero_value_rows(out, parent_children_map)
|
||||
|
||||
@ -191,7 +206,7 @@ def calculate_values(
|
||||
d["opening_balance"] = d.get("opening_balance", 0.0) + flt(entry.debit) - flt(entry.credit)
|
||||
|
||||
|
||||
def accumulate_values_into_parents(accounts, accounts_by_name, period_list, accumulated_values):
|
||||
def accumulate_values_into_parents(accounts, accounts_by_name, period_list):
|
||||
"""accumulate children's values in parent accounts"""
|
||||
for d in reversed(accounts):
|
||||
if d.parent_account:
|
||||
@ -420,6 +435,8 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters):
|
||||
filters[dimension.fieldname] = get_dimension_with_children(dimension.document_type,
|
||||
filters.get(dimension.fieldname))
|
||||
additional_conditions.append("{0} in %({0})s".format(dimension.fieldname))
|
||||
else:
|
||||
additional_conditions.append("{0} in (%({0})s)".format(dimension.fieldname))
|
||||
|
||||
return " and {}".format(" and ".join(additional_conditions)) if additional_conditions else ""
|
||||
|
||||
|
@ -203,6 +203,8 @@ def get_conditions(filters):
|
||||
filters[dimension.fieldname] = get_dimension_with_children(dimension.document_type,
|
||||
filters.get(dimension.fieldname))
|
||||
conditions.append("{0} in %({0})s".format(dimension.fieldname))
|
||||
else:
|
||||
conditions.append("{0} in (%({0})s)".format(dimension.fieldname))
|
||||
|
||||
return "and {}".format(" and ".join(conditions)) if conditions else ""
|
||||
|
||||
|
@ -15,11 +15,6 @@ frappe.require("assets/erpnext/js/financial_statements.js", function() {
|
||||
return frappe.db.get_link_options('Project', txt);
|
||||
}
|
||||
},
|
||||
{
|
||||
"fieldname": "accumulated_values",
|
||||
"label": __("Accumulated Values"),
|
||||
"fieldtype": "Check"
|
||||
},
|
||||
{
|
||||
"fieldname": "include_default_book_entries",
|
||||
"label": __("Include Default Book Entries"),
|
||||
|
@ -9,7 +9,8 @@ from erpnext.accounts.report.financial_statements import (get_period_list, get_c
|
||||
|
||||
def execute(filters=None):
|
||||
period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year,
|
||||
filters.periodicity, filters.accumulated_values, filters.company)
|
||||
filters.period_start_date, filters.period_end_date, filters.filter_based_on, filters.periodicity,
|
||||
company=filters.company)
|
||||
|
||||
income = get_data(filters.company, "Income", "Credit", period_list, filters = filters,
|
||||
accumulated_values=filters.accumulated_values,
|
||||
@ -31,20 +32,22 @@ def execute(filters=None):
|
||||
|
||||
chart = get_chart_data(filters, columns, income, expense, net_profit_loss)
|
||||
|
||||
report_summary = get_report_summary(columns, income, expense, net_profit_loss, filters.periodicity, period_list)
|
||||
default_currency = frappe.get_cached_value('Company', filters.company, "default_currency")
|
||||
report_summary = get_report_summary(period_list, filters.periodicity, income, expense, net_profit_loss, default_currency)
|
||||
|
||||
return columns, data, None, chart, report_summary
|
||||
|
||||
def get_report_summary(columns, income, expense, net_profit_loss, period_list, periodicity):
|
||||
income_data, expense_data, net_profit = [], [], []
|
||||
def get_report_summary(period_list, periodicity, income, expense, net_profit_loss, default_currency, consolidated=False):
|
||||
net_income, net_expense, net_profit = 0.0, 0.0, 0.0
|
||||
|
||||
for p in columns[2:]:
|
||||
for period in period_list:
|
||||
key = period if consolidated else period.key
|
||||
if income:
|
||||
income_data.append(income[-2].get(p.get("fieldname")))
|
||||
net_income += income[-2].get(key)
|
||||
if expense:
|
||||
expense_data.append(expense[-2].get(p.get("fieldname")))
|
||||
net_expense += expense[-2].get(key)
|
||||
if net_profit_loss:
|
||||
net_profit.append(net_profit_loss.get(p.get("fieldname")))
|
||||
net_profit += net_profit_loss.get(key)
|
||||
|
||||
if (len(period_list) == 1 and periodicity== 'Yearly'):
|
||||
profit_label = _("Profit This Year")
|
||||
@ -57,23 +60,23 @@ def get_report_summary(columns, income, expense, net_profit_loss, period_list, p
|
||||
|
||||
return [
|
||||
{
|
||||
"value": net_profit[-1],
|
||||
"indicator": "Green" if net_profit[-1] > 0 else "Red",
|
||||
"value": net_profit,
|
||||
"indicator": "Green" if net_profit > 0 else "Red",
|
||||
"label": profit_label,
|
||||
"datatype": "Currency",
|
||||
"currency": net_profit_loss.get("currency")
|
||||
"currency": net_profit_loss.get("currency") if net_profit_loss else default_currency
|
||||
},
|
||||
{
|
||||
"value": income_data[-1],
|
||||
"value": net_income,
|
||||
"label": income_label,
|
||||
"datatype": "Currency",
|
||||
"currency": income[-1].get('currency')
|
||||
"currency": income[-1].get('currency') if income else default_currency
|
||||
},
|
||||
{
|
||||
"value": expense_data[-1],
|
||||
"value": net_expense,
|
||||
"label": expense_label,
|
||||
"datatype": "Currency",
|
||||
"currency": expense[-1].get('currency')
|
||||
"currency": expense[-1].get('currency') if expense else default_currency
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -344,16 +344,19 @@ def get_conditions(filters):
|
||||
accounting_dimensions = get_accounting_dimensions(as_list=False)
|
||||
|
||||
if accounting_dimensions:
|
||||
common_condition = """
|
||||
and exists(select name from `tabSales Invoice Item`
|
||||
where parent=`tabSales Invoice`.name
|
||||
"""
|
||||
for dimension in accounting_dimensions:
|
||||
if filters.get(dimension.fieldname):
|
||||
if frappe.get_cached_value('DocType', dimension.document_type, 'is_tree'):
|
||||
filters[dimension.fieldname] = get_dimension_with_children(dimension.document_type,
|
||||
filters.get(dimension.fieldname))
|
||||
|
||||
conditions += """ and exists(select name from `tabSales Invoice Item`
|
||||
where parent=`tabSales Invoice`.name
|
||||
and ifnull(`tabSales Invoice Item`.{0}, '') in %({0})s)""".format(dimension.fieldname)
|
||||
|
||||
conditions += common_condition + "and ifnull(`tabSales Invoice Item`.{0}, '') in %({0})s)".format(dimension.fieldname)
|
||||
else:
|
||||
conditions += common_condition + "and ifnull(`tabSales Invoice Item`.{0}, '') in (%({0})s))".format(dimension.fieldname)
|
||||
|
||||
return conditions
|
||||
|
||||
|
@ -127,6 +127,8 @@ def get_rootwise_opening_balances(filters, report_type):
|
||||
filters[dimension.fieldname] = get_dimension_with_children(dimension.document_type,
|
||||
filters.get(dimension.fieldname))
|
||||
additional_conditions += "and {0} in %({0})s".format(dimension.fieldname)
|
||||
else:
|
||||
additional_conditions += "and {0} in (%({0})s)".format(dimension.fieldname)
|
||||
|
||||
query_filters.update({
|
||||
dimension.fieldname: filters.get(dimension.fieldname)
|
||||
|
@ -27,6 +27,8 @@
|
||||
"supplier_type",
|
||||
"pan",
|
||||
"language",
|
||||
"allow_purchase_invoice_creation_without_purchase_order",
|
||||
"allow_purchase_invoice_creation_without_purchase_receipt",
|
||||
"disabled",
|
||||
"warn_rfqs",
|
||||
"warn_pos",
|
||||
@ -364,13 +366,25 @@
|
||||
"fieldname": "is_frozen",
|
||||
"fieldtype": "Check",
|
||||
"label": "Is Frozen"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "allow_purchase_invoice_creation_without_purchase_order",
|
||||
"fieldtype": "Check",
|
||||
"label": "Allow Purchase Invoice Creation Without Purchase Order"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "allow_purchase_invoice_creation_without_purchase_receipt",
|
||||
"fieldtype": "Check",
|
||||
"label": "Allow Purchase Invoice Creation Without Purchase Receipt"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-user",
|
||||
"idx": 370,
|
||||
"image_field": "image",
|
||||
"links": [],
|
||||
"modified": "2019-12-19 18:17:16.614567",
|
||||
"modified": "2020-03-17 09:48:30.578242",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Buying",
|
||||
"name": "Supplier",
|
||||
|
@ -19,6 +19,7 @@ from erpnext.accounts.doctype.pricing_rule.utils import (apply_pricing_rule_on_t
|
||||
from erpnext.exceptions import InvalidCurrency
|
||||
from six import text_type
|
||||
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions
|
||||
from erpnext.stock.get_item_details import get_item_warehouse
|
||||
|
||||
force_item_fields = ("item_group", "brand", "stock_uom", "is_fixed_asset", "item_tax_rate", "pricing_rules")
|
||||
|
||||
@ -1126,16 +1127,16 @@ def set_sales_order_defaults(parent_doctype, parent_doctype_name, child_docname,
|
||||
"""
|
||||
Returns a Sales Order Item child item containing the default values
|
||||
"""
|
||||
p_doctype = frappe.get_doc(parent_doctype, parent_doctype_name)
|
||||
child_item = frappe.new_doc('Sales Order Item', p_doctype, child_docname)
|
||||
p_doc = frappe.get_doc(parent_doctype, parent_doctype_name)
|
||||
child_item = frappe.new_doc('Sales Order Item', p_doc, child_docname)
|
||||
item = frappe.get_doc("Item", item_code)
|
||||
child_item.item_code = item.item_code
|
||||
child_item.item_name = item.item_name
|
||||
child_item.description = item.description
|
||||
child_item.reqd_by_date = p_doctype.delivery_date
|
||||
child_item.reqd_by_date = p_doc.delivery_date
|
||||
child_item.uom = item.stock_uom
|
||||
child_item.conversion_factor = get_conversion_factor(item_code, item.stock_uom).get("conversion_factor") or 1.0
|
||||
child_item.warehouse = p_doctype.set_warehouse or p_doctype.items[0].warehouse
|
||||
child_item.warehouse = get_item_warehouse(item, p_doc, overwrite_warehouse=True)
|
||||
return child_item
|
||||
|
||||
|
||||
@ -1143,13 +1144,13 @@ def set_purchase_order_defaults(parent_doctype, parent_doctype_name, child_docna
|
||||
"""
|
||||
Returns a Purchase Order Item child item containing the default values
|
||||
"""
|
||||
p_doctype = frappe.get_doc(parent_doctype, parent_doctype_name)
|
||||
child_item = frappe.new_doc('Purchase Order Item', p_doctype, child_docname)
|
||||
p_doc = frappe.get_doc(parent_doctype, parent_doctype_name)
|
||||
child_item = frappe.new_doc('Purchase Order Item', p_doc, child_docname)
|
||||
item = frappe.get_doc("Item", item_code)
|
||||
child_item.item_code = item.item_code
|
||||
child_item.item_name = item.item_name
|
||||
child_item.description = item.description
|
||||
child_item.schedule_date = p_doctype.schedule_date
|
||||
child_item.schedule_date = p_doc.schedule_date
|
||||
child_item.uom = item.stock_uom
|
||||
child_item.conversion_factor = get_conversion_factor(item_code, item.stock_uom).get("conversion_factor") or 1.0
|
||||
child_item.base_rate = 1 # Initiallize value will update in parent validation
|
||||
|
@ -179,6 +179,12 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
|
||||
# scan description only if items are less than 50000
|
||||
description_cond = 'or tabItem.description LIKE %(txt)s'
|
||||
|
||||
extra_cond = " and tabItem.has_variants=0"
|
||||
if (filters and isinstance(filters, dict)
|
||||
and filters.get("doctype") == "BOM"):
|
||||
extra_cond = ""
|
||||
del filters["doctype"]
|
||||
|
||||
return frappe.db.sql("""select tabItem.name,
|
||||
if(length(tabItem.item_name) > 40,
|
||||
concat(substr(tabItem.item_name, 1, 40), "..."), item_name) as item_name,
|
||||
@ -188,11 +194,11 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
|
||||
{columns}
|
||||
from tabItem
|
||||
where tabItem.docstatus < 2
|
||||
and tabItem.has_variants=0
|
||||
and tabItem.disabled=0
|
||||
and (tabItem.end_of_life > %(today)s or ifnull(tabItem.end_of_life, '0000-00-00')='0000-00-00')
|
||||
and ({scond} or tabItem.item_code IN (select parent from `tabItem Barcode` where barcode LIKE %(txt)s)
|
||||
{description_cond})
|
||||
{extra_cond}
|
||||
{fcond} {mcond}
|
||||
order by
|
||||
if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999),
|
||||
@ -203,6 +209,7 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
|
||||
key=searchfield,
|
||||
columns=columns,
|
||||
scond=searchfields,
|
||||
extra_cond=extra_cond,
|
||||
fcond=get_filters_cond(doctype, filters, conditions).replace('%', '%%'),
|
||||
mcond=get_match_cond(doctype).replace('%', '%%'),
|
||||
description_cond = description_cond),
|
||||
|
@ -12,9 +12,6 @@ from frappe.email.inbox import link_communication_to_document
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
from frappe.utils import cint, comma_and, cstr, getdate, has_gravatar, nowdate, validate_email_address
|
||||
|
||||
sender_field = "email_id"
|
||||
|
||||
|
||||
class Lead(SellingController):
|
||||
def get_feed(self):
|
||||
return '{0}: {1}'.format(_(self.status), self.lead_name)
|
||||
@ -129,7 +126,7 @@ class Lead(SellingController):
|
||||
self.title = self.lead_name
|
||||
|
||||
def create_address(self):
|
||||
address_fields = ["address_title", "address_line1", "address_line2",
|
||||
address_fields = ["address_type", "address_title", "address_line1", "address_line2",
|
||||
"city", "county", "state", "country", "pincode"]
|
||||
info_fields = ["email_id", "phone", "fax"]
|
||||
|
||||
@ -212,7 +209,7 @@ class Lead(SellingController):
|
||||
self.contact_doc.save()
|
||||
|
||||
def flush_address_and_contact_fields(self):
|
||||
fields = ['address_line1', 'address_line2', 'address_title',
|
||||
fields = ['address_type', 'address_line1', 'address_line2', 'address_title',
|
||||
'city', 'county', 'country', 'fax', 'pincode', 'state']
|
||||
|
||||
for field in fields:
|
||||
|
@ -8,6 +8,7 @@
|
||||
"doctype": "DocType",
|
||||
"document_type": "Document",
|
||||
"editable_grid": 1,
|
||||
"email_append_to": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"from_section",
|
||||
@ -328,6 +329,7 @@
|
||||
"fieldname": "contact_email",
|
||||
"fieldtype": "Data",
|
||||
"label": "Contact Email",
|
||||
"options": "Email",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
@ -421,7 +423,7 @@
|
||||
"icon": "fa fa-info-sign",
|
||||
"idx": 195,
|
||||
"links": [],
|
||||
"modified": "2020-03-20 12:28:45.228994",
|
||||
"modified": "2020-04-07 09:05:39.391109",
|
||||
"modified_by": "Administrator",
|
||||
"module": "CRM",
|
||||
"name": "Opportunity",
|
||||
@ -453,9 +455,11 @@
|
||||
}
|
||||
],
|
||||
"search_fields": "status,transaction_date,party_name,opportunity_type,territory,company",
|
||||
"sender_field": "contact_email",
|
||||
"show_name_in_global_search": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"subject_field": "title",
|
||||
"timeline_field": "party_name",
|
||||
"title_field": "title",
|
||||
"track_seen": 1,
|
||||
|
@ -11,9 +11,6 @@ from erpnext.utilities.transaction_base import TransactionBase
|
||||
from erpnext.accounts.party import get_party_account_currency
|
||||
from frappe.email.inbox import link_communication_to_document
|
||||
|
||||
subject_field = "title"
|
||||
sender_field = "contact_email"
|
||||
|
||||
class Opportunity(TransactionBase):
|
||||
def after_insert(self):
|
||||
if self.opportunity_from == "Lead":
|
||||
|
60
erpnext/erpnext_integrations/custom/contact.json
Normal file
60
erpnext/erpnext_integrations/custom/contact.json
Normal file
@ -0,0 +1,60 @@
|
||||
{
|
||||
"custom_fields": [
|
||||
{
|
||||
"_assign": null,
|
||||
"_comments": null,
|
||||
"_liked_by": null,
|
||||
"_user_tags": null,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"collapsible_depends_on": null,
|
||||
"columns": 0,
|
||||
"creation": "2019-12-02 11:00:03.432994",
|
||||
"default": null,
|
||||
"depends_on": null,
|
||||
"description": null,
|
||||
"docstatus": 0,
|
||||
"dt": "Contact",
|
||||
"fetch_from": null,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "is_billing_contact",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
"idx": 27,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"insert_after": "is_primary_contact",
|
||||
"label": "Is Billing Contact",
|
||||
"length": 0,
|
||||
"modified": "2019-12-02 11:00:03.432994",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Contact-is_billing_contact",
|
||||
"no_copy": 0,
|
||||
"options": null,
|
||||
"owner": "Administrator",
|
||||
"parent": null,
|
||||
"parentfield": null,
|
||||
"parenttype": null,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"print_width": null,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0,
|
||||
"width": null
|
||||
}
|
||||
],
|
||||
"custom_perms": [],
|
||||
"doctype": "Contact",
|
||||
"property_setters": [],
|
||||
"sync_on_migrate": 1
|
||||
}
|
@ -55,12 +55,8 @@ treeviews = ['Account', 'Cost Center', 'Warehouse', 'Item Group', 'Customer Grou
|
||||
update_website_context = ["erpnext.shopping_cart.utils.update_website_context", "erpnext.education.doctype.education_settings.education_settings.update_website_context"]
|
||||
my_account_context = "erpnext.shopping_cart.utils.update_my_account_context"
|
||||
|
||||
email_append_to = ["Job Applicant", "Lead", "Opportunity", "Issue"]
|
||||
|
||||
calendars = ["Task", "Work Order", "Leave Application", "Sales Order", "Holiday List", "Course Schedule"]
|
||||
|
||||
|
||||
|
||||
domains = {
|
||||
'Agriculture': 'erpnext.domains.agriculture',
|
||||
'Distribution': 'erpnext.domains.distribution',
|
||||
@ -243,7 +239,7 @@ doc_events = {
|
||||
"on_trash": "erpnext.regional.check_deletion_permission"
|
||||
},
|
||||
"Payment Entry": {
|
||||
"on_submit": ["erpnext.regional.create_transaction_log", "erpnext.accounts.doctype.payment_request.payment_request.make_status_as_paid"],
|
||||
"on_submit": ["erpnext.regional.create_transaction_log", "erpnext.accounts.doctype.payment_request.payment_request.update_payment_req_status"],
|
||||
"on_trash": "erpnext.regional.check_deletion_permission"
|
||||
},
|
||||
'Address': {
|
||||
|
@ -1,385 +1,123 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 0,
|
||||
"actions": [],
|
||||
"allow_rename": 1,
|
||||
"autoname": "HR-APP-.YYYY.-.#####",
|
||||
"beta": 0,
|
||||
"creation": "2013-01-29 19:25:37",
|
||||
"custom": 0,
|
||||
"description": "Applicant for a Job",
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"document_type": "Document",
|
||||
"editable_grid": 0,
|
||||
"email_append_to": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"applicant_name",
|
||||
"email_id",
|
||||
"status",
|
||||
"column_break_3",
|
||||
"job_title",
|
||||
"source",
|
||||
"source_name",
|
||||
"section_break_6",
|
||||
"notes",
|
||||
"cover_letter",
|
||||
"resume_attachment"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 1,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "applicant_name",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 1,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Applicant Name",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 1,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "email_id",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Email Address",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Email",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "status",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Status",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Open\nReplied\nRejected\nHold\nAccepted",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "column_break_3",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "job_title",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Job Opening",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Job Opening",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
"options": "Job Opening"
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "source",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Source",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Job Applicant Source",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
"options": "Job Applicant Source"
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval: doc.source==\"Employee Referral\" ",
|
||||
"fieldname": "source_name",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Source Name",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Employee",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
"options": "Employee"
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "section_break_6",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "cover_letter",
|
||||
"fieldtype": "Text",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Cover Letter",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
"label": "Cover Letter"
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "resume_attachment",
|
||||
"fieldtype": "Attach",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Resume Attachment",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
"label": "Resume Attachment"
|
||||
},
|
||||
{
|
||||
"fieldname": "notes",
|
||||
"fieldtype": "Data",
|
||||
"label": "Notes",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"has_web_view": 0,
|
||||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
"icon": "fa fa-user",
|
||||
"idx": 1,
|
||||
"image_view": 0,
|
||||
"in_create": 0,
|
||||
"is_submittable": 0,
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2019-07-21 16:15:43.552049",
|
||||
"links": [],
|
||||
"modified": "2020-01-13 16:19:39.113330",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Job Applicant",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 0,
|
||||
"if_owner": 0,
|
||||
"import": 0,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "HR User",
|
||||
"set_user_permissions": 0,
|
||||
"share": 1,
|
||||
"submit": 0,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"quick_entry": 0,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"search_fields": "applicant_name",
|
||||
"show_name_in_global_search": 0,
|
||||
"sender_field": "email_id",
|
||||
"sort_field": "modified",
|
||||
"sort_order": "ASC",
|
||||
"title_field": "applicant_name",
|
||||
"track_changes": 0,
|
||||
"track_seen": 0,
|
||||
"track_views": 0
|
||||
"subject_field": "notes",
|
||||
"title_field": "applicant_name"
|
||||
}
|
@ -9,8 +9,6 @@ import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import comma_and, validate_email_address
|
||||
|
||||
sender_field = "email_id"
|
||||
|
||||
class DuplicationError(frappe.ValidationError): pass
|
||||
|
||||
class JobApplicant(Document):
|
||||
|
@ -130,7 +130,7 @@ class LeaveApplication(Document):
|
||||
if self.status == "Approved":
|
||||
for dt in daterange(getdate(self.from_date), getdate(self.to_date)):
|
||||
date = dt.strftime("%Y-%m-%d")
|
||||
status = "Half Day" if date == self.half_day_date else "On Leave"
|
||||
status = "Half Day" if getdate(date) == getdate(self.half_day_date) else "On Leave"
|
||||
|
||||
attendance_name = frappe.db.exists('Attendance', dict(employee = self.employee,
|
||||
attendance_date = date, docstatus = ('!=', 2)))
|
||||
|
@ -14,27 +14,37 @@ frappe.ui.form.on('Blanket Order', {
|
||||
refresh: function(frm) {
|
||||
erpnext.hide_company();
|
||||
if (frm.doc.customer && frm.doc.docstatus === 1) {
|
||||
frm.add_custom_button(__('View Orders'), function() {
|
||||
frappe.set_route('List', 'Sales Order', {blanket_order: frm.doc.name});
|
||||
});
|
||||
frm.add_custom_button(__("Create Sales Order"), function(){
|
||||
frm.add_custom_button(__("Sales Order"), function() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.manufacturing.doctype.blanket_order.blanket_order.make_sales_order",
|
||||
frm: frm
|
||||
method: "erpnext.manufacturing.doctype.blanket_order.blanket_order.make_order",
|
||||
frm: frm,
|
||||
args: {
|
||||
doctype: 'Sales Order'
|
||||
}
|
||||
});
|
||||
}).addClass("btn-primary");
|
||||
}, __('Create'));
|
||||
|
||||
frm.add_custom_button(__("Quotation"), function() {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.manufacturing.doctype.blanket_order.blanket_order.make_order",
|
||||
frm: frm,
|
||||
args: {
|
||||
doctype: 'Quotation'
|
||||
}
|
||||
});
|
||||
}, __('Create'));
|
||||
}
|
||||
|
||||
if (frm.doc.supplier && frm.doc.docstatus === 1) {
|
||||
frm.add_custom_button(__('View Orders'), function() {
|
||||
frappe.set_route('List', 'Purchase Order', {blanket_order: frm.doc.name});
|
||||
});
|
||||
frm.add_custom_button(__("Create Purchase Order"), function(){
|
||||
frm.add_custom_button(__("Purchase Order"), function(){
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.manufacturing.doctype.blanket_order.blanket_order.make_purchase_order",
|
||||
frm: frm
|
||||
method: "erpnext.manufacturing.doctype.blanket_order.blanket_order.make_order",
|
||||
frm: frm,
|
||||
args: {
|
||||
doctype: 'Purchase Order'
|
||||
}
|
||||
});
|
||||
}).addClass("btn-primary");
|
||||
}, __('Create'));
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -14,11 +14,19 @@ from erpnext.stock.doctype.item.item import get_item_defaults
|
||||
class BlanketOrder(Document):
|
||||
def validate(self):
|
||||
self.validate_dates()
|
||||
self.validate_duplicate_items()
|
||||
|
||||
def validate_dates(self):
|
||||
if getdate(self.from_date) > getdate(self.to_date):
|
||||
frappe.throw(_("From date cannot be greater than To date"))
|
||||
|
||||
def validate_duplicate_items(self):
|
||||
item_list = []
|
||||
for item in self.items:
|
||||
if item.item_code in item_list:
|
||||
frappe.throw(_("Note: Item {0} added multiple times").format(frappe.bold(item.item_code)))
|
||||
item_list.append(item.item_code)
|
||||
|
||||
def update_ordered_qty(self):
|
||||
ref_doctype = "Sales Order" if self.blanket_order_type == "Selling" else "Purchase Order"
|
||||
item_ordered_qty = frappe._dict(frappe.db.sql("""
|
||||
@ -35,7 +43,14 @@ class BlanketOrder(Document):
|
||||
d.db_set("ordered_qty", item_ordered_qty.get(d.item_code, 0))
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_sales_order(source_name):
|
||||
def make_order(source_name):
|
||||
doctype = frappe.flags.args.doctype
|
||||
|
||||
def update_doc(source_doc, target_doc, source_parent):
|
||||
if doctype == 'Quotation':
|
||||
target_doc.quotation_to = 'Customer'
|
||||
target_doc.party_name = source_doc.customer
|
||||
|
||||
def update_item(source, target, source_parent):
|
||||
target_qty = source.get("qty") - source.get("ordered_qty")
|
||||
target.qty = target_qty if not flt(target_qty) < 0 else 0
|
||||
@ -49,39 +64,11 @@ def make_sales_order(source_name):
|
||||
|
||||
target_doc = get_mapped_doc("Blanket Order", source_name, {
|
||||
"Blanket Order": {
|
||||
"doctype": "Sales Order"
|
||||
"doctype": doctype,
|
||||
"postprocess": update_doc
|
||||
},
|
||||
"Blanket Order Item": {
|
||||
"doctype": "Sales Order Item",
|
||||
"field_map": {
|
||||
"rate": "blanket_order_rate",
|
||||
"parent": "blanket_order"
|
||||
},
|
||||
"postprocess": update_item
|
||||
}
|
||||
})
|
||||
return target_doc
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_purchase_order(source_name):
|
||||
def update_item(source, target, source_parent):
|
||||
target_qty = source.get("qty") - source.get("ordered_qty")
|
||||
target.qty = target_qty if not flt(target_qty) < 0 else 0
|
||||
item = get_item_defaults(target.item_code, source_parent.company)
|
||||
if item:
|
||||
target.item_name = item.get("item_name")
|
||||
target.description = item.get("description")
|
||||
target.uom = item.get("stock_uom")
|
||||
target.warehouse = item.get("default_warehouse")
|
||||
target.against_blanket_order = 1
|
||||
target.blanket_order = source_name
|
||||
|
||||
target_doc = get_mapped_doc("Blanket Order", source_name, {
|
||||
"Blanket Order": {
|
||||
"doctype": "Purchase Order"
|
||||
},
|
||||
"Blanket Order Item": {
|
||||
"doctype": "Purchase Order Item",
|
||||
"doctype": doctype + " Item",
|
||||
"field_map": {
|
||||
"rate": "blanket_order_rate",
|
||||
"parent": "blanket_order"
|
||||
|
@ -6,7 +6,7 @@ def get_data():
|
||||
'fieldname': 'blanket_order',
|
||||
'transactions': [
|
||||
{
|
||||
'items': ['Purchase Order', 'Sales Order']
|
||||
'items': ['Purchase Order', 'Sales Order', 'Quotation']
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -7,13 +7,17 @@ import frappe
|
||||
import unittest
|
||||
from frappe.utils import add_months, today
|
||||
from erpnext import get_company_currency
|
||||
from .blanket_order import make_sales_order, make_purchase_order
|
||||
from .blanket_order import make_order
|
||||
|
||||
class TestBlanketOrder(unittest.TestCase):
|
||||
def setUp(self):
|
||||
frappe.flags.args = frappe._dict()
|
||||
|
||||
def test_sales_order_creation(self):
|
||||
bo = make_blanket_order(blanket_order_type="Selling")
|
||||
|
||||
so = make_sales_order(bo.name)
|
||||
frappe.flags.args.doctype = 'Sales Order'
|
||||
so = make_order(bo.name)
|
||||
so.currency = get_company_currency(so.company)
|
||||
so.delivery_date = today()
|
||||
so.items[0].qty = 10
|
||||
@ -29,7 +33,8 @@ class TestBlanketOrder(unittest.TestCase):
|
||||
self.assertEqual(so.items[0].qty, bo.items[0].ordered_qty)
|
||||
|
||||
# test the quantity
|
||||
so1 = make_sales_order(bo.name)
|
||||
frappe.flags.args.doctype = 'Sales Order'
|
||||
so1 = make_order(bo.name)
|
||||
so1.currency = get_company_currency(so1.company)
|
||||
self.assertEqual(so1.items[0].qty, (bo.items[0].qty-bo.items[0].ordered_qty))
|
||||
|
||||
@ -37,7 +42,8 @@ class TestBlanketOrder(unittest.TestCase):
|
||||
def test_purchase_order_creation(self):
|
||||
bo = make_blanket_order(blanket_order_type="Purchasing")
|
||||
|
||||
po = make_purchase_order(bo.name)
|
||||
frappe.flags.args.doctype = 'Purchase Order'
|
||||
po = make_order(bo.name)
|
||||
po.currency = get_company_currency(po.company)
|
||||
po.schedule_date = today()
|
||||
po.items[0].qty = 10
|
||||
@ -53,7 +59,8 @@ class TestBlanketOrder(unittest.TestCase):
|
||||
self.assertEqual(po.items[0].qty, bo.items[0].ordered_qty)
|
||||
|
||||
# test the quantity
|
||||
po1 = make_sales_order(bo.name)
|
||||
frappe.flags.args.doctype = 'Purchase Order'
|
||||
po1 = make_order(bo.name)
|
||||
po1.currency = get_company_currency(po1.company)
|
||||
self.assertEqual(po1.items[0].qty, (bo.items[0].qty-bo.items[0].ordered_qty))
|
||||
|
||||
|
@ -29,7 +29,10 @@ frappe.ui.form.on("BOM", {
|
||||
|
||||
frm.set_query("item", function() {
|
||||
return {
|
||||
query: "erpnext.controllers.queries.item_query"
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
filters: {
|
||||
"doctype": "BOM"
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@ -119,23 +122,58 @@ frappe.ui.form.on("BOM", {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (frm.doc.__onload && frm.doc.__onload["has_variants"]) {
|
||||
frm.set_intro(__('This is a Template BOM and will be used to make the work order for {0} of the item {1}',
|
||||
[
|
||||
`<a class="variants-intro">variants</a>`,
|
||||
`<a href="#Form/Item/${frm.doc.item}">${frm.doc.item}</a>`,
|
||||
]), true);
|
||||
|
||||
frm.$wrapper.find(".variants-intro").on("click", () => {
|
||||
frappe.set_route("List", "Item", {"variant_of": frm.doc.item});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
make_work_order: function(frm) {
|
||||
const fields = [{
|
||||
const fields = [];
|
||||
|
||||
if (frm.doc.__onload && frm.doc.__onload["has_variants"]) {
|
||||
fields.push({
|
||||
fieldtype: 'Link',
|
||||
label: __('Variant Item'),
|
||||
fieldname: 'item',
|
||||
options: "Item",
|
||||
reqd: 1,
|
||||
get_query: function() {
|
||||
return {
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
filters: {
|
||||
"variant_of": frm.doc.item
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fields.push({
|
||||
fieldtype: 'Float',
|
||||
label: __('Qty To Manufacture'),
|
||||
fieldname: 'qty',
|
||||
reqd: 1,
|
||||
default: 1
|
||||
}];
|
||||
});
|
||||
|
||||
frappe.prompt(fields, data => {
|
||||
let item = data.item || frm.doc.item;
|
||||
|
||||
frappe.call({
|
||||
method: "erpnext.manufacturing.doctype.work_order.work_order.make_work_order",
|
||||
args: {
|
||||
bom_no: frm.doc.name,
|
||||
item: frm.doc.item,
|
||||
item: item,
|
||||
qty: data.qty || 0.0,
|
||||
project: frm.doc.project
|
||||
},
|
||||
|
@ -59,6 +59,10 @@ class BOM(WebsiteGenerator):
|
||||
|
||||
self.name = name
|
||||
|
||||
def onload(self):
|
||||
super(BOM, self).onload()
|
||||
if self.get("item") and cint(frappe.db.get_value("Item", self.item, "has_variants")):
|
||||
self.set_onload("has_variants", True)
|
||||
|
||||
def validate(self):
|
||||
self.route = frappe.scrub(self.name).replace('_', '-')
|
||||
|
@ -1,12 +1,9 @@
|
||||
import frappe
|
||||
from frappe.permissions import add_permission, update_permission_property
|
||||
from erpnext.regional.india.setup import add_permissions
|
||||
|
||||
def execute():
|
||||
company = frappe.get_all('Company', filters = {'country': 'India'})
|
||||
if not company:
|
||||
return
|
||||
|
||||
for doctype in ('GST HSN Code', 'GST Settings'):
|
||||
add_permission(doctype, 'Accounts Manager', 0)
|
||||
update_permission_property(doctype, 'Accounts Manager', 0, 'write', 1)
|
||||
update_permission_property(doctype, 'Accounts Manager', 0, 'create', 1)
|
||||
add_permissions()
|
@ -118,7 +118,9 @@ def get_item_tax_template(item_tax_templates, item_tax_map, item_code, parenttyp
|
||||
account.insert()
|
||||
tax_type = account.name
|
||||
|
||||
if tax_type:
|
||||
account_type = frappe.get_cached_value("Account", tax_type, "account_type")
|
||||
|
||||
if tax_type and account_type in ('Tax', 'Chargeable', 'Income Account', 'Expense Account', 'Expenses Included In Valuation'):
|
||||
item_tax_template.append("taxes", {"tax_type": tax_type, "tax_rate": tax_rate})
|
||||
item_tax_templates.setdefault(item_tax_template.title, {})
|
||||
item_tax_templates[item_tax_template.title][tax_type] = tax_rate
|
||||
|
13
erpnext/patches/v12_0/recalculate_requested_qty_in_bin.py
Normal file
13
erpnext/patches/v12_0/recalculate_requested_qty_in_bin.py
Normal file
@ -0,0 +1,13 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from erpnext.stock.stock_balance import update_bin_qty, get_indented_qty
|
||||
|
||||
def execute():
|
||||
bin_details = frappe.db.sql("""
|
||||
SELECT item_code, warehouse
|
||||
FROM `tabBin`""",as_dict=1)
|
||||
|
||||
for entry in bin_details:
|
||||
update_bin_qty(entry.get("item_code"), entry.get("warehouse"), {
|
||||
"indented_qty": get_indented_qty(entry.get("item_code"), entry.get("warehouse"))
|
||||
})
|
@ -0,0 +1,30 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
purchase_receipts = frappe.db.sql("""
|
||||
SELECT
|
||||
parent from `tabPurchase Receipt Item`
|
||||
WHERE
|
||||
material_request is not null
|
||||
AND docstatus=1
|
||||
""",as_dict=1)
|
||||
|
||||
purchase_receipts = set([d.parent for d in purchase_receipts])
|
||||
|
||||
for pr in purchase_receipts:
|
||||
doc = frappe.get_doc("Purchase Receipt", pr)
|
||||
doc.status_updater = [
|
||||
{
|
||||
'source_dt': 'Purchase Receipt Item',
|
||||
'target_dt': 'Material Request Item',
|
||||
'join_field': 'material_request_item',
|
||||
'target_field': 'received_qty',
|
||||
'target_parent_dt': 'Material Request',
|
||||
'target_parent_field': 'per_received',
|
||||
'target_ref_field': 'stock_qty',
|
||||
'source_field': 'stock_qty',
|
||||
'percent_join_field': 'material_request'
|
||||
}
|
||||
]
|
||||
doc.update_qty()
|
@ -85,12 +85,6 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
||||
filters:{ 'is_sub_contracted_item': 1 }
|
||||
}
|
||||
}
|
||||
else if (me.frm.doc.material_request_type == "Customer Provided") {
|
||||
return{
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
filters:{ 'customer': me.frm.doc.customer }
|
||||
}
|
||||
}
|
||||
else {
|
||||
return{
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
|
@ -6,7 +6,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
|
||||
|
||||
apply_pricing_rule_on_item: function(item){
|
||||
let effective_item_rate = item.price_list_rate;
|
||||
if (item.parenttype === "Sales Order" && item.blanket_order_rate) {
|
||||
if (in_list(["Sales Order", "Quotation"], item.parenttype) && item.blanket_order_rate) {
|
||||
effective_item_rate = item.blanket_order_rate;
|
||||
}
|
||||
if(item.margin_type == "Percentage"){
|
||||
|
@ -473,6 +473,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
item_code: item.item_code,
|
||||
barcode: item.barcode,
|
||||
serial_no: item.serial_no,
|
||||
batch_no: item.batch_no,
|
||||
set_warehouse: me.frm.doc.set_warehouse,
|
||||
warehouse: item.warehouse,
|
||||
customer: me.frm.doc.customer || me.frm.doc.party_name,
|
||||
@ -637,6 +638,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
|
||||
// Add the new list to the serial no. field in grid with each in new line
|
||||
item.serial_no = valid_serial_nos.join('\n');
|
||||
item.conversion_factor = item.conversion_factor || 1;
|
||||
|
||||
refresh_field("serial_no", item.name, item.parentfield);
|
||||
if(!doc.is_return && cint(user_defaults.set_qty_in_transactions_based_on_serial_no_input)) {
|
||||
|
@ -29,7 +29,7 @@ class Quiz {
|
||||
this.questions.push(question)
|
||||
this.wrapper.appendChild(question_wrapper);
|
||||
})
|
||||
if (data.activity.is_complete) {
|
||||
if (data.activity && data.activity.is_complete) {
|
||||
this.disable()
|
||||
let indicator = 'red'
|
||||
let message = 'Your are not allowed to attempt the quiz again.'
|
||||
|
@ -78,6 +78,39 @@ function get_filters(){
|
||||
"fieldtype": "Link",
|
||||
"options": "Finance Book"
|
||||
},
|
||||
{
|
||||
"fieldname":"filter_based_on",
|
||||
"label": __("Filter Based On"),
|
||||
"fieldtype": "Select",
|
||||
"options": ["Fiscal Year", "Date Range"],
|
||||
"default": ["Fiscal Year"],
|
||||
"reqd": 1,
|
||||
on_change: function() {
|
||||
let filter_based_on = frappe.query_report.get_filter_value('filter_based_on');
|
||||
frappe.query_report.toggle_filter_display('from_fiscal_year', filter_based_on === 'Date Range');
|
||||
frappe.query_report.toggle_filter_display('to_fiscal_year', filter_based_on === 'Date Range');
|
||||
frappe.query_report.toggle_filter_display('period_start_date', filter_based_on === 'Fiscal Year');
|
||||
frappe.query_report.toggle_filter_display('period_end_date', filter_based_on === 'Fiscal Year');
|
||||
|
||||
frappe.query_report.refresh();
|
||||
}
|
||||
},
|
||||
{
|
||||
"fieldname":"period_start_date",
|
||||
"label": __("Start Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": frappe.datetime.nowdate(),
|
||||
"hidden": 1,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname":"period_end_date",
|
||||
"label": __("End Date"),
|
||||
"fieldtype": "Date",
|
||||
"default": frappe.datetime.add_months(frappe.datetime.nowdate(), 12),
|
||||
"hidden": 1,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname":"from_fiscal_year",
|
||||
"label": __("Start Year"),
|
||||
|
@ -453,7 +453,8 @@ erpnext.utils.update_child_items = function(opts) {
|
||||
fields: [{
|
||||
fieldtype:'Data',
|
||||
fieldname:"docname",
|
||||
hidden: 0,
|
||||
read_only: 1,
|
||||
hidden: 1,
|
||||
}, {
|
||||
fieldtype:'Link',
|
||||
fieldname:"item_code",
|
||||
|
@ -8,12 +8,19 @@ frappe.ui.form.ItemQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({
|
||||
render_dialog: function() {
|
||||
this.mandatory = this.get_variant_fields().concat(this.mandatory);
|
||||
this.mandatory = this.mandatory.concat(this.get_attributes_fields());
|
||||
this.check_naming_series_based_on();
|
||||
this._super();
|
||||
this.init_post_render_dialog_operations();
|
||||
this.preset_fields_for_template();
|
||||
this.dialog.$wrapper.find('.edit-full').text(__('Edit in full page for more options like assets, serial nos, batches etc.'))
|
||||
},
|
||||
|
||||
check_naming_series_based_on: function() {
|
||||
if (frappe.defaults.get_default("item_naming_by") === "Naming Series") {
|
||||
this.mandatory = this.mandatory.filter(d => d.fieldname !== "item_code");
|
||||
}
|
||||
},
|
||||
|
||||
init_post_render_dialog_operations: function() {
|
||||
this.dialog.fields_dict.attribute_html.$wrapper.append(frappe.render_template("item_quick_entry"));
|
||||
this.init_for_create_variant_trigger();
|
||||
|
@ -78,3 +78,7 @@
|
||||
z-index: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.place-order-container {
|
||||
text-align: right;
|
||||
}
|
@ -29,7 +29,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>(a) {{__("Outward taxable supplies(other than zero rated, nil rated and exempted")}}</td>
|
||||
<td>(a) {{__("Outward taxable supplies(other than zero rated, nil rated and exempted)")}}</td>
|
||||
<td class="right">{{ flt(data.sup_details.osup_det.txval, 2) }}</td>
|
||||
<td class="right">{{ flt(data.sup_details.osup_det.iamt, 2) }}</td>
|
||||
<td class="right">{{ flt(data.sup_details.osup_det.camt, 2) }}</td>
|
||||
|
@ -1,4 +1,5 @@
|
||||
{
|
||||
"actions": [],
|
||||
"autoname": "format:GSTR3B-{month}-{year}-{company_address}",
|
||||
"creation": "2019-02-04 11:35:55.964639",
|
||||
"doctype": "DocType",
|
||||
@ -48,25 +49,13 @@
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"modified": "2019-08-10 22:30:26.727038",
|
||||
"links": [],
|
||||
"modified": "2020-04-04 19:32:30.772908",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Regional",
|
||||
"name": "GSTR 3B Report",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"permissions": [],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1
|
||||
|
@ -77,9 +77,15 @@ def add_custom_roles_for_reports():
|
||||
)).insert()
|
||||
|
||||
def add_permissions():
|
||||
for doctype in ('GST HSN Code', 'GST Settings'):
|
||||
for doctype in ('GST HSN Code', 'GST Settings', 'GSTR 3B Report'):
|
||||
add_permission(doctype, 'All', 0)
|
||||
for role in ('Accounts Manager', 'System Manager', 'Item Manager', 'Stock Manager'):
|
||||
for role in ('Accounts Manager', 'Accounts User', 'System Manager'):
|
||||
add_permission(doctype, role, 0)
|
||||
update_permission_property(doctype, role, 0, 'write', 1)
|
||||
update_permission_property(doctype, role, 0, 'create', 1)
|
||||
|
||||
if doctype == 'GST HSN Code':
|
||||
for role in ('Item Manager', 'Stock Manager'):
|
||||
add_permission(doctype, role, 0)
|
||||
update_permission_property(doctype, role, 0, 'write', 1)
|
||||
update_permission_property(doctype, role, 0, 'create', 1)
|
||||
|
@ -25,6 +25,8 @@
|
||||
"territory",
|
||||
"tax_id",
|
||||
"tax_category",
|
||||
"so_required",
|
||||
"dn_required",
|
||||
"disabled",
|
||||
"is_internal_customer",
|
||||
"represents_company",
|
||||
@ -465,13 +467,25 @@
|
||||
"fieldtype": "Table",
|
||||
"label": "Credit Limit",
|
||||
"options": "Customer Credit Limit"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "so_required",
|
||||
"fieldtype": "Check",
|
||||
"label": "Allow Sales Invoice Creation Without Sales Order"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "dn_required",
|
||||
"fieldtype": "Check",
|
||||
"label": "Allow Sales Invoice Creation Without Delivery Note"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-user",
|
||||
"idx": 363,
|
||||
"image_field": "image",
|
||||
"links": [],
|
||||
"modified": "2020-01-29 20:36:37.879581",
|
||||
"modified": "2020-03-17 11:03:42.706907",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Selling",
|
||||
"name": "Customer",
|
||||
|
@ -155,6 +155,11 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False):
|
||||
def update_item(obj, target, source_parent):
|
||||
target.stock_qty = flt(obj.qty) * flt(obj.conversion_factor)
|
||||
|
||||
if obj.against_blanket_order:
|
||||
target.against_blanket_order = obj.against_blanket_order
|
||||
target.blanket_order = obj.blanket_order
|
||||
target.blanket_order_rate = obj.blanket_order_rate
|
||||
|
||||
doclist = get_mapped_doc("Quotation", source_name, {
|
||||
"Quotation": {
|
||||
"doctype": "Sales Order",
|
||||
|
@ -55,6 +55,9 @@
|
||||
"weight_uom",
|
||||
"reference",
|
||||
"warehouse",
|
||||
"against_blanket_order",
|
||||
"blanket_order",
|
||||
"blanket_order_rate",
|
||||
"column_break_30",
|
||||
"prevdoc_doctype",
|
||||
"prevdoc_docname",
|
||||
@ -573,12 +576,38 @@
|
||||
"fieldname": "image_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Image"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.against_blanket_order",
|
||||
"fieldname": "blanket_order",
|
||||
"fieldtype": "Link",
|
||||
"label": "Blanket Order",
|
||||
"no_copy": 1,
|
||||
"options": "Blanket Order",
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.against_blanket_order",
|
||||
"fieldname": "blanket_order_rate",
|
||||
"fieldtype": "Currency",
|
||||
"label": "Blanket Order Rate",
|
||||
"no_copy": 1,
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "against_blanket_order",
|
||||
"fieldtype": "Check",
|
||||
"label": "Against Blanket Order",
|
||||
"no_copy": 1,
|
||||
"print_hide": 1
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2020-03-05 14:18:58.783751",
|
||||
"modified": "2020-03-30 18:40:28.782720",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Selling",
|
||||
"name": "Quotation Item",
|
||||
|
@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import getdate, cint
|
||||
from frappe.utils import getdate, cint, cstr
|
||||
import calendar
|
||||
|
||||
def execute(filters=None):
|
||||
@ -48,7 +48,7 @@ def execute(filters=None):
|
||||
new = new_customers_in.get(key, [0,0.0])
|
||||
repeat = repeat_customers_in.get(key, [0,0.0])
|
||||
|
||||
out.append([year, calendar.month_name[month],
|
||||
out.append([cstr(year), calendar.month_name[month],
|
||||
new[0], repeat[0], new[0] + repeat[0],
|
||||
new[1], repeat[1], new[1] + repeat[1]])
|
||||
|
||||
|
@ -16,6 +16,7 @@ from frappe.utils.nestedset import NestedSet
|
||||
|
||||
from past.builtins import cmp
|
||||
import functools
|
||||
from erpnext.accounts.doctype.account.account import get_account_currency
|
||||
|
||||
class Company(NestedSet):
|
||||
nsm_parent_field = 'parent_company'
|
||||
@ -73,18 +74,22 @@ class Company(NestedSet):
|
||||
|
||||
def validate_default_accounts(self):
|
||||
accounts = [
|
||||
"default_bank_account", "default_cash_account",
|
||||
"default_receivable_account", "default_payable_account",
|
||||
"default_expense_account", "default_income_account",
|
||||
"stock_received_but_not_billed", "stock_adjustment_account",
|
||||
"expenses_included_in_valuation", "default_payroll_payable_account"
|
||||
["Default Bank Account", "default_bank_account"], ["Default Cash Account", "default_cash_account"],
|
||||
["Default Receivable Account", "default_receivable_account"], ["Default Payable Account", "default_payable_account"],
|
||||
["Default Expense Account", "default_expense_account"], ["Default Income Account", "default_income_account"],
|
||||
["Stock Received But Not Billed Account", "stock_received_but_not_billed"], ["Stock Adjustment Account", "stock_adjustment_account"],
|
||||
["Expense Included In Valuation Account", "expenses_included_in_valuation"], ["Default Payroll Payable Account", "default_payroll_payable_account"]
|
||||
]
|
||||
|
||||
for field in accounts:
|
||||
if self.get(field):
|
||||
for_company = frappe.db.get_value("Account", self.get(field), "company")
|
||||
for account in accounts:
|
||||
if self.get(account[1]):
|
||||
for_company = frappe.db.get_value("Account", self.get(account[1]), "company")
|
||||
if for_company != self.name:
|
||||
frappe.throw(_("Account {0} does not belong to company: {1}").format(self.get(field), self.name))
|
||||
frappe.throw(_("Account {0} does not belong to company: {1}").format(self.get(account[1]), self.name))
|
||||
|
||||
if get_account_currency(self.get(account[1])) != self.default_currency:
|
||||
frappe.throw(_("""{0} currency must be same as company's default currency.
|
||||
Please select another account""").format(frappe.bold(account[0])))
|
||||
|
||||
def validate_currency(self):
|
||||
if self.is_new():
|
||||
|
@ -38,14 +38,14 @@ def get_cart_quotation(doc=None):
|
||||
addresses = get_address_docs(party=party)
|
||||
|
||||
if not doc.customer_address and addresses:
|
||||
update_cart_address("customer_address", addresses[0].name)
|
||||
update_cart_address("billing", addresses[0].name)
|
||||
|
||||
return {
|
||||
"doc": decorate_quotation_doc(doc),
|
||||
"shipping_addresses": [{"name": address.name, "display": address.display}
|
||||
for address in addresses],
|
||||
for address in addresses if address.address_type == "Shipping"],
|
||||
"billing_addresses": [{"name": address.name, "display": address.display}
|
||||
for address in addresses],
|
||||
for address in addresses if address.address_type == "Billing"],
|
||||
"shipping_rules": get_applicable_shipping_rules(party),
|
||||
"cart_settings": frappe.get_cached_doc("Shopping Cart Settings")
|
||||
}
|
||||
@ -64,6 +64,9 @@ def place_order():
|
||||
# company used to create customer accounts
|
||||
frappe.defaults.set_user_default("company", quotation.company)
|
||||
|
||||
if not (quotation.shipping_address_name or quotation.customer_address):
|
||||
frappe.throw(_("Set Shipping Address or Billing Address"))
|
||||
|
||||
from erpnext.selling.doctype.quotation.quotation import _make_sales_order
|
||||
sales_order = frappe.get_doc(_make_sales_order(quotation.name, ignore_permissions=True))
|
||||
sales_order.payment_schedule = []
|
||||
@ -194,21 +197,18 @@ def get_terms_and_conditions(terms_name):
|
||||
return frappe.db.get_value('Terms and Conditions', terms_name, 'terms')
|
||||
|
||||
@frappe.whitelist()
|
||||
def update_cart_address(address_fieldname, address_name):
|
||||
def update_cart_address(address_type, address_name):
|
||||
quotation = _get_cart_quotation()
|
||||
address_display = get_address_display(frappe.get_doc("Address", address_name).as_dict())
|
||||
|
||||
if address_fieldname == "shipping_address_name":
|
||||
quotation.shipping_address_name = address_name
|
||||
quotation.shipping_address = address_display
|
||||
|
||||
if not quotation.customer_address:
|
||||
address_fieldname == "customer_address"
|
||||
|
||||
if address_fieldname == "customer_address":
|
||||
if address_type.lower() == "billing":
|
||||
quotation.customer_address = address_name
|
||||
quotation.address_display = address_display
|
||||
|
||||
quotation.shipping_address_name == quotation.shipping_address_name or address_name
|
||||
elif address_type.lower() == "shipping":
|
||||
quotation.shipping_address_name = address_name
|
||||
quotation.shipping_address = address_display
|
||||
quotation.customer_address == quotation.customer_address or address_name
|
||||
|
||||
apply_cart_settings(quotation=quotation)
|
||||
|
||||
|
@ -101,6 +101,7 @@ class Item(WebsiteGenerator):
|
||||
self.add_default_uom_in_conversion_factor_table()
|
||||
self.validate_conversion_factor()
|
||||
self.validate_item_type()
|
||||
self.validate_naming_series()
|
||||
self.check_for_active_boms()
|
||||
self.fill_customer_code()
|
||||
self.check_item_tax()
|
||||
@ -522,6 +523,13 @@ class Item(WebsiteGenerator):
|
||||
if self.has_serial_no == 0 and self.serial_no_series:
|
||||
self.serial_no_series = None
|
||||
|
||||
def validate_naming_series(self):
|
||||
for field in ["serial_no_series", "batch_number_series"]:
|
||||
series = self.get(field)
|
||||
if series and "#" in series and "." not in series:
|
||||
frappe.throw(_("Invalid naming series (. missing) for {0}")
|
||||
.format(frappe.bold(self.meta.get_field(field).label)))
|
||||
|
||||
def check_for_active_boms(self):
|
||||
if self.default_bom:
|
||||
bom_item = frappe.db.get_value("BOM", self.default_bom, "item")
|
||||
@ -1007,8 +1015,6 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
|
||||
order by pr.posting_date desc, pr.posting_time desc, pr.name desc
|
||||
limit 1""", (item_code, cstr(doc_name)), as_dict=1)
|
||||
|
||||
|
||||
|
||||
purchase_order_date = getdate(last_purchase_order and last_purchase_order[0].transaction_date
|
||||
or "1900-01-01")
|
||||
purchase_receipt_date = getdate(last_purchase_receipt and
|
||||
|
@ -19,11 +19,6 @@ frappe.ui.form.on('Material Request', {
|
||||
frm.set_indicator_formatter('item_code',
|
||||
function(doc) { return (doc.qty<=doc.ordered_qty) ? "green" : "orange"; });
|
||||
|
||||
frm.set_query("item_code", "items", function() {
|
||||
return {
|
||||
query: "erpnext.controllers.queries.item_query"
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
onload: function(frm) {
|
||||
@ -145,7 +140,8 @@ frappe.ui.form.on('Material Request', {
|
||||
},
|
||||
|
||||
get_item_data: function(frm, item) {
|
||||
if (!item.item_code) return;
|
||||
if (item && !item.item_code) { return; }
|
||||
|
||||
frm.call({
|
||||
method: "erpnext.stock.get_item_details.get_item_details",
|
||||
child: item,
|
||||
@ -360,6 +356,22 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten
|
||||
set_schedule_date(this.frm);
|
||||
},
|
||||
|
||||
onload: function(doc, cdt, cdn) {
|
||||
this.frm.set_query("item_code", "items", function() {
|
||||
if (doc.material_request_type == "Customer Provided") {
|
||||
return{
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
filters:{ 'customer': me.frm.doc.customer }
|
||||
}
|
||||
} else if (doc.material_request_type != "Manufacture") {
|
||||
return{
|
||||
query: "erpnext.controllers.queries.item_query",
|
||||
filters: {'is_purchase_item': 1}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
items_add: function(doc, cdt, cdn) {
|
||||
var row = frappe.get_doc(cdt, cdn);
|
||||
if(doc.schedule_date) {
|
||||
|
@ -276,8 +276,8 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
current_requested_qty_item1 = self._get_requested_qty("_Test Item Home Desktop 100", "_Test Warehouse - _TC")
|
||||
current_requested_qty_item2 = self._get_requested_qty("_Test Item Home Desktop 200", "_Test Warehouse - _TC")
|
||||
|
||||
self.assertEqual(current_requested_qty_item1, existing_requested_qty_item1 + 54.0)
|
||||
self.assertEqual(current_requested_qty_item2, existing_requested_qty_item2 + 3.0)
|
||||
self.assertEqual(current_requested_qty_item1, existing_requested_qty_item1 - 54.0)
|
||||
self.assertEqual(current_requested_qty_item2, existing_requested_qty_item2 - 3.0)
|
||||
|
||||
from erpnext.stock.doctype.material_request.material_request import make_stock_entry
|
||||
|
||||
@ -331,8 +331,8 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
current_requested_qty_item1 = self._get_requested_qty("_Test Item Home Desktop 100", "_Test Warehouse - _TC")
|
||||
current_requested_qty_item2 = self._get_requested_qty("_Test Item Home Desktop 200", "_Test Warehouse - _TC")
|
||||
|
||||
self.assertEqual(current_requested_qty_item1, existing_requested_qty_item1 + 27.0)
|
||||
self.assertEqual(current_requested_qty_item2, existing_requested_qty_item2 + 1.5)
|
||||
self.assertEqual(current_requested_qty_item1, existing_requested_qty_item1 - 27.0)
|
||||
self.assertEqual(current_requested_qty_item2, existing_requested_qty_item2 - 1.5)
|
||||
|
||||
# check if per complete is as expected for Stock Entry cancelled
|
||||
se.cancel()
|
||||
@ -344,8 +344,8 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
current_requested_qty_item1 = self._get_requested_qty("_Test Item Home Desktop 100", "_Test Warehouse - _TC")
|
||||
current_requested_qty_item2 = self._get_requested_qty("_Test Item Home Desktop 200", "_Test Warehouse - _TC")
|
||||
|
||||
self.assertEqual(current_requested_qty_item1, existing_requested_qty_item1 + 54.0)
|
||||
self.assertEqual(current_requested_qty_item2, existing_requested_qty_item2 + 3.0)
|
||||
self.assertEqual(current_requested_qty_item1, existing_requested_qty_item1 - 54.0)
|
||||
self.assertEqual(current_requested_qty_item2, existing_requested_qty_item2 - 3.0)
|
||||
|
||||
def test_completed_qty_for_over_transfer(self):
|
||||
existing_requested_qty_item1 = self._get_requested_qty("_Test Item Home Desktop 100", "_Test Warehouse - _TC")
|
||||
@ -425,8 +425,8 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
current_requested_qty_item1 = self._get_requested_qty("_Test Item Home Desktop 100", "_Test Warehouse - _TC")
|
||||
current_requested_qty_item2 = self._get_requested_qty("_Test Item Home Desktop 200", "_Test Warehouse - _TC")
|
||||
|
||||
self.assertEqual(current_requested_qty_item1, existing_requested_qty_item1 + 54.0)
|
||||
self.assertEqual(current_requested_qty_item2, existing_requested_qty_item2 + 3.0)
|
||||
self.assertEqual(current_requested_qty_item1, existing_requested_qty_item1 - 54.0)
|
||||
self.assertEqual(current_requested_qty_item2, existing_requested_qty_item2 - 3.0)
|
||||
|
||||
def test_incorrect_mapping_of_stock_entry(self):
|
||||
# submit material request of type Transfer
|
||||
@ -512,7 +512,7 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
mr.submit()
|
||||
|
||||
#testing bin value after material request is submitted
|
||||
self.assertEqual(_get_requested_qty(), existing_requested_qty + 54.0)
|
||||
self.assertEqual(_get_requested_qty(), existing_requested_qty - 54.0)
|
||||
|
||||
# receive items to allow issue
|
||||
self._insert_stock_entry(60, 6, "_Test Warehouse - _TC")
|
||||
@ -609,6 +609,8 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
def test_customer_provided_parts_mr(self):
|
||||
from erpnext.stock.doctype.material_request.material_request import make_stock_entry
|
||||
create_item('CUST-0987', is_customer_provided_item = 1, customer = '_Test Customer', is_purchase_item = 0)
|
||||
existing_requested_qty = self._get_requested_qty("_Test Customer", "_Test Warehouse - _TC")
|
||||
|
||||
mr = make_material_request(item_code='CUST-0987', material_request_type='Customer Provided')
|
||||
se = make_stock_entry(mr.name)
|
||||
se.insert()
|
||||
@ -617,7 +619,10 @@ class TestMaterialRequest(unittest.TestCase):
|
||||
self.assertEqual(se.get("items")[0].material_request, mr.name)
|
||||
mr = frappe.get_doc("Material Request", mr.name)
|
||||
mr.submit()
|
||||
current_requested_qty = self._get_requested_qty("_Test Customer", "_Test Warehouse - _TC")
|
||||
|
||||
self.assertEqual(mr.per_ordered, 100)
|
||||
self.assertEqual(existing_requested_qty, current_requested_qty)
|
||||
|
||||
def make_material_request(**args):
|
||||
args = frappe._dict(args)
|
||||
|
@ -47,6 +47,7 @@
|
||||
"is_subcontracted",
|
||||
"supplier_warehouse",
|
||||
"items_section",
|
||||
"scan_barcode",
|
||||
"items",
|
||||
"pricing_rule_details",
|
||||
"pricing_rules",
|
||||
@ -1070,13 +1071,18 @@
|
||||
"label": "Inter Company Reference",
|
||||
"options": "Delivery Note",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "scan_barcode",
|
||||
"fieldtype": "Data",
|
||||
"label": "Scan Barcode"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-truck",
|
||||
"idx": 261,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2019-12-30 19:12:49.709711",
|
||||
"modified": "2020-04-06 16:31:37.444891",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Purchase Receipt",
|
||||
|
@ -50,8 +50,8 @@ class PurchaseReceipt(BuyingController):
|
||||
'target_field': 'received_qty',
|
||||
'target_parent_dt': 'Material Request',
|
||||
'target_parent_field': 'per_received',
|
||||
'target_ref_field': 'qty',
|
||||
'source_field': 'qty',
|
||||
'target_ref_field': 'stock_qty',
|
||||
'source_field': 'stock_qty',
|
||||
'percent_join_field': 'material_request'
|
||||
}]
|
||||
if cint(self.is_return):
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,8 @@ import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils.html_utils import clean_html
|
||||
from frappe.utils import cint
|
||||
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
|
||||
|
||||
class StockSettings(Document):
|
||||
def validate(self):
|
||||
@ -61,6 +63,15 @@ class StockSettings(Document):
|
||||
# changed to text
|
||||
frappe.enqueue('erpnext.stock.doctype.stock_settings.stock_settings.clean_all_descriptions', now=frappe.flags.in_test)
|
||||
|
||||
def on_update(self):
|
||||
self.toggle_warehouse_field_for_inter_warehouse_transfer()
|
||||
|
||||
def toggle_warehouse_field_for_inter_warehouse_transfer(self):
|
||||
make_property_setter("Sales Invoice Item", "target_warehouse", "hidden", 1 - cint(self.allow_from_dn), "Check")
|
||||
make_property_setter("Delivery Note Item", "target_warehouse", "hidden", 1 - cint(self.allow_from_dn), "Check")
|
||||
make_property_setter("Purchase Invoice Item", "from_warehouse", "hidden", 1 - cint(self.allow_from_pr), "Check")
|
||||
make_property_setter("Purchase Receipt Item", "from_warehouse", "hidden", 1 - cint(self.allow_from_pr), "Check")
|
||||
|
||||
|
||||
def clean_all_descriptions():
|
||||
for item in frappe.get_all('Item', ['name', 'description']):
|
||||
|
@ -240,26 +240,13 @@ def get_basic_details(args, item, overwrite_warehouse=True):
|
||||
item_group_defaults = get_item_group_defaults(item.name, args.company)
|
||||
brand_defaults = get_brand_defaults(item.name, args.company)
|
||||
|
||||
if overwrite_warehouse or not args.warehouse:
|
||||
warehouse = (
|
||||
args.get("set_warehouse") or
|
||||
item_defaults.get("default_warehouse") or
|
||||
item_group_defaults.get("default_warehouse") or
|
||||
brand_defaults.get("default_warehouse") or
|
||||
args.warehouse
|
||||
)
|
||||
|
||||
if not warehouse:
|
||||
defaults = frappe.defaults.get_defaults() or {}
|
||||
warehouse_exists = frappe.db.exists("Warehouse", {
|
||||
'name': defaults.default_warehouse,
|
||||
'company': args.company
|
||||
defaults = frappe._dict({
|
||||
'item_defaults': item_defaults,
|
||||
'item_group_defaults': item_group_defaults,
|
||||
'brand_defaults': brand_defaults
|
||||
})
|
||||
if defaults.get("default_warehouse") and warehouse_exists:
|
||||
warehouse = defaults.default_warehouse
|
||||
|
||||
else:
|
||||
warehouse = args.warehouse
|
||||
warehouse = get_item_warehouse(item, args, overwrite_warehouse, defaults)
|
||||
|
||||
if args.get('doctype') == "Material Request" and not args.get('material_request_type'):
|
||||
args['material_request_type'] = frappe.db.get_value('Material Request',
|
||||
@ -272,7 +259,7 @@ def get_basic_details(args, item, overwrite_warehouse=True):
|
||||
expense_account = get_asset_category_account(fieldname = "fixed_asset_account", item = args.item_code, company= args.company)
|
||||
|
||||
#Set the UOM to the Default Sales UOM or Default Purchase UOM if configured in the Item Master
|
||||
if not args.uom:
|
||||
if not args.get('uom'):
|
||||
if args.get('doctype') in sales_doctypes:
|
||||
args.uom = item.sales_uom if item.sales_uom else item.stock_uom
|
||||
elif (args.get('doctype') in ['Purchase Order', 'Purchase Receipt', 'Purchase Invoice']) or \
|
||||
@ -292,7 +279,7 @@ def get_basic_details(args, item, overwrite_warehouse=True):
|
||||
"cost_center": get_default_cost_center(args, item_defaults, item_group_defaults, brand_defaults),
|
||||
'has_serial_no': item.has_serial_no,
|
||||
'has_batch_no': item.has_batch_no,
|
||||
"batch_no": None,
|
||||
"batch_no": args.get("batch_no"),
|
||||
"uom": args.uom,
|
||||
"min_order_qty": flt(item.min_order_qty) if args.doctype == "Material Request" else "",
|
||||
"qty": flt(args.qty) or 1.0,
|
||||
@ -362,6 +349,37 @@ def get_basic_details(args, item, overwrite_warehouse=True):
|
||||
|
||||
return out
|
||||
|
||||
def get_item_warehouse(item, args, overwrite_warehouse, defaults={}):
|
||||
if not defaults:
|
||||
defaults = frappe._dict({
|
||||
'item_defaults' : get_item_defaults(item.name, args.company),
|
||||
'item_group_defaults' : get_item_group_defaults(item.name, args.company),
|
||||
'brand_defaults' : get_brand_defaults(item.name, args.company)
|
||||
})
|
||||
|
||||
if overwrite_warehouse or not args.warehouse:
|
||||
warehouse = (
|
||||
args.get("set_warehouse") or
|
||||
defaults.item_defaults.get("default_warehouse") or
|
||||
defaults.item_group_defaults.get("default_warehouse") or
|
||||
defaults.brand_defaults.get("default_warehouse") or
|
||||
args.get('warehouse')
|
||||
)
|
||||
|
||||
if not warehouse:
|
||||
defaults = frappe.defaults.get_defaults() or {}
|
||||
warehouse_exists = frappe.db.exists("Warehouse", {
|
||||
'name': defaults.default_warehouse,
|
||||
'company': args.company
|
||||
})
|
||||
if defaults.get("default_warehouse") and warehouse_exists:
|
||||
warehouse = defaults.default_warehouse
|
||||
|
||||
else:
|
||||
warehouse = args.get('warehouse')
|
||||
|
||||
return warehouse
|
||||
|
||||
def update_barcode_value(out):
|
||||
from erpnext.accounts.doctype.sales_invoice.pos import get_barcode_data
|
||||
barcode_data = get_barcode_data([out])
|
||||
|
@ -113,13 +113,24 @@ def get_reserved_qty(item_code, warehouse):
|
||||
return flt(reserved_qty[0][0]) if reserved_qty else 0
|
||||
|
||||
def get_indented_qty(item_code, warehouse):
|
||||
indented_qty = frappe.db.sql("""select sum((mr_item.qty - mr_item.ordered_qty) * mr_item.conversion_factor)
|
||||
inward_qty = frappe.db.sql("""select sum((mr_item.qty - mr_item.ordered_qty) * mr_item.conversion_factor)
|
||||
from `tabMaterial Request Item` mr_item, `tabMaterial Request` mr
|
||||
where mr_item.item_code=%s and mr_item.warehouse=%s
|
||||
and mr.material_request_type in ('Purchase', 'Manufacture')
|
||||
and mr_item.qty > mr_item.ordered_qty and mr_item.parent=mr.name
|
||||
and mr.status!='Stopped' and mr.docstatus=1""", (item_code, warehouse))
|
||||
|
||||
return flt(indented_qty[0][0]) if indented_qty else 0
|
||||
outward_qty = frappe.db.sql("""select sum((mr_item.qty - mr_item.ordered_qty) * mr_item.conversion_factor)
|
||||
from `tabMaterial Request Item` mr_item, `tabMaterial Request` mr
|
||||
where mr_item.item_code=%s and mr_item.warehouse=%s
|
||||
and mr.material_request_type in ('Material Issue', 'Material Transfer')
|
||||
and mr_item.qty > mr_item.ordered_qty and mr_item.parent=mr.name
|
||||
and mr.status!='Stopped' and mr.docstatus=1""", (item_code, warehouse))
|
||||
|
||||
inward_qty, outward_qty = flt(inward_qty[0][0]) if inward_qty else 0, flt(outward_qty[0][0]) if outward_qty else 0
|
||||
indented_qty = inward_qty - outward_qty
|
||||
|
||||
return indented_qty
|
||||
|
||||
def get_ordered_qty(item_code, warehouse):
|
||||
ordered_qty = frappe.db.sql("""
|
||||
@ -145,9 +156,9 @@ def update_bin_qty(item_code, warehouse, qty_dict=None):
|
||||
from erpnext.stock.utils import get_bin
|
||||
bin = get_bin(item_code, warehouse)
|
||||
mismatch = False
|
||||
for fld, val in qty_dict.items():
|
||||
if flt(bin.get(fld)) != flt(val):
|
||||
bin.set(fld, flt(val))
|
||||
for field, value in qty_dict.items():
|
||||
if flt(bin.get(field)) != flt(value):
|
||||
bin.set(field, flt(value))
|
||||
mismatch = True
|
||||
|
||||
if mismatch:
|
||||
|
@ -428,7 +428,7 @@ class update_entries_after(object):
|
||||
frappe.get_desk_link(self.exceptions[0]["voucher_type"], self.exceptions[0]["voucher_no"]))
|
||||
|
||||
if self.verbose:
|
||||
frappe.throw(msg, NegativeStockError, title='Insufficent Stock')
|
||||
frappe.throw(msg, NegativeStockError, title='Insufficient Stock')
|
||||
else:
|
||||
raise NegativeStockError(msg)
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
"creation": "2013-02-01 10:36:25",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Setup",
|
||||
"email_append_to": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"subject_section",
|
||||
@ -366,7 +367,7 @@
|
||||
"icon": "fa fa-ticket",
|
||||
"idx": 7,
|
||||
"links": [],
|
||||
"modified": "2020-02-26 02:19:49.477928",
|
||||
"modified": "2020-03-13 02:19:49.477928",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Support",
|
||||
"name": "Issue",
|
||||
@ -386,8 +387,10 @@
|
||||
],
|
||||
"quick_entry": 1,
|
||||
"search_fields": "status,customer,subject,raised_by",
|
||||
"sender_field": "raised_by",
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"subject_field": "subject",
|
||||
"timeline_field": "customer",
|
||||
"title_field": "subject",
|
||||
"track_changes": 1,
|
||||
|
@ -14,9 +14,6 @@ from frappe.utils.user import is_website_user
|
||||
from erpnext.support.doctype.service_level_agreement.service_level_agreement import get_active_service_level_agreement_for
|
||||
from frappe.email.inbox import link_communication_to_document
|
||||
|
||||
sender_field = "raised_by"
|
||||
|
||||
|
||||
class Issue(Document):
|
||||
def get_feed(self):
|
||||
return "{0}: {1}".format(_(self.status), self.subject)
|
||||
|
@ -26,15 +26,14 @@ $.extend(shopping_cart, {
|
||||
bind_address_select: function() {
|
||||
$(".cart-addresses").on('click', '.address-card', function(e) {
|
||||
const $card = $(e.currentTarget);
|
||||
const address_fieldname = $card.closest('[data-fieldname]').attr('data-fieldname');
|
||||
const address_type = $card.closest('[data-address-type]').attr('data-address-type');
|
||||
const address_name = $card.closest('[data-address-name]').attr('data-address-name');
|
||||
|
||||
return frappe.call({
|
||||
type: "POST",
|
||||
method: "erpnext.shopping_cart.cart.update_cart_address",
|
||||
freeze: true,
|
||||
args: {
|
||||
address_fieldname,
|
||||
address_type,
|
||||
address_name
|
||||
},
|
||||
callback: function(r) {
|
||||
|
@ -18,7 +18,7 @@
|
||||
<h6 class="text-uppercase">{{ _("Shipping Address") }}</h6>
|
||||
<div class="row no-gutters" data-fieldname="shipping_address_name">
|
||||
{% for address in shipping_addresses %}
|
||||
<div class="mr-3 mb-3 w-25" data-address-name="{{address.name}}" {% if doc.shipping_address_name == address.name %} data-active {% endif %}>
|
||||
<div class="mr-3 mb-3 w-25" data-address-name="{{address.name}}" data-address-type="shipping" {% if doc.shipping_address_name == address.name %} data-active {% endif %}>
|
||||
{% include "templates/includes/cart/address_card.html" %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
@ -28,7 +28,7 @@
|
||||
<h6 class="text-uppercase">{{ _("Billing Address") }}</h6>
|
||||
<div class="row no-gutters" data-fieldname="customer_address">
|
||||
{% for address in billing_addresses %}
|
||||
<div class="mr-3 mb-3 w-25" data-address-name="{{address.name}}" {% if doc.customer_address == address.name %} data-active {% endif %}>
|
||||
<div class="mr-3 mb-3 w-25" data-address-name="{{address.name}}" data-address-type="billing" {% if doc.customer_address == address.name %} data-active {% endif %}>
|
||||
{% include "templates/includes/cart/address_card.html" %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
@ -123,9 +123,19 @@ frappe.ready(() => {
|
||||
primary_action: (values) => {
|
||||
frappe.call('erpnext.shopping_cart.cart.add_new_address', { doc: values })
|
||||
.then(r => {
|
||||
frappe.call({
|
||||
method: "erpnext.shopping_cart.cart.update_cart_address",
|
||||
args: {
|
||||
address_type: r.message.address_type,
|
||||
address_name: r.message.name
|
||||
},
|
||||
callback: function (r) {
|
||||
d.hide();
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -10,16 +10,16 @@
|
||||
{% endif %}
|
||||
|
||||
{% for d in doc.taxes %}
|
||||
{% if d.base_tax_amount > 0 %}
|
||||
<tr>
|
||||
{% if d.base_tax_amount %}
|
||||
<tr>
|
||||
<td class="text-right" colspan="2">
|
||||
{{ d.description }}
|
||||
</td>
|
||||
<td class="text-right">
|
||||
{{ d.get_formatted("base_tax_amount") }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if doc.doctype == 'Quotation' %}
|
||||
|
@ -12,16 +12,6 @@
|
||||
|
||||
|
||||
{% block header_actions %}
|
||||
{% if doc.items and cart_settings.enable_checkout %}
|
||||
<button class="btn btn-primary btn-place-order" type="button">
|
||||
{{ _("Place Order") }}
|
||||
</button>
|
||||
{% endif %}
|
||||
{% if doc.items and not cart_settings.enable_checkout %}
|
||||
<button class="btn btn-primary btn-request-for-quotation" type="button">
|
||||
{{ _("Request for Quotation") }}
|
||||
</button>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block page_content %}
|
||||
@ -55,6 +45,20 @@
|
||||
<p class="text-muted">{{ _('Your cart is Empty') }}</p>
|
||||
{% endif %}
|
||||
|
||||
{% if doc.items %}
|
||||
<div class="place-order-container">
|
||||
{% if cart_settings.enable_checkout %}
|
||||
<button class="btn btn-primary btn-place-order" type="button">
|
||||
{{ _("Place Order") }}
|
||||
</button>
|
||||
{% else %}
|
||||
<button class="btn btn-primary btn-request-for-quotation" type="button">
|
||||
{{ _("Request for Quotation") }}
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if doc.items %}
|
||||
{% if doc.tc_name %}
|
||||
<div class="terms-and-conditions-link">
|
||||
|
@ -63,7 +63,7 @@
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
<h1>{{ content.name }} <span class="small text-muted">({{ position + 1 }}/{{length}})</span></h1>
|
||||
<h2>{{ content.name }} <span class="small text-muted">({{ position + 1 }}/{{length}})</span></h2>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
|
@ -1133,9 +1133,9 @@ minimatch@^3.0.4:
|
||||
brace-expansion "^1.1.7"
|
||||
|
||||
minimist@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
|
||||
integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=
|
||||
version "1.2.5"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
|
||||
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
|
||||
|
||||
ms@2.0.0:
|
||||
version "2.0.0"
|
||||
|
Loading…
x
Reference in New Issue
Block a user