Fixed merge conflict

This commit is contained in:
Nabin Hait 2018-02-22 14:47:26 +05:30
commit cf72d7f135
38 changed files with 351 additions and 278 deletions

View File

@ -5,7 +5,7 @@ import frappe
from erpnext.hooks import regional_overrides from erpnext.hooks import regional_overrides
from frappe.utils import getdate from frappe.utils import getdate
__version__ = '10.0.23' __version__ = '10.1.0'
def get_default_company(user=None): def get_default_company(user=None):
'''Get default company for user''' '''Get default company for user'''

View File

@ -59,16 +59,21 @@ class PaymentEntry(AccountsController):
if self.difference_amount: if self.difference_amount:
frappe.throw(_("Difference Amount must be zero")) frappe.throw(_("Difference Amount must be zero"))
self.make_gl_entries() self.make_gl_entries()
self.update_outstanding_amounts()
self.update_advance_paid() self.update_advance_paid()
self.update_expense_claim() self.update_expense_claim()
def on_cancel(self): def on_cancel(self):
self.setup_party_account_field() self.setup_party_account_field()
self.make_gl_entries(cancel=1) self.make_gl_entries(cancel=1)
self.update_outstanding_amounts()
self.update_advance_paid() self.update_advance_paid()
self.update_expense_claim() self.update_expense_claim()
self.delink_advance_entry_references() self.delink_advance_entry_references()
def update_outstanding_amounts(self):
self.set_missing_ref_details(force=True)
def validate_duplicate_entry(self): def validate_duplicate_entry(self):
reference_names = [] reference_names = []
for d in self.get("references"): for d in self.get("references"):
@ -130,14 +135,14 @@ class PaymentEntry(AccountsController):
self.set_missing_ref_details() self.set_missing_ref_details()
def set_missing_ref_details(self): def set_missing_ref_details(self, force=False):
for d in self.get("references"): for d in self.get("references"):
if d.allocated_amount: if d.allocated_amount:
ref_details = get_reference_details(d.reference_doctype, ref_details = get_reference_details(d.reference_doctype,
d.reference_name, self.party_account_currency) d.reference_name, self.party_account_currency)
for field, value in ref_details.items(): for field, value in ref_details.items():
if not d.get(field): if not d.get(field) or force:
d.set(field, value) d.set(field, value)
def validate_payment_type(self): def validate_payment_type(self):

View File

@ -3,9 +3,26 @@
frappe.provide("erpnext.accounts"); frappe.provide("erpnext.accounts");
frappe.ui.form.on("Payment Reconciliation Payment", {
invoice_number: function(frm, cdt, cdn) {
var row = locals[cdt][cdn];
if(row.invoice_number) {
var parts = row.invoice_number.split(' | ');
var invoice_type = parts[0];
var invoice_number = parts[1];
var invoice_amount = frm.doc.invoices.filter(function(d) {
return d.invoice_type === invoice_type && d.invoice_number === invoice_number;
})[0].outstanding_amount;
frappe.model.set_value(cdt, cdn, "allocated_amount", Math.min(invoice_amount, row.amount));
}
}
});
erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.extend({ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.extend({
onload: function() { onload: function() {
var me = this var me = this;
this.frm.set_query("party_type", function() { this.frm.set_query("party_type", function() {
return{ return{
query: "erpnext.setup.doctype.party_type.party_type.get_party_type" query: "erpnext.setup.doctype.party_type.party_type.get_party_type"

View File

@ -55,6 +55,7 @@ class PaymentReconciliation(Document):
THEN 1=1 THEN 1=1
ELSE {bank_account_condition} ELSE {bank_account_condition}
END) END)
order by t1.posting_date
""".format(**{ """.format(**{
"dr_or_cr": dr_or_cr, "dr_or_cr": dr_or_cr,
"bank_account_condition": bank_account_condition, "bank_account_condition": bank_account_condition,

View File

@ -32,7 +32,7 @@ class POSProfile(Document):
.format(res[0][0], row.user), raise_exception=1) .format(res[0][0], row.user), raise_exception=1)
elif not row.default and not res: elif not row.default and not res:
msgprint(_("User {0} doesn't have any default POS Profile. Check Default at Row {1} for this User.") msgprint(_("User {0} doesn't have any default POS Profile. Check Default at Row {1} for this User.")
.format(row.user, row.idx), raise_exception=1) .format(row.user, row.idx))
def validate_all_link_fields(self): def validate_all_link_fields(self):
accounts = {"Account": [self.income_account, accounts = {"Account": [self.income_account,

View File

@ -106,6 +106,10 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
on_submit: function(doc, dt, dn) { on_submit: function(doc, dt, dn) {
var me = this; var me = this;
if (frappe.get_route()[0] != 'Sales Invoice') {
return
}
$.each(doc["items"], function(i, row) { $.each(doc["items"], function(i, row) {
if(row.delivery_note) frappe.model.clear_doc("Delivery Note", row.delivery_note) if(row.delivery_note) frappe.model.clear_doc("Delivery Note", row.delivery_note)
}) })

View File

@ -50,10 +50,12 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum
row += [ row += [
d.customer_group, d.debit_to, ", ".join(mode_of_payments.get(d.parent, [])), d.customer_group, d.debit_to, ", ".join(mode_of_payments.get(d.parent, [])),
d.territory, d.project, d.company, d.sales_order, d.territory, d.project, d.company, d.sales_order,
delivery_note, d.income_account, d.cost_center, d.stock_qty, d.stock_uom, delivery_note, d.income_account, d.cost_center, d.stock_qty, d.stock_uom
d.base_net_rate, d.base_net_amount
] ]
row += [d.base_net_rate/d.stock_qty, d.base_net_amount] \
if d.stock_uom != d.uom else [d.base_net_rate, d.base_net_amount]
total_tax = 0 total_tax = 0
for tax in tax_columns: for tax in tax_columns:
item_tax = itemised_tax.get(d.name, {}).get(tax, {}) item_tax = itemised_tax.get(d.name, {}).get(tax, {})
@ -131,7 +133,7 @@ def get_items(filters, additional_query_columns):
`tabSales Invoice Item`.stock_uom, `tabSales Invoice Item`.base_net_rate, `tabSales Invoice Item`.stock_uom, `tabSales Invoice Item`.base_net_rate,
`tabSales Invoice Item`.base_net_amount, `tabSales Invoice`.customer_name, `tabSales Invoice Item`.base_net_amount, `tabSales Invoice`.customer_name,
`tabSales Invoice`.customer_group, `tabSales Invoice Item`.so_detail, `tabSales Invoice`.customer_group, `tabSales Invoice Item`.so_detail,
`tabSales Invoice`.update_stock {0} `tabSales Invoice`.update_stock, `tabSales Invoice Item`.uom {0}
from `tabSales Invoice`, `tabSales Invoice Item` from `tabSales Invoice`, `tabSales Invoice Item`
where `tabSales Invoice`.name = `tabSales Invoice Item`.parent where `tabSales Invoice`.name = `tabSales Invoice Item`.parent
and `tabSales Invoice`.docstatus = 1 %s %s and `tabSales Invoice`.docstatus = 1 %s %s

View File

@ -1,5 +1,5 @@
{ {
"add_total_row": 0, "add_total_row": 1,
"apply_user_permissions": 1, "apply_user_permissions": 1,
"creation": "2013-06-13 18:46:55", "creation": "2013-06-13 18:46:55",
"disabled": 0, "disabled": 0,
@ -7,7 +7,7 @@
"doctype": "Report", "doctype": "Report",
"idx": 3, "idx": 3,
"is_standard": "Yes", "is_standard": "Yes",
"modified": "2017-02-24 20:16:25.027061", "modified": "2018-02-21 01:28:31.261299",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Purchase Invoice Trends", "name": "Purchase Invoice Trends",

View File

@ -1,5 +1,5 @@
{ {
"add_total_row": 0, "add_total_row": 1,
"apply_user_permissions": 1, "apply_user_permissions": 1,
"creation": "2013-06-13 18:44:21", "creation": "2013-06-13 18:44:21",
"disabled": 0, "disabled": 0,
@ -7,7 +7,7 @@
"doctype": "Report", "doctype": "Report",
"idx": 3, "idx": 3,
"is_standard": "Yes", "is_standard": "Yes",
"modified": "2017-02-24 20:15:12.885723", "modified": "2018-02-21 01:28:03.622485",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Sales Invoice Trends", "name": "Sales Invoice Trends",

View File

@ -3096,6 +3096,37 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": "supplied_items",
"columns": 0,
"fieldname": "raw_material_details",
"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": "Raw Materials Supplied",
"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,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
@ -3324,7 +3355,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2018-01-11 14:39:36.869688", "modified": "2018-02-17 11:00:05.037716",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Buying", "module": "Buying",
"name": "Purchase Order", "name": "Purchase Order",

View File

@ -1,5 +1,5 @@
{ {
"add_total_row": 0, "add_total_row": 1,
"apply_user_permissions": 1, "apply_user_permissions": 1,
"creation": "2013-06-13 18:45:01", "creation": "2013-06-13 18:45:01",
"disabled": 0, "disabled": 0,
@ -7,7 +7,7 @@
"doctype": "Report", "doctype": "Report",
"idx": 3, "idx": 3,
"is_standard": "Yes", "is_standard": "Yes",
"modified": "2017-02-24 20:16:13.121638", "modified": "2018-02-21 01:28:37.416562",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Buying", "module": "Buying",
"name": "Purchase Order Trends", "name": "Purchase Order Trends",

View File

@ -883,6 +883,7 @@ def get_advance_payment_entries(party_type, party, party_account,
t1.name = t2.parent and t1.{0} = %s and t1.payment_type = %s t1.name = t2.parent and t1.{0} = %s and t1.payment_type = %s
and t1.party_type = %s and t1.party = %s and t1.docstatus = 1 and t1.party_type = %s and t1.party = %s and t1.docstatus = 1
and t2.reference_doctype = %s {1} and t2.reference_doctype = %s {1}
order by t1.posting_date
""".format(party_account_field, reference_condition), """.format(party_account_field, reference_condition),
[party_account, payment_type, party_type, party, order_doctype] + order_list, as_dict=1) [party_account, payment_type, party_type, party, order_doctype] + order_list, as_dict=1)
@ -894,6 +895,7 @@ def get_advance_payment_entries(party_type, party, party_account,
where where
{0} = %s and party_type = %s and party = %s and payment_type = %s {0} = %s and party_type = %s and party = %s and payment_type = %s
and docstatus = 1 and unallocated_amount > 0 and docstatus = 1 and unallocated_amount > 0
order by posting_date
""".format(party_account_field), (party_account, party_type, party, payment_type), as_dict=1) """.format(party_account_field), (party_account, party_type, party, payment_type), as_dict=1)
return list(payment_entries_against_order) + list(unallocated_payment_entries) return list(payment_entries_against_order) + list(unallocated_payment_entries)

View File

@ -52,7 +52,6 @@ Using Price List Rule, you can ultimately define rate or %discount to be applied
Rate or Discount specified in the Pricing Rule will be applied only if above applicability rules are matched with values in the transaction. Rate mentioned in Pricing Rule will be given priority over item's Price List rate. Rate or Discount specified in the Pricing Rule will be applied only if above applicability rules are matched with values in the transaction. Rate mentioned in Pricing Rule will be given priority over item's Price List rate.
<img alt="Applicable Rate" class="screenshot" src="/docs/assets/img/articles/pricing-rule-price.png"> <img alt="Applicable Rate" class="screenshot" src="/docs/assets/img/articles/pricing-rule-price.png">
>>>>>>> Renamed price to rate in pricing rule
#### 2.2 Discount Percentage #### 2.2 Discount Percentage

View File

@ -14,6 +14,10 @@
margin-bottom: -4px; margin-bottom: -4px;
} }
.medical_record-row > * {
z-index: -999;
}
.date-indicator { .date-indicator {
background:none; background:none;
font-size:12px; font-size:12px;
@ -48,7 +52,6 @@
.medical_record-date { .medical_record-date {
padding: 15px; padding: 15px;
padding-right: 0px; padding-right: 0px;
z-index: 1;
} }
#page-medical_record .plot-wrapper { #page-medical_record .plot-wrapper {

View File

@ -11,7 +11,7 @@ app_email = "info@erpnext.com"
app_license = "GNU General Public License (v3)" app_license = "GNU General Public License (v3)"
source_link = "https://github.com/frappe/erpnext" source_link = "https://github.com/frappe/erpnext"
develop_version = '9.x.x-develop' develop_version = '10.x.x-develop'
error_report_email = "support@erpnext.com" error_report_email = "support@erpnext.com"

View File

@ -10,9 +10,7 @@ from frappe import _
from erpnext.utilities.product import get_price, get_qty_in_stock from erpnext.utilities.product import get_price, get_qty_in_stock
from six import string_types from six import string_types
# hub_url = "http://erpnext.hub:8000" hub_url = "https://hubmarket.org"
hub_url = "https://hub.erpnext.org"
# hub_url = "http://192.168.29.145:3000"
class HubSetupError(frappe.ValidationError): pass class HubSetupError(frappe.ValidationError): pass
@ -102,4 +100,4 @@ def reset_hub_settings(last_sync_datetime = ""):
@frappe.whitelist() @frappe.whitelist()
def sync(): def sync():
hub_settings = frappe.get_doc('Hub Settings') hub_settings = frappe.get_doc('Hub Settings')
hub_settings.sync() hub_settings.sync()

View File

@ -202,6 +202,14 @@ class BOM(WebsiteGenerator):
if not from_child_bom: if not from_child_bom:
frappe.msgprint(_("Cost Updated")) frappe.msgprint(_("Cost Updated"))
def update_parent_cost(self):
if self.total_cost:
cost = self.total_cost / self.quantity
frappe.db.sql("""update `tabBOM Item` set rate=%s, amount=stock_qty*%s
where bom_no = %s and docstatus < 2 and parenttype='BOM'""",
(cost, cost, self.name))
def get_bom_unitcost(self, bom_no): def get_bom_unitcost(self, bom_no):
bom = frappe.db.sql("""select name, base_total_cost/quantity as unit_cost from `tabBOM` bom = frappe.db.sql("""select name, base_total_cost/quantity as unit_cost from `tabBOM`
where is_active = 1 and name = %s""", bom_no, as_dict=1) where is_active = 1 and name = %s""", bom_no, as_dict=1)

View File

@ -13,6 +13,7 @@ frappe.treeview_settings["BOM"] = {
disable_add_node: true, disable_add_node: true,
root_label: "BOM", //fieldname from filters root_label: "BOM", //fieldname from filters
get_tree_root: false, get_tree_root: false,
show_expand_all: false,
get_label: function(node) { get_label: function(node) {
if(node.data.qty) { if(node.data.qty) {
return node.data.qty + " x " + node.data.item_code; return node.data.qty + " x " + node.data.item_code;

View File

@ -13,11 +13,14 @@ class BOMUpdateTool(Document):
def replace_bom(self): def replace_bom(self):
self.validate_bom() self.validate_bom()
self.update_new_bom() self.update_new_bom()
bom_list = self.get_parent_boms() bom_list = self.get_parent_boms(self.new_bom)
updated_bom = [] updated_bom = []
for bom in bom_list: for bom in bom_list:
bom_obj = frappe.get_doc("BOM", bom) bom_obj = frappe.get_doc("BOM", bom)
updated_bom = bom_obj.update_cost_and_exploded_items(updated_bom) updated_bom = bom_obj.update_cost_and_exploded_items(updated_bom)
bom_obj.calculate_cost()
bom_obj.update_parent_cost()
bom_obj.db_update()
frappe.msgprint(_("BOM replaced")) frappe.msgprint(_("BOM replaced"))
@ -38,10 +41,18 @@ class BOMUpdateTool(Document):
rate=%s, amount=stock_qty*%s where bom_no = %s and docstatus < 2 and parenttype='BOM'""", rate=%s, amount=stock_qty*%s where bom_no = %s and docstatus < 2 and parenttype='BOM'""",
(self.new_bom, new_bom_unitcost, new_bom_unitcost, self.current_bom)) (self.new_bom, new_bom_unitcost, new_bom_unitcost, self.current_bom))
def get_parent_boms(self): def get_parent_boms(self, bom, bom_list=None):
return [d[0] for d in frappe.db.sql("""select distinct parent if not bom_list:
from `tabBOM Item` where ifnull(bom_no, '') = %s and docstatus < 2 and parenttype='BOM'""", bom_list = []
self.new_bom)]
data = frappe.db.sql(""" select distinct parent from `tabBOM Item`
where ifnull(bom_no, '') = %s and docstatus < 2 and parenttype='BOM'""", bom)
for d in data:
bom_list.append(d[0])
self.get_parent_boms(d[0], bom_list)
return bom_list
@frappe.whitelist() @frappe.whitelist()
def enqueue_update_cost(): def enqueue_update_cost():

View File

@ -504,4 +504,4 @@ execute:frappe.delete_doc('DocType', 'Production Planning Tool', ignore_missing=
erpnext.patches.v10_0.migrate_daily_work_summary_settings_to_daily_work_summary_group erpnext.patches.v10_0.migrate_daily_work_summary_settings_to_daily_work_summary_group
erpnext.patches.v10_0.add_default_cash_flow_mappers erpnext.patches.v10_0.add_default_cash_flow_mappers
erpnext.patches.v11_0.make_quality_inspection_template erpnext.patches.v11_0.make_quality_inspection_template
erpnext.patches.v10_0.update_territory_and_customer_group erpnext.patches.v10_0.update_territory_and_customer_group

View File

@ -92,7 +92,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
item.amount = flt(item.rate * item.qty, precision("amount", item)); item.amount = flt(item.rate * item.qty, precision("amount", item));
item.net_amount = item.amount; item.net_amount = item.amount;
item.item_tax_amount = 0.0; item.item_tax_amount = 0.0;
item.total_weight = flt(item.weight_per_unit * item.qty); item.total_weight = flt(item.weight_per_unit * item.stock_qty);
me.set_in_company_currency(item, ["price_list_rate", "rate", "amount", "net_rate", "net_amount"]); me.set_in_company_currency(item, ["price_list_rate", "rate", "amount", "net_rate", "net_amount"]);
}); });

View File

@ -121,7 +121,6 @@ class Gstr1Report(object):
conditions += """ and SUBSTR(place_of_supply, 1, 2) != SUBSTR(company_gstin, 1, 2) conditions += """ and SUBSTR(place_of_supply, 1, 2) != SUBSTR(company_gstin, 1, 2)
and grand_total > {0} and is_return != 1 and customer in ('{1}')""".\ and grand_total > {0} and is_return != 1 and customer in ('{1}')""".\
format(flt(b2c_limit), "', '".join([frappe.db.escape(c.name) for c in customers])) format(flt(b2c_limit), "', '".join([frappe.db.escape(c.name) for c in customers]))
elif self.filters.get("type_of_business") == "B2C Small": elif self.filters.get("type_of_business") == "B2C Small":
conditions += """ and ( conditions += """ and (
SUBSTR(place_of_supply, 1, 2) = SUBSTR(company_gstin, 1, 2) SUBSTR(place_of_supply, 1, 2) = SUBSTR(company_gstin, 1, 2)

View File

@ -258,17 +258,22 @@ erpnext.pos.PointOfSale = class PointOfSale {
if (field == 'qty' && value < 0) { if (field == 'qty' && value < 0) {
frappe.msgprint(__("Quantity must be positive")); frappe.msgprint(__("Quantity must be positive"));
value = item.qty; value = item.qty;
} else {
item[field] = value;
if (field == "serial_no" && value) {
let serial_nos = value.split("\n");
item["qty"] = serial_nos.filter(d => {
return d!=="";
}).length;
}
} }
if (field) { return this.frm.script_manager.trigger('qty', item.doctype, item.name)
return frappe.model.set_value(item.doctype, item.name, field, value) .then(() => {
.then(() => this.frm.script_manager.trigger('qty', item.doctype, item.name)) if (field === 'qty' && item.qty === 0) {
.then(() => { frappe.model.clear_doc(item.doctype, item.name);
if (field === 'qty' && item.qty === 0) { }
frappe.model.clear_doc(item.doctype, item.name); })
}
})
}
return Promise.resolve(); return Promise.resolve();
} }
@ -285,24 +290,13 @@ erpnext.pos.PointOfSale = class PointOfSale {
} }
submit_sales_invoice() { submit_sales_invoice() {
var is_saved = 0; this.frm.savesubmit()
if(!this.frm.doc.__islocal){ .then((r) => {
is_saved = 1; if (r && r.doc) {
} this.frm.doc.docstatus = r.doc.docstatus;
frappe.confirm(__("Permanently Submit {0}?", [this.frm.doc.name]), () => {
frappe.call({
method: 'erpnext.selling.page.point_of_sale.point_of_sale.submit_invoice',
freeze: true,
args: {
doc: this.frm.doc,
is_saved: is_saved
}
}).then(r => {
if(r.message) {
this.frm.doc = r.message;
frappe.show_alert({ frappe.show_alert({
indicator: 'green', indicator: 'green',
message: __(`Sales invoice ${r.message.name} created succesfully`) message: __(`Sales invoice ${r.doc.name} created succesfully`)
}); });
this.toggle_editing(); this.toggle_editing();
@ -310,21 +304,22 @@ erpnext.pos.PointOfSale = class PointOfSale {
this.set_primary_action_in_modal(); this.set_primary_action_in_modal();
} }
}); });
});
} }
set_primary_action_in_modal() { set_primary_action_in_modal() {
this.frm.msgbox = frappe.msgprint( if (!this.frm.msgbox) {
`<a class="btn btn-primary" onclick="cur_frm.print_preview.printit(true)" style="margin-right: 5px;"> this.frm.msgbox = frappe.msgprint(
${__('Print')}</a> `<a class="btn btn-primary" onclick="cur_frm.print_preview.printit(true)" style="margin-right: 5px;">
<a class="btn btn-default"> ${__('Print')}</a>
${__('New')}</a>` <a class="btn btn-default">
); ${__('New')}</a>`
);
$(this.frm.msgbox.body).find('.btn-default').on('click', () => { $(this.frm.msgbox.body).find('.btn-default').on('click', () => {
this.frm.msgbox.hide(); this.frm.msgbox.hide();
this.make_new_invoice(); this.make_new_invoice();
}) })
}
} }
change_pos_profile() { change_pos_profile() {
@ -493,11 +488,6 @@ erpnext.pos.PointOfSale = class PointOfSale {
// //
// }).addClass('visible-xs'); // }).addClass('visible-xs');
this.page.add_menu_item(__("Form View"), function () {
frappe.model.sync(me.frm.doc);
frappe.set_route("Form", me.frm.doc.doctype, me.frm.doc.name);
});
this.page.add_menu_item(__("POS Profile"), function () { this.page.add_menu_item(__("POS Profile"), function () {
frappe.set_route('List', 'POS Profile'); frappe.set_route('List', 'POS Profile');
}); });
@ -606,6 +596,7 @@ class POSCart {
this.$taxes_and_totals.html(this.get_taxes_and_totals()); this.$taxes_and_totals.html(this.get_taxes_and_totals());
this.numpad && this.numpad.reset_value(); this.numpad && this.numpad.reset_value();
this.customer_field.set_value(""); this.customer_field.set_value("");
this.frm.msgbox = "";
this.$discount_amount.find('input:text').val(''); this.$discount_amount.find('input:text').val('');
this.wrapper.find('.grand-total-value').text( this.wrapper.find('.grand-total-value').text(

View File

@ -90,23 +90,6 @@ def get_conditions(item_code, serial_no, batch_no, barcode):
return '%%%s%%'%(frappe.db.escape(item_code)), condition return '%%%s%%'%(frappe.db.escape(item_code)), condition
@frappe.whitelist()
def submit_invoice(doc,is_saved):
if isinstance(doc, string_types):
args = json.loads(doc)
if(cint(is_saved) == 1):
doc = frappe.get_doc('Sales Invoice',args["name"])
else:
doc = frappe.new_doc('Sales Invoice')
doc.update(args)
doc.run_method("set_missing_values")
doc.run_method("calculate_taxes_and_totals")
doc.submit()
return doc
def get_item_group_condition(pos_profile): def get_item_group_condition(pos_profile):
cond = "and 1=1" cond = "and 1=1"
item_groups = get_item_groups(pos_profile) item_groups = get_item_groups(pos_profile)

View File

@ -1,5 +1,5 @@
{ {
"add_total_row": 0, "add_total_row": 1,
"apply_user_permissions": 1, "apply_user_permissions": 1,
"creation": "2013-06-07 16:01:16", "creation": "2013-06-07 16:01:16",
"disabled": 0, "disabled": 0,
@ -7,7 +7,7 @@
"doctype": "Report", "doctype": "Report",
"idx": 3, "idx": 3,
"is_standard": "Yes", "is_standard": "Yes",
"modified": "2017-02-24 20:15:33.967044", "modified": "2018-02-21 01:28:14.928929",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Selling", "module": "Selling",
"name": "Quotation Trends", "name": "Quotation Trends",

View File

@ -1,5 +1,5 @@
{ {
"add_total_row": 0, "add_total_row": 1,
"apply_user_permissions": 1, "apply_user_permissions": 1,
"creation": "2013-06-13 18:43:30", "creation": "2013-06-13 18:43:30",
"disabled": 0, "disabled": 0,
@ -7,7 +7,7 @@
"doctype": "Report", "doctype": "Report",
"idx": 3, "idx": 3,
"is_standard": "Yes", "is_standard": "Yes",
"modified": "2017-02-24 20:15:01.634392", "modified": "2018-02-20 08:05:46.191588",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Selling", "module": "Selling",
"name": "Sales Order Trends", "name": "Sales Order Trends",

View File

@ -13,10 +13,8 @@ def execute(filters=None):
entries = get_entries(filters) entries = get_entries(filters)
item_details = get_item_details() item_details = get_item_details()
data = [] data = []
total_contribution_amount = 0
for d in entries:
total_contribution_amount += flt(d.contribution_amt)
for d in entries:
data.append([ data.append([
d.name, d.customer, d.territory, d.posting_date, d.item_code, d.name, d.customer, d.territory, d.posting_date, d.item_code,
item_details.get(d.item_code, {}).get("item_group"), item_details.get(d.item_code, {}).get("brand"), item_details.get(d.item_code, {}).get("item_group"), item_details.get(d.item_code, {}).get("brand"),
@ -25,8 +23,6 @@ def execute(filters=None):
if data: if data:
total_row = [""]*len(data[0]) total_row = [""]*len(data[0])
total_row[0] = _("Total")
total_row[-1] = total_contribution_amount
data.append(total_row) data.append(total_row)
return columns, data return columns, data

View File

@ -163,9 +163,9 @@ def notify_customers(docname, date, driver, vehicle, sender_email, delivery_noti
if delivery_stop_info.delivery_notes: if delivery_stop_info.delivery_notes:
delivery_notes = (delivery_stop_info.delivery_notes).split(",") delivery_notes = (delivery_stop_info.delivery_notes).split(",")
default_print_format = frappe.get_meta('Delivery Note').default_print_format
attachments = [] attachments = []
for delivery_note in delivery_notes: for delivery_note in delivery_notes:
default_print_format = frappe.get_value('Delivery Note', delivery_note, 'default_print_format')
attachments.append( attachments.append(
frappe.attach_print('Delivery Note', frappe.attach_print('Delivery Note',
delivery_note, delivery_note,

View File

@ -109,9 +109,9 @@ class LandedCostVoucher(Document):
# set valuation amount in pr item # set valuation amount in pr item
doc.update_valuation_rate("items") doc.update_valuation_rate("items")
# save will update landed_cost_voucher_amount and voucher_amount in PR, # db_update will update and save landed_cost_voucher_amount and voucher_amount in PR
# as those fields are allowed to edit after submit for item in doc.get("items"):
doc.save() item.db_update()
# update latest valuation rate in serial no # update latest valuation rate in serial no
self.update_rate_in_serial_no(doc) self.update_rate_in_serial_no(doc)

View File

@ -1,5 +1,5 @@
{ {
"add_total_row": 0, "add_total_row": 1,
"apply_user_permissions": 1, "apply_user_permissions": 1,
"creation": "2013-06-13 18:42:11", "creation": "2013-06-13 18:42:11",
"disabled": 0, "disabled": 0,
@ -7,7 +7,7 @@
"doctype": "Report", "doctype": "Report",
"idx": 3, "idx": 3,
"is_standard": "Yes", "is_standard": "Yes",
"modified": "2017-02-24 20:18:32.793637", "modified": "2018-02-21 01:28:47.049042",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Delivery Note Trends", "name": "Delivery Note Trends",

View File

@ -0,0 +1,30 @@
{
"add_total_row": 0,
"apply_user_permissions": 1,
"creation": "2018-02-17 19:52:16.370979",
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 0,
"is_standard": "Yes",
"modified": "2018-02-19 12:03:53.902167",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item Balance (Simple)",
"owner": "Administrator",
"query": "select a.item_code as \"Item:Link/Item:120\",\n\t a.item_name as \"Item Name::150\",\n\t a.item_group as \"Item Group:Link/Item Group:120\",\n\t a.brand as \"Brand:Link/Brand:120\",\n\t a.description as \"Description::150\",\n\t b.warehouse as \"Warehouse:Link/Warehouse:120\",\n\t b.actual_qty as \"Balance Qty:Float:140\"\n from `tabItem` a left join `tabBin` b\n ON a.item_code = b.item_code",
"ref_doctype": "Bin",
"report_name": "Item Balance (Simple)",
"report_type": "Query Report",
"roles": [
{
"role": "Sales User"
},
{
"role": "Purchase User"
},
{
"role": "Stock User"
}
]
}

View File

@ -1,5 +1,5 @@
{ {
"add_total_row": 0, "add_total_row": 1,
"apply_user_permissions": 1, "apply_user_permissions": 1,
"creation": "2013-06-13 18:45:44", "creation": "2013-06-13 18:45:44",
"disabled": 0, "disabled": 0,
@ -7,7 +7,7 @@
"doctype": "Report", "doctype": "Report",
"idx": 3, "idx": 3,
"is_standard": "Yes", "is_standard": "Yes",
"modified": "2017-02-24 20:16:00.211762", "modified": "2018-02-21 01:28:22.682161",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Purchase Receipt Trends", "name": "Purchase Receipt Trends",

View File

@ -7,8 +7,9 @@
<tr> <tr>
<th style="border: 1px solid #d1d8dd; width: 35%; text-align: left; padding: 5px;">{{ _("Item") }}</th> <th style="border: 1px solid #d1d8dd; width: 35%; text-align: left; padding: 5px;">{{ _("Item") }}</th>
<th style="border: 1px solid #d1d8dd; width: 35%; text-align: left; padding: 5px;">{{ _("Warehouse") }}</th> <th style="border: 1px solid #d1d8dd; width: 35%; text-align: left; padding: 5px;">{{ _("Warehouse") }}</th>
<th style="border: 1px solid #d1d8dd; width: 20%; text-align: right; padding: 5px;">{{ _("Quantity") }}</th> <th style="border: 1px solid #d1d8dd; width: 10%; text-align: right; padding: 5px;">{{ _("Quantity") }}</th>
<th style="border: 1px solid #d1d8dd; width: 10%; text-align: left; padding: 5px;">{{ _("UOM") }}</th> <th style="border: 1px solid #d1d8dd; width: 10%; text-align: left; padding: 5px;">{{ _("UOM") }}</th>
<th style="border: 1px solid #d1d8dd; width: 10%; text-align: left; padding: 5px;">{{ _("Balance Qty") }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -21,6 +22,7 @@
<td style="border: 1px solid #d1d8dd; text-align: left; padding: 5px;">{{ item.warehouse }}</td> <td style="border: 1px solid #d1d8dd; text-align: left; padding: 5px;">{{ item.warehouse }}</td>
<td style="border: 1px solid #d1d8dd; text-align: right; padding: 5px;">{{ item.qty }}</td> <td style="border: 1px solid #d1d8dd; text-align: right; padding: 5px;">{{ item.qty }}</td>
<td style="border: 1px solid #d1d8dd; text-align: left; padding: 5px;">{{ item.uom }}</td> <td style="border: 1px solid #d1d8dd; text-align: left; padding: 5px;">{{ item.uom }}</td>
<td style="border: 1px solid #d1d8dd; text-align: left; padding: 5px;">{{ item.balance_qty }}</td>
</tr> </tr>
{%- endfor %} {%- endfor %}
</tbody> </tbody>

View File

@ -13,6 +13,9 @@ frappe.ui.form.on("Rename Tool", {
}, },
refresh: function(frm) { refresh: function(frm) {
frm.disable_save(); frm.disable_save();
if (!frm.doc.file_to_rename) {
frm.get_field("rename_log").$wrapper.html("");
}
frm.page.set_primary_action(__("Rename"), function() { frm.page.set_primary_action(__("Rename"), function() {
frm.get_field("rename_log").$wrapper.html("<p>Renaming...</p>"); frm.get_field("rename_log").$wrapper.html("<p>Renaming...</p>");
frappe.call({ frappe.call({

View File

@ -17,14 +17,15 @@ frappe.Leaderboard = Class.extend({
this.$sidebar_list = this.page.sidebar.find('ul'); this.$sidebar_list = this.page.sidebar.find('ul');
// const list of doctypes // const list of doctypes
this.doctypes = ["Customer", "Item", "Supplier", "Sales Partner"]; this.doctypes = ["Customer", "Item", "Supplier", "Sales Partner","Sales Person"];
this.timespans = ["Week", "Month", "Quarter", "Year"]; this.timespans = ["Week", "Month", "Quarter", "Year"];
this.desc_fields = ["total_amount", "total_request", "annual_billing", "commission_rate"];
this.filters = { this.filters = {
"Customer": ["total_amount", "total_item_purchased"], "Customer": ["total_sales_amount", "total_qty_sold", "outstanding_amount", ],
"Item": ["total_request", "total_purchase", "avg_price"], "Item": ["total_sales_amount", "total_qty_sold", "total_purchase_amount",
"Supplier": ["annual_billing", "total_unpaid"], "total_qty_purchased", "available_stock_qty", "available_stock_value"],
"Sales Partner": ["commission_rate", "target_qty", "target_amount"], "Supplier": ["total_purchase_amount", "total_qty_purchased", "outstanding_amount"],
"Sales Partner": ["total_sales_amount", "total_commision"],
"Sales Person": ["total_sales_amount"],
}; };
// for saving current selected filters // for saving current selected filters
@ -58,14 +59,24 @@ frappe.Leaderboard = Class.extend({
this.get_sidebar_item(doctype).appendTo(this.$sidebar_list); this.get_sidebar_item(doctype).appendTo(this.$sidebar_list);
}); });
this.company_select = this.page.add_field({
fieldname: 'company',
label: __('Company'),
fieldtype:'Link',
options:'Company',
default:frappe.defaults.get_default('company'),
reqd: 1,
change: function() {
me.options.selected_company = this.value;
me.make_request($container);
}
});
this.timespan_select = this.page.add_select(__("Timespan"), this.timespan_select = this.page.add_select(__("Timespan"),
this.timespans.map(d => { this.timespans.map(d => {
return {"label": __(d), value: d } return {"label": __(d), value: d }
}) })
); );
// this.timespan_select.val(this.timespans[1]);
this.type_select = this.page.add_select(__("Type"), this.type_select = this.page.add_select(__("Type"),
me.options.selected_filter.map(d => { me.options.selected_filter.map(d => {
return {"label": __(frappe.model.unscrub(d)), value: d } return {"label": __(frappe.model.unscrub(d)), value: d }
@ -76,6 +87,7 @@ frappe.Leaderboard = Class.extend({
let $li = $(this); let $li = $(this);
let doctype = $li.find('span').html(); let doctype = $li.find('span').html();
me.options.selected_company = frappe.defaults.get_default('company');
me.options.selected_doctype = doctype; me.options.selected_doctype = doctype;
me.options.selected_filter = me.filters[doctype]; me.options.selected_filter = me.filters[doctype];
me.options.selected_filter_item = me.filters[doctype][0]; me.options.selected_filter_item = me.filters[doctype][0];
@ -114,16 +126,18 @@ frappe.Leaderboard = Class.extend({
}); });
}, },
get_leaderboard: function (notify, $container, start=0) { get_leaderboard: function (notify, $container) {
var me = this; var me = this;
if(!me.options.selected_company) {
frappe.throw(__("Please select Company"));
}
frappe.call({ frappe.call({
method: "erpnext.utilities.page.leaderboard.leaderboard.get_leaderboard", method: "erpnext.utilities.page.leaderboard.leaderboard.get_leaderboard",
args: { args: {
doctype: me.options.selected_doctype, doctype: me.options.selected_doctype,
timespan: me.options.selected_timespan, timespan: me.options.selected_timespan,
company: me.options.selected_company,
field: me.options.selected_filter_item, field: me.options.selected_filter_item,
start: start
}, },
callback: function (r) { callback: function (r) {
let results = r.message || []; let results = r.message || [];
@ -256,28 +270,27 @@ frappe.Leaderboard = Class.extend({
get_item_html: function (item) { get_item_html: function (item) {
var me = this; var me = this;
const _selected_filter = me.options.selected_filter const company = me.options.selected_company;
.map(i => frappe.model.unscrub(i)); const currency = frappe.get_doc(":Company", company).default_currency;
const fields = ['name', me.options.selected_filter_item]; const fields = ['name','value'];
const html = const html =
`<div class="list-item"> `<div class="list-item">
${ ${
fields.map(filter => { fields.map(col => {
const col = frappe.model.unscrub(filter); let val = item[col];
let val = item[filter]; if(col=="name") {
if (col === "Modified") { var formatted_value = `<a class="grey list-id ellipsis"
val = comment_when(val); href="#Form/${me.options.selected_doctype}/${item["name"]}"> ${val} </a>`
} else {
var formatted_value = `<span class="text-muted ellipsis">
${(me.options.selected_filter_item.indexOf('qty') == -1) ? format_currency(val, currency) : val}</span>`
} }
return ( return (
`<div class="list-item_content ellipsis list-item__content--flex-2 `<div class="list-item_content ellipsis list-item__content--flex-2
${(col !== "Name" && col !== "Modified") ? "hidden-xs" : ""} ${(col == "value") ? "text-right" : ""}">
${(col && _selected_filter.indexOf(col) !== -1) ? "text-right" : ""}"> ${formatted_value}
${
col === "Name"
? `<a class="grey list-id ellipsis" href="${item["href"]}"> ${val} </a>`
: `<span class="text-muted ellipsis"> ${val}</span>`
}
</div>`); </div>`);
}).join("") }).join("")
} }

View File

@ -3,148 +3,141 @@
from __future__ import unicode_literals, print_function from __future__ import unicode_literals, print_function
import frappe import frappe
import json from frappe.utils import add_to_date
from operator import itemgetter
from frappe.utils import add_to_date, fmt_money
from erpnext.accounts.party import get_dashboard_info
from erpnext.accounts.utils import get_currency_precision
@frappe.whitelist() @frappe.whitelist()
def get_leaderboard(doctype, timespan, field, start=0): def get_leaderboard(doctype, timespan, company, field):
"""return top 10 items for that doctype based on conditions""" """return top 10 items for that doctype based on conditions"""
from_date = get_from_date(timespan)
filters = {"modified":(">=", get_date_from_string(timespan))} records = []
items = []
if doctype == "Customer": if doctype == "Customer":
items = get_all_customers(doctype, filters, [], field) records = get_all_customers(from_date, company, field)
elif doctype == "Item": elif doctype == "Item":
items = get_all_items(doctype, filters, [], field) records = get_all_items(from_date, company, field)
elif doctype == "Supplier": elif doctype == "Supplier":
items = get_all_suppliers(doctype, filters, [], field) records = get_all_suppliers(from_date, company, field)
elif doctype == "Sales Partner": elif doctype == "Sales Partner":
items = get_all_sales_partner(doctype, filters, [], field) records = get_all_sales_partner(from_date, company, field)
elif doctype == "Sales Person":
records = get_all_sales_person(from_date, company)
if len(items) > 0: return records
return items
return []
def get_all_customers(doctype, filters, items, field, start=0, limit=20): def get_all_customers(from_date, company, field):
"""return all customers""" if field == "outstanding_amount":
return frappe.db.sql("""
select customer as name, sum(outstanding_amount) as value
FROM `tabSales Invoice`
where docstatus = 1 and posting_date >= %s and company = %s
group by customer
order by value DESC
limit 20
""", (from_date, company), as_dict=1)
else:
if field == "total_sales_amount":
select_field = "sum(so_item.base_net_amount)"
elif field == "total_qty_sold":
select_field = "sum(so_item.stock_qty)"
x = frappe.get_list(doctype, filters=filters, limit_start=start, limit_page_length=limit) return frappe.db.sql("""
select so.customer as name, {0} as value
FROM `tabSales Order` as so JOIN `tabSales Order Item` as so_item
ON so.name = so_item.parent
where so.docstatus = 1 and so.transaction_date >= %s and so.company = %s
group by so.customer
order by value DESC
limit 20
""".format(select_field), (from_date, company), as_dict=1)
for val in x: def get_all_items(from_date, company, field):
y = dict(frappe.db.sql('''select name, grand_total from `tabSales Invoice`\ if field in ("available_stock_qty", "available_stock_value"):
where customer = %s and docstatus != 2''', (val.name))) return frappe.db.sql("""
invoice_list = y.keys() select item_code as name, {0} as value
if len(invoice_list) > 0: from tabBin
item_count = frappe.db.sql('''select count(name) from `tabSales Invoice Item` where parent in (%s)''' % ", ".join( group by item_code
['%s'] * len(invoice_list)), tuple(invoice_list)) order by value desc
limit 20
""".format("sum(actual_qty)" if field=="available_stock_qty" else "sum(stock_value)"), as_dict=1)
else:
if field == "total_sales_amount":
select_field = "sum(order_item.base_net_amount)"
select_doctype = "Sales Order"
elif field == "total_purchase_amount":
select_field = "sum(order_item.base_net_amount)"
select_doctype = "Purchase Order"
elif field == "total_qty_sold":
select_field = "sum(order_item.stock_qty)"
select_doctype = "Sales Order"
elif field == "total_qty_purchased":
select_field = "sum(order_item.stock_qty)"
select_doctype = "Purchase Order"
value = 0 return frappe.db.sql("""
if(field=="total_amount"): select order_item.item_code as name, {0} as value
value = sum(y.values()) from `tab{1}` sales_order join `tab{1} Item` as order_item
elif(field=="total_item_purchased"): on sales_order.name = order_item.parent
value = sum(destructure_tuple_of_tuples(item_count)) where sales_order.docstatus = 1
and sales_order.company = %s and sales_order.transaction_date >= %s
group by order_item.item_code
order by value desc
limit 20
""".format(select_field, select_doctype), (company, from_date), as_dict=1)
item_obj = {"name": val.name, def get_all_suppliers(from_date, company, field):
"total_amount": get_formatted_value(sum(y.values())), if field == "outstanding_amount":
"total_item_purchased": sum(destructure_tuple_of_tuples(item_count)), return frappe.db.sql("""
"href":"#Form/Customer/" + val.name, select supplier as name, sum(outstanding_amount) as value
"value": value} FROM `tabPurchase Invoice`
items.append(item_obj) where docstatus = 1 and posting_date >= %s and company = %s
group by supplier
order by value DESC
limit 20""", (from_date, company), as_dict=1)
else:
if field == "total_purchase_amount":
select_field = "sum(purchase_order_item.base_net_amount)"
elif field == "total_qty_purchased":
select_field = "sum(purchase_order_item.stock_qty)"
items.sort(key=lambda k: k['value'], reverse=True) return frappe.db.sql("""
return items select purchase_order.supplier as name, {0} as value
FROM `tabPurchase Order` as purchase_order LEFT JOIN `tabPurchase Order Item`
as purchase_order_item ON purchase_order.name = purchase_order_item.parent
where purchase_order.docstatus = 1 and purchase_order.modified >= %s
and purchase_order.company = %s
group by purchase_order.supplier
order by value DESC
limit 20""".format(select_field), (from_date, company), as_dict=1)
def get_all_items(doctype, filters, items, field, start=0, limit=20): def get_all_sales_partner(from_date, company, field):
"""return all items""" if field == "total_sales_amount":
select_field = "sum(base_net_total)"
elif field == "total_commission":
select_field = "sum(total_commission)"
x = frappe.get_list(doctype, filters=filters, limit_start=start, limit_page_length=limit) return frappe.db.sql("""
for val in x: select sales_partner as name, {0} as value
data = frappe.db.sql('''select item_code from `tabMaterial Request Item` where item_code = %s''', (val.name), as_list=1) from `tabSales Order`
requests = destructure_tuple_of_tuples(data) where ifnull(sales_partner, '') != '' and docstatus = 1
data = frappe.db.sql('''select price_list_rate from `tabItem Price` where item_code = %s''', (val.name), as_list=1) and transaction_date >= %s and company = %s
avg_price = get_avg(destructure_tuple_of_tuples(data)) group by sales_partner
data = frappe.db.sql('''select item_code from `tabPurchase Invoice Item` where item_code = %s''', (val.name), as_list=1) order by value DESC
purchases = destructure_tuple_of_tuples(data) limit 20
""".format(select_field), (from_date, company), as_dict=1)
value = 0 def get_all_sales_person(from_date, company):
if(field=="total_request"): return frappe.db.sql("""
value = len(requests) select sales_team.sales_person as name, sum(sales_order.base_net_total) as value
elif(field=="total_purchase"): from `tabSales Order` as sales_order join `tabSales Team` as sales_team
value = len(purchases) on sales_order.name = sales_team.parent and sales_team.parenttype = 'Sales Order'
elif(field=="avg_price"): where sales_order.docstatus = 1
value=avg_price and sales_order.transaction_date >= %s
item_obj = {"name": val.name, and sales_order.company = %s
"total_request":len(requests), group by sales_team.sales_person
"total_purchase": len(purchases), order by value DESC
"avg_price": get_formatted_value(avg_price), limit 20
"href":"#Form/Item/" + val.name, """, (from_date, company), as_dict=1)
"value": value}
items.append(item_obj)
items.sort(key=lambda k: k['value'], reverse=True) def get_from_date(seleted_timespan):
return items
def get_all_suppliers(doctype, filters, items, field, start=0, limit=20):
"""return all suppliers"""
x = frappe.get_list(doctype, filters=filters, limit_start=start, limit_page_length=limit)
for val in x:
info = get_dashboard_info(doctype, val.name)
value = 0
if(field=="annual_billing"):
value = info["billing_this_year"]
elif(field=="total_unpaid"):
value = abs(info["total_unpaid"])
item_obj = {"name": val.name,
"annual_billing": get_formatted_value(info["billing_this_year"]),
"total_unpaid": get_formatted_value(abs(info["total_unpaid"])),
"href":"#Form/Supplier/" + val.name,
"value": value}
items.append(item_obj)
items.sort(key=lambda k: k['value'], reverse=True)
return items
def get_all_sales_partner(doctype, filters, items, field, start=0, limit=20):
"""return all sales partner"""
x = frappe.get_list(doctype, fields=["name", "commission_rate", "modified"], filters=filters, limit_start=start, limit_page_length=limit)
for val in x:
y = frappe.db.sql('''select target_qty, target_amount from `tabTarget Detail` where parent = %s''', (val.name), as_dict=1)
target_qty = sum([f["target_qty"] for f in y])
target_amount = sum([f["target_amount"] for f in y])
value = 0
if(field=="commission_rate"):
value = val.commission_rate
elif(field=="target_qty"):
value = target_qty
elif(field=="target_amount"):
value = target_qty
item_obj = {"name": val.name,
"commission_rate": get_formatted_value(val.commission_rate, False),
"target_qty": target_qty,
"target_amount": get_formatted_value(target_qty),
"href":"#Form/Sales Partner/" + val.name,
"value": value}
items.append(item_obj)
items.sort(key=lambda k: k['value'], reverse=True)
return items
def destructure_tuple_of_tuples(tup_of_tup):
"""return tuple(tuples) as list"""
return [y for x in tup_of_tup for y in x]
def get_date_from_string(seleted_timespan):
"""return string for ex:this week as date:string""" """return string for ex:this week as date:string"""
days = months = years = 0 days = months = years = 0
if "month" == seleted_timespan.lower(): if "month" == seleted_timespan.lower():
@ -156,24 +149,5 @@ def get_date_from_string(seleted_timespan):
else: else:
days = -7 days = -7
return add_to_date(None, years=years, months=months, days=days, as_string=True, as_datetime=True) return add_to_date(None, years=years, months=months, days=days,
as_string=True, as_datetime=True)
def get_filter_list(selected_filter):
"""return list of keys"""
return map((lambda y : y["field"]), filter(lambda x : not (x["field"] == "name" or x["field"] == "modified"), selected_filter))
def get_avg(items):
"""return avg of list items"""
length = len(items)
if length > 0:
return sum(items) / length
return 0
def get_formatted_value(value, add_symbol=True):
"""return formatted value"""
if not add_symbol:
return '{:.{pre}f}'.format(value, pre=(get_currency_precision() or 2))
currency_precision = get_currency_precision() or 2
company = frappe.db.get_default("company")
currency = frappe.get_doc("Company", company).default_currency or frappe.boot.sysdefaults.currency
return fmt_money(value, currency_precision, currency)

View File

@ -45,7 +45,7 @@ def get_slide_settings():
help=_("Set a sales goal you'd like to achieve for your company."), help=_("Set a sales goal you'd like to achieve for your company."),
fields=[ fields=[
{"fieldtype":"Currency", "fieldname":"monthly_sales_target", {"fieldtype":"Currency", "fieldname":"monthly_sales_target",
"label":_("Monthly Sales Target (" + currency + ")")}, "label":_("Monthly Sales Target (" + currency + ")"), "reqd":1},
], ],
submit_method="erpnext.utilities.user_progress_utils.set_sales_target", submit_method="erpnext.utilities.user_progress_utils.set_sales_target",
done_state_title=_("Go to " + company), done_state_title=_("Go to " + company),