[fix] against account in general ledger will show party
This commit is contained in:
parent
ecf220a721
commit
6b35ea873b
@ -127,7 +127,7 @@ def update_outstanding_amt(account, party_type, party, against_voucher_type, aga
|
|||||||
against_voucher_amount = flt(frappe.db.sql("""
|
against_voucher_amount = flt(frappe.db.sql("""
|
||||||
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
|
||||||
from `tabGL Entry` where voucher_type = 'Journal Entry' and voucher_no = %s
|
from `tabGL Entry` where voucher_type = 'Journal Entry' and voucher_no = %s
|
||||||
and account = %s and ifnull(party_type, '')=%s and ifnull(party, '')=%s
|
and account = %s and ifnull(party_type, '')=%s and ifnull(party, '')=%s
|
||||||
and ifnull(against_voucher, '') = ''""",
|
and ifnull(against_voucher, '') = ''""",
|
||||||
(against_voucher, account, cstr(party_type), cstr(party)))[0][0])
|
(against_voucher, account, cstr(party_type), cstr(party)))[0][0])
|
||||||
|
|
||||||
@ -158,3 +158,22 @@ def validate_frozen_account(account, adv_adj=None):
|
|||||||
frappe.throw(_("Account {0} is frozen").format(account))
|
frappe.throw(_("Account {0} is frozen").format(account))
|
||||||
elif frozen_accounts_modifier not in frappe.get_roles():
|
elif frozen_accounts_modifier not in frappe.get_roles():
|
||||||
frappe.throw(_("Not authorized to edit frozen Account {0}").format(account))
|
frappe.throw(_("Not authorized to edit frozen Account {0}").format(account))
|
||||||
|
|
||||||
|
def update_against_account(voucher_type, voucher_no):
|
||||||
|
entries = frappe.db.get_all("GL Entry",
|
||||||
|
filters={"voucher_type": voucher_type, "voucher_no": voucher_no},
|
||||||
|
fields=["name", "party", "against", "debit", "credit", "account"])
|
||||||
|
|
||||||
|
accounts_debited, accounts_credited = [], []
|
||||||
|
for d in entries:
|
||||||
|
if flt(d.debit > 0): accounts_debited.append(d.party or d.account)
|
||||||
|
if flt(d.credit) > 0: accounts_credited.append(d.party or d.account)
|
||||||
|
|
||||||
|
for d in entries:
|
||||||
|
if flt(d.debit > 0):
|
||||||
|
new_against = ", ".join(list(set(accounts_credited)))
|
||||||
|
if flt(d.credit > 0):
|
||||||
|
new_against = ", ".join(list(set(accounts_debited)))
|
||||||
|
|
||||||
|
if d.against != new_against:
|
||||||
|
frappe.db.set_value("GL Entry", d.name, "against", new_against)
|
||||||
|
@ -81,7 +81,7 @@ class JournalEntry(AccountsController):
|
|||||||
frappe.throw(_("Row {0}: Party Type and Party is only applicable against Receivable / Payable account").format(d.idx))
|
frappe.throw(_("Row {0}: Party Type and Party is only applicable against Receivable / Payable account").format(d.idx))
|
||||||
|
|
||||||
def check_credit_limit(self):
|
def check_credit_limit(self):
|
||||||
customers = list(set([d.party for d in self.get("accounts")
|
customers = list(set([d.party for d in self.get("accounts")
|
||||||
if d.party_type=="Customer" and d.party and flt(d.debit) > 0]))
|
if d.party_type=="Customer" and d.party and flt(d.debit) > 0]))
|
||||||
if customers:
|
if customers:
|
||||||
from erpnext.selling.doctype.customer.customer import check_credit_limit
|
from erpnext.selling.doctype.customer.customer import check_credit_limit
|
||||||
@ -243,8 +243,8 @@ class JournalEntry(AccountsController):
|
|||||||
def set_against_account(self):
|
def set_against_account(self):
|
||||||
accounts_debited, accounts_credited = [], []
|
accounts_debited, accounts_credited = [], []
|
||||||
for d in self.get("accounts"):
|
for d in self.get("accounts"):
|
||||||
if flt(d.debit > 0): accounts_debited.append(d.account)
|
if flt(d.debit > 0): accounts_debited.append(d.party or d.account)
|
||||||
if flt(d.credit) > 0: accounts_credited.append(d.account)
|
if flt(d.credit) > 0: accounts_credited.append(d.party or d.account)
|
||||||
|
|
||||||
for d in self.get("accounts"):
|
for d in self.get("accounts"):
|
||||||
if flt(d.debit > 0): d.against_account = ", ".join(list(set(accounts_credited)))
|
if flt(d.debit > 0): d.against_account = ", ".join(list(set(accounts_credited)))
|
||||||
@ -274,9 +274,9 @@ class JournalEntry(AccountsController):
|
|||||||
r.append(_('Reference #{0} dated {1}').format(self.cheque_no, formatdate(self.cheque_date)))
|
r.append(_('Reference #{0} dated {1}').format(self.cheque_no, formatdate(self.cheque_date)))
|
||||||
else:
|
else:
|
||||||
msgprint(_("Please enter Reference date"), raise_exception=frappe.MandatoryError)
|
msgprint(_("Please enter Reference date"), raise_exception=frappe.MandatoryError)
|
||||||
|
|
||||||
company_currency = get_company_currency(self.company)
|
company_currency = get_company_currency(self.company)
|
||||||
|
|
||||||
for d in self.get('accounts'):
|
for d in self.get('accounts'):
|
||||||
if d.against_invoice and d.credit:
|
if d.against_invoice and d.credit:
|
||||||
r.append(_("{0} against Sales Invoice {1}").format(fmt_money(flt(d.credit), currency = company_currency), \
|
r.append(_("{0} against Sales Invoice {1}").format(fmt_money(flt(d.credit), currency = company_currency), \
|
||||||
@ -426,7 +426,7 @@ class JournalEntry(AccountsController):
|
|||||||
def validate_expense_claim(self):
|
def validate_expense_claim(self):
|
||||||
for d in self.accounts:
|
for d in self.accounts:
|
||||||
if d.against_expense_claim:
|
if d.against_expense_claim:
|
||||||
sanctioned_amount, reimbursed_amount = frappe.db.get_value("Expense Claim",
|
sanctioned_amount, reimbursed_amount = frappe.db.get_value("Expense Claim",
|
||||||
d.against_expense_claim, ("total_sanctioned_amount", "total_amount_reimbursed"))
|
d.against_expense_claim, ("total_sanctioned_amount", "total_amount_reimbursed"))
|
||||||
pending_amount = flt(sanctioned_amount) - flt(reimbursed_amount)
|
pending_amount = flt(sanctioned_amount) - flt(reimbursed_amount)
|
||||||
if d.debit > pending_amount:
|
if d.debit > pending_amount:
|
||||||
|
@ -164,7 +164,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
elif item.expense_account not in against_accounts:
|
elif item.expense_account not in against_accounts:
|
||||||
# if no auto_accounting_for_stock or not a stock item
|
# if no auto_accounting_for_stock or not a stock item
|
||||||
against_accounts.append(item.expense_account)
|
against_accounts.append(item.expense_account)
|
||||||
|
|
||||||
self.against_expense_account = ",".join(against_accounts)
|
self.against_expense_account = ",".join(against_accounts)
|
||||||
|
|
||||||
def po_required(self):
|
def po_required(self):
|
||||||
@ -271,7 +271,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": tax.account_head,
|
"account": tax.account_head,
|
||||||
"against": self.credit_to,
|
"against": self.supplier,
|
||||||
"debit": tax.add_deduct_tax == "Add" and tax.base_tax_amount_after_discount_amount or 0,
|
"debit": tax.add_deduct_tax == "Add" and tax.base_tax_amount_after_discount_amount or 0,
|
||||||
"credit": tax.add_deduct_tax == "Deduct" and tax.base_tax_amount_after_discount_amount or 0,
|
"credit": tax.add_deduct_tax == "Deduct" and tax.base_tax_amount_after_discount_amount or 0,
|
||||||
"remarks": self.remarks,
|
"remarks": self.remarks,
|
||||||
@ -295,7 +295,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": item.expense_account,
|
"account": item.expense_account,
|
||||||
"against": self.credit_to,
|
"against": self.supplier,
|
||||||
"debit": item.base_net_amount,
|
"debit": item.base_net_amount,
|
||||||
"remarks": self.remarks,
|
"remarks": self.remarks,
|
||||||
"cost_center": item.cost_center
|
"cost_center": item.cost_center
|
||||||
@ -315,7 +315,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
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.supplier,
|
||||||
"debit": flt(item.item_tax_amount, self.precision("item_tax_amount", item)),
|
"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"
|
||||||
})
|
})
|
||||||
@ -341,7 +341,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": expenses_included_in_valuation,
|
"account": expenses_included_in_valuation,
|
||||||
"cost_center": cost_center,
|
"cost_center": cost_center,
|
||||||
"against": self.credit_to,
|
"against": self.supplier,
|
||||||
"credit": applicable_amount,
|
"credit": applicable_amount,
|
||||||
"remarks": self.remarks or "Accounting Entry for Stock"
|
"remarks": self.remarks or "Accounting Entry for Stock"
|
||||||
})
|
})
|
||||||
@ -355,7 +355,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": self.write_off_account,
|
"account": self.write_off_account,
|
||||||
"against": self.credit_to,
|
"against": self.supplier,
|
||||||
"credit": flt(self.write_off_amount),
|
"credit": flt(self.write_off_amount),
|
||||||
"remarks": self.remarks,
|
"remarks": self.remarks,
|
||||||
"cost_center": self.write_off_cost_center
|
"cost_center": self.write_off_cost_center
|
||||||
@ -374,7 +374,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
||||||
self.make_gl_entries_on_cancel()
|
self.make_gl_entries_on_cancel()
|
||||||
self.update_project()
|
self.update_project()
|
||||||
|
|
||||||
def update_project(self):
|
def update_project(self):
|
||||||
project_list = []
|
project_list = []
|
||||||
for d in self.items:
|
for d in self.items:
|
||||||
@ -384,7 +384,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
project.update_purchase_costing()
|
project.update_purchase_costing()
|
||||||
project.save()
|
project.save()
|
||||||
project_list.append(d.project_name)
|
project_list.append(d.project_name)
|
||||||
|
|
||||||
def validate_supplier_invoice(self):
|
def validate_supplier_invoice(self):
|
||||||
if self.bill_date:
|
if self.bill_date:
|
||||||
if getdate(self.bill_date) > getdate(self.posting_date):
|
if getdate(self.bill_date) > getdate(self.posting_date):
|
||||||
|
@ -503,7 +503,7 @@ class SalesInvoice(SellingController):
|
|||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": tax.account_head,
|
"account": tax.account_head,
|
||||||
"against": self.debit_to,
|
"against": self.customer,
|
||||||
"credit": flt(tax.base_tax_amount_after_discount_amount),
|
"credit": flt(tax.base_tax_amount_after_discount_amount),
|
||||||
"remarks": self.remarks,
|
"remarks": self.remarks,
|
||||||
"cost_center": tax.cost_center
|
"cost_center": tax.cost_center
|
||||||
@ -517,7 +517,7 @@ class SalesInvoice(SellingController):
|
|||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": item.income_account,
|
"account": item.income_account,
|
||||||
"against": self.debit_to,
|
"against": self.customer,
|
||||||
"credit": item.base_net_amount,
|
"credit": item.base_net_amount,
|
||||||
"remarks": self.remarks,
|
"remarks": self.remarks,
|
||||||
"cost_center": item.cost_center
|
"cost_center": item.cost_center
|
||||||
@ -548,7 +548,7 @@ class SalesInvoice(SellingController):
|
|||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": self.cash_bank_account,
|
"account": self.cash_bank_account,
|
||||||
"against": self.debit_to,
|
"against": self.customer,
|
||||||
"debit": self.paid_amount,
|
"debit": self.paid_amount,
|
||||||
"remarks": self.remarks,
|
"remarks": self.remarks,
|
||||||
})
|
})
|
||||||
@ -572,7 +572,7 @@ class SalesInvoice(SellingController):
|
|||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
"account": self.write_off_account,
|
"account": self.write_off_account,
|
||||||
"against": self.debit_to,
|
"against": self.customer,
|
||||||
"debit": self.write_off_amount,
|
"debit": self.write_off_amount,
|
||||||
"remarks": self.remarks,
|
"remarks": self.remarks,
|
||||||
"cost_center": self.write_off_cost_center
|
"cost_center": self.write_off_cost_center
|
||||||
@ -587,7 +587,7 @@ def get_list_context(context=None):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_bank_cash_account(mode_of_payment, company):
|
def get_bank_cash_account(mode_of_payment, company):
|
||||||
account = frappe.db.get_value("Mode of Payment Account",
|
account = frappe.db.get_value("Mode of Payment Account",
|
||||||
{"parent": mode_of_payment, "company": company}, "default_account")
|
{"parent": mode_of_payment, "company": company}, "default_account")
|
||||||
if not account:
|
if not account:
|
||||||
frappe.msgprint(_("Please set default Cash or Bank account in Mode of Payment {0}").format(mode_of_payment))
|
frappe.msgprint(_("Please set default Cash or Bank account in Mode of Payment {0}").format(mode_of_payment))
|
||||||
|
@ -169,4 +169,5 @@ erpnext.patches.v5_0.update_material_transferred_for_manufacturing_again
|
|||||||
erpnext.patches.v5_0.index_on_account_and_gl_entry
|
erpnext.patches.v5_0.index_on_account_and_gl_entry
|
||||||
execute:frappe.db.sql("""delete from `tabProject Task`""")
|
execute:frappe.db.sql("""delete from `tabProject Task`""")
|
||||||
erpnext.patches.v5_0.item_variants
|
erpnext.patches.v5_0.item_variants
|
||||||
erpnext.patches.v5_0.update_item_desc_in_invoice
|
erpnext.patches.v5_0.update_item_desc_in_invoice
|
||||||
|
erpnext.patches.v5_1.fix_against_account
|
||||||
|
0
erpnext/patches/v5_1/__init__.py
Normal file
0
erpnext/patches/v5_1/__init__.py
Normal file
37
erpnext/patches/v5_1/fix_against_account.py
Normal file
37
erpnext/patches/v5_1/fix_against_account.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
from erpnext.accounts.doctype.gl_entry.gl_entry import update_against_account
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
from_date = "2015-01-01"
|
||||||
|
|
||||||
|
for doc in frappe.get_all("Journal Entry",
|
||||||
|
filters={"creation": (">", from_date), "docstatus": "1"}):
|
||||||
|
|
||||||
|
# update in gl_entry
|
||||||
|
update_against_account("Journal Entry", doc.name)
|
||||||
|
|
||||||
|
# update in jv
|
||||||
|
doc = frappe.get_doc("Journal Entry", doc.name)
|
||||||
|
doc.set_against_account()
|
||||||
|
doc.db_update()
|
||||||
|
|
||||||
|
for doc in frappe.get_all("Sales Invoice",
|
||||||
|
filters={"creation": (">", from_date), "docstatus": "1"},
|
||||||
|
fields=["name", "customer"]):
|
||||||
|
|
||||||
|
frappe.db.sql("""update `tabGL Entry` set against=%s
|
||||||
|
where voucher_type='Sales Invoice' and voucher_no=%s
|
||||||
|
and credit > 0 and ifnull(party, '')=''""",
|
||||||
|
(doc.customer, doc.name))
|
||||||
|
|
||||||
|
for doc in frappe.get_all("Purchase Invoice",
|
||||||
|
filters={"creation": (">", from_date), "docstatus": "1"},
|
||||||
|
fields=["name", "supplier"]):
|
||||||
|
|
||||||
|
frappe.db.sql("""update `tabGL Entry` set against=%s
|
||||||
|
where voucher_type='Purchase Invoice' and voucher_no=%s
|
||||||
|
and debit > 0 and ifnull(party, '')=''""",
|
||||||
|
(doc.supplier, doc.name))
|
Loading…
x
Reference in New Issue
Block a user