Merge https://github.com/frappe/erpnext into purchase-invoice-fix

This commit is contained in:
Neil Trini Lasrado 2014-08-20 14:39:22 +05:30
commit bf4ceb981f
9 changed files with 50 additions and 38 deletions

View File

@ -135,8 +135,10 @@ def get_pricing_rule_for_item(args):
frappe.throw(_("Item Group not mentioned in item master for item {0}").format(args.item_code)) frappe.throw(_("Item Group not mentioned in item master for item {0}").format(args.item_code))
if args.customer and not (args.customer_group and args.territory): if args.customer and not (args.customer_group and args.territory):
args.customer_group, args.territory = frappe.db.get_value("Customer", args.customer, customer = frappe.db.get_value("Customer", args.customer, ["customer_group", "territory"])
["customer_group", "territory"]) if customer:
args.customer_group, args.territory = customer
elif args.supplier and not args.supplier_type: elif args.supplier and not args.supplier_type:
args.supplier_type = frappe.db.get_value("Supplier", args.supplier, "supplier_type") args.supplier_type = frappe.db.get_value("Supplier", args.supplier, "supplier_type")

View File

@ -333,13 +333,12 @@ class PurchaseInvoice(BuyingController):
self.get_gl_dict({ self.get_gl_dict({
"account": stock_received_but_not_billed, "account": stock_received_but_not_billed,
"against": self.credit_to, "against": self.credit_to,
"debit": flt(item.item_tax_amount), "debit": flt(item.item_tax_amount, self.precision("item_tax_amount", item)),
"remarks": self.remarks or "Accounting Entry for Stock" "remarks": self.remarks or "Accounting Entry for Stock"
}) })
) )
negative_expense_to_be_booked += flt(item.item_tax_amount) negative_expense_to_be_booked += flt(item.item_tax_amount, self.precision("item_tax_amount", item))
if negative_expense_to_be_booked and valuation_tax: if negative_expense_to_be_booked and valuation_tax:
# credit valuation tax amount in "Expenses Included In Valuation" # credit valuation tax amount in "Expenses Included In Valuation"

View File

@ -4,6 +4,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import flt from frappe.utils import flt
from frappe import _
def execute(filters=None): def execute(filters=None):
if not filters: filters = {} if not filters: filters = {}
@ -15,25 +16,38 @@ def execute(filters=None):
data = get_entries(filters) data = get_entries(filters)
from erpnext.accounts.utils import get_balance_on from erpnext.accounts.utils import get_balance_on
balance_as_per_company = get_balance_on(filters["account"], filters["report_date"]) balance_as_per_system = get_balance_on(filters["account"], filters["report_date"])
total_debit, total_credit = 0,0 total_debit, total_credit = 0,0
for d in data: for d in data:
total_debit += flt(d[2]) total_debit += flt(d[2])
total_credit += flt(d[3]) total_credit += flt(d[3])
bank_bal = flt(balance_as_per_company) - flt(total_debit) + flt(total_credit) amounts_not_reflected_in_system = frappe.db.sql("""select sum(ifnull(jvd.debit, 0) - ifnull(jvd.credit, 0))
from `tabJournal Voucher Detail` jvd, `tabJournal Voucher` jv
where jvd.parent = jv.name and jv.docstatus=1 and jvd.account=%s
and jv.posting_date > %s and jv.clearance_date <= %s
""", (filters["account"], filters["report_date"], filters["report_date"]))
amounts_not_reflected_in_system = flt(amounts_not_reflected_in_system[0][0]) \
if amounts_not_reflected_in_system else 0.0
bank_bal = flt(balance_as_per_system) - flt(total_debit) + flt(total_credit) \
+ amounts_not_reflected_in_system
data += [ data += [
get_balance_row("Balance as per company books", balance_as_per_company), get_balance_row(_("System Balance"), balance_as_per_system),
["", "Amounts not reflected in bank", total_debit, total_credit, "", "", "", ""], [""]*len(columns),
get_balance_row("Balance as per bank", bank_bal) ["", _("Amounts not reflected in bank"), total_debit, total_credit, "", "", "", ""],
get_balance_row(_("Amounts not reflected in system"), amounts_not_reflected_in_system),
[""]*len(columns),
get_balance_row(_("Expected balance as per bank"), bank_bal)
] ]
return columns, data return columns, data
def get_columns(): def get_columns():
return ["Posting Date:Date:100", "Journal Voucher:Link/Journal Voucher:200", return ["Posting Date:Date:100", "Journal Voucher:Link/Journal Voucher:220",
"Debit:Currency:120", "Credit:Currency:120", "Debit:Currency:120", "Credit:Currency:120",
"Against Account:Link/Account:200", "Reference::100", "Ref Date:Date:110", "Clearance Date:Date:110" "Against Account:Link/Account:200", "Reference::100", "Ref Date:Date:110", "Clearance Date:Date:110"
] ]
@ -55,4 +69,4 @@ def get_balance_row(label, amount):
if amount > 0: if amount > 0:
return ["", label, amount, 0, "", "", "", ""] return ["", label, amount, 0, "", "", "", ""]
else: else:
return ["", label, 0, amount, "", "", "", ""] return ["", label, 0, abs(amount), "", "", "", ""]

View File

@ -209,7 +209,7 @@ class AccountsController(TransactionBase):
def calculate_taxes(self): def calculate_taxes(self):
# maintain actual tax rate based on idx # maintain actual tax rate based on idx
actual_tax_dict = dict([[tax.idx, tax.rate] for tax in self.tax_doclist actual_tax_dict = dict([[tax.idx, flt(tax.rate, self.precision("tax_amount", tax))] for tax in self.tax_doclist
if tax.charge_type == "Actual"]) if tax.charge_type == "Actual"])
for n, item in enumerate(self.item_doclist): for n, item in enumerate(self.item_doclist):

View File

@ -166,21 +166,19 @@ class StockController(AccountsController):
def get_future_stock_vouchers(self): def get_future_stock_vouchers(self):
future_stock_vouchers = []
if hasattr(self, "fname"):
item_list = [d.item_code for d in self.get(self.fname)]
condition = ''.join(['and item_code in (\'', '\', \''.join(item_list) ,'\')'])
else:
condition = "" condition = ""
item_list = []
if getattr(self, "fname", None):
item_list = [d.item_code for d in self.get(self.fname)]
if item_list:
condition = "and item_code in ({})".format(", ".join(["%s"] * len(item_list)))
for d in frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no future_stock_vouchers = frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no
from `tabStock Ledger Entry` sle from `tabStock Ledger Entry` sle
where timestamp(sle.posting_date, sle.posting_time) >= timestamp(%s, %s) %s where timestamp(sle.posting_date, sle.posting_time) >= timestamp(%s, %s) {condition}
order by timestamp(sle.posting_date, sle.posting_time) asc, name asc""" % order by timestamp(sle.posting_date, sle.posting_time) asc, name asc""".format(
('%s', '%s', condition), (self.posting_date, self.posting_time), condition=condition), tuple([self.posting_date, self.posting_date] + item_list),
as_dict=True): as_list=True)
future_stock_vouchers.append([d.voucher_type, d.voucher_no])
return future_stock_vouchers return future_stock_vouchers

View File

@ -324,7 +324,7 @@ class ProductionPlanningTool(Document):
total_qty = sum([flt(d[0]) for d in so_item_qty]) total_qty = sum([flt(d[0]) for d in so_item_qty])
if total_qty > item_projected_qty.get(item, 0): if total_qty > item_projected_qty.get(item, 0):
# shortage # shortage
requested_qty = total_qty - item_projected_qty.get(item, 0) requested_qty = total_qty - flt(item_projected_qty.get(item))
# consider minimum order qty # consider minimum order qty
requested_qty = requested_qty > flt(so_item_qty[0][3]) and \ requested_qty = requested_qty > flt(so_item_qty[0][3]) and \
requested_qty or flt(so_item_qty[0][3]) requested_qty or flt(so_item_qty[0][3])

View File

@ -647,7 +647,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
// maintain actual tax rate based on idx // maintain actual tax rate based on idx
$.each(this.frm.tax_doclist, function(i, tax) { $.each(this.frm.tax_doclist, function(i, tax) {
if (tax.charge_type == "Actual") { if (tax.charge_type == "Actual") {
actual_tax_dict[tax.idx] = flt(tax.rate); actual_tax_dict[tax.idx] = flt(tax.rate, precision("tax_amount", tax));
} }
}); });

View File

@ -19,8 +19,7 @@ cur_frm.cscript.set_root_readonly = function(doc) {
//get query select Customer Group //get query select Customer Group
cur_frm.fields_dict['parent_customer_group'].get_query = function(doc,cdt,cdn) { cur_frm.fields_dict['parent_customer_group'].get_query = function(doc,cdt,cdn) {
return{ return {
searchfield:['name', 'parent_customer_group'],
filters: { filters: {
'is_group': "Yes" 'is_group': "Yes"
} }

View File

@ -96,7 +96,7 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten
title: __("Get Items from BOM"), title: __("Get Items from BOM"),
fields: [ fields: [
{"fieldname":"bom", "fieldtype":"Link", "label":__("BOM"), {"fieldname":"bom", "fieldtype":"Link", "label":__("BOM"),
options:"BOM"}, options:"BOM", reqd: 1},
{"fieldname":"fetch_exploded", "fieldtype":"Check", {"fieldname":"fetch_exploded", "fieldtype":"Check",
"label":__("Fetch exploded BOM (including sub-assemblies)"), "default":1}, "label":__("Fetch exploded BOM (including sub-assemblies)"), "default":1},
{fieldname:"fetch", "label":__("Get Items from BOM"), "fieldtype":"Button"} {fieldname:"fetch", "label":__("Get Items from BOM"), "fieldtype":"Button"}