mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-14 18:51:21 +00:00
update translation strings #1403
This commit is contained in:
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user