Merge branch 'develop' into so-mr-wo-back-update

This commit is contained in:
Marica 2022-02-15 17:51:54 +05:30 committed by GitHub
commit e6fa33012f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 32 deletions

View File

@ -319,13 +319,18 @@ def make_reverse_gl_entries(gl_entries=None, voucher_type=None, voucher_no=None,
""" """
if not gl_entries: if not gl_entries:
gl_entries = frappe.get_all("GL Entry", gl_entry = frappe.qb.DocType("GL Entry")
fields = ["*"], gl_entries = (frappe.qb.from_(
filters = { gl_entry
"voucher_type": voucher_type, ).select(
"voucher_no": voucher_no, '*'
"is_cancelled": 0 ).where(
}) gl_entry.voucher_type == voucher_type
).where(
gl_entry.voucher_no == voucher_no
).where(
gl_entry.is_cancelled == 0
).for_update()).run(as_dict=1)
if gl_entries: if gl_entries:
validate_accounting_period(gl_entries) validate_accounting_period(gl_entries)
@ -333,23 +338,24 @@ def make_reverse_gl_entries(gl_entries=None, voucher_type=None, voucher_no=None,
set_as_cancel(gl_entries[0]['voucher_type'], gl_entries[0]['voucher_no']) set_as_cancel(gl_entries[0]['voucher_type'], gl_entries[0]['voucher_no'])
for entry in gl_entries: for entry in gl_entries:
entry['name'] = None new_gle = copy.deepcopy(entry)
debit = entry.get('debit', 0) new_gle['name'] = None
credit = entry.get('credit', 0) debit = new_gle.get('debit', 0)
credit = new_gle.get('credit', 0)
debit_in_account_currency = entry.get('debit_in_account_currency', 0) debit_in_account_currency = new_gle.get('debit_in_account_currency', 0)
credit_in_account_currency = entry.get('credit_in_account_currency', 0) credit_in_account_currency = new_gle.get('credit_in_account_currency', 0)
entry['debit'] = credit new_gle['debit'] = credit
entry['credit'] = debit new_gle['credit'] = debit
entry['debit_in_account_currency'] = credit_in_account_currency new_gle['debit_in_account_currency'] = credit_in_account_currency
entry['credit_in_account_currency'] = debit_in_account_currency new_gle['credit_in_account_currency'] = debit_in_account_currency
entry['remarks'] = "On cancellation of " + entry['voucher_no'] new_gle['remarks'] = "On cancellation of " + new_gle['voucher_no']
entry['is_cancelled'] = 1 new_gle['is_cancelled'] = 1
if entry['debit'] or entry['credit']: if new_gle['debit'] or new_gle['credit']:
make_entry(entry, adv_adj, "Yes") make_entry(new_gle, adv_adj, "Yes")
def check_freezing_date(posting_date, adv_adj=False): def check_freezing_date(posting_date, adv_adj=False):

View File

@ -23,7 +23,7 @@ def validate_filters(filters):
def get_result(filters, tds_docs, tds_accounts, tax_category_map): def get_result(filters, tds_docs, tds_accounts, tax_category_map):
supplier_map = get_supplier_pan_map() supplier_map = get_supplier_pan_map()
tax_rate_map = get_tax_rate_map(filters) tax_rate_map = get_tax_rate_map(filters)
gle_map = get_gle_map(filters, tds_docs) gle_map = get_gle_map(tds_docs)
out = [] out = []
for name, details in gle_map.items(): for name, details in gle_map.items():
@ -78,7 +78,7 @@ def get_supplier_pan_map():
return supplier_map return supplier_map
def get_gle_map(filters, documents): def get_gle_map(documents):
# create gle_map of the form # create gle_map of the form
# {"purchase_invoice": list of dict of all gle created for this invoice} # {"purchase_invoice": list of dict of all gle created for this invoice}
gle_map = {} gle_map = {}
@ -86,7 +86,7 @@ def get_gle_map(filters, documents):
gle = frappe.db.get_all('GL Entry', gle = frappe.db.get_all('GL Entry',
{ {
"voucher_no": ["in", documents], "voucher_no": ["in", documents],
"credit": (">", 0) "is_cancelled": 0
}, },
["credit", "debit", "account", "voucher_no", "posting_date", "voucher_type", "against", "party"], ["credit", "debit", "account", "voucher_no", "posting_date", "voucher_type", "against", "party"],
) )
@ -184,21 +184,28 @@ def get_tds_docs(filters):
payment_entries = [] payment_entries = []
journal_entries = [] journal_entries = []
tax_category_map = {} tax_category_map = {}
or_filters = {}
bank_accounts = frappe.get_all('Account', {'is_group': 0, 'account_type': 'Bank'}, pluck="name")
tds_accounts = frappe.get_all("Tax Withholding Account", {'company': filters.get('company')}, tds_accounts = frappe.get_all("Tax Withholding Account", {'company': filters.get('company')},
pluck="account") pluck="account")
query_filters = { query_filters = {
"credit": ('>', 0),
"account": ("in", tds_accounts), "account": ("in", tds_accounts),
"posting_date": ("between", [filters.get("from_date"), filters.get("to_date")]), "posting_date": ("between", [filters.get("from_date"), filters.get("to_date")]),
"is_cancelled": 0 "is_cancelled": 0,
"against": ("not in", bank_accounts)
} }
if filters.get('supplier'): if filters.get("supplier"):
query_filters.update({'against': filters.get('supplier')}) del query_filters["account"]
del query_filters["against"]
or_filters = {
"against": filters.get('supplier'),
"party": filters.get('supplier')
}
tds_docs = frappe.get_all("GL Entry", query_filters, ["voucher_no", "voucher_type", "against", "party"]) tds_docs = frappe.get_all("GL Entry", filters=query_filters, or_filters=or_filters, fields=["voucher_no", "voucher_type", "against", "party"])
for d in tds_docs: for d in tds_docs:
if d.voucher_type == "Purchase Invoice": if d.voucher_type == "Purchase Invoice":

View File

@ -227,11 +227,11 @@ erpnext.selling.SellingController = class SellingController extends erpnext.Tran
}, },
callback:function(r){ callback:function(r){
if (in_list(['Delivery Note', 'Sales Invoice'], doc.doctype)) { if (in_list(['Delivery Note', 'Sales Invoice'], doc.doctype)) {
if (doc.doctype === 'Sales Invoice' && (!doc.update_stock)) return; if (doc.doctype === 'Sales Invoice' && (!doc.update_stock)) return;
if (has_batch_no) {
me.set_batch_number(cdt, cdn); me.set_batch_number(cdt, cdn);
me.batch_no(doc, cdt, cdn); me.batch_no(doc, cdt, cdn);
}
} }
} }
}); });