pr and pi gl entries
This commit is contained in:
parent
98e7dcfe2c
commit
8ca3189f07
@ -275,6 +275,7 @@ class PurchaseInvoice(BuyingController):
|
||||
cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
|
||||
|
||||
stock_received_but_not_billed = self.get_company_default("stock_received_but_not_billed")
|
||||
expenses_included_in_valuation = self.get_company_default("expenses_included_in_valuation")
|
||||
|
||||
gl_entries = []
|
||||
|
||||
@ -331,13 +332,13 @@ class PurchaseInvoice(BuyingController):
|
||||
|
||||
if auto_accounting_for_stock and item.item_code in stock_items and item.item_tax_amount:
|
||||
# Post reverse entry for Stock-Received-But-Not-Billed if it is booked in Purchase Receipt
|
||||
stock_rbnb_booked_in_pr = None
|
||||
negative_expense_booked_in_pi = None
|
||||
if item.purchase_receipt:
|
||||
stock_rbnb_booked_in_pr = frappe.db.sql("""select name from `tabGL Entry`
|
||||
negative_expense_booked_in_pi = frappe.db.sql("""select name from `tabGL Entry`
|
||||
where voucher_type='Purchase Receipt' and voucher_no=%s and account=%s""",
|
||||
(item.purchase_receipt, stock_received_but_not_billed))
|
||||
(item.purchase_receipt, expenses_included_in_valuation))
|
||||
|
||||
if stock_rbnb_booked_in_pr:
|
||||
if not negative_expense_booked_in_pi:
|
||||
gl_entries.append(
|
||||
self.get_gl_dict({
|
||||
"account": stock_received_but_not_billed,
|
||||
@ -353,7 +354,6 @@ class PurchaseInvoice(BuyingController):
|
||||
if negative_expense_to_be_booked and valuation_tax:
|
||||
# credit valuation tax amount in "Expenses Included In Valuation"
|
||||
# this will balance out valuation amount included in cost of goods sold
|
||||
expenses_included_in_valuation = self.get_company_default("expenses_included_in_valuation")
|
||||
|
||||
total_valuation_amount = sum(valuation_tax.values())
|
||||
amount_including_divisional_loss = negative_expense_to_be_booked
|
||||
|
@ -37,7 +37,7 @@ class PurchaseReceipt(BuyingController):
|
||||
|
||||
def onload(self):
|
||||
billed_qty = frappe.db.sql("""select sum(ifnull(qty, 0)) from `tabPurchase Invoice Item`
|
||||
where purchase_receipt=%s""", self.name)
|
||||
where purchase_receipt=%s and docstatus=1""", self.name)
|
||||
if billed_qty:
|
||||
total_qty = sum((item.qty for item in self.get("purchase_receipt_details")))
|
||||
self.get("__onload").billing_complete = (billed_qty[0][0] == total_qty)
|
||||
@ -358,12 +358,12 @@ class PurchaseReceipt(BuyingController):
|
||||
# and charges added via Landed Cost Voucher,
|
||||
# post valuation related charges on "Stock Received But Not Billed"
|
||||
|
||||
stock_rbnb_booked_in_pi = frappe.db.sql("""select name from `tabPurchase Invoice Item` pi
|
||||
negative_expense_booked_in_pi = 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, stock_rbnb))
|
||||
and voucher_no=pi.parent and account=%s)""", (self.name, expenses_included_in_valuation))
|
||||
|
||||
if stock_rbnb_booked_in_pi:
|
||||
if negative_expense_booked_in_pi:
|
||||
expenses_included_in_valuation = stock_rbnb
|
||||
|
||||
against_account = ", ".join([d.account for d in gl_entries if flt(d.debit) > 0])
|
||||
|
Loading…
Reference in New Issue
Block a user