mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-28 22:28:24 +00:00
update translation strings #1403
This commit is contained in:
@@ -417,8 +417,7 @@ class AccountsController(TransactionBase):
|
||||
ref_amt = flt(frappe.db.get_value(ref_dt + " Item",
|
||||
item.get(item_ref_dn), based_on), self.precision(based_on, item))
|
||||
if not ref_amt:
|
||||
frappe.msgprint(_("As amount for item") + ": " + item.item_code + _(" in ") +
|
||||
ref_dt + _(" is zero, system will not check for over-billed"))
|
||||
frappe.msgprint(_("Warning: System will not check overbilling since amount for Item {0} in {1} is zero").format(item.item_code, ref_dt))
|
||||
else:
|
||||
already_billed = frappe.db.sql("""select sum(%s) from `tab%s`
|
||||
where %s=%s and docstatus=1 and parent != %s""" %
|
||||
|
||||
@@ -14,22 +14,22 @@ class BuyingController(StockController):
|
||||
def onload_post_render(self):
|
||||
# contact, address, item details
|
||||
self.set_missing_values()
|
||||
|
||||
|
||||
def validate(self):
|
||||
super(BuyingController, self).validate()
|
||||
if getattr(self, "supplier", None) and not self.supplier_name:
|
||||
self.supplier_name = frappe.db.get_value("Supplier",
|
||||
self.supplier_name = frappe.db.get_value("Supplier",
|
||||
self.supplier, "supplier_name")
|
||||
self.is_item_table_empty()
|
||||
self.validate_stock_or_nonstock_items()
|
||||
self.validate_warehouse()
|
||||
|
||||
|
||||
def set_missing_values(self, for_validate=False):
|
||||
super(BuyingController, self).set_missing_values(for_validate)
|
||||
|
||||
self.set_supplier_from_item_default()
|
||||
self.set_price_list_currency("Buying")
|
||||
|
||||
|
||||
# set contact and address details for supplier, if they are not mentioned
|
||||
if getattr(self, "supplier", None):
|
||||
self.update_if_missing(get_party_details(self.supplier, party_type="Supplier"))
|
||||
@@ -45,24 +45,24 @@ class BuyingController(StockController):
|
||||
if supplier:
|
||||
self.supplier = supplier
|
||||
break
|
||||
|
||||
|
||||
def validate_warehouse(self):
|
||||
from erpnext.stock.utils import validate_warehouse_company
|
||||
|
||||
warehouses = list(set([d.warehouse for d in
|
||||
|
||||
warehouses = list(set([d.warehouse for d in
|
||||
self.get(self.fname) if getattr(d, "warehouse", None)]))
|
||||
|
||||
|
||||
for w in warehouses:
|
||||
validate_warehouse_company(w, self.company)
|
||||
|
||||
def validate_stock_or_nonstock_items(self):
|
||||
if not self.get_stock_items():
|
||||
tax_for_valuation = [d.account_head for d in
|
||||
self.get("other_charges")
|
||||
tax_for_valuation = [d.account_head for d in
|
||||
self.get("other_charges")
|
||||
if d.category in ["Valuation", "Valuation and Total"]]
|
||||
if tax_for_valuation:
|
||||
frappe.msgprint(_("""Tax Category can not be 'Valuation' or 'Valuation and Total' as all items are non-stock items"""), raise_exception=1)
|
||||
|
||||
frappe.throw(_("Tax Category can not be 'Valuation' or 'Valuation and Total' as all items are non-stock items"))
|
||||
|
||||
def set_total_in_words(self):
|
||||
from frappe.utils import money_in_words
|
||||
company_currency = get_company_currency(self.company)
|
||||
@@ -71,12 +71,12 @@ class BuyingController(StockController):
|
||||
if self.meta.get_field("in_words_import"):
|
||||
self.in_words_import = money_in_words(self.grand_total_import,
|
||||
self.currency)
|
||||
|
||||
|
||||
def calculate_taxes_and_totals(self):
|
||||
self.other_fname = "other_charges"
|
||||
super(BuyingController, self).calculate_taxes_and_totals()
|
||||
self.calculate_total_advance("Purchase Invoice", "advance_allocation_details")
|
||||
|
||||
|
||||
def calculate_item_values(self):
|
||||
for item in self.item_doclist:
|
||||
self.round_floats_in(item)
|
||||
@@ -86,7 +86,7 @@ class BuyingController(StockController):
|
||||
elif not item.rate:
|
||||
item.rate = flt(item.price_list_rate * (1.0 - (item.discount_percentage / 100.0)),
|
||||
self.precision("rate", item))
|
||||
|
||||
|
||||
item.amount = flt(item.rate * item.qty,
|
||||
self.precision("amount", item))
|
||||
item.item_tax_amount = 0.0;
|
||||
@@ -94,19 +94,19 @@ class BuyingController(StockController):
|
||||
self._set_in_company_currency(item, "amount", "base_amount")
|
||||
self._set_in_company_currency(item, "price_list_rate", "base_price_list_rate")
|
||||
self._set_in_company_currency(item, "rate", "base_rate")
|
||||
|
||||
|
||||
|
||||
|
||||
def calculate_net_total(self):
|
||||
self.net_total = self.net_total_import = 0.0
|
||||
|
||||
for item in self.item_doclist:
|
||||
self.net_total += item.base_amount
|
||||
self.net_total_import += item.amount
|
||||
|
||||
|
||||
self.round_floats_in(self, ["net_total", "net_total_import"])
|
||||
|
||||
|
||||
def calculate_totals(self):
|
||||
self.grand_total = flt(self.tax_doclist[-1].total if self.tax_doclist
|
||||
self.grand_total = flt(self.tax_doclist[-1].total if self.tax_doclist
|
||||
else self.net_total, self.precision("grand_total"))
|
||||
self.grand_total_import = flt(self.grand_total / self.conversion_rate,
|
||||
self.precision("grand_total_import"))
|
||||
@@ -116,28 +116,28 @@ class BuyingController(StockController):
|
||||
|
||||
if self.meta.get_field("rounded_total"):
|
||||
self.rounded_total = _round(self.grand_total)
|
||||
|
||||
|
||||
if self.meta.get_field("rounded_total_import"):
|
||||
self.rounded_total_import = _round(self.grand_total_import)
|
||||
|
||||
|
||||
if self.meta.get_field("other_charges_added"):
|
||||
self.other_charges_added = flt(sum([flt(d.tax_amount) for d in self.tax_doclist
|
||||
if d.add_deduct_tax=="Add" and d.category in ["Valuation and Total", "Total"]]),
|
||||
self.other_charges_added = flt(sum([flt(d.tax_amount) for d in self.tax_doclist
|
||||
if d.add_deduct_tax=="Add" and d.category in ["Valuation and Total", "Total"]]),
|
||||
self.precision("other_charges_added"))
|
||||
|
||||
|
||||
if self.meta.get_field("other_charges_deducted"):
|
||||
self.other_charges_deducted = flt(sum([flt(d.tax_amount) for d in self.tax_doclist
|
||||
if d.add_deduct_tax=="Deduct" and d.category in ["Valuation and Total", "Total"]]),
|
||||
self.other_charges_deducted = flt(sum([flt(d.tax_amount) for d in self.tax_doclist
|
||||
if d.add_deduct_tax=="Deduct" and d.category in ["Valuation and Total", "Total"]]),
|
||||
self.precision("other_charges_deducted"))
|
||||
|
||||
|
||||
if self.meta.get_field("other_charges_added_import"):
|
||||
self.other_charges_added_import = flt(self.other_charges_added /
|
||||
self.other_charges_added_import = flt(self.other_charges_added /
|
||||
self.conversion_rate, self.precision("other_charges_added_import"))
|
||||
|
||||
|
||||
if self.meta.get_field("other_charges_deducted_import"):
|
||||
self.other_charges_deducted_import = flt(self.other_charges_deducted /
|
||||
self.other_charges_deducted_import = flt(self.other_charges_deducted /
|
||||
self.conversion_rate, self.precision("other_charges_deducted_import"))
|
||||
|
||||
|
||||
def calculate_outstanding_amount(self):
|
||||
if self.doctype == "Purchase Invoice" and self.docstatus == 0:
|
||||
self.total_advance = flt(self.total_advance,
|
||||
@@ -146,17 +146,17 @@ class BuyingController(StockController):
|
||||
self.precision("write_off_amount")), self.precision("total_amount_to_pay"))
|
||||
self.outstanding_amount = flt(self.total_amount_to_pay - self.total_advance,
|
||||
self.precision("outstanding_amount"))
|
||||
|
||||
|
||||
# update valuation rate
|
||||
def update_valuation_rate(self, parentfield):
|
||||
"""
|
||||
item_tax_amount is the total tax amount applied on that item
|
||||
stored for valuation
|
||||
|
||||
stored for valuation
|
||||
|
||||
TODO: rename item_tax_amount to valuation_tax_amount
|
||||
"""
|
||||
stock_items = self.get_stock_items()
|
||||
|
||||
|
||||
stock_items_qty, stock_items_amount = 0, 0
|
||||
last_stock_item_idx = 1
|
||||
for d in self.get(parentfield):
|
||||
@@ -164,47 +164,45 @@ class BuyingController(StockController):
|
||||
stock_items_qty += flt(d.qty)
|
||||
stock_items_amount += flt(d.base_amount)
|
||||
last_stock_item_idx = d.idx
|
||||
|
||||
total_valuation_amount = sum([flt(d.tax_amount) for d in
|
||||
self.get("other_charges")
|
||||
|
||||
total_valuation_amount = sum([flt(d.tax_amount) for d in
|
||||
self.get("other_charges")
|
||||
if d.category in ["Valuation", "Valuation and Total"]])
|
||||
|
||||
|
||||
|
||||
|
||||
valuation_amount_adjustment = total_valuation_amount
|
||||
for i, item in enumerate(self.get(parentfield)):
|
||||
if item.item_code and item.qty and item.item_code in stock_items:
|
||||
item_proportion = flt(item.base_amount) / stock_items_amount if stock_items_amount \
|
||||
else flt(item.qty) / stock_items_qty
|
||||
|
||||
|
||||
if i == (last_stock_item_idx - 1):
|
||||
item.item_tax_amount = flt(valuation_amount_adjustment,
|
||||
item.item_tax_amount = flt(valuation_amount_adjustment,
|
||||
self.precision("item_tax_amount", item))
|
||||
else:
|
||||
item.item_tax_amount = flt(item_proportion * total_valuation_amount,
|
||||
item.item_tax_amount = flt(item_proportion * total_valuation_amount,
|
||||
self.precision("item_tax_amount", item))
|
||||
valuation_amount_adjustment -= item.item_tax_amount
|
||||
|
||||
self.round_floats_in(item)
|
||||
|
||||
|
||||
item.conversion_factor = item.conversion_factor or flt(frappe.db.get_value(
|
||||
"UOM Conversion Detail", {"parent": item.item_code, "uom": item.uom},
|
||||
"UOM Conversion Detail", {"parent": item.item_code, "uom": item.uom},
|
||||
"conversion_factor")) or 1
|
||||
qty_in_stock_uom = flt(item.qty * item.conversion_factor)
|
||||
item.valuation_rate = ((item.base_amount + item.item_tax_amount + item.rm_supp_cost)
|
||||
/ qty_in_stock_uom)
|
||||
else:
|
||||
item.valuation_rate = 0.0
|
||||
|
||||
|
||||
def validate_for_subcontracting(self):
|
||||
if not self.is_subcontracted and self.sub_contracted_items:
|
||||
frappe.msgprint(_("""Please enter whether %s is made for subcontracting or purchasing,
|
||||
in 'Is Subcontracted' field""" % self.doctype), raise_exception=1)
|
||||
|
||||
frappe.throw(_("Please enter 'Is Subcontracted' as Yes or No"))
|
||||
|
||||
if self.doctype == "Purchase Receipt" and self.is_subcontracted=="Yes" \
|
||||
and not self.supplier_warehouse:
|
||||
frappe.msgprint(_("Supplier Warehouse mandatory subcontracted purchase receipt"),
|
||||
raise_exception=1)
|
||||
|
||||
frappe.throw(_("Supplier Warehouse mandatory for sub-contracted Purchase Receipt"))
|
||||
|
||||
def update_raw_materials_supplied(self, raw_material_table):
|
||||
self.set(raw_material_table, [])
|
||||
if self.is_subcontracted=="Yes":
|
||||
@@ -234,30 +232,30 @@ class BuyingController(StockController):
|
||||
"consumed_qty": required_qty,
|
||||
"description": item.description,
|
||||
})
|
||||
|
||||
|
||||
self.append(raw_material_table, rm_doclist)
|
||||
|
||||
|
||||
raw_materials_cost += required_qty * flt(item.rate)
|
||||
|
||||
|
||||
if self.doctype == "Purchase Receipt":
|
||||
d.rm_supp_cost = raw_materials_cost
|
||||
|
||||
def get_items_from_default_bom(self, item_code):
|
||||
bom_items = frappe.db.sql("""select t2.item_code, t2.qty_consumed_per_unit,
|
||||
t2.rate, t2.stock_uom, t2.name, t2.description
|
||||
from `tabBOM` t1, `tabBOM Item` t2
|
||||
where t2.parent = t1.name and t1.item = %s and t1.is_default = 1
|
||||
bom_items = frappe.db.sql("""select t2.item_code, t2.qty_consumed_per_unit,
|
||||
t2.rate, t2.stock_uom, t2.name, t2.description
|
||||
from `tabBOM` t1, `tabBOM Item` t2
|
||||
where t2.parent = t1.name and t1.item = %s and t1.is_default = 1
|
||||
and t1.docstatus = 1 and t1.is_active = 1""", item_code, as_dict=1)
|
||||
if not bom_items:
|
||||
msgprint(_("No default BOM exists for item: ") + item_code, raise_exception=1)
|
||||
|
||||
msgprint(_("No default BOM exists for Item {0}").format(item_code), raise_exception=1)
|
||||
|
||||
return bom_items
|
||||
|
||||
@property
|
||||
def sub_contracted_items(self):
|
||||
if not hasattr(self, "_sub_contracted_items"):
|
||||
self._sub_contracted_items = []
|
||||
item_codes = list(set(item.item_code for item in
|
||||
item_codes = list(set(item.item_code for item in
|
||||
self.get(self.fname)))
|
||||
if item_codes:
|
||||
self._sub_contracted_items = [r[0] for r in frappe.db.sql("""select name
|
||||
@@ -265,12 +263,12 @@ class BuyingController(StockController):
|
||||
(", ".join((["%s"]*len(item_codes))),), item_codes)]
|
||||
|
||||
return self._sub_contracted_items
|
||||
|
||||
|
||||
@property
|
||||
def purchase_items(self):
|
||||
if not hasattr(self, "_purchase_items"):
|
||||
self._purchase_items = []
|
||||
item_codes = list(set(item.item_code for item in
|
||||
item_codes = list(set(item.item_code for item in
|
||||
self.get(self.fname)))
|
||||
if item_codes:
|
||||
self._purchase_items = [r[0] for r in frappe.db.sql("""select name
|
||||
@@ -282,4 +280,4 @@ class BuyingController(StockController):
|
||||
|
||||
def is_item_table_empty(self):
|
||||
if not len(self.get(self.fname)):
|
||||
frappe.throw(_("Item table can not be blank"))
|
||||
frappe.throw(_("Item table can not be blank"))
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import cint, flt, comma_or, _round, cstr
|
||||
from frappe.utils import cint, flt, _round, cstr
|
||||
from erpnext.setup.utils import get_company_currency
|
||||
from frappe import msgprint, _
|
||||
from frappe import _, throw
|
||||
|
||||
from erpnext.controllers.stock_controller import StockController
|
||||
|
||||
@@ -233,8 +233,7 @@ class SellingController(StockController):
|
||||
if self.meta.get_field("commission_rate"):
|
||||
self.round_floats_in(self, ["net_total", "commission_rate"])
|
||||
if self.commission_rate > 100.0:
|
||||
msgprint(_(self.meta.get_label("commission_rate")) + " " +
|
||||
_("cannot be greater than 100"), raise_exception=True)
|
||||
throw(_("Commission rate cannot be greater than 100"))
|
||||
|
||||
self.total_commission = flt(self.net_total * self.commission_rate / 100.0,
|
||||
self.precision("total_commission"))
|
||||
@@ -252,17 +251,14 @@ class SellingController(StockController):
|
||||
total += sales_person.allocated_percentage
|
||||
|
||||
if sales_team and total != 100.0:
|
||||
msgprint(_("Total") + " " +
|
||||
_(self.meta.get_label("allocated_percentage", parentfield="sales_team")) +
|
||||
" " + _("should be 100%"), raise_exception=True)
|
||||
throw(_("Total allocated percentage for sales team should be 100"))
|
||||
|
||||
def validate_order_type(self):
|
||||
valid_types = ["Sales", "Maintenance", "Shopping Cart"]
|
||||
if not self.order_type:
|
||||
self.order_type = "Sales"
|
||||
elif self.order_type not in valid_types:
|
||||
msgprint(_(self.meta.get_label("order_type")) + " " +
|
||||
_("must be one of") + ": " + comma_or(valid_types), raise_exception=True)
|
||||
throw(_("Order Type must be one of {1}").comma_or(valid_types))
|
||||
|
||||
def check_credit(self, grand_total):
|
||||
customer_account = frappe.db.get_value("Account", {"company": self.company,
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import flt, cstr
|
||||
from frappe import msgprint
|
||||
from frappe.utils import flt
|
||||
from frappe import msgprint, _, throw
|
||||
|
||||
from frappe.model.controller import DocListController
|
||||
|
||||
@@ -129,19 +129,13 @@ class StatusUpdater(DocListController):
|
||||
item['target_ref_field'] = args['target_ref_field'].replace('_', ' ')
|
||||
|
||||
if not item[args['target_ref_field']]:
|
||||
msgprint("""As %(target_ref_field)s for item: %(item_code)s in \
|
||||
%(parenttype)s: %(parent)s is zero, system will not check \
|
||||
over-delivery or over-billed""" % item)
|
||||
msgprint(_("Note: System will not check over-delivery and over-booking for Item {0} as quantity or amount is 0").format(item.item_code))
|
||||
elif args.get('no_tolerance'):
|
||||
item['reduce_by'] = item[args['target_field']] - \
|
||||
item[args['target_ref_field']]
|
||||
if item['reduce_by'] > .01:
|
||||
msgprint("""
|
||||
Row #%(idx)s: Max %(target_ref_field)s allowed for <b>Item \
|
||||
%(item_code)s</b> against <b>%(parenttype)s %(parent)s</b> \
|
||||
is <b>""" % item + cstr(item[args['target_ref_field']]) +
|
||||
"""</b>.<br>You must reduce the %(target_ref_field)s by \
|
||||
%(reduce_by)s""" % item, raise_exception=1)
|
||||
msgprint(_("Allowance for over-delivery / over-billing crossed for Item {0}").format(item.item_code))
|
||||
throw(_("{0} must be less than or equal to {1}").format(_(item.target_ref_field), item[args["target_ref_field"]]))
|
||||
|
||||
else:
|
||||
self.check_overflow_with_tolerance(item, args)
|
||||
@@ -161,18 +155,8 @@ class StatusUpdater(DocListController):
|
||||
item['max_allowed'] = flt(item[args['target_ref_field']] * (100+tolerance)/100)
|
||||
item['reduce_by'] = item[args['target_field']] - item['max_allowed']
|
||||
|
||||
msgprint("""
|
||||
Row #%(idx)s: Max %(target_ref_field)s allowed for <b>Item %(item_code)s</b> \
|
||||
against <b>%(parenttype)s %(parent)s</b> is <b>%(max_allowed)s</b>.
|
||||
|
||||
If you want to increase your overflow tolerance, please increase tolerance %% in \
|
||||
Global Defaults or Item master.
|
||||
|
||||
Or, you must reduce the %(target_ref_field)s by %(reduce_by)s
|
||||
|
||||
Also, please check if the order item has already been billed in the Sales Order""" %
|
||||
item, raise_exception=1)
|
||||
|
||||
msgprint(_("Allowance for over-delivery / over-billing crossed for Item {0}").format(item["item_code"]))
|
||||
throw(_("{0} must be less than or equal to {1}").format(_(item["target_ref_field"]), item[args["max_allowed"]]))
|
||||
|
||||
def update_qty(self, change_modified=True):
|
||||
"""
|
||||
|
||||
@@ -65,7 +65,7 @@ class StockController(AccountsController):
|
||||
warehouse_with_no_account.append(sle.warehouse)
|
||||
|
||||
if warehouse_with_no_account:
|
||||
msgprint(_("No accounting entries for following warehouses") + ": \n" +
|
||||
msgprint(_("No accounting entries for the following warehouses") + ": \n" +
|
||||
"\n".join(warehouse_with_no_account))
|
||||
|
||||
return process_gl_map(gl_list)
|
||||
@@ -231,12 +231,10 @@ class StockController(AccountsController):
|
||||
|
||||
def check_expense_account(self, item):
|
||||
if item.meta.get_field("expense_account") and not item.expense_account:
|
||||
msgprint(_("""Expense/Difference account is mandatory for item: """) + item.item_code,
|
||||
raise_exception=1)
|
||||
frappe.throw(_("Expense or Difference account is mandatory for Item {0}").format(item.item_code))
|
||||
|
||||
if item.meta.get_field("expense_account") and not item.cost_center:
|
||||
msgprint(_("""Cost Center is mandatory for item: """) + item.item_code,
|
||||
raise_exception=1)
|
||||
frappe.throw(_("""Cost Center is mandatory for item {0}""").format(item.item_code))
|
||||
|
||||
def get_sl_entries(self, d, args):
|
||||
sl_dict = {
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import add_days, add_months, cstr, getdate
|
||||
from frappe.utils import getdate
|
||||
from frappe import _
|
||||
|
||||
def get_columns(filters, trans):
|
||||
validate_filters(filters)
|
||||
|
||||
|
||||
# get conditions for based_on filter cond
|
||||
based_on_details = based_wise_colums_query(filters.get("based_on"), trans)
|
||||
# get conditions for periodic filter cond
|
||||
@@ -17,11 +17,11 @@ def get_columns(filters, trans):
|
||||
group_by_cols = group_wise_column(filters.get("group_by"))
|
||||
|
||||
columns = based_on_details["based_on_cols"] + period_cols + ["Total(Qty):Float:120", "Total(Amt):Currency:120"]
|
||||
if group_by_cols:
|
||||
if group_by_cols:
|
||||
columns = based_on_details["based_on_cols"] + group_by_cols + period_cols + \
|
||||
["Total(Qty):Float:120", "Total(Amt):Currency:120"]
|
||||
["Total(Qty):Float:120", "Total(Amt):Currency:120"]
|
||||
|
||||
conditions = {"based_on_select": based_on_details["based_on_select"], "period_wise_select": period_select,
|
||||
conditions = {"based_on_select": based_on_details["based_on_select"], "period_wise_select": period_select,
|
||||
"columns": columns, "group_by": based_on_details["based_on_group_by"], "grbc": group_by_cols, "trans": trans,
|
||||
"addl_tables": based_on_details["addl_tables"]}
|
||||
|
||||
@@ -30,16 +30,16 @@ def get_columns(filters, trans):
|
||||
def validate_filters(filters):
|
||||
for f in ["Fiscal Year", "Based On", "Period", "Company"]:
|
||||
if not filters.get(f.lower().replace(" ", "_")):
|
||||
frappe.msgprint(f + _(" is mandatory"), raise_exception=1)
|
||||
|
||||
frappe.throw(_("{0} is mandatory").format(f))
|
||||
|
||||
if filters.get("based_on") == filters.get("group_by"):
|
||||
frappe.msgprint("'Based On' and 'Group By' can not be same", raise_exception=1)
|
||||
frappe.throw(_("'Based On' and 'Group By' can not be same"))
|
||||
|
||||
def get_data(filters, conditions):
|
||||
data = []
|
||||
inc, cond= '',''
|
||||
query_details = conditions["based_on_select"] + conditions["period_wise_select"]
|
||||
|
||||
|
||||
if conditions["based_on_select"] in ["t1.project_name,", "t2.project_name,"]:
|
||||
cond = 'and '+ conditions["based_on_select"][:-1] +' IS Not NULL'
|
||||
|
||||
@@ -59,55 +59,55 @@ def get_data(filters, conditions):
|
||||
else :
|
||||
inc = 1
|
||||
data1 = frappe.db.sql(""" select %s from `tab%s` t1, `tab%s Item` t2 %s
|
||||
where t2.parent = t1.name and t1.company = %s and t1.fiscal_year = %s and
|
||||
t1.docstatus = 1 %s
|
||||
group by %s
|
||||
""" % (query_details, conditions["trans"], conditions["trans"], conditions["addl_tables"], "%s",
|
||||
"%s", cond, conditions["group_by"]), (filters.get("company"),
|
||||
where t2.parent = t1.name and t1.company = %s and t1.fiscal_year = %s and
|
||||
t1.docstatus = 1 %s
|
||||
group by %s
|
||||
""" % (query_details, conditions["trans"], conditions["trans"], conditions["addl_tables"], "%s",
|
||||
"%s", cond, conditions["group_by"]), (filters.get("company"),
|
||||
filters["fiscal_year"]),as_list=1)
|
||||
|
||||
for d in range(len(data1)):
|
||||
#to add blanck column
|
||||
dt = data1[d]
|
||||
dt.insert(ind,'')
|
||||
dt.insert(ind,'')
|
||||
data.append(dt)
|
||||
|
||||
#to get distinct value of col specified by group_by in filter
|
||||
row = frappe.db.sql("""select DISTINCT(%s) from `tab%s` t1, `tab%s Item` t2 %s
|
||||
where t2.parent = t1.name and t1.company = %s and t1.fiscal_year = %s
|
||||
and t1.docstatus = 1 and %s = %s
|
||||
""" %
|
||||
(sel_col, conditions["trans"], conditions["trans"], conditions["addl_tables"],
|
||||
where t2.parent = t1.name and t1.company = %s and t1.fiscal_year = %s
|
||||
and t1.docstatus = 1 and %s = %s
|
||||
""" %
|
||||
(sel_col, conditions["trans"], conditions["trans"], conditions["addl_tables"],
|
||||
"%s", "%s", conditions["group_by"], "%s"),
|
||||
(filters.get("company"), filters.get("fiscal_year"), data1[d][0]), as_list=1)
|
||||
|
||||
for i in range(len(row)):
|
||||
des = ['' for q in range(len(conditions["columns"]))]
|
||||
|
||||
#get data for group_by filter
|
||||
|
||||
#get data for group_by filter
|
||||
row1 = frappe.db.sql(""" select %s , %s from `tab%s` t1, `tab%s Item` t2 %s
|
||||
where t2.parent = t1.name and t1.company = %s and t1.fiscal_year = %s
|
||||
and t1.docstatus = 1 and %s = %s and %s = %s
|
||||
""" %
|
||||
(sel_col, conditions["period_wise_select"], conditions["trans"],
|
||||
conditions["trans"], conditions["addl_tables"], "%s", "%s", sel_col,
|
||||
"%s", conditions["group_by"], "%s"),
|
||||
(filters.get("company"), filters.get("fiscal_year"), row[i][0],
|
||||
where t2.parent = t1.name and t1.company = %s and t1.fiscal_year = %s
|
||||
and t1.docstatus = 1 and %s = %s and %s = %s
|
||||
""" %
|
||||
(sel_col, conditions["period_wise_select"], conditions["trans"],
|
||||
conditions["trans"], conditions["addl_tables"], "%s", "%s", sel_col,
|
||||
"%s", conditions["group_by"], "%s"),
|
||||
(filters.get("company"), filters.get("fiscal_year"), row[i][0],
|
||||
data1[d][0]), as_list=1)
|
||||
|
||||
des[ind] = row[i]
|
||||
for j in range(1,len(conditions["columns"])-inc):
|
||||
for j in range(1,len(conditions["columns"])-inc):
|
||||
des[j+inc] = row1[0][j]
|
||||
|
||||
|
||||
data.append(des)
|
||||
else:
|
||||
data = frappe.db.sql(""" select %s from `tab%s` t1, `tab%s Item` t2 %s
|
||||
where t2.parent = t1.name and t1.company = %s and t1.fiscal_year = %s and
|
||||
t1.docstatus = 1 %s
|
||||
group by %s
|
||||
""" %
|
||||
(query_details, conditions["trans"], conditions["trans"], conditions["addl_tables"],
|
||||
"%s", "%s", cond,conditions["group_by"]),
|
||||
where t2.parent = t1.name and t1.company = %s and t1.fiscal_year = %s and
|
||||
t1.docstatus = 1 %s
|
||||
group by %s
|
||||
""" %
|
||||
(query_details, conditions["trans"], conditions["trans"], conditions["addl_tables"],
|
||||
"%s", "%s", cond,conditions["group_by"]),
|
||||
(filters.get("company"), filters.get("fiscal_year")), as_list=1)
|
||||
|
||||
return data
|
||||
@@ -124,13 +124,13 @@ def period_wise_colums_query(filters, trans):
|
||||
trans_date = 'posting_date'
|
||||
else:
|
||||
trans_date = 'transaction_date'
|
||||
|
||||
|
||||
if filters.get("period") != 'Yearly':
|
||||
for dt in bet_dates:
|
||||
get_period_wise_columns(dt, filters.get("period"), pwc)
|
||||
query_details = get_period_wise_query(dt, trans_date, query_details)
|
||||
else:
|
||||
pwc = [filters.get("fiscal_year") + " (Qty):Float:120",
|
||||
pwc = [filters.get("fiscal_year") + " (Qty):Float:120",
|
||||
filters.get("fiscal_year") + " (Amt):Currency:120"]
|
||||
query_details = " SUM(t2.qty), SUM(t1.grand_total),"
|
||||
|
||||
@@ -139,14 +139,14 @@ def period_wise_colums_query(filters, trans):
|
||||
|
||||
def get_period_wise_columns(bet_dates, period, pwc):
|
||||
if period == 'Monthly':
|
||||
pwc += [get_mon(bet_dates[0]) + " (Qty):Float:120",
|
||||
pwc += [get_mon(bet_dates[0]) + " (Qty):Float:120",
|
||||
get_mon(bet_dates[0]) + " (Amt):Currency:120"]
|
||||
else:
|
||||
pwc += [get_mon(bet_dates[0]) + "-" + get_mon(bet_dates[1]) + " (Qty):Float:120",
|
||||
pwc += [get_mon(bet_dates[0]) + "-" + get_mon(bet_dates[1]) + " (Qty):Float:120",
|
||||
get_mon(bet_dates[0]) + "-" + get_mon(bet_dates[1]) + " (Amt):Currency:120"]
|
||||
|
||||
def get_period_wise_query(bet_dates, trans_date, query_details):
|
||||
query_details += """SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.qty, NULL)),
|
||||
query_details += """SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t2.qty, NULL)),
|
||||
SUM(IF(t1.%(trans_date)s BETWEEN '%(sd)s' AND '%(ed)s', t1.grand_total, NULL)),
|
||||
""" % {"trans_date": trans_date, "sd": bet_dates[0],"ed": bet_dates[1]}
|
||||
return query_details
|
||||
@@ -156,7 +156,7 @@ def get_period_date_ranges(period, fiscal_year=None, year_start_date=None):
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
if not year_start_date:
|
||||
year_start_date, year_end_date = frappe.db.get_value("Fiscal Year",
|
||||
year_start_date, year_end_date = frappe.db.get_value("Fiscal Year",
|
||||
fiscal_year, ["year_start_date", "year_end_date"])
|
||||
|
||||
increment = {
|
||||
@@ -197,13 +197,13 @@ def based_wise_colums_query(based_on, trans):
|
||||
# based_on_cols, based_on_select, based_on_group_by, addl_tables
|
||||
if based_on == "Item":
|
||||
based_on_details["based_on_cols"] = ["Item:Link/Item:120", "Item Name:Data:120"]
|
||||
based_on_details["based_on_select"] = "t2.item_code, t2.item_name,"
|
||||
based_on_details["based_on_select"] = "t2.item_code, t2.item_name,"
|
||||
based_on_details["based_on_group_by"] = 't2.item_code'
|
||||
based_on_details["addl_tables"] = ''
|
||||
|
||||
elif based_on == "Item Group":
|
||||
based_on_details["based_on_cols"] = ["Item Group:Link/Item Group:120"]
|
||||
based_on_details["based_on_select"] = "t2.item_group,"
|
||||
based_on_details["based_on_select"] = "t2.item_group,"
|
||||
based_on_details["based_on_group_by"] = 't2.item_group'
|
||||
based_on_details["addl_tables"] = ''
|
||||
|
||||
@@ -224,7 +224,7 @@ def based_wise_colums_query(based_on, trans):
|
||||
based_on_details["based_on_select"] = "t1.supplier, t3.supplier_type,"
|
||||
based_on_details["based_on_group_by"] = 't1.supplier'
|
||||
based_on_details["addl_tables"] = ',`tabSupplier` t3'
|
||||
|
||||
|
||||
elif based_on == 'Supplier Type':
|
||||
based_on_details["based_on_cols"] = ["Supplier Type:Link/Supplier Type:140"]
|
||||
based_on_details["based_on_select"] = "t3.supplier_type,"
|
||||
@@ -249,7 +249,7 @@ def based_wise_colums_query(based_on, trans):
|
||||
based_on_details["based_on_group_by"] = 't2.project_name'
|
||||
based_on_details["addl_tables"] = ''
|
||||
else:
|
||||
frappe.msgprint("Project-wise data is not available for Quotation", raise_exception=1)
|
||||
frappe.throw(_("Project-wise data is not available for Quotation"))
|
||||
|
||||
return based_on_details
|
||||
|
||||
@@ -257,4 +257,4 @@ def group_wise_column(group_by):
|
||||
if group_by:
|
||||
return [group_by+":Link/"+group_by+":120"]
|
||||
else:
|
||||
return []
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user