Merge branch 'staging-fixes' into fix-patch

This commit is contained in:
Nabin Hait 2018-11-27 13:26:05 +05:30 committed by GitHub
commit 3854940e42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 1282 additions and 1287 deletions

2
.github/stale.yml vendored
View File

@ -1,7 +1,7 @@
# Configuration for probot-stale - https://github.com/probot/stale
# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 10
daysUntilStale: 30
# Number of days of inactivity before a stale Issue or Pull Request is closed.
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.

View File

@ -226,7 +226,7 @@ class PurchaseInvoice(BuyingController):
item.expense_account = warehouse_account[item.warehouse]["account"]
else:
item.expense_account = stock_not_billed_account
elif not item.expense_account and for_validate:
throw(_("Expense account is mandatory for item {0}").format(item.item_code or item.item_name))
@ -379,7 +379,7 @@ class PurchaseInvoice(BuyingController):
return gl_entries
def make_supplier_gl_entry(self, gl_entries):
# Checked both rounding_adjustment and rounded_total
# Checked both rounding_adjustment and rounded_total
# because rounded_total had value even before introcution of posting GLE based on rounded total
grand_total = self.rounded_total if (self.rounding_adjustment and self.rounded_total) else self.grand_total
@ -859,7 +859,8 @@ def make_stock_entry(source_name, target_doc=None):
"Purchase Invoice Item": {
"doctype": "Stock Entry Detail",
"field_map": {
"stock_qty": "transfer_qty"
"stock_qty": "transfer_qty",
"batch_no": "batch_no"
},
}
}, target_doc)

View File

@ -189,7 +189,7 @@ class ShareTransfer(Document):
if (shareholder == 'from_shareholder') else self.to_folio_no;
doc.save()
else:
if doc.folio_no != (self.from_folio_no if (shareholder == 'from_shareholder') else self.to_folio_no):
if doc.folio_no and doc.folio_no != (self.from_folio_no if (shareholder == 'from_shareholder') else self.to_folio_no):
frappe.throw(_('The folio numbers are not matching'))
def autoname_folio(self, shareholder, is_company=False):

View File

@ -79,7 +79,8 @@ class TestShareTransfer(unittest.TestCase):
}
]
for d in share_transfers:
frappe.get_doc(d).submit()
st = frappe.get_doc(d)
st.submit()
def test_invalid_share_transfer(self):
doc = frappe.get_doc({

View File

@ -335,7 +335,7 @@ def get_due_date_from_template(template_name, posting_date, bill_date):
def validate_due_date(posting_date, due_date, party_type, party, company=None, bill_date=None, template_name=None):
if getdate(due_date) < getdate(posting_date):
frappe.throw(_("Due Date cannot be before Posting Date"))
frappe.throw(_("Due Date cannot be before Posting / Supplier Invoice Date"))
else:
if not template_name: return

View File

@ -16,8 +16,6 @@ def execute(filters=None):
return [], []
account_details = {}
if not filters.get("group_by"):
filters['group_by'] = _('Group by Voucher (Consolidated)')
if filters and filters.get('print_in_account_currency') and \
not filters.get('account'):

View File

@ -236,7 +236,7 @@ class GrossProfitGenerator(object):
previous_stock_value = len(my_sle) > i+1 and \
flt(my_sle[i+1].stock_value) or 0.0
if previous_stock_value:
return previous_stock_value - flt(sle.stock_value)
return (previous_stock_value - flt(sle.stock_value)) * flt(row.qty) / abs(flt(sle.qty))
else:
return flt(row.qty) * self.get_average_buying_rate(row, item_code)
else:

View File

@ -231,6 +231,13 @@ def get_columns():
"options": "Account",
"width": 300
},
{
"fieldname": "currency",
"label": _("Currency"),
"fieldtype": "Link",
"options": "Currency",
"hidden": 1
},
{
"fieldname": "opening_debit",
"label": _("Opening (Dr)"),
@ -272,13 +279,6 @@ def get_columns():
"fieldtype": "Currency",
"options": "currency",
"width": 120
},
{
"fieldname": "currency",
"label": _("Currency"),
"fieldtype": "Link",
"options": "Currency",
"hidden": 1
}
]

View File

@ -57,6 +57,8 @@ class AccountsController(TransactionBase):
_('{0} is blocked so this transaction cannot proceed'.format(supplier_name)), raise_exception=1)
def validate(self):
self.validate_qty_is_not_zero()
if self.get("_action") and self._action != "update_after_submit":
self.set_missing_values(for_validate=True)
@ -179,7 +181,7 @@ class AccountsController(TransactionBase):
validate_due_date(self.posting_date, self.due_date,
"Customer", self.customer, self.company, self.payment_terms_template)
elif self.doctype == "Purchase Invoice":
validate_due_date(self.posting_date, self.due_date,
validate_due_date(self.bill_date or self.posting_date, self.due_date,
"Supplier", self.supplier, self.company, self.bill_date, self.payment_terms_template)
def set_price_list_currency(self, buying_or_selling):
@ -359,6 +361,11 @@ class AccountsController(TransactionBase):
return gl_dict
def validate_qty_is_not_zero(self):
for item in self.items:
if not item.qty:
frappe.throw("Item quantity can not be zero")
def validate_account_currency(self, account, account_currency=None):
valid_currency = [self.company_currency]
if self.get("currency") and self.currency != self.company_currency:
@ -405,7 +412,8 @@ class AccountsController(TransactionBase):
if d.against_order:
allocated_amount = flt(d.amount)
else:
allocated_amount = min(self.grand_total - advance_allocated, d.amount)
amount = self.rounded_total or self.grand_total
allocated_amount = min(amount - advance_allocated, d.amount)
advance_allocated += flt(allocated_amount)
self.append("advances", {

View File

@ -41,6 +41,7 @@ class SellingController(StockController):
self.validate_selling_price()
self.set_qty_as_per_stock_uom()
self.set_po_nos()
self.set_gross_profit()
set_default_income_account_for_item(self)
def set_missing_values(self, for_validate=False):
@ -348,6 +349,12 @@ class SellingController(StockController):
if po_nos and po_nos[0].get('po_no'):
self.po_no = ', '.join(list(set([d.po_no for d in po_nos if d.po_no])))
def set_gross_profit(self):
if self.doctype == "Sales Order":
for item in self.items:
item.gross_profit = flt(((item.base_rate - item.valuation_rate) * item.stock_qty), self.precision("amount", item))
def validate_items(self):
# validate items to see if they have is_sales_item enabled
from erpnext.controllers.buying_controller import validate_item_type

View File

@ -1,5 +1,6 @@
{
"allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 1,
"allow_rename": 0,
@ -991,39 +992,6 @@
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "0",
"fieldname": "paid_amount",
"fieldtype": "Currency",
"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": "Paid Amount",
"length": 0,
"no_copy": 1,
"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
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
@ -1360,7 +1328,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2018-08-21 14:44:48.968839",
"modified": "2018-11-26 20:42:14.467284",
"modified_by": "Administrator",
"module": "Education",
"name": "Fees",

View File

@ -112,7 +112,10 @@ def get_fee_list(doctype, txt, filters, limit_start, limit_page_length=20, order
user = frappe.session.user
student = frappe.db.sql("select name from `tabStudent` where student_email_id= %s", user)
if student:
return frappe. db.sql('''select name, program, due_date, paid_amount, outstanding_amount, grand_total from `tabFees`
return frappe. db.sql('''
select name, program, due_date, grand_total - outstanding_amount as paid_amount,
outstanding_amount, grand_total, currency
from `tabFees`
where student= %s and docstatus=1
order by due_date asc limit {0} , {1}'''
.format(limit_start, limit_page_length), student, as_dict = True)

View File

@ -120,3 +120,16 @@ var btn_invoice_registration = function (frm) {
}
});
};
frappe.ui.form.on('Patient Relation', {
patient_relation_add: function(frm){
frm.fields_dict['patient_relation'].grid.get_field('patient').get_query = function(frm){
var patient_list = [];
if(!frm.doc.__islocal) patient_list.push(frm.doc.name);
$.each(frm.doc.patient_relation, function(idx, val){
if (val.patient) patient_list.push(val.patient);
});
return { filters: [['Patient', 'name', 'not in', patient_list]] };
};
}
});

View File

@ -36,10 +36,13 @@ class EmployeeBenefitClaim(Document):
frappe.throw(_("Maximum benefit amount of employee {0} exceeds {1}").format(self.employee, max_benefits))
def validate_max_benefit_for_component(self, payroll_period):
claimed_amount = self.claimed_amount
claimed_amount += get_previous_claimed_amount(self.employee, payroll_period, component = self.earning_component)
if claimed_amount > self.max_amount_eligible:
frappe.throw(_("Maximum amount eligible for the component {0} exceeds {1}").format(self.earning_component, self.max_amount_eligible))
if self.max_amount_eligible:
claimed_amount = self.claimed_amount
claimed_amount += get_previous_claimed_amount(self.employee,
payroll_period, component = self.earning_component)
if claimed_amount > self.max_amount_eligible:
frappe.throw(_("Maximum amount eligible for the component {0} exceeds {1}")
.format(self.earning_component, self.max_amount_eligible))
def validate_non_pro_rata_benefit_claim(self, max_benefits, payroll_period):
claimed_amount = self.claimed_amount

View File

@ -3,7 +3,9 @@
frappe.ui.form.on('Holiday List', {
refresh: function(frm) {
frm.set_value('total_holidays', frm.doc.holidays.length);
if (frm.doc.holidays) {
frm.set_value('total_holidays', frm.doc.holidays.length);
}
},
from_date: function(frm) {
if (frm.doc.from_date && !frm.doc.to_date) {

View File

@ -14,7 +14,7 @@ frappe.ui.form.on("Job Offer", {
refresh: function (frm) {
if ((!frm.doc.__islocal) && (frm.doc.status == 'Accepted')
&& (frm.doc.docstatus === 1) && (!frm.doc.__onload.employee)) {
&& (frm.doc.docstatus === 1) && (!frm.doc.__onload || !frm.doc.__onload.employee)) {
frm.add_custom_button(__('Make Employee'),
function () {
erpnext.job_offer.make_employee(frm);
@ -22,7 +22,7 @@ frappe.ui.form.on("Job Offer", {
);
}
if(frm.doc.__onload.employee) {
if(frm.doc.__onload && frm.doc.__onload.employee) {
frm.add_custom_button(__('Show Employee'),
function () {
frappe.set_route("Form", "Employee", frm.doc.__onload.employee);

View File

@ -1,3 +1,10 @@
frappe.listview_settings['Leave Application'] = {
add_fields: ["leave_type", "employee", "employee_name", "total_leave_days", "from_date", "to_date"]
add_fields: ["leave_type", "employee", "employee_name", "total_leave_days", "from_date", "to_date"],
get_indicator: function (doc) {
if (doc.status === "Approved") {
return [__("Approved"), "green", "status,=,Approved"];
} else if (doc.status === "Rejected") {
return [__("Rejected"), "red", "status,=,Rejected"];
}
}
};

View File

@ -177,7 +177,7 @@ var calculate_earning_total = function(doc, dt, dn, reset_amount) {
if(cint(tbl[i].depends_on_lwp) == 1) {
tbl[i].amount = Math.round(tbl[i].default_amount)*(flt(doc.payment_days) /
cint(doc.total_working_days)*100)/100;
} else if(reset_amount) {
} else if(reset_amount && tbl[i].default_amount) {
tbl[i].amount = tbl[i].default_amount;
}
if(!tbl[i].do_not_include_in_total) {
@ -198,7 +198,7 @@ var calculate_ded_total = function(doc, dt, dn, reset_amount) {
for(var i = 0; i < tbl.length; i++){
if(cint(tbl[i].depends_on_lwp) == 1) {
tbl[i].amount = Math.round(tbl[i].default_amount)*(flt(doc.payment_days)/cint(doc.total_working_days)*100)/100;
} else if(reset_amount) {
} else if(reset_amount && tbl[i].default_amount) {
tbl[i].amount = tbl[i].default_amount;
}
if(!tbl[i].do_not_include_in_total) {

View File

@ -26,6 +26,7 @@ class TestSalarySlip(unittest.TestCase):
self.make_holiday_list()
frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", "Salary Slip Test Holiday List")
frappe.db.set_value("HR Settings", None, "email_salary_slip_to_employee", 0)
def tearDown(self):
frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 0)

View File

@ -10,7 +10,8 @@
"rate": 5000.0,
"uom": "_Test UOM",
"stock_uom": "_Test UOM",
"source_warehouse": "_Test Warehouse - _TC"
"source_warehouse": "_Test Warehouse - _TC",
"allow_transfer_for_manufacture": 1
},
{
"amount": 2000.0,
@ -21,7 +22,8 @@
"rate": 1000.0,
"uom": "_Test UOM",
"stock_uom": "_Test UOM",
"source_warehouse": "_Test Warehouse - _TC"
"source_warehouse": "_Test Warehouse - _TC",
"allow_transfer_for_manufacture": 1
}
],
"docstatus": 1,
@ -54,7 +56,8 @@
"rate": 5000.0,
"uom": "_Test UOM",
"stock_uom": "_Test UOM",
"source_warehouse": "_Test Warehouse - _TC"
"source_warehouse": "_Test Warehouse - _TC",
"allow_transfer_for_manufacture": 1
},
{
"amount": 2000.0,
@ -65,7 +68,8 @@
"rate": 1000.0,
"uom": "_Test UOM",
"stock_uom": "_Test UOM",
"source_warehouse": "_Test Warehouse - _TC"
"source_warehouse": "_Test Warehouse - _TC",
"allow_transfer_for_manufacture": 1
}
],
"docstatus": 1,
@ -97,7 +101,8 @@
"rate": 5000.0,
"uom": "_Test UOM",
"stock_uom": "_Test UOM",
"source_warehouse": "_Test Warehouse - _TC"
"source_warehouse": "_Test Warehouse - _TC",
"allow_transfer_for_manufacture": 1
},
{
"amount": 3000.0,
@ -109,7 +114,8 @@
"rate": 1000.0,
"uom": "_Test UOM",
"stock_uom": "_Test UOM",
"source_warehouse": "_Test Warehouse - _TC"
"source_warehouse": "_Test Warehouse - _TC",
"allow_transfer_for_manufacture": 1
}
],
"docstatus": 1,
@ -143,7 +149,8 @@
"rate": 3000.0,
"uom": "_Test UOM",
"stock_uom": "_Test UOM",
"source_warehouse": "_Test Warehouse - _TC"
"source_warehouse": "_Test Warehouse - _TC",
"allow_transfer_for_manufacture": 1
}
],
"docstatus": 1,

File diff suppressed because it is too large Load Diff

View File

@ -13,3 +13,11 @@ class ManufacturingSettings(Document):
def get_mins_between_operations():
return relativedelta(minutes=cint(frappe.db.get_single_value("Manufacturing Settings",
"mins_between_operations")) or 10)
@frappe.whitelist()
def is_material_consumption_enabled():
if not hasattr(frappe.local, 'material_consumption'):
frappe.local.material_consumption = cint(frappe.db.get_single_value('Manufacturing Settings',
'material_consumption'))
return frappe.local.material_consumption

View File

@ -48,7 +48,7 @@ class TestProductionPlan(unittest.TestCase):
filters = {'production_plan': pln.name}, as_list=1)
self.assertTrue(len(work_orders), len(pln.po_items))
for name in material_requests:
mr = frappe.get_doc('Material Request', name[0])
mr.cancel()
@ -164,7 +164,7 @@ def create_production_plan(**args):
mr_items = get_items_for_material_requests(pln.as_dict())
for d in mr_items:
pln.append('mr_items', d)
if not args.do_not_save:
pln.insert()
if not args.do_not_submit:
@ -182,7 +182,7 @@ def make_bom(**args):
'quantity': args.quantity or 1,
'company': args.company or '_Test Company'
})
for item in args.raw_materials:
item_doc = frappe.get_doc('Item', item)
@ -191,8 +191,8 @@ def make_bom(**args):
'qty': 1,
'uom': item_doc.stock_uom,
'stock_uom': item_doc.stock_uom,
'rate': item_doc.valuation_rate or args.rate
'rate': item_doc.valuation_rate or args.rate,
})
bom.insert(ignore_permissions=True)
bom.submit()

View File

@ -292,6 +292,7 @@ class TestWorkOrder(unittest.TestCase):
make_bom(item=fg_item, rate=1000, raw_materials = ['_Test FG Item', '_Test FG Non Stock Item'])
wo = make_wo_order_test_record(production_item = fg_item)
se = frappe.get_doc(make_stock_entry(wo.name, "Material Transfer for Manufacture", 1))
se.insert()
se.submit()

View File

@ -568,10 +568,10 @@ erpnext.patches.v11_0.remove_land_unit_icon
erpnext.patches.v11_0.add_default_dispatch_notification_template
erpnext.patches.v11_0.add_market_segments
erpnext.patches.v11_0.add_sales_stages
execute:frappe.delete_doc("Page", "Sales Analytics")
execute:frappe.delete_doc("Page", "Purchase Analytics")
execute:frappe.delete_doc("Page", "Stock Analytics")
execute:frappe.delete_doc("Page", "Production Analytics")
execute:frappe.delete_doc("Page", "sales-analytics")
execute:frappe.delete_doc("Page", "purchase-analytics")
execute:frappe.delete_doc("Page", "stock-analytics")
execute:frappe.delete_doc("Page", "production-analytics")
erpnext.patches.v11_0.ewaybill_fields_gst_india #2018-11-13
erpnext.patches.v11_0.drop_column_max_days_allowed
erpnext.patches.v11_0.change_healthcare_desktop_icons

View File

@ -1,5 +1,6 @@
{
"allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 1,
"allow_rename": 0,
@ -444,39 +445,6 @@
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "start_date",
"fieldtype": "Date",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 1,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "User",
"length": 0,
"no_copy": 0,
"options": "User",
"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
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
@ -1032,7 +1000,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2018-08-28 14:44:32.912004",
"modified": "2018-11-15 07:58:42.629845",
"modified_by": "Administrator",
"module": "Projects",
"name": "Timesheet",

View File

@ -33,7 +33,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
item.margin_rate_or_amount = 0;
item.rate_with_margin = 0;
}
item.base_rate_with_margin = item.rate_with_margin * flt(this.frm.doc.conversion_rate);
item.base_rate_with_margin = item.rate_with_margin * flt(frm.doc.conversion_rate);
cur_frm.cscript.set_gross_profit(item);
cur_frm.cscript.calculate_taxes_and_totals();
@ -185,6 +185,12 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
}
},
is_return: function() {
if(!this.frm.doc.is_return && this.frm.doc.return_against) {
this.frm.set_value('return_against', '');
}
},
setup_quality_inspection: function() {
if(!in_list(["Delivery Note", "Sales Invoice", "Purchase Receipt", "Purchase Invoice"], this.frm.doc.doctype)) {
return;

View File

@ -350,12 +350,17 @@ def set_tax_withholding_category(company):
def set_tds_account(docs, company):
abbr = frappe.get_value("Company", company, "abbr")
docs.extend([
{
"doctype": "Account", "account_name": "TDS Payable", "account_type": "Tax",
"parent_account": "Duties and Taxes - {0}".format(abbr), "company": company
}
])
parent_account = frappe.db.get_value("Account", filters = {"account_name": "Duties and Taxes", "company": company})
if parent_account:
docs.extend([
{
"doctype": "Account",
"account_name": "TDS Payable",
"account_type": "Tax",
"parent_account": parent_account,
"company": company
}
])
def get_tds_details(accounts, fiscal_year):
# bootstrap default tax withholding sections

View File

@ -32,7 +32,6 @@ class SalesOrder(SellingController):
def validate(self):
super(SalesOrder, self).validate()
self.validate_order_type()
self.validate_delivery_date()
self.validate_proj_cust()
@ -342,9 +341,11 @@ class SalesOrder(SellingController):
delivered_qty += item.delivered_qty
tot_qty += item.qty
self.db_set("per_delivered", flt(delivered_qty/tot_qty) * 100,
update_modified=False)
if tot_qty != 0:
self.db_set("per_delivered", flt(delivered_qty/tot_qty) * 100,
update_modified=False)
def set_indicator(self):
"""Set indicator for portal"""

View File

@ -6,8 +6,7 @@
"docstatus": 0,
"doctype": "Report",
"idx": 0,
"is_standard": "Yes",
"letter_head": "Test",
"is_standard": "Yes",
"modified": "2018-06-01 09:39:39.604944",
"modified_by": "Administrator",
"module": "Selling",
@ -30,4 +29,4 @@
"role": "Accounts User"
}
]
}
}

View File

@ -67,23 +67,17 @@ frappe.query_reports["Sales Analytics"] = {
reqd: 1
}
],
"formatter": function(value, row, column, data) {
if(!value){
value = 0
}
return value;
},
get_datatable_options(options) {
return Object.assign(options, {
checkboxColumn: true,
events: {
onCheckRow: function(data) {
row_name = data[2].content;
row_values = data.slice(5).map(function (column) {
length = data.length
row_values = data.slice(4,length-1).map(function (column) {
return column.content;
})
entry = {
entry = {
'name':row_name,
'values':row_values
}
@ -109,12 +103,12 @@ frappe.query_reports["Sales Analytics"] = {
labels: raw_data.labels,
datasets: new_datasets
}
setTimeout(() => {
frappe.query_report.chart.update(new_data)
},200)
setTimeout(() => {
frappe.query_report.chart.draw(true);
}, 800)

View File

@ -166,7 +166,7 @@ class Analytics(object):
for entity, period_data in iteritems(self.entity_periodic_data):
row = {
"entity": entity,
"entity_name": self.entity_names.get(entity)
"entity_name": self.entity_names.get(entity)
}
total = 0
for dummy, end_date in self.periodic_daterange:
@ -177,7 +177,7 @@ class Analytics(object):
row["total"] = total
self.data.append(row)
def get_rows_by_group(self):
self.get_periodic_data()
out = []
@ -185,7 +185,7 @@ class Analytics(object):
for d in reversed(self.group_entries):
row = {
"entity": d.name,
"indent": self.depth_map.get(d.name)
"indent": self.depth_map.get(d.name)
}
total = 0
for dummy, end_date in self.periodic_daterange:
@ -275,7 +275,8 @@ class Analytics(object):
self.parent_child_map = frappe._dict(frappe.db.sql(""" select name, supplier_group from `tabSupplier`"""))
def get_chart_data(self):
labels = [d.get("label") for d in self.columns[3:]]
length = len(self.columns)
labels = [d.get("label") for d in self.columns[2:length-1]]
self.chart = {
"data": {
'labels': labels,

View File

@ -8,19 +8,23 @@ from erpnext.selling.report.sales_analytics.sales_analytics import execute
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
class TestAnalytics(unittest.TestCase):
def test_sales_analytics(self):
frappe.db.sql("delete from `tabSales Order` where company='_Test Company 2'")
def tearDown(self):
frappe.db.sql(""" DELETE FROM `tabSales Order` """)
create_sales_orders()
def test_by_entity(self):
create_sales_order()
self.compare_result_for_customer()
self.compare_result_for_customer_group()
self.compare_result_for_customer_based_on_quantity()
def compare_result_for_customer(self):
filters = {
'doc_type': 'Sales Order',
'range': 'Monthly',
'to_date': '2018-03-31',
'tree_type': 'Customer',
'company': '_Test Company',
'company': '_Test Company 2',
'from_date': '2017-04-01',
'value_quantity': 'Value'
}
@ -45,23 +49,6 @@ class TestAnalytics(unittest.TestCase):
"mar": 0.0,
"total":2000.0
},
{
"entity": "_Test Customer 3",
"entity_name": "_Test Customer 3",
"apr": 0.0,
"may": 0.0,
"jun": 2000.0,
"jul": 1000.0,
"aug": 0.0,
"sep": 0.0,
"oct": 0.0,
"nov": 0.0,
"dec": 0.0,
"jan": 0.0,
"feb": 0.0,
"mar": 0.0,
"total": 3000.0
},
{
"entity": "_Test Customer 2",
"entity_name": "_Test Customer 2",
@ -78,106 +65,67 @@ class TestAnalytics(unittest.TestCase):
"feb": 0.0,
"mar": 0.0,
"total":2500.0
},
{
"entity": "_Test Customer 3",
"entity_name": "_Test Customer 3",
"apr": 0.0,
"may": 0.0,
"jun": 2000.0,
"jul": 1000.0,
"aug": 0.0,
"sep": 0.0,
"oct": 0.0,
"nov": 0.0,
"dec": 0.0,
"jan": 0.0,
"feb": 0.0,
"mar": 0.0,
"total": 3000.0
}
]
self.assertEqual(expected_data, report[1])
def test_by_group(self):
create_sales_order()
result = sorted(report[1], key=lambda k: k['entity'])
self.assertEqual(expected_data, result)
def compare_result_for_customer_group(self):
filters = {
'doc_type': 'Sales Order',
'range': 'Monthly',
'to_date': '2018-03-31',
'tree_type': 'Customer Group',
'company': '_Test Company',
'company': '_Test Company 2',
'from_date': '2017-04-01',
'value_quantity': 'Value'
}
report = execute(filters)
expected_data = [
{
"entity": "All Customer Groups",
"indent": 0,
"apr": 0.0,
"may": 0.0,
"jun": 2000.0,
"jul": 1000.0,
"aug": 0.0,
"sep": 1500.0,
"oct": 1000.0,
"nov": 0.0,
"dec": 0.0,
"jan": 0.0,
"feb": 2000.0,
"mar": 0.0,
"total":7500.0
},
{
"entity": "Individual",
"indent": 1,
"apr": 0.0,
"may": 0.0,
"jun": 0.0,
"jul": 0.0,
"aug": 0.0,
"sep": 0.0,
"oct": 0.0,
"nov": 0.0,
"dec": 0.0,
"jan": 0.0,
"feb": 0.0,
"mar": 0.0,
"total": 0.0
},
{
"entity": "_Test Customer Group",
"indent": 1,
"apr": 0.0,
"may": 0.0,
"jun": 0.0,
"jul": 0.0,
"aug": 0.0,
"sep": 0.0,
"oct": 0.0,
"nov": 0.0,
"dec": 0.0,
"jan": 0.0,
"feb": 0.0,
"mar": 0.0,
"total":0.0
},
{
"entity": "_Test Customer Group 1",
"indent": 1,
"apr": 0.0,
"may": 0.0,
"jun": 0.0,
"jul": 0.0,
"aug": 0.0,
"sep": 0.0,
"oct": 0.0,
"nov": 0.0,
"dec": 0.0,
"jan": 0.0,
"feb": 0.0,
"mar": 0.0,
"total":0.0
}
]
self.assertEqual(expected_data, report[1])
def test_by_quantity(self):
create_sales_order()
expected_first_row = {
"entity": "All Customer Groups",
"indent": 0,
"apr": 0.0,
"may": 0.0,
"jun": 2000.0,
"jul": 1000.0,
"aug": 0.0,
"sep": 1500.0,
"oct": 1000.0,
"nov": 0.0,
"dec": 0.0,
"jan": 0.0,
"feb": 2000.0,
"mar": 0.0,
"total":7500.0
}
self.assertEqual(expected_first_row, report[1][0])
def compare_result_for_customer_based_on_quantity(self):
filters = {
'doc_type': 'Sales Order',
'range': 'Monthly',
'to_date': '2018-03-31',
'tree_type': 'Customer',
'company': '_Test Company',
'company': '_Test Company 2',
'from_date': '2017-04-01',
'value_quantity': 'Quantity'
}
@ -202,23 +150,6 @@ class TestAnalytics(unittest.TestCase):
"mar": 0.0,
"total":20.0
},
{
"entity": "_Test Customer 3",
"entity_name": "_Test Customer 3",
"apr": 0.0,
"may": 0.0,
"jun": 20.0,
"jul": 10.0,
"aug": 0.0,
"sep": 0.0,
"oct": 0.0,
"nov": 0.0,
"dec": 0.0,
"jan": 0.0,
"feb": 0.0,
"mar": 0.0,
"total": 30.0
},
{
"entity": "_Test Customer 2",
"entity_name": "_Test Customer 2",
@ -235,16 +166,63 @@ class TestAnalytics(unittest.TestCase):
"feb": 0.0,
"mar": 0.0,
"total":25.0
},
{
"entity": "_Test Customer 3",
"entity_name": "_Test Customer 3",
"apr": 0.0,
"may": 0.0,
"jun": 20.0,
"jul": 10.0,
"aug": 0.0,
"sep": 0.0,
"oct": 0.0,
"nov": 0.0,
"dec": 0.0,
"jan": 0.0,
"feb": 0.0,
"mar": 0.0,
"total": 30.0
}
]
self.assertEqual(expected_data, report[1])
result = sorted(report[1], key=lambda k: k['entity'])
self.assertEqual(expected_data, result)
def create_sales_order():
def create_sales_orders():
frappe.set_user("Administrator")
make_sales_order(qty=10, customer = "_Test Customer 1", transaction_date='2018-02-10')
make_sales_order(qty=10, customer = "_Test Customer 1", transaction_date='2018-02-15')
make_sales_order(qty=15, customer = "_Test Customer 2", transaction_date='2017-09-23')
make_sales_order(qty=10, customer = "_Test Customer 2", transaction_date='2017-10-10')
make_sales_order(qty=20, customer = "_Test Customer 3", transaction_date='2017-06-15')
make_sales_order(qty=10, customer = "_Test Customer 3", transaction_date='2017-07-10')
make_sales_order(company="_Test Company 2", qty=10,
customer = "_Test Customer 1",
transaction_date = '2018-02-10',
warehouse = 'Finished Goods - _TC2',
currency = 'EUR')
make_sales_order(company="_Test Company 2",
qty=10, customer = "_Test Customer 1",
transaction_date = '2018-02-15',
warehouse = 'Finished Goods - _TC2',
currency = 'EUR')
make_sales_order(company = "_Test Company 2",
qty=10, customer = "_Test Customer 2",
transaction_date = '2017-10-10',
warehouse='Finished Goods - _TC2',
currency = 'EUR')
make_sales_order(company="_Test Company 2",
qty=15, customer = "_Test Customer 2",
transaction_date='2017-09-23',
warehouse='Finished Goods - _TC2',
currency = 'EUR')
make_sales_order(company="_Test Company 2",
qty=20, customer = "_Test Customer 3",
transaction_date='2017-06-15',
warehouse='Finished Goods - _TC2',
currency = 'EUR')
make_sales_order(company="_Test Company 2",
qty=10, customer = "_Test Customer 3",
transaction_date='2017-07-10',
warehouse='Finished Goods - _TC2',
currency = 'EUR')

View File

@ -363,7 +363,8 @@ def replace_abbr(company, old, new):
for d in doc:
_rename_record(d)
for dt in ["Warehouse", "Account", "Cost Center"]:
for dt in ["Warehouse", "Account", "Cost Center", "Department", "Location",
"Sales Taxes and Charges Template", "Purchase Taxes and Charges Template"]:
_rename_records(dt)
frappe.db.commit()

View File

@ -57,6 +57,7 @@
"stock_uom": "_Test UOM",
"show_in_website": 1,
"website_warehouse": "_Test Warehouse - _TC",
"gst_hsn_code": "999800",
"item_defaults": [{
"company": "_Test Company",
"default_warehouse": "_Test Warehouse - _TC",
@ -78,6 +79,7 @@
"item_group": "_Test Item Group Desktops",
"item_name": "_Test Item Home Desktop 100",
"valuation_rate": 100,
"gst_hsn_code": "999800",
"item_defaults": [{
"company": "_Test Company",
"default_warehouse": "_Test Warehouse - _TC",
@ -107,6 +109,7 @@
"item_group": "_Test Item Group Desktops",
"item_name": "_Test Item Home Desktop 200",
"stock_uom": "_Test UOM 1",
"gst_hsn_code": "999800",
"item_defaults": [{
"company": "_Test Company",
"default_warehouse": "_Test Warehouse - _TC",
@ -128,6 +131,7 @@
"item_group": "_Test Item Group Desktops",
"item_name": "_Test Product Bundle Item",
"stock_uom": "_Test UOM",
"gst_hsn_code": "999800",
"item_defaults": [{
"company": "_Test Company",
"default_warehouse": "_Test Warehouse - _TC",
@ -149,6 +153,7 @@
"item_group": "_Test Item Group Desktops",
"item_name": "_Test FG Item",
"stock_uom": "_Test UOM",
"gst_hsn_code": "999800",
"item_defaults": [{
"company": "_Test Company",
"default_warehouse": "_Test Warehouse - _TC",
@ -170,6 +175,7 @@
"item_group": "_Test Item Group Desktops",
"item_name": "_Test Non Stock Item",
"stock_uom": "_Test UOM",
"gst_hsn_code": "999800",
"item_defaults": [{
"company": "_Test Company",
"default_warehouse": "_Test Warehouse - _TC",
@ -191,6 +197,7 @@
"item_group": "_Test Item Group Desktops",
"item_name": "_Test Serialized Item",
"stock_uom": "_Test UOM",
"gst_hsn_code": "999800",
"item_defaults": [{
"company": "_Test Company",
"default_warehouse": "_Test Warehouse - _TC",
@ -213,6 +220,7 @@
"item_name": "_Test Serialized Item With Series",
"serial_no_series": "ABCD.#####",
"stock_uom": "_Test UOM",
"gst_hsn_code": "999800",
"item_defaults": [{
"company": "_Test Company",
"default_warehouse": "_Test Warehouse - _TC",
@ -234,6 +242,7 @@
"item_group": "_Test Item Group Desktops",
"item_name": "_Test Item Home Desktop Manufactured",
"stock_uom": "_Test UOM",
"gst_hsn_code": "999800",
"item_defaults": [{
"company": "_Test Company",
"default_warehouse": "_Test Warehouse - _TC",
@ -255,6 +264,7 @@
"item_group": "_Test Item Group Desktops",
"item_name": "_Test FG Item 2",
"stock_uom": "_Test UOM",
"gst_hsn_code": "999800",
"item_defaults": [{
"company": "_Test Company",
"default_warehouse": "_Test Warehouse - _TC",
@ -276,6 +286,7 @@
"item_group": "_Test Item Group Desktops",
"item_name": "_Test Variant Item",
"stock_uom": "_Test UOM",
"gst_hsn_code": "999800",
"has_variants": 1,
"item_defaults": [{
"company": "_Test Company",
@ -312,6 +323,7 @@
"item_group": "_Test Item Group",
"item_name": "_Test Item Warehouse Group Wise Reorder",
"apply_warehouse_wise_reorder_level": 1,
"gst_hsn_code": "999800",
"item_defaults": [{
"company": "_Test Company",
"default_warehouse": "_Test Warehouse Group-C1 - _TC",

View File

@ -199,12 +199,15 @@ frappe.ui.form.on('Stock Entry', {
},
validate_purpose_consumption: function(frm) {
frappe.model.get_value('Manufacturing Settings', {'name': 'Manufacturing Settings'}, 'material_consumption', function(d) {
if (d.material_consumption==0 && frm.doc.purpose=="Material Consumption for Manufacture") {
frappe.call({
method: "erpnext.manufacturing.doctype.manufacturing_settings.manufacturing_settings.is_material_consumption_enabled",
}).then(r => {
if (cint(r.message) == 0
&& frm.doc.purpose=="Material Consumption for Manufacture") {
frm.set_value("purpose", 'Manufacture');
frappe.throw(__('Material Consumption is not set in Manufacturing Settings.'));
}
})
});
},
company: function(frm) {

View File

@ -594,22 +594,21 @@ def get_pos_profile(company, pos_profile=None, user=None):
if not user:
user = frappe.session['user']
pos_profile = frappe.db.sql("""select pf.*
from
`tabPOS Profile` pf, `tabPOS Profile User` pfu
where
pfu.parent = pf.name and pfu.user = %s and pf.company = %s
and pf.disabled = 0 and pfu.default=1""", (user, company), as_dict=1)
if not pos_profile:
pos_profile = frappe.db.sql("""select pf.*
from
`tabPOS Profile` pf left join `tabPOS Profile User` pfu
on
pos_profile = frappe.db.sql("""SELECT pf.*
FROM
`tabPOS Profile` pf LEFT JOIN `tabPOS Profile User` pfu
ON
pf.name = pfu.parent
where
ifnull(pfu.user, '') = '' and pf.company = %s
and pf.disabled = 0""", (company), as_dict=1)
WHERE
(
(pfu.user = %(user)s AND pf.company = %(company)s AND pfu.default=1)
OR (pfu.user = %(user)s AND pfu.default=1)
OR (ifnull(pfu.user, '') = '' AND pf.company = %(company)s)
) AND pf.disabled = 0
""", {
'user': user,
'company': company
}, as_dict=1)
return pos_profile and pos_profile[0] or None

View File

@ -88,10 +88,9 @@ frappe.query_reports["Stock Analytics"] = {
events: {
onCheckRow: function(data) {
row_name = data[2].content;
row_values = data.slice(6).map(function (column) {
row_values = data.slice(7).map(function (column) {
return column.content;
})
entry = {
'name':row_name,
'values':row_values
@ -118,12 +117,12 @@ frappe.query_reports["Stock Analytics"] = {
labels: raw_data.labels,
datasets: new_datasets
}
setTimeout(() => {
frappe.query_report.chart.update(new_data)
},200)
setTimeout(() => {
frappe.query_report.chart.draw(true);
}, 800)

View File

@ -167,13 +167,11 @@ def get_data(filters):
return data
def get_chart_data(columns):
labels = [d.get("label") for d in columns[4:]]
labels = [d.get("label") for d in columns[5:]]
chart = {
"data": {
'labels': labels,
'datasets':[
{ "values": ['0' for d in columns[4:]] }
]
'datasets':[]
}
}
chart["type"] = "line"

View File

@ -7,7 +7,8 @@ frappe.query_reports["Stock Projected Qty"] = {
"fieldname":"company",
"label": __("Company"),
"fieldtype": "Link",
"options": "Company"
"options": "Company",
"default": frappe.defaults.get_user_default("Company")
},
{
"fieldname":"warehouse",

View File

@ -5,13 +5,13 @@
{{ doc.program }}
</div>
<div class="col-xs-2">
{{ doc.get_formatted("total_amount") }}
{{ frappe.utils.fmt_money(doc.grand_total, currency=doc.currency) }}
</div>
<div class="col-xs-2">
{{ doc.get_formatted("paid_amount") }}
{{ frappe.utils.fmt_money(doc.paid_amount, currency=doc.currency) }}
</div>
<div class="col-xs-2">
{{ doc.get_formatted("outstanding_amount") }}
{{ frappe.utils.fmt_money(doc.outstanding_amount, currency=doc.currency) }}
</div>
</div>
</a>