purchase receipt gl entries
This commit is contained in:
parent
509aa52efc
commit
11594c7927
@ -316,15 +316,24 @@ class PurchaseInvoice(BuyingController):
|
|||||||
stock_item_and_auto_accounting_for_stock = False
|
stock_item_and_auto_accounting_for_stock = False
|
||||||
stock_items = self.get_stock_items()
|
stock_items = self.get_stock_items()
|
||||||
for item in self.get("entries"):
|
for item in self.get("entries"):
|
||||||
if auto_accounting_for_stock and item.item_code in stock_items:
|
if flt(item.base_amount):
|
||||||
if flt(item.valuation_rate):
|
gl_entries.append(
|
||||||
|
self.get_gl_dict({
|
||||||
|
"account": item.expense_account,
|
||||||
|
"against": self.credit_to,
|
||||||
|
"debit": item.base_amount,
|
||||||
|
"remarks": self.remarks,
|
||||||
|
"cost_center": item.cost_center
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
if auto_accounting_for_stock and item.item_code in stock_items and item.valuation_rate:
|
||||||
# if auto inventory accounting enabled and stock item,
|
# if auto inventory accounting enabled and stock item,
|
||||||
# then do stock related gl entries
|
# then do stock related gl entries
|
||||||
# expense will be booked in sales invoice
|
# expense will be booked in sales invoice
|
||||||
stock_item_and_auto_accounting_for_stock = True
|
stock_item_and_auto_accounting_for_stock = True
|
||||||
|
|
||||||
valuation_amt = flt(item.base_amount + item.item_tax_amount,
|
|
||||||
self.precision("base_amount", item))
|
|
||||||
|
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
@ -353,6 +362,9 @@ class PurchaseInvoice(BuyingController):
|
|||||||
expenses_included_in_valuation = \
|
expenses_included_in_valuation = \
|
||||||
self.get_company_default("expenses_included_in_valuation")
|
self.get_company_default("expenses_included_in_valuation")
|
||||||
|
|
||||||
|
# Backward compatibility:
|
||||||
|
# Post expenses_included_in_valuation only if it is not booked in Purchase Receipt
|
||||||
|
|
||||||
for cost_center, amount in valuation_tax.items():
|
for cost_center, amount in valuation_tax.items():
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
|
@ -312,7 +312,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
"against": warehouse_account[d.warehouse],
|
"against": warehouse_account[d.warehouse],
|
||||||
"cost_center": d.cost_center,
|
"cost_center": d.cost_center,
|
||||||
"remarks": self.get("remarks") or "Accounting Entry for Stock",
|
"remarks": self.get("remarks") or "Accounting Entry for Stock",
|
||||||
"credit": flt(d.base_amount + d.item_tax_amount, self.precision("base_amount", d))
|
"credit": flt(d.base_amount, self.precision("base_amount", d))
|
||||||
}))
|
}))
|
||||||
|
|
||||||
# Amount added through landed-cost-voucher
|
# Amount added through landed-cost-voucher
|
||||||
@ -339,6 +339,40 @@ class PurchaseReceipt(BuyingController):
|
|||||||
d.rejected_warehouse not in warehouse_with_no_account:
|
d.rejected_warehouse not in warehouse_with_no_account:
|
||||||
warehouse_with_no_account.append(d.warehouse)
|
warehouse_with_no_account.append(d.warehouse)
|
||||||
|
|
||||||
|
# Cost center-wise amount breakup for other charges included for valuation
|
||||||
|
valuation_tax = {}
|
||||||
|
for tax in self.get("other_charges"):
|
||||||
|
if tax.category in ("Valuation", "Valuation and Total") and flt(tax.tax_amount):
|
||||||
|
if not tax.cost_center:
|
||||||
|
frappe.throw(_("Cost Center is required in row {0} in Taxes table for type {1}").format(tax.idx, _(tax.category)))
|
||||||
|
valuation_tax.setdefault(tax.cost_center, 0)
|
||||||
|
valuation_tax[tax.cost_center] += \
|
||||||
|
(tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.tax_amount)
|
||||||
|
|
||||||
|
# Backward compatibility:
|
||||||
|
# If expenses_included_in_valuation account has been credited in against PI
|
||||||
|
# and charges added via Landed Cost Voucher,
|
||||||
|
# post valuation related charges on "Stock Received But Not Billed"
|
||||||
|
|
||||||
|
pi_exists = frappe.db.sql("""select name from `tabPurchase Invoice Item` pi
|
||||||
|
where docstatus = 1 and purchase_receipt=%s
|
||||||
|
and exists(select name from `tabGL Entry` where voucher_type='Purchase Invoice'
|
||||||
|
and voucher_no=pi.parent and account=%s)""", (self.name, expenses_included_in_valuation))
|
||||||
|
|
||||||
|
if pi_exists:
|
||||||
|
expenses_included_in_valuation = stock_rbnb
|
||||||
|
|
||||||
|
# Expense included in valuation
|
||||||
|
for cost_center, amount in valuation_tax.items():
|
||||||
|
gl_entries.append(
|
||||||
|
self.get_gl_dict({
|
||||||
|
"account": expenses_included_in_valuation,
|
||||||
|
"cost_center": cost_center,
|
||||||
|
"credit": amount,
|
||||||
|
"remarks": self.remarks or "Accounting Entry for Stock"
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
if warehouse_with_no_account:
|
if warehouse_with_no_account:
|
||||||
frappe.msgprint(_("No accounting entries for the following warehouses") + ": \n" +
|
frappe.msgprint(_("No accounting entries for the following warehouses") + ": \n" +
|
||||||
"\n".join(warehouse_with_no_account))
|
"\n".join(warehouse_with_no_account))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user