Merge branch 'develop' into pay-entry-ux-fix

This commit is contained in:
Deepesh Garg 2020-04-09 12:54:33 +05:30 committed by GitHub
commit ef220c1989
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
90 changed files with 1451 additions and 3213 deletions

19
CODEOWNERS Normal file
View File

@ -0,0 +1,19 @@
# Each line is a file pattern followed by one or more owners.
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
* @nabinhait
manufacturing/ @rohitwaghchaure
accounts/ @deepeshgarg007 @nextchamp-saqib
loan_management/ @deepeshgarg007
pos* @nextchamp-saqib
assets/ @nextchamp-saqib
stock/ @marination @rohitwaghchaure
buying/ @marination @rohitwaghchaure
hr/ @Anurag810
projects/ @hrwX
support/ @hrwX
healthcare/ @ruchamahabal
erpnext_integrations/ @Mangesh-Khairnar
requirements.txt @gavindsouza

View File

@ -1,7 +1,7 @@
frappe.provide("frappe.treeview_settings")
frappe.treeview_settings["Account"] = {
breadcrumbs: "Accounts",
breadcrumb: "Accounts",
title: __("Chart Of Accounts"),
get_tree_root: false,
filters: [

View File

@ -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

View File

@ -1,5 +1,5 @@
frappe.treeview_settings["Cost Center"] = {
breadcrumbs: "Accounts",
breadcrumb: "Accounts",
get_tree_root: false,
filters: [{
fieldname: "company",

View File

@ -81,7 +81,12 @@ 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)

View File

@ -15,11 +15,11 @@ frappe.ui.form.on('Payment Order', {
if (frm.doc.docstatus == 0) {
frm.add_custom_button(__('Payment Request'), function() {
frm.trigger("get_from_payment_request");
}, __("Get from"));
}, __("Get Payments from"));
frm.add_custom_button(__('Payment Entry'), function() {
frm.trigger("get_from_payment_entry");
}, __("Get from"));
}, __("Get Payments from"));
frm.trigger('remove_button');
}

View File

@ -59,7 +59,6 @@
"fieldtype": "Section Break"
},
{
"allow_bulk_edit": 1,
"fieldname": "references",
"fieldtype": "Table",
"label": "Payment Order Reference",
@ -108,7 +107,7 @@
}
],
"is_submittable": 1,
"modified": "2019-05-14 17:12:24.912666",
"modified": "2020-04-06 18:00:56.022642",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Order",

File diff suppressed because it is too large Load Diff

View File

@ -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,17 +418,31 @@ 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')
frappe.db.commit()
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):
return frappe.render_template("""{% if doc.contact_person -%}

View File

@ -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"];
}
}
}

View File

@ -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()

View File

@ -82,7 +82,7 @@ class ShippingRule(Document):
if not shipping_country:
frappe.throw(_('Shipping Address does not have country, which is required for this Shipping Rule'))
if shipping_country not in [d.country for d in self.countries]:
frappe.throw(_('Shipping rule not applicable for country {0}').format(shipping_country))
frappe.throw(_('Shipping rule not applicable for country {0} in Shipping Address').format(shipping_country))
def add_shipping_rule_to_tax_table(self, doc, shipping_amount):
shipping_charge = {

View File

@ -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")

View File

@ -9,7 +9,7 @@ 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(
{

View File

@ -17,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()

View File

@ -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"),

View File

@ -4,7 +4,7 @@
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,
@ -208,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)
@ -229,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
@ -241,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):
@ -295,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
@ -309,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)
})

View File

@ -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)"""
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)
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)
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)
@ -419,7 +434,9 @@ def get_additional_conditions(from_date, ignore_closing_entries, filters):
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))
additional_conditions.append("{0} in %({0})s".format(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 ""

View File

@ -202,7 +202,9 @@ def get_conditions(filters):
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.append("{0} in %({0})s".format(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 ""

View File

@ -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,

View File

@ -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

View File

@ -126,7 +126,9 @@ def get_rootwise_opening_balances(filters, report_type):
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))
additional_conditions += "and {0} in %({0})s".format(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)

View File

@ -439,7 +439,7 @@ class AccountsController(TransactionBase):
if account_currency not in valid_currency:
frappe.throw(_("Account {0} is invalid. Account Currency must be {1}")
.format(account, _(" or ").join(valid_currency)))
.format(account, (' ' + _("or") + ' ').join(valid_currency)))
def clear_unallocated_advances(self, childtype, parentfield):
self.set(parentfield, self.get(parentfield, {"allocated_amount": ["not in", [0, None, ""]]}))

View File

@ -45,6 +45,7 @@ class BuyingController(StockController):
self.validate_warehouse()
self.validate_from_warehouse()
self.set_supplier_address()
self.validate_asset_return()
if self.doctype=="Purchase Invoice":
self.validate_purchase_receipt_if_update_stock()
@ -100,6 +101,19 @@ class BuyingController(StockController):
for d in tax_for_valuation:
d.category = 'Total'
msgprint(_('Tax Category has been changed to "Total" because all the Items are non-stock items'))
def validate_asset_return(self):
if self.doctype not in ['Purchase Receipt', 'Purchase Invoice'] or not self.is_return:
return
purchase_doc_field = 'purchase_receipt' if self.doctype == 'Purchase Receipt' else 'purchase_invoice'
not_cancelled_asset = [d.name for d in frappe.db.get_all("Asset", {
purchase_doc_field: self.return_against,
"docstatus": 1
})]
if self.is_return and len(not_cancelled_asset):
frappe.throw(_("{} has submitted assets linked to it. You need to cancel the assets to create purchase return.".format(self.return_against)),
title=_("Not Allowed"))
def get_asset_items(self):
if self.doctype not in ['Purchase Order', 'Purchase Invoice', 'Purchase Receipt']:

View File

@ -1,12 +1,10 @@
{
"actions": [],
"allow_events_in_timeline": 1,
"allow_import": 1,
"autoname": "naming_series:",
"creation": "2013-04-10 11:45:37",
"doctype": "DocType",
"document_type": "Document",
"email_append_to": 1,
"engine": "InnoDB",
"field_order": [
"organization_lead",
@ -34,6 +32,7 @@
"notes",
"address_info",
"address_html",
"address_type",
"address_title",
"address_line1",
"address_line2",
@ -285,8 +284,7 @@
"depends_on": "eval: doc.__islocal",
"fieldname": "pincode",
"fieldtype": "Data",
"label": "Postal Code",
"options": "Country"
"label": "Postal Code"
},
{
"fieldname": "column_break2",
@ -304,7 +302,8 @@
"fieldtype": "Data",
"label": "Phone",
"oldfieldname": "contact_no",
"oldfieldtype": "Data"
"oldfieldtype": "Data",
"options": "Phone"
},
{
"depends_on": "eval: doc.__islocal",
@ -312,7 +311,8 @@
"fieldtype": "Data",
"label": "Mobile No.",
"oldfieldname": "mobile_no",
"oldfieldtype": "Data"
"oldfieldtype": "Data",
"options": "Phone"
},
{
"depends_on": "eval: doc.__islocal",
@ -433,13 +433,21 @@
"fieldname": "contact_section",
"fieldtype": "Section Break",
"label": "Contact"
},
{
"default": "Billing",
"depends_on": "eval: doc.__islocal",
"fieldname": "address_type",
"fieldtype": "Select",
"label": "Address Type",
"options": "Billing\nShipping\nOffice\nPersonal\nPlant\nPostal\nShop\nSubsidiary\nWarehouse\nCurrent\nPermanent\nOther"
}
],
"icon": "fa fa-user",
"idx": 5,
"image_field": "image",
"links": [],
"modified": "2020-01-13 16:16:48.885228",
"modified": "2020-04-08 22:26:11.687110",
"modified_by": "Administrator",
"module": "CRM",
"name": "Lead",
@ -508,9 +516,8 @@
}
],
"search_fields": "lead_name,lead_owner,status",
"sender_field": "email_id",
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "title"
}
}

View File

@ -126,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"]
@ -209,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:

View File

@ -423,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",

View File

@ -14,7 +14,7 @@ def execute(filters=None):
student_batch_name = filters.get("student_batch_name")
columns = get_columns()
program_enrollments = frappe.get_list("Program Enrollment", fields=["student", "student_name"],
filters={"academic_year": academic_year, "program": program, "student_batch_name": student_batch_name})
@ -46,9 +46,9 @@ def execute(filters=None):
def get_columns():
columns = [
_(" Group Roll No") + "::60",
_("Student ID") + ":Link/Student:90",
_("Student Name") + "::150",
_("Group Roll No") + "::60",
_("Student ID") + ":Link/Student:90",
_("Student Name") + "::150",
_("Student Mobile No.") + "::110",
_("Student Email ID") + "::125",
_("Student Address") + "::175",
@ -84,10 +84,10 @@ def get_guardian_map(student_list):
guardian_list = list(set([g.guardian for g in guardian_details])) or ['']
guardian_mobile_no = dict(frappe.db.sql("""select name, mobile_number from `tabGuardian`
guardian_mobile_no = dict(frappe.db.sql("""select name, mobile_number from `tabGuardian`
where name in (%s)""" % ", ".join(['%s']*len(guardian_list)), tuple(guardian_list)))
guardian_email_id = dict(frappe.db.sql("""select name, email_address from `tabGuardian`
guardian_email_id = dict(frappe.db.sql("""select name, email_address from `tabGuardian`
where name in (%s)""" % ", ".join(['%s']*len(guardian_list)), tuple(guardian_list)))
for guardian in guardian_details:

View File

@ -121,7 +121,7 @@ def call_mws_method(mws_method, *args, **kwargs):
time.sleep(delay)
continue
mws_settings.enable_synch = 0
mws_settings.enable_sync = 0
mws_settings.save()
frappe.throw(_("Sync has been temporarily disabled because maximum retries have been exceeded"))

View File

@ -39,16 +39,19 @@ __all__ = [
# for a list of the end points and marketplace IDs
MARKETPLACES = {
"CA" : "https://mws.amazonservices.ca", #A2EUQ1WTGCTBG2
"US" : "https://mws.amazonservices.com", #ATVPDKIKX0DER",
"DE" : "https://mws-eu.amazonservices.com", #A1PA6795UKMFR9
"ES" : "https://mws-eu.amazonservices.com", #A1RKKUPIHCS9HS
"FR" : "https://mws-eu.amazonservices.com", #A13V1IB3VIYZZH
"IN" : "https://mws.amazonservices.in", #A21TJRUUN4KGV
"IT" : "https://mws-eu.amazonservices.com", #APJ6JRA9NG5V4
"UK" : "https://mws-eu.amazonservices.com", #A1F83G8C2ARO7P
"JP" : "https://mws.amazonservices.jp", #A1VC38T7YXB528
"CN" : "https://mws.amazonservices.com.cn", #AAHKV2X7AFYLW
"CA": "https://mws.amazonservices.ca", #A2EUQ1WTGCTBG2
"US": "https://mws.amazonservices.com", #ATVPDKIKX0DER",
"DE": "https://mws-eu.amazonservices.com", #A1PA6795UKMFR9
"ES": "https://mws-eu.amazonservices.com", #A1RKKUPIHCS9HS
"FR": "https://mws-eu.amazonservices.com", #A13V1IB3VIYZZH
"IN": "https://mws.amazonservices.in", #A21TJRUUN4KGV
"IT": "https://mws-eu.amazonservices.com", #APJ6JRA9NG5V4
"UK": "https://mws-eu.amazonservices.com", #A1F83G8C2ARO7P
"JP": "https://mws.amazonservices.jp", #A1VC38T7YXB528
"CN": "https://mws.amazonservices.com.cn", #AAHKV2X7AFYLW
"AE": " https://mws.amazonservices.ae", #A2VIGQ35RCS4UG
"MX": "https://mws.amazonservices.com.mx", #A1AM78C64UM0Y8
"BR": "https://mws.amazonservices.com", #A2Q3Y263D00KWC
}

View File

@ -7,14 +7,15 @@ import frappe
from frappe.model.document import Document
import dateutil
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
from erpnext.erpnext_integrations.doctype.amazon_mws_settings.amazon_methods import get_orders
class AmazonMWSSettings(Document):
def validate(self):
if self.enable_amazon == 1:
self.enable_synch = 1
self.enable_sync = 1
setup_custom_fields()
else:
self.enable_synch = 0
self.enable_sync = 0
def get_products_details(self):
if self.enable_amazon == 1:
@ -27,7 +28,7 @@ class AmazonMWSSettings(Document):
def schedule_get_order_details():
mws_settings = frappe.get_doc("Amazon MWS Settings")
if mws_settings.enable_synch and mws_settings.enable_amazon:
if mws_settings.enable_sync and mws_settings.enable_amazon:
after_date = dateutil.parser.parse(mws_settings.after_date).strftime("%Y-%m-%d")
get_orders(after_date = after_date)

View File

@ -239,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': {

View File

@ -259,7 +259,8 @@
"bold": 1,
"fieldname": "emergency_phone_number",
"fieldtype": "Data",
"label": "Emergency Phone"
"label": "Emergency Phone",
"options": "Phone"
},
{
"bold": 1,
@ -480,7 +481,8 @@
{
"fieldname": "cell_number",
"fieldtype": "Data",
"label": "Mobile"
"label": "Mobile",
"options": "Phone"
},
{
"fieldname": "prefered_contact_email",
@ -787,7 +789,7 @@
"idx": 24,
"image_field": "image",
"links": [],
"modified": "2020-01-09 04:23:55.611366",
"modified": "2020-04-08 12:25:34.306695",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee",
@ -834,6 +836,5 @@
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "employee_name",
"track_changes": 1
}
"title_field": "employee_name"
}

View File

@ -687,8 +687,7 @@ def add_leaves(events, start, end, filter_conditions=None):
"to_date": d.to_date,
"docstatus": d.docstatus,
"color": d.color,
"title": cstr(d.employee_name) + \
(d.half_day and _(" (Half Day)") or ""),
"title": cstr(d.employee_name) + (' ' + _('(Half Day)') if d.half_day else ''),
}
if e not in events:
events.append(e)

View File

@ -356,13 +356,13 @@ class SalarySlip(TransactionBase):
def eval_condition_and_formula(self, d, data):
try:
condition = d.condition.strip() if d.condition else None
condition = d.condition.strip().replace("\n", " ") if d.condition else None
if condition:
if not frappe.safe_eval(condition, self.whitelisted_globals, data):
return None
amount = d.amount
if d.amount_based_on_formula:
formula = d.formula.strip() if d.formula else None
formula = d.formula.strip().replace("\n", " ") if d.formula else None
if formula:
amount = flt(frappe.safe_eval(formula, self.whitelisted_globals, data), d.precision("amount"))
if amount:

View File

@ -661,4 +661,8 @@ erpnext.patches.v12_0.set_job_offer_applicant_email
erpnext.patches.v12_0.create_irs_1099_field_united_states
erpnext.patches.v12_0.move_bank_account_swift_number_to_bank
erpnext.patches.v12_0.rename_bank_reconciliation_fields # 2020-01-22
erpnext.patches.v12_0.set_received_qty_in_material_request_as_per_stock_uom
erpnext.patches.v12_0.set_received_qty_in_material_request_as_per_stock_uom
erpnext.patches.v12_0.recalculate_requested_qty_in_bin
erpnext.patches.v12_0.set_total_batch_quantity
erpnext.patches.v12_0.rename_mws_settings_fields
erpnext.patches.v12_0.set_updated_purpose_in_pick_list

View File

@ -3,10 +3,10 @@
from __future__ import unicode_literals
import frappe
from erpnext.regional.india.setup import update_address_template
from erpnext.regional.address_template.setup import set_up_address_templates
def execute():
if frappe.db.get_value('Company', {'country': 'India'}, 'name'):
address_template = frappe.db.get_value('Address Template', 'India', 'template')
if not address_template or "gstin" not in address_template:
update_address_template()
set_up_address_templates(default_country='India')

View File

@ -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

View 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"))
})

View File

@ -0,0 +1,11 @@
# Copyright (c) 2020, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
import frappe
def execute():
count = frappe.db.sql("SELECT COUNT(*) FROM `tabSingles` WHERE doctype='Amazon MWS Settings' AND field='enable_sync';")[0][0]
if count == 0:
frappe.db.sql("UPDATE `tabSingles` SET field='enable_sync' WHERE doctype='Amazon MWS Settings' AND field='enable_synch';")
frappe.reload_doc("ERPNext Integrations", "doctype", "Amazon MWS Settings")

View File

@ -1,16 +1,15 @@
import frappe
def execute():
frappe.reload_doctype('Task')
frappe.reload_doctype('Task')
# add "Completed" if customized
for doctype in ('Task'):
property_setter_name = frappe.db.exists('Property Setter', dict(doc_type = doctype, field_name = 'status', property = 'options'))
if property_setter_name:
property_setter = frappe.get_doc('Property Setter', property_setter_name)
if not "Completed" in property_setter.value:
property_setter.value = property_setter.value + '\nCompleted'
property_setter.save()
# add "Completed" if customized
property_setter_name = frappe.db.exists('Property Setter', dict(doc_type='Task', field_name = 'status', property = 'options'))
if property_setter_name:
property_setter = frappe.get_doc('Property Setter', property_setter_name)
if not "Completed" in property_setter.value:
property_setter.value = property_setter.value + '\nCompleted'
property_setter.save()
# renamed default status to Completed as status "Closed" is ambiguous
frappe.db.sql('update tabTask set status = "Completed" where status = "Closed"')
# renamed default status to Completed as status "Closed" is ambiguous
frappe.db.sql('update tabTask set status = "Completed" where status = "Closed"')

View File

@ -0,0 +1,11 @@
import frappe
def execute():
frappe.reload_doc("stock", "doctype", "batch")
for batch in frappe.get_all("Batch", fields=["name", "batch_id"]):
batch_qty = frappe.db.get_value("Stock Ledger Entry",
{"docstatus": 1, "batch_no": batch.batch_id, "is_cancelled": "No"},
"sum(actual_qty)") or 0.0
frappe.db.set_value("Batch", batch.name, "batch_qty", batch_qty, update_modified=False)

View File

@ -0,0 +1,11 @@
# Copyright (c) 2019, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc("stock", "doctype", "pick_list")
frappe.db.sql("""UPDATE `tabPick List` set purpose = 'Delivery'
WHERE docstatus = 1 and purpose = 'Delivery against Sales Order' """)

View File

@ -1,7 +1,8 @@
from __future__ import unicode_literals
import frappe
from frappe.custom.doctype.custom_field.custom_field import create_custom_field
from erpnext.regional.india.setup import update_address_template
from erpnext.regional.address_template.setup import set_up_address_templates
def execute():
company = frappe.get_all('Company', filters = {'country': 'India'})
@ -10,9 +11,10 @@ def execute():
update_existing_custom_fields()
add_custom_fields()
update_address_template()
set_up_address_templates(default_country='India')
frappe.reload_doc("regional", "print_format", "gst_tax_invoice")
def update_existing_custom_fields():
frappe.db.sql("""update `tabCustom Field` set label = 'HSN/SAC'
where fieldname='gst_hsn_code' and label='GST HSN Code'
@ -34,6 +36,7 @@ def update_existing_custom_fields():
where fieldname='gst_hsn_code' and dt in ('Sales Invoice Item', 'Purchase Invoice Item')
""")
def add_custom_fields():
hsn_sac_field = dict(fieldname='gst_hsn_code', label='HSN/SAC',
fieldtype='Data', options='item_code.gst_hsn_code', insert_after='description')

View File

@ -53,7 +53,7 @@ def get_columns():
def get_data(filters):
data = []
if(filters.from_date > filters.to_date):
frappe.msgprint(_(" From Date can not be greater than To Date"))
frappe.msgprint(_("From Date can not be greater than To Date"))
return data
timesheets = get_timesheets(filters)

View File

@ -43,7 +43,6 @@ $.extend(frappe.breadcrumbs.preferred, {
$.extend(frappe.breadcrumbs.module_map, {
'ERPNext Integrations': 'Integrations',
'Geo': 'Settings',
'Accounts': 'Accounting',
'Portal': 'Website',
'Utilities': 'Settings',
'Shopping Cart': 'Website',

View File

@ -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",

View File

@ -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)) {
@ -892,7 +894,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
shipping_rule: function() {
var me = this;
if(this.frm.doc.shipping_rule) {
if(this.frm.doc.shipping_rule && this.frm.doc.shipping_address) {
return this.frm.call({
doc: this.frm.doc,
method: "apply_shipping_rule",

View File

@ -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"),

View File

@ -78,3 +78,7 @@
z-index: 0;
}
}
.place-order-container {
text-align: right;
}

View File

@ -0,0 +1,18 @@
To add an **Address Template** for your country, place a new file in this directory:
* File name: `your_country.html` (lower case with underscores)
* File content: a [Jinja Template](http://jinja.pocoo.org/docs/templates/).
All the fields of **Address** (including Custom Fields, if any) will be available to the template. Example:
```jinja
{{ address_line1 }}<br>
{% if address_line2 %}{{ address_line2 }}<br>{% endif -%}
{{ city }}<br>
{% if state %}{{ state }}<br>{% endif -%}
{% if pincode %} PIN: {{ pincode }}<br>{% endif -%}
{{ country }}<br>
{% if phone %}Phone: {{ phone }}<br>{% endif -%}
{% if fax %}Fax: {{ fax }}<br>{% endif -%}
{% if email_id %}Email: {{ email_id }}<br>{% endif -%}
```

View File

@ -0,0 +1,53 @@
"""Import Address Templates from ./templates directory."""
import os
import frappe
def set_up_address_templates(default_country=None):
for country, html in get_address_templates():
is_default = 1 if country == default_country else 0
update_address_template(country, html, is_default)
def get_address_templates():
"""
Return country and path for all HTML files in this directory.
Returns a list of dicts.
"""
def country(file_name):
"""Convert 'united_states.html' to 'United States'."""
suffix_pos = file_name.find(".html")
country_snake_case = file_name[:suffix_pos]
country_title_case = " ".join(country_snake_case.split("_")).title()
return country_title_case
def get_file_content(file_name):
"""Convert 'united_states.html' to '/path/to/united_states.html'."""
full_path = os.path.join(template_dir, file_name)
with open(full_path, "r") as f:
content = f.read()
return content
dir_name = os.path.dirname(__file__)
template_dir = os.path.join(dir_name, "templates")
file_names = os.listdir(template_dir)
html_files = [file for file in file_names if file.endswith(".html")]
return [(country(file_name), get_file_content(file_name)) for file_name in html_files]
def update_address_template(country, html, is_default=0):
"""Update existing Address Template or create a new one."""
if not frappe.db.exists("Country", country):
frappe.log_error("Country {} for regional Address Template does not exist.".format(country))
return
if frappe.db.exists("Address Template", country):
frappe.db.set_value("Address Template", country, "template", html)
frappe.db.set_value("Address Template", country, "is_default", is_default)
else:
frappe.get_doc(dict(
doctype="Address Template",
country=country,
is_default=is_default,
template=html
)).insert()

View File

@ -6,4 +6,4 @@
{% if phone %}Phone: {{ phone }}<br>{% endif -%}
{% if fax %}Fax: {{ fax }}<br>{% endif -%}
{% if email_id %}Email: {{ email_id }}<br>{% endif -%}
{% if gstin %}GSTIN: {{ gstin }}<br>{% endif -%}
{% if gstin %}GSTIN: {{ gstin }}<br>{% endif -%}

View File

@ -0,0 +1,45 @@
from __future__ import unicode_literals
from unittest import TestCase
import frappe
from erpnext.regional.address_template.setup import get_address_templates
from erpnext.regional.address_template.setup import update_address_template
def ensure_country(country):
if frappe.db.exists("Country", country):
return frappe.get_doc("Country", country)
else:
c = frappe.get_doc({
"doctype": "Country",
"country_name": country
})
c.insert()
return c
class TestRegionalAddressTemplate(TestCase):
def test_get_address_templates(self):
"""Get the countries and paths from the templates directory."""
templates = get_address_templates()
self.assertIsInstance(templates, list)
self.assertIsInstance(templates[0], tuple)
def test_create_address_template(self):
"""Create a new Address Template."""
country = ensure_country("Germany")
update_address_template(country.name, "TEST")
doc = frappe.get_doc("Address Template", country.name)
self.assertEqual(doc.template, "TEST")
def test_update_address_template(self):
"""Update an existing Address Template."""
country = ensure_country("Germany")
if not frappe.db.exists("Address Template", country.name):
template = frappe.get_doc({
"doctype": "Address Template",
"country": country.name,
"template": "EXISTING"
}).insert()
update_address_template(country.name, "NEW")
doc = frappe.get_doc("Address Template", country.name)
self.assertEqual(doc.template, "NEW")

View File

@ -3,29 +3,4 @@ import frappe
def setup(company=None, patch=True):
if not patch:
update_address_template()
def update_address_template():
"""
Read address template from file. Update existing Address Template or create a
new one.
"""
dir_name = os.path.dirname(__file__)
template_path = os.path.join(dir_name, 'address_template.html')
with open(template_path, 'r') as template_file:
template_html = template_file.read()
address_template = frappe.db.get_value('Address Template', 'Germany')
if address_template:
frappe.db.set_value('Address Template', 'Germany', 'template', template_html)
else:
# make new html template for Germany
frappe.get_doc(dict(
doctype='Address Template',
country='Germany',
template=template_html
)).insert()
pass

View File

@ -13,7 +13,6 @@ from frappe.utils import today
def setup(company=None, patch=True):
setup_company_independent_fixtures()
if not patch:
update_address_template()
make_fixtures(company)
# TODO: for all countries
@ -24,21 +23,6 @@ def setup_company_independent_fixtures():
frappe.enqueue('erpnext.regional.india.setup.add_hsn_sac_codes', now=frappe.flags.in_test)
add_print_formats()
def update_address_template():
with open(os.path.join(os.path.dirname(__file__), 'address_template.html'), 'r') as f:
html = f.read()
address_template = frappe.db.get_value('Address Template', 'India')
if address_template:
frappe.db.set_value('Address Template', 'India', 'template', html)
else:
# make new html template for India
frappe.get_doc(dict(
doctype='Address Template',
country='India',
template=html
)).insert()
def add_hsn_sac_codes():
# HSN codes
with open(os.path.join(os.path.dirname(__file__), 'hsn_code_data.json'), 'r') as f:

View File

@ -13,6 +13,7 @@ import json
import zlib
import zipfile
import six
from csv import QUOTE_NONNUMERIC
from six import BytesIO
from six import string_types
import frappe
@ -80,7 +81,7 @@ def get_transactions(filters, as_dict=1):
gl.posting_date as 'Belegdatum',
gl.voucher_no as 'Belegfeld 1',
gl.remarks as 'Buchungstext',
LEFT(gl.remarks, 60) as 'Buchungstext',
gl.voucher_type as 'Beleginfo - Art 1',
gl.voucher_no as 'Beleginfo - Inhalt 1',
gl.against_voucher_type as 'Beleginfo - Art 2',
@ -268,7 +269,9 @@ def get_datev_csv(data, filters, csv_class):
# Do not number rows
index=False,
# Use all columns defined above
columns=csv_class.COLUMNS
columns=csv_class.COLUMNS,
# Quote most fields, even currency values with "," separator
quoting=QUOTE_NONNUMERIC
)
if not six.PY2:
@ -285,6 +288,7 @@ def get_datev_csv(data, filters, csv_class):
def get_header(filters, csv_class):
coa = frappe.get_value("Company", filters.get("company"), "chart_of_accounts")
description = filters.get("voucher_type", csv_class.FORMAT_NAME)
coa_used = "04" if "SKR04" in coa else ("03" if "SKR03" in coa else "")
header = [
@ -323,12 +327,8 @@ def get_header(filters, csv_class):
frappe.utils.formatdate(filters.get('from_date'), "yyyyMMdd"),
# P = Transaction batch end date (YYYYMMDD)
frappe.utils.formatdate(filters.get('to_date'), "yyyyMMdd"),
# Q = Description (for example, "January - February 2019 Transactions")
'"{} - {} {}"'.format(
frappe.utils.formatdate(filters.get('from_date'), "MMMM yyyy"),
frappe.utils.formatdate(filters.get('to_date'), "MMMM yyyy"),
csv_class.FORMAT_NAME
),
# Q = Description (for example, "Sales Invoice") Max. 30 chars
'"{}"'.format(_(description)),
# R = Diktatkürzel
'',
# S = Buchungstyp

View File

@ -5,12 +5,9 @@ from __future__ import unicode_literals
import frappe
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
def setup(company=None, patch=True):
make_custom_fields()
add_print_formats()
update_address_template()
def make_custom_fields():
custom_fields = {
@ -21,22 +18,7 @@ def make_custom_fields():
}
create_custom_fields(custom_fields)
def add_print_formats():
frappe.reload_doc("regional", "print_format", "irs_1099_form")
frappe.db.sql(""" update `tabPrint Format` set disabled = 0 where
name in('IRS 1099 Form') """)
def update_address_template():
html = """{{ address_line1 }}<br>
{% if address_line2 %}{{ address_line2 }}<br>{% endif -%}
{{ city }}, {% if state %}{{ state }}{% endif -%}{% if pincode %} {{ pincode }}<br>{% endif -%}
{% if country != "United States" %}{{ country|upper }}{% endif -%}
"""
address_template = frappe.db.get_value('Address Template', 'United States')
if address_template:
frappe.db.set_value('Address Template', 'United States', 'template', html)
else:
frappe.get_doc(dict(doctype='Address Template', country='United States', template=html)).insert()

View File

@ -1036,7 +1036,7 @@ def create_pick_list(source_name, target_doc=None):
},
}, target_doc)
doc.purpose = 'Delivery against Sales Order'
doc.purpose = 'Delivery'
doc.set_item_locations()

View File

@ -8,9 +8,11 @@ import frappe, os, json
from frappe import _
from frappe.desk.page.setup_wizard.setup_wizard import make_records
from frappe.utils import cstr, getdate
from erpnext.accounts.doctype.account.account import RootNotEditable
from frappe.desk.doctype.global_search_settings.global_search_settings import update_global_search_doctypes
from erpnext.accounts.doctype.account.account import RootNotEditable
from erpnext.regional.address_template.setup import set_up_address_templates
default_lead_sources = ["Existing Customer", "Reference", "Advertisement",
"Cold Calling", "Exhibition", "Supplier Reference", "Mass Mailing",
"Customer's Vendor", "Campaign", "Walk In"]
@ -30,7 +32,7 @@ def install(country=None):
{ 'doctype': 'Domain', 'domain': 'Agriculture'},
{ 'doctype': 'Domain', 'domain': 'Non Profit'},
# address template
# ensure at least an empty Address Template exists for this Country
{'doctype':"Address Template", "country": country},
# item group
@ -269,12 +271,11 @@ def install(country=None):
# Records for the Supplier Scorecard
from erpnext.buying.doctype.supplier_scorecard.supplier_scorecard import make_default_records
make_default_records()
make_records(records)
set_up_address_templates(default_country=country)
set_more_defaults()
update_global_search_doctypes()
# path = frappe.get_app_path('erpnext', 'regional', frappe.scrub(country))

View File

@ -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)

View File

@ -108,8 +108,8 @@ erpnext.stock.ItemDashboard = Class.extend({
if (context.data.length > 0) {
$(frappe.render_template('item_dashboard_list', context)).appendTo(this.result);
} else {
var message = __(" Currently no stock available in any warehouse")
$("<span class='text-muted small'>"+message+"</span>").appendTo(this.result);
var message = __("Currently no stock available in any warehouse");
$(`<span class='text-muted small'> ${message} </span>`).appendTo(this.result);
}
},
get_item_dashboard_data: function(data, max_count, show_item) {

View File

@ -1,554 +1,194 @@
{
"allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 1,
"allow_rename": 0,
"autoname": "field:batch_id",
"beta": 0,
"creation": "2013-03-05 14:50:38",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "Setup",
"editable_grid": 0,
"engine": "InnoDB",
"field_order": [
"sb_disabled",
"disabled",
"sb_batch",
"batch_id",
"item",
"item_name",
"image",
"parent_batch",
"manufacturing_date",
"column_break_3",
"batch_qty",
"stock_uom",
"expiry_date",
"source",
"supplier",
"column_break_9",
"reference_doctype",
"reference_name",
"section_break_7",
"description"
],
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "0",
"fieldname": "disabled",
"fieldtype": "Check",
"label": "Disabled"
},
{
"depends_on": "eval:doc.__islocal",
"fieldname": "batch_id",
"fieldtype": "Data",
"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": "Batch ID",
"length": 0,
"no_copy": 1,
"oldfieldname": "batch_id",
"oldfieldtype": "Data",
"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": 1
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "item",
"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": 1,
"label": "Item",
"length": 0,
"no_copy": 0,
"oldfieldname": "item",
"oldfieldtype": "Link",
"options": "Item",
"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": "image",
"fieldtype": "Attach Image",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "image",
"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": "image"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.parent_batch",
"fieldname": "parent_batch",
"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": "Parent Batch",
"length": 0,
"no_copy": 0,
"options": "Batch",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
"read_only": 1
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_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,
"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
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "disabled",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Disabled",
"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
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "Today",
"fieldname": "manufacturing_date",
"fieldtype": "Date",
"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": "Manufacturing Date",
"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": "Manufacturing Date"
},
{
"fieldname": "column_break_3",
"fieldtype": "Column Break"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "expiry_date",
"fieldtype": "Date",
"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": "Expiry Date",
"length": 0,
"no_copy": 0,
"oldfieldname": "expiry_date",
"oldfieldtype": "Date",
"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
"oldfieldtype": "Date"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "source",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Source",
"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": "Source"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "supplier",
"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": "Supplier",
"length": 0,
"no_copy": 0,
"options": "Supplier",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
"read_only": 1
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_9",
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
"fieldtype": "Column Break"
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "reference_doctype",
"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 Document Type",
"length": 0,
"no_copy": 0,
"options": "DocType",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
"read_only": 1
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "reference_name",
"fieldtype": "Dynamic 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 Document Name",
"length": 0,
"no_copy": 0,
"options": "reference_doctype",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
"read_only": 1
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_7",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"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": "description",
"fieldtype": "Small Text",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Batch Description",
"length": 0,
"no_copy": 0,
"oldfieldname": "description",
"oldfieldtype": "Small Text",
"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": "300px"
},
{
"fieldname": "sb_disabled",
"fieldtype": "Section Break"
},
{
"fieldname": "sb_batch",
"fieldtype": "Section Break",
"label": "Batch Details"
},
{
"fetch_from": "item.item_name",
"fieldname": "item_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Item Name",
"read_only": 1
},
{
"fieldname": "batch_qty",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Batch Quantity",
"read_only": 1
},
{
"fetch_from": "item.stock_uom",
"fieldname": "stock_uom",
"fieldtype": "Link",
"label": "Batch UOM",
"options": "UOM",
"read_only": 1
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "fa fa-archive",
"idx": 1,
"image_field": "image",
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 5,
"modified": "2018-08-29 06:28:57.985997",
"modified": "2019-10-03 22:38:45.104056",
"modified_by": "Administrator",
"module": "Stock",
"name": "Batch",
"owner": "harshada@webnotestech.com",
"permissions": [
{
"amend": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"if_owner": 0,
"import": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Item Manager",
"set_user_permissions": 1,
"share": 1,
"submit": 0,
"write": 1
}
],
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "item",
"track_changes": 0,
"track_seen": 0,
"track_views": 0
"title_field": "batch_id"
}

View File

@ -0,0 +1,27 @@
from __future__ import unicode_literals
from frappe import _
def get_data():
return {
'fieldname': 'batch_no',
'transactions': [
{
'label': _('Buy'),
'items': ['Purchase Invoice', 'Purchase Receipt']
},
{
'label': _('Sell'),
'items': ['Sales Invoice', 'Delivery Note']
},
{
'label': _('Move'),
'items': ['Stock Entry']
},
{
'label': _('Quality'),
'items': ['Quality Inspection']
}
]
}

View File

@ -1,12 +1,14 @@
frappe.listview_settings['Batch'] = {
add_fields: ["item", "expiry_date"],
get_indicator: function(doc) {
if(doc.expiry_date && frappe.datetime.get_diff(doc.expiry_date, frappe.datetime.nowdate()) <= 0) {
return [__("Expired"), "red", "expiry_date,>=,Today"]
} else if(doc.expiry_date) {
return [__("Not Expired"), "green", "expiry_date,<,Today"]
add_fields: ["item", "expiry_date", "batch_qty", "disabled"],
get_indicator: (doc) => {
if (doc.disabled) {
return [__("Disabled"), "darkgrey", "disabled,=,1"];
} else if (!doc.batch_qty) {
return [__("Empty"), "darkgrey", "batch_qty,=,0|disabled,=,0"];
} else if (doc.expiry_date && frappe.datetime.get_diff(doc.expiry_date, frappe.datetime.nowdate()) <= 0) {
return [__("Expired"), "red", "expiry_date,not in,|expiry_date,<=,Today|batch_qty,>,0|disabled,=,0"]
} else {
return ["Not Set", "darkgrey", ""];
}
return [__("Active"), "green", "batch_qty,>,0|disabled,=,0"];
};
}
};

View File

@ -7,7 +7,7 @@ from frappe.exceptions import ValidationError
import unittest
from erpnext.stock.doctype.batch.batch import get_batch_qty, UnableToSelectBatchError, get_batch_no
from frappe.utils import cint
from frappe.utils import cint, flt
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
class TestBatch(unittest.TestCase):
@ -35,12 +35,13 @@ class TestBatch(unittest.TestCase):
receipt = frappe.get_doc(dict(
doctype='Purchase Receipt',
supplier='_Test Supplier',
company='_Test Company',
items=[
dict(
item_code='ITEM-BATCH-1',
qty=batch_qty,
rate=10,
warehouse= 'Stores - WP'
warehouse= 'Stores - _TC'
)
]
)).insert()
@ -175,6 +176,18 @@ class TestBatch(unittest.TestCase):
self.assertEqual(get_batch_qty('batch a', '_Test Warehouse - _TC'), 90)
def test_total_batch_qty(self):
self.make_batch_item('ITEM-BATCH-3')
existing_batch_qty = flt(frappe.db.get_value("Batch", "B100", "batch_qty"))
stock_entry = self.make_new_batch_and_entry('ITEM-BATCH-3', 'B100', '_Test Warehouse - _TC')
current_batch_qty = flt(frappe.db.get_value("Batch", "B100", "batch_qty"))
self.assertEqual(current_batch_qty, existing_batch_qty + 90)
stock_entry.cancel()
current_batch_qty = flt(frappe.db.get_value("Batch", "B100", "batch_qty"))
self.assertEqual(current_batch_qty, existing_batch_qty)
@classmethod
def make_new_batch_and_entry(cls, item_name, batch_name, warehouse):
'''Make a new stock entry for given target warehouse and batch name of item'''
@ -208,6 +221,8 @@ class TestBatch(unittest.TestCase):
stock_entry.insert()
stock_entry.submit()
return stock_entry
def test_batch_name_with_naming_series(self):
stock_settings = frappe.get_single('Stock Settings')
use_naming_series = cint(stock_settings.use_naming_series)

View File

@ -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()
@ -186,7 +187,7 @@ class Item(WebsiteGenerator):
or frappe.db.get_single_value('Stock Settings', 'default_warehouse'))
if default_warehouse:
warehouse_company = frappe.db.get_value("Warehouse", default_warehouse, "company")
if not default_warehouse or warehouse_company != default.company:
default_warehouse = frappe.db.get_value('Warehouse',
{'warehouse_name': _('Stores'), 'company': default.company})
@ -307,7 +308,7 @@ class Item(WebsiteGenerator):
if self.retain_sample and not frappe.db.get_single_value('Stock Settings', 'sample_retention_warehouse'):
frappe.throw(_("Please select Sample Retention Warehouse in Stock Settings first"))
if self.retain_sample and not self.has_batch_no:
frappe.throw(_(" {0} Retain Sample is based on batch, please check Has Batch No to retain sample of item").format(
frappe.throw(_("{0} Retain Sample is based on batch, please check Has Batch No to retain sample of item").format(
self.item_code))
def get_context(self, context):
@ -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
@ -1016,7 +1022,7 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
if last_purchase_order and (purchase_order_date >= purchase_receipt_date or not last_purchase_receipt):
# use purchase order
last_purchase = last_purchase_order[0]
purchase_date = purchase_order_date
@ -1036,7 +1042,7 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
"discount_percentage": flt(last_purchase.discount_percentage),
"purchase_date": purchase_date
})
conversion_rate = flt(conversion_rate) or 1.0
out.update({

View File

@ -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) {

View File

@ -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)

View File

@ -38,13 +38,17 @@ frappe.ui.form.on('Pick List', {
};
});
},
get_item_locations: (frm) => {
if (!frm.doc.locations || !frm.doc.locations.length) {
frappe.msgprint(__('First add items in the Item Locations table'));
set_item_locations:(frm, save) => {
if (!(frm.doc.locations && frm.doc.locations.length)) {
frappe.msgprint(__('Add items in the Item Locations table'));
} else {
frm.call('set_item_locations');
frm.call('set_item_locations', {save: save});
}
},
get_item_locations: (frm) => {
// Button on the form
frm.events.set_item_locations(frm, false);
},
refresh: (frm) => {
frm.trigger('add_get_items_button');
if (frm.doc.docstatus === 1) {
@ -52,8 +56,13 @@ frappe.ui.form.on('Pick List', {
'pick_list_name': frm.doc.name,
'purpose': frm.doc.purpose
}).then(target_document_exists => {
frm.set_df_property("locations", "allow_on_submit", target_document_exists ? 0 : 1);
if (target_document_exists) return;
if (frm.doc.purpose === 'Delivery against Sales Order') {
frm.add_custom_button(__('Update Current Stock'), () => frm.trigger('update_pick_list_stock'));
if (frm.doc.purpose === 'Delivery') {
frm.add_custom_button(__('Delivery Note'), () => frm.trigger('create_delivery_note'), __('Create'));
} else {
frm.add_custom_button(__('Stock Entry'), () => frm.trigger('create_stock_entry'), __('Create'));
@ -105,6 +114,7 @@ frappe.ui.form.on('Pick List', {
method: 'erpnext.stock.doctype.pick_list.pick_list.create_delivery_note',
frm: frm
});
},
create_stock_entry: (frm) => {
frappe.xcall('erpnext.stock.doctype.pick_list.pick_list.create_stock_entry', {
@ -114,9 +124,12 @@ frappe.ui.form.on('Pick List', {
frappe.set_route("Form", 'Stock Entry', stock_entry.name);
});
},
update_pick_list_stock: (frm) => {
frm.events.set_item_locations(frm, true);
},
add_get_items_button: (frm) => {
let purpose = frm.doc.purpose;
if (purpose != 'Delivery against Sales Order' || frm.doc.docstatus !== 0) return;
if (purpose != 'Delivery' || frm.doc.docstatus !== 0) return;
let get_query_filters = {
docstatus: 1,
per_delivered: ['<', 100],

View File

@ -1,4 +1,5 @@
{
"actions": [],
"autoname": "naming_series:",
"creation": "2019-07-11 16:03:13.681045",
"doctype": "DocType",
@ -44,7 +45,7 @@
"options": "Warehouse"
},
{
"depends_on": "eval:doc.purpose==='Delivery against Sales Order'",
"depends_on": "eval:doc.purpose==='Delivery'",
"fieldname": "customer",
"fieldtype": "Link",
"in_list_view": 1,
@ -59,6 +60,7 @@
"options": "Work Order"
},
{
"allow_on_submit": 1,
"fieldname": "locations",
"fieldtype": "Table",
"label": "Item Locations",
@ -86,7 +88,7 @@
"fieldname": "purpose",
"fieldtype": "Select",
"label": "Purpose",
"options": "Material Transfer for Manufacture\nMaterial Transfer\nDelivery against Sales Order"
"options": "Material Transfer for Manufacture\nMaterial Transfer\nDelivery"
},
{
"depends_on": "eval:['Material Transfer', 'Material Issue'].includes(doc.purpose)",
@ -111,7 +113,8 @@
}
],
"is_submittable": 1,
"modified": "2019-08-29 21:10:11.572387",
"links": [],
"modified": "2020-03-17 11:38:41.932875",
"modified_by": "Administrator",
"module": "Stock",
"name": "Pick List",

View File

@ -29,7 +29,7 @@ class PickList(Document):
frappe.throw(_('For item {0} at row {1}, count of serial numbers does not match with the picked quantity')
.format(frappe.bold(item.item_code), frappe.bold(item.idx)))
def set_item_locations(self):
def set_item_locations(self, save=False):
items = self.aggregate_item_qty()
self.item_location_map = frappe._dict()
@ -43,7 +43,7 @@ class PickList(Document):
item_code = item_doc.item_code
self.item_location_map.setdefault(item_code,
get_available_item_locations(item_code, from_warehouses, self.item_count_map.get(item_code)))
get_available_item_locations(item_code, from_warehouses, self.item_count_map.get(item_code), self.company))
locations = get_items_with_location_and_quantity(item_doc, self.item_location_map)
@ -59,12 +59,17 @@ class PickList(Document):
location.update(row)
self.append('locations', location)
if save:
self.save()
def aggregate_item_qty(self):
locations = self.get('locations')
self.item_count_map = {}
# aggregate qty for same item
item_map = OrderedDict()
for item in locations:
if not item.item_code:
frappe.throw("Row #{0}: Item Code is Mandatory".format(item.idx))
item_code = item.item_code
reference = item.sales_order_item or item.material_request_item
key = (item_code, item.uom, reference)
@ -85,6 +90,10 @@ class PickList(Document):
return item_map.values()
def validate_item_locations(pick_list):
if not pick_list.locations:
frappe.throw(_("Add items in the Item Locations table"))
def get_items_with_location_and_quantity(item_doc, item_location_map):
available_locations = item_location_map.get(item_doc.item_code)
locations = []
@ -130,14 +139,14 @@ def get_items_with_location_and_quantity(item_doc, item_location_map):
item_location_map[item_doc.item_code] = available_locations
return locations
def get_available_item_locations(item_code, from_warehouses, required_qty):
def get_available_item_locations(item_code, from_warehouses, required_qty, company):
locations = []
if frappe.get_cached_value('Item', item_code, 'has_serial_no'):
locations = get_available_item_locations_for_serialized_item(item_code, from_warehouses, required_qty)
locations = get_available_item_locations_for_serialized_item(item_code, from_warehouses, required_qty, company)
elif frappe.get_cached_value('Item', item_code, 'has_batch_no'):
locations = get_available_item_locations_for_batched_item(item_code, from_warehouses, required_qty)
locations = get_available_item_locations_for_batched_item(item_code, from_warehouses, required_qty, company)
else:
locations = get_available_item_locations_for_other_item(item_code, from_warehouses, required_qty)
locations = get_available_item_locations_for_other_item(item_code, from_warehouses, required_qty, company)
total_qty_available = sum(location.get('qty') for location in locations)
@ -150,9 +159,10 @@ def get_available_item_locations(item_code, from_warehouses, required_qty):
return locations
def get_available_item_locations_for_serialized_item(item_code, from_warehouses, required_qty):
def get_available_item_locations_for_serialized_item(item_code, from_warehouses, required_qty, company):
filters = frappe._dict({
'item_code': item_code,
'company': company,
'warehouse': ['!=', '']
})
@ -180,7 +190,7 @@ def get_available_item_locations_for_serialized_item(item_code, from_warehouses,
return locations
def get_available_item_locations_for_batched_item(item_code, from_warehouses, required_qty):
def get_available_item_locations_for_batched_item(item_code, from_warehouses, required_qty, company):
warehouse_condition = 'and warehouse in %(warehouses)s' if from_warehouses else ''
batch_locations = frappe.db.sql("""
SELECT
@ -192,6 +202,7 @@ def get_available_item_locations_for_batched_item(item_code, from_warehouses, re
WHERE
sle.batch_no = batch.name
and sle.`item_code`=%(item_code)s
and sle.`company` = %(company)s
and IFNULL(batch.`expiry_date`, '2200-01-01') > %(today)s
{warehouse_condition}
GROUP BY
@ -202,16 +213,20 @@ def get_available_item_locations_for_batched_item(item_code, from_warehouses, re
ORDER BY IFNULL(batch.`expiry_date`, '2200-01-01'), batch.`creation`
""".format(warehouse_condition=warehouse_condition), { #nosec
'item_code': item_code,
'company': company,
'today': today(),
'warehouses': from_warehouses
}, as_dict=1)
return batch_locations
def get_available_item_locations_for_other_item(item_code, from_warehouses, required_qty):
def get_available_item_locations_for_other_item(item_code, from_warehouses, required_qty, company):
# gets all items available in different warehouses
warehouses = [x.get('name') for x in frappe.get_list("Warehouse", {'company': company}, "name")]
filters = frappe._dict({
'item_code': item_code,
'warehouse': ['in', warehouses],
'actual_qty': ['>', 0]
})
@ -230,7 +245,9 @@ def get_available_item_locations_for_other_item(item_code, from_warehouses, requ
@frappe.whitelist()
def create_delivery_note(source_name, target_doc=None):
pick_list = frappe.get_doc('Pick List', source_name)
sales_orders = [d.sales_order for d in pick_list.locations]
validate_item_locations(pick_list)
sales_orders = [d.sales_order for d in pick_list.locations if d.sales_order]
sales_orders = set(sales_orders)
delivery_note = None
@ -238,6 +255,10 @@ def create_delivery_note(source_name, target_doc=None):
delivery_note = create_delivery_note_from_sales_order(sales_order,
delivery_note, skip_item_mapping=True)
# map rows without sales orders as well
if not delivery_note:
delivery_note = frappe.new_doc("Delivery Note")
item_table_mapper = {
'doctype': 'Delivery Note Item',
'field_map': {
@ -248,9 +269,25 @@ def create_delivery_note(source_name, target_doc=None):
'condition': lambda doc: abs(doc.delivered_qty) < abs(doc.qty) and doc.delivered_by_supplier!=1
}
item_table_mapper_without_so = {
'doctype': 'Delivery Note Item',
'field_map': {
'rate': 'rate',
'name': 'name',
'parent': '',
}
}
for location in pick_list.locations:
sales_order_item = frappe.get_cached_doc('Sales Order Item', location.sales_order_item)
dn_item = map_child_doc(sales_order_item, delivery_note, item_table_mapper)
if location.sales_order_item:
sales_order_item = frappe.get_cached_doc('Sales Order Item', {'name':location.sales_order_item})
else:
sales_order_item = None
source_doc, table_mapper = [sales_order_item, item_table_mapper] if sales_order_item \
else [location, item_table_mapper_without_so]
dn_item = map_child_doc(source_doc, delivery_note, table_mapper)
if dn_item:
dn_item.warehouse = location.warehouse
@ -258,7 +295,7 @@ def create_delivery_note(source_name, target_doc=None):
dn_item.batch_no = location.batch_no
dn_item.serial_no = location.serial_no
update_delivery_note_item(sales_order_item, dn_item, delivery_note)
update_delivery_note_item(source_doc, dn_item, delivery_note)
set_delivery_note_missing_values(delivery_note)
@ -269,6 +306,7 @@ def create_delivery_note(source_name, target_doc=None):
@frappe.whitelist()
def create_stock_entry(pick_list):
pick_list = frappe.get_doc(json.loads(pick_list))
validate_item_locations(pick_list)
if stock_entry_exists(pick_list.get('name')):
return frappe.msgprint(_('Stock Entry has been already created against this Pick List'))
@ -318,7 +356,7 @@ def get_pending_work_orders(doctype, txt, searchfield, start, page_length, filte
@frappe.whitelist()
def target_document_exists(pick_list_name, purpose):
if purpose == 'Delivery against Sales Order':
if purpose == 'Delivery':
return frappe.db.exists('Delivery Note', {
'pick_list': pick_list_name
})

View File

@ -1,4 +1,5 @@
{
"actions": [],
"creation": "2019-07-11 16:01:22.832885",
"doctype": "DocType",
"editable_grid": 1,
@ -8,6 +9,7 @@
"item_name",
"column_break_2",
"description",
"item_group",
"section_break_5",
"warehouse",
"quantity_section",
@ -120,7 +122,8 @@
"fieldtype": "Link",
"in_list_view": 1,
"label": "Item",
"options": "Item"
"options": "Item",
"reqd": 1
},
{
"fieldname": "quantity_section",
@ -166,10 +169,18 @@
"fieldtype": "Data",
"label": "Material Request Item",
"read_only": 1
},
{
"fetch_from": "item_code.item_group",
"fieldname": "item_group",
"fieldtype": "Data",
"label": "Item Group",
"read_only": 1
}
],
"istable": 1,
"modified": "2019-08-29 21:28:39.539007",
"links": [],
"modified": "2020-03-13 19:08:21.995986",
"modified_by": "Administrator",
"module": "Stock",
"name": "Pick List Item",

View File

@ -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",

View File

@ -375,6 +375,33 @@ class TestPurchaseReceipt(unittest.TestCase):
location = frappe.db.get_value('Asset', assets[0].name, 'location')
self.assertEquals(location, "Test Location")
def test_purchase_return_with_submitted_asset(self):
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_return
pr = make_purchase_receipt(item_code="Test Asset Item", qty=1)
asset = frappe.get_doc("Asset", {
'purchase_receipt': pr.name
})
asset.available_for_use_date = frappe.utils.nowdate()
asset.gross_purchase_amount = 50.0
asset.append("finance_books", {
"expected_value_after_useful_life": 10,
"depreciation_method": "Straight Line",
"total_number_of_depreciations": 3,
"frequency_of_depreciation": 1,
"depreciation_start_date": frappe.utils.nowdate()
})
asset.submit()
pr_return = make_purchase_return(pr.name)
self.assertRaises(frappe.exceptions.ValidationError, pr_return.submit)
asset.load_from_db()
asset.cancel()
pr_return.submit()
def test_purchase_receipt_for_enable_allow_cost_center_in_entry_of_bs_account(self):
from erpnext.accounts.doctype.cost_center.test_cost_center import create_cost_center

View File

@ -37,11 +37,19 @@ class StockLedgerEntry(Document):
def on_submit(self):
self.check_stock_frozen_date()
self.actual_amt_check()
self.calculate_batch_qty()
if not self.get("via_landed_cost_voucher"):
from erpnext.stock.doctype.serial_no.serial_no import process_serial_no
process_serial_no(self)
def calculate_batch_qty(self):
if self.batch_no:
batch_qty = frappe.db.get_value("Stock Ledger Entry",
{"docstatus": 1, "batch_no": self.batch_no, "is_cancelled": "No"},
"sum(actual_qty)") or 0
frappe.db.set_value("Batch", self.batch_no, "batch_qty", batch_qty)
#check for item quantity available in stock
def actual_amt_check(self):
if self.batch_no and not self.get("allow_negative_stock"):
@ -139,4 +147,3 @@ def on_doctype_update():
frappe.db.add_index("Stock Ledger Entry", ["voucher_no", "voucher_type"])
frappe.db.add_index("Stock Ledger Entry", ["batch_no", "item_code", "warehouse"])

View File

@ -488,12 +488,14 @@ def get_stock_balance_for(item_code, warehouse,
["has_serial_no", "has_batch_no"], as_dict=1)
serial_nos = ""
if item_dict.get("has_serial_no"):
qty, rate, serial_nos = get_qty_rate_for_serial_nos(item_code,
warehouse, posting_date, posting_time, item_dict)
with_serial_no = True if item_dict.get("has_serial_no") else False
data = get_stock_balance(item_code, warehouse, posting_date, posting_time,
with_valuation_rate=with_valuation_rate, with_serial_no=with_serial_no)
if with_serial_no:
qty, rate, serial_nos = data
else:
qty, rate = get_stock_balance(item_code, warehouse,
posting_date, posting_time, with_valuation_rate=with_valuation_rate)
qty, rate = data
if item_dict.get("has_batch_no"):
qty = get_batch_qty(batch_no, warehouse) or 0
@ -504,28 +506,6 @@ def get_stock_balance_for(item_code, warehouse,
'serial_nos': serial_nos
}
def get_qty_rate_for_serial_nos(item_code, warehouse, posting_date, posting_time, item_dict):
args = {
"item_code": item_code,
"warehouse": warehouse,
"posting_date": posting_date,
"posting_time": posting_time,
}
serial_nos_list = [serial_no.get("name")
for serial_no in get_available_serial_nos(args)]
qty = len(serial_nos_list)
serial_nos = '\n'.join(serial_nos_list)
args.update({
'qty': qty,
"serial_nos": serial_nos
})
rate = get_incoming_rate(args, raise_error_if_no_rate=False) or 0
return qty, rate, serial_nos
@frappe.whitelist()
def get_difference_account(purpose, company):
if purpose == 'Stock Reconciliation':

View File

@ -245,7 +245,7 @@ def get_basic_details(args, item, overwrite_warehouse=True):
'item_group_defaults': item_group_defaults,
'brand_defaults': brand_defaults
})
warehouse = get_item_warehouse(item, args, overwrite_warehouse, defaults)
if args.get('doctype') == "Material Request" and not args.get('material_request_type'):
@ -279,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,
@ -377,7 +377,7 @@ def get_item_warehouse(item, args, overwrite_warehouse, defaults={}):
else:
warehouse = args.get('warehouse')
return warehouse
def update_barcode_value(out):

View File

@ -35,7 +35,7 @@ def get_data(report_filters):
gl_data = voucher_wise_gl_data.get(key) or {}
d.account_value = gl_data.get("account_value", 0)
d.difference_value = (d.stock_value - d.account_value)
if abs(d.difference_value) > 1.0/10 ** currency_precision:
if abs(d.difference_value) > 0.1:
data.append(d)
return data

View File

@ -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))
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))
return flt(indented_qty[0][0]) if indented_qty else 0
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:

View File

@ -74,7 +74,8 @@ def get_stock_value_on(warehouse=None, posting_date=None, item_code=None):
return sum(sle_map.values())
@frappe.whitelist()
def get_stock_balance(item_code, warehouse, posting_date=None, posting_time=None, with_valuation_rate=False):
def get_stock_balance(item_code, warehouse, posting_date=None, posting_time=None,
with_valuation_rate=False, with_serial_no=False):
"""Returns stock balance quantity at given warehouse on given posting date or current date.
If `with_valuation_rate` is True, will return tuple (qty, rate)"""
@ -84,17 +85,51 @@ def get_stock_balance(item_code, warehouse, posting_date=None, posting_time=None
if not posting_date: posting_date = nowdate()
if not posting_time: posting_time = nowtime()
last_entry = get_previous_sle({
args = {
"item_code": item_code,
"warehouse":warehouse,
"posting_date": posting_date,
"posting_time": posting_time })
"posting_time": posting_time
}
last_entry = get_previous_sle(args)
if with_valuation_rate:
return (last_entry.qty_after_transaction, last_entry.valuation_rate) if last_entry else (0.0, 0.0)
if with_serial_no:
serial_nos = last_entry.get("serial_no")
if (serial_nos and
len(get_serial_nos_data(serial_nos)) < last_entry.qty_after_transaction):
serial_nos = get_serial_nos_data_after_transactions(args)
return ((last_entry.qty_after_transaction, last_entry.valuation_rate, serial_nos)
if last_entry else (0.0, 0.0, 0.0))
else:
return (last_entry.qty_after_transaction, last_entry.valuation_rate) if last_entry else (0.0, 0.0)
else:
return last_entry.qty_after_transaction if last_entry else 0.0
def get_serial_nos_data_after_transactions(args):
serial_nos = []
data = frappe.db.sql(""" SELECT serial_no, actual_qty
FROM `tabStock Ledger Entry`
WHERE
item_code = %(item_code)s and warehouse = %(warehouse)s
and timestamp(posting_date, posting_time) < timestamp(%(posting_date)s, %(posting_time)s)
order by posting_date, posting_time asc """, args, as_dict=1)
for d in data:
if d.actual_qty > 0:
serial_nos.extend(get_serial_nos_data(d.serial_no))
else:
serial_nos = list(set(serial_nos) - set(get_serial_nos_data(d.serial_no)))
return '\n'.join(serial_nos)
def get_serial_nos_data(serial_nos):
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
return get_serial_nos(serial_nos)
@frappe.whitelist()
def get_latest_stock_qty(item_code, warehouse=None):
values, condition = [item_code], ""

View File

@ -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) {

View File

@ -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 => {
d.hide();
window.location.reload();
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();
}
});
});
}
})

View File

@ -10,16 +10,16 @@
{% endif %}
{% for d in doc.taxes %}
{% if d.base_tax_amount > 0 %}
<tr>
<td class="text-right" colspan="2">
{{ d.description }}
</td>
<td class="text-right">
{{ d.get_formatted("base_tax_amount") }}
</td>
</tr>
{% endif %}
{% 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 %}
{% endfor %}
{% if doc.doctype == 'Quotation' %}

View File

@ -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">

View File

@ -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"