Anand Doshi | 885e074 | 2015-03-03 14:55:30 +0530 | [diff] [blame] | 1 | # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors |
Rushabh Mehta | e67d1fb | 2013-08-05 14:59:54 +0530 | [diff] [blame] | 2 | # License: GNU General Public License v3. See license.txt |
Nabin Hait | bf495c9 | 2013-01-30 12:49:08 +0530 | [diff] [blame] | 3 | |
| 4 | from __future__ import unicode_literals |
Rohit Waghchaure | e9ff191 | 2017-06-19 12:54:59 +0530 | [diff] [blame] | 5 | import frappe, erpnext |
Nabin Hait | 818d967 | 2015-06-22 18:21:38 +0530 | [diff] [blame] | 6 | from frappe.utils import flt, cstr, cint |
Rushabh Mehta | 793ba6b | 2014-02-14 15:47:51 +0530 | [diff] [blame] | 7 | from frappe import _ |
Nabin Hait | e2c200a | 2015-05-28 13:00:37 +0530 | [diff] [blame] | 8 | from frappe.model.meta import get_field_precision |
Nabin Hait | b9bc7d6 | 2016-05-16 14:38:47 +0530 | [diff] [blame] | 9 | from erpnext.accounts.doctype.budget.budget import validate_expense_against_budget |
Nabin Hait | bf495c9 | 2013-01-30 12:49:08 +0530 | [diff] [blame] | 10 | |
Nabin Hait | bb77756 | 2013-08-29 18:19:37 +0530 | [diff] [blame] | 11 | |
Rushabh Mehta | 793ba6b | 2014-02-14 15:47:51 +0530 | [diff] [blame] | 12 | class StockAccountInvalidTransaction(frappe.ValidationError): pass |
Nabin Hait | bf495c9 | 2013-01-30 12:49:08 +0530 | [diff] [blame] | 13 | |
Nabin Hait | 9784d27 | 2016-12-30 16:21:35 +0530 | [diff] [blame] | 14 | def make_gl_entries(gl_map, cancel=False, adv_adj=False, merge_entries=True, update_outstanding='Yes', from_repost=False): |
Nabin Hait | 2e296fa | 2013-08-28 18:53:11 +0530 | [diff] [blame] | 15 | if gl_map: |
| 16 | if not cancel: |
| 17 | gl_map = process_gl_map(gl_map, merge_entries) |
nabinhait | c343292 | 2014-07-29 18:06:18 +0530 | [diff] [blame] | 18 | if gl_map and len(gl_map) > 1: |
Nabin Hait | 9784d27 | 2016-12-30 16:21:35 +0530 | [diff] [blame] | 19 | save_entries(gl_map, adv_adj, update_outstanding, from_repost) |
nabinhait | c343292 | 2014-07-29 18:06:18 +0530 | [diff] [blame] | 20 | else: |
nabinhait | 4859b48 | 2014-07-30 14:28:24 +0530 | [diff] [blame] | 21 | frappe.throw(_("Incorrect number of General Ledger Entries found. You might have selected a wrong Account in the transaction.")) |
Nabin Hait | 2e296fa | 2013-08-28 18:53:11 +0530 | [diff] [blame] | 22 | else: |
| 23 | delete_gl_entries(gl_map, adv_adj=adv_adj, update_outstanding=update_outstanding) |
Anand Doshi | 652bc07 | 2014-04-16 15:21:46 +0530 | [diff] [blame] | 24 | |
Nabin Hait | 27994c2 | 2013-08-26 16:53:30 +0530 | [diff] [blame] | 25 | def process_gl_map(gl_map, merge_entries=True): |
Nabin Hait | bf495c9 | 2013-01-30 12:49:08 +0530 | [diff] [blame] | 26 | if merge_entries: |
| 27 | gl_map = merge_similar_entries(gl_map) |
Nabin Hait | 27994c2 | 2013-08-26 16:53:30 +0530 | [diff] [blame] | 28 | for entry in gl_map: |
Anand Doshi | 602e825 | 2015-11-16 19:05:46 +0530 | [diff] [blame] | 29 | # toggle debit, credit if negative entry |
Nabin Hait | 88f3cd5 | 2013-10-23 16:29:19 +0530 | [diff] [blame] | 30 | if flt(entry.debit) < 0: |
| 31 | entry.credit = flt(entry.credit) - flt(entry.debit) |
| 32 | entry.debit = 0.0 |
Anand Doshi | 602e825 | 2015-11-16 19:05:46 +0530 | [diff] [blame] | 33 | |
Nabin Hait | c561a49 | 2015-08-19 19:22:34 +0530 | [diff] [blame] | 34 | if flt(entry.debit_in_account_currency) < 0: |
| 35 | entry.credit_in_account_currency = \ |
| 36 | flt(entry.credit_in_account_currency) - flt(entry.debit_in_account_currency) |
| 37 | entry.debit_in_account_currency = 0.0 |
Anand Doshi | 602e825 | 2015-11-16 19:05:46 +0530 | [diff] [blame] | 38 | |
Nabin Hait | 88f3cd5 | 2013-10-23 16:29:19 +0530 | [diff] [blame] | 39 | if flt(entry.credit) < 0: |
| 40 | entry.debit = flt(entry.debit) - flt(entry.credit) |
| 41 | entry.credit = 0.0 |
Anand Doshi | 602e825 | 2015-11-16 19:05:46 +0530 | [diff] [blame] | 42 | |
Nabin Hait | c561a49 | 2015-08-19 19:22:34 +0530 | [diff] [blame] | 43 | if flt(entry.credit_in_account_currency) < 0: |
| 44 | entry.debit_in_account_currency = \ |
| 45 | flt(entry.debit_in_account_currency) - flt(entry.credit_in_account_currency) |
| 46 | entry.credit_in_account_currency = 0.0 |
Anand Doshi | 602e825 | 2015-11-16 19:05:46 +0530 | [diff] [blame] | 47 | |
Nabin Hait | 27994c2 | 2013-08-26 16:53:30 +0530 | [diff] [blame] | 48 | return gl_map |
Anand Doshi | 652bc07 | 2014-04-16 15:21:46 +0530 | [diff] [blame] | 49 | |
Nabin Hait | bf495c9 | 2013-01-30 12:49:08 +0530 | [diff] [blame] | 50 | def merge_similar_entries(gl_map): |
| 51 | merged_gl_map = [] |
| 52 | for entry in gl_map: |
Anand Doshi | 652bc07 | 2014-04-16 15:21:46 +0530 | [diff] [blame] | 53 | # if there is already an entry in this account then just add it |
Nabin Hait | bf495c9 | 2013-01-30 12:49:08 +0530 | [diff] [blame] | 54 | # to that entry |
| 55 | same_head = check_if_in_list(entry, merged_gl_map) |
| 56 | if same_head: |
Nabin Hait | 2e296fa | 2013-08-28 18:53:11 +0530 | [diff] [blame] | 57 | same_head.debit = flt(same_head.debit) + flt(entry.debit) |
Nabin Hait | c561a49 | 2015-08-19 19:22:34 +0530 | [diff] [blame] | 58 | same_head.debit_in_account_currency = \ |
| 59 | flt(same_head.debit_in_account_currency) + flt(entry.debit_in_account_currency) |
Nabin Hait | 2e296fa | 2013-08-28 18:53:11 +0530 | [diff] [blame] | 60 | same_head.credit = flt(same_head.credit) + flt(entry.credit) |
Nabin Hait | c561a49 | 2015-08-19 19:22:34 +0530 | [diff] [blame] | 61 | same_head.credit_in_account_currency = \ |
| 62 | flt(same_head.credit_in_account_currency) + flt(entry.credit_in_account_currency) |
Nabin Hait | bf495c9 | 2013-01-30 12:49:08 +0530 | [diff] [blame] | 63 | else: |
| 64 | merged_gl_map.append(entry) |
Anand Doshi | 652bc07 | 2014-04-16 15:21:46 +0530 | [diff] [blame] | 65 | |
Nabin Hait | 815a49e | 2013-08-07 17:00:01 +0530 | [diff] [blame] | 66 | # filter zero debit and credit entries |
Nabin Hait | 2e54da2 | 2015-08-13 12:19:20 +0530 | [diff] [blame] | 67 | merged_gl_map = filter(lambda x: flt(x.debit, 9)!=0 or flt(x.credit, 9)!=0, merged_gl_map) |
Achilles Rasquinha | 908289d | 2018-03-08 13:10:51 +0530 | [diff] [blame] | 68 | merged_gl_map = list(merged_gl_map) |
Rushabh Mehta | 708e47a | 2018-08-08 16:37:31 +0530 | [diff] [blame] | 69 | |
Nabin Hait | bf495c9 | 2013-01-30 12:49:08 +0530 | [diff] [blame] | 70 | return merged_gl_map |
| 71 | |
Nabin Hait | bb77756 | 2013-08-29 18:19:37 +0530 | [diff] [blame] | 72 | def check_if_in_list(gle, gl_map): |
| 73 | for e in gl_map: |
Nabin Hait | 1119026 | 2015-06-01 16:21:25 +0530 | [diff] [blame] | 74 | if e.account == gle.account \ |
| 75 | and cstr(e.get('party_type'))==cstr(gle.get('party_type')) \ |
| 76 | and cstr(e.get('party'))==cstr(gle.get('party')) \ |
| 77 | and cstr(e.get('against_voucher'))==cstr(gle.get('against_voucher')) \ |
| 78 | and cstr(e.get('against_voucher_type')) == cstr(gle.get('against_voucher_type')) \ |
Nabin Hait | 591a5ab | 2016-05-26 17:41:39 +0530 | [diff] [blame] | 79 | and cstr(e.get('cost_center')) == cstr(gle.get('cost_center')) \ |
| 80 | and cstr(e.get('project')) == cstr(gle.get('project')): |
Nabin Hait | 1119026 | 2015-06-01 16:21:25 +0530 | [diff] [blame] | 81 | return e |
Nabin Hait | bf495c9 | 2013-01-30 12:49:08 +0530 | [diff] [blame] | 82 | |
Nabin Hait | 9784d27 | 2016-12-30 16:21:35 +0530 | [diff] [blame] | 83 | def save_entries(gl_map, adv_adj, update_outstanding, from_repost=False): |
| 84 | if not from_repost: |
Rohit Waghchaure | a5f4094 | 2017-06-16 15:21:36 +0530 | [diff] [blame] | 85 | validate_account_for_perpetual_inventory(gl_map) |
Rushabh Mehta | 708e47a | 2018-08-08 16:37:31 +0530 | [diff] [blame] | 86 | |
Nabin Hait | e2c200a | 2015-05-28 13:00:37 +0530 | [diff] [blame] | 87 | round_off_debit_credit(gl_map) |
Anand Doshi | 602e825 | 2015-11-16 19:05:46 +0530 | [diff] [blame] | 88 | |
Nabin Hait | bf495c9 | 2013-01-30 12:49:08 +0530 | [diff] [blame] | 89 | for entry in gl_map: |
Nabin Hait | 9784d27 | 2016-12-30 16:21:35 +0530 | [diff] [blame] | 90 | make_entry(entry, adv_adj, update_outstanding, from_repost) |
Rushabh Mehta | 708e47a | 2018-08-08 16:37:31 +0530 | [diff] [blame] | 91 | |
Nabin Hait | 27994c2 | 2013-08-26 16:53:30 +0530 | [diff] [blame] | 92 | # check against budget |
Nabin Hait | 9784d27 | 2016-12-30 16:21:35 +0530 | [diff] [blame] | 93 | if not from_repost: |
| 94 | validate_expense_against_budget(entry) |
Anand Doshi | 652bc07 | 2014-04-16 15:21:46 +0530 | [diff] [blame] | 95 | |
Nabin Hait | 9784d27 | 2016-12-30 16:21:35 +0530 | [diff] [blame] | 96 | def make_entry(args, adv_adj, update_outstanding, from_repost=False): |
Nabin Hait | aeba24e | 2013-08-23 15:17:36 +0530 | [diff] [blame] | 97 | args.update({"doctype": "GL Entry"}) |
Rushabh Mehta | a504f06 | 2014-04-04 12:16:26 +0530 | [diff] [blame] | 98 | gle = frappe.get_doc(args) |
Anand Doshi | 6dfd430 | 2015-02-10 14:41:27 +0530 | [diff] [blame] | 99 | gle.flags.ignore_permissions = 1 |
Nabin Hait | 9784d27 | 2016-12-30 16:21:35 +0530 | [diff] [blame] | 100 | gle.flags.from_repost = from_repost |
Nabin Hait | aeba24e | 2013-08-23 15:17:36 +0530 | [diff] [blame] | 101 | gle.insert() |
Nabin Hait | 9784d27 | 2016-12-30 16:21:35 +0530 | [diff] [blame] | 102 | gle.run_method("on_update_with_args", adv_adj, update_outstanding, from_repost) |
Nabin Hait | aeba24e | 2013-08-23 15:17:36 +0530 | [diff] [blame] | 103 | gle.submit() |
Anand Doshi | 652bc07 | 2014-04-16 15:21:46 +0530 | [diff] [blame] | 104 | |
Rohit Waghchaure | a5f4094 | 2017-06-16 15:21:36 +0530 | [diff] [blame] | 105 | def validate_account_for_perpetual_inventory(gl_map): |
Rohit Waghchaure | e9ff191 | 2017-06-19 12:54:59 +0530 | [diff] [blame] | 106 | if cint(erpnext.is_perpetual_inventory_enabled(gl_map[0].company)) \ |
Nabin Hait | e7f479b | 2015-06-22 07:31:49 +0530 | [diff] [blame] | 107 | and gl_map[0].voucher_type=="Journal Entry": |
| 108 | aii_accounts = [d[0] for d in frappe.db.sql("""select name from tabAccount |
Nabin Hait | 6d7b0ce | 2017-06-15 11:09:27 +0530 | [diff] [blame] | 109 | where account_type = 'Stock' and is_group=0""")] |
Anand Doshi | 652bc07 | 2014-04-16 15:21:46 +0530 | [diff] [blame] | 110 | |
Nabin Hait | e7f479b | 2015-06-22 07:31:49 +0530 | [diff] [blame] | 111 | for entry in gl_map: |
| 112 | if entry.account in aii_accounts: |
| 113 | frappe.throw(_("Account: {0} can only be updated via Stock Transactions") |
| 114 | .format(entry.account), StockAccountInvalidTransaction) |
Anand Doshi | 652bc07 | 2014-04-16 15:21:46 +0530 | [diff] [blame] | 115 | |
Nabin Hait | e2c200a | 2015-05-28 13:00:37 +0530 | [diff] [blame] | 116 | def round_off_debit_credit(gl_map): |
| 117 | precision = get_field_precision(frappe.get_meta("GL Entry").get_field("debit"), |
Rushabh Mehta | 708e47a | 2018-08-08 16:37:31 +0530 | [diff] [blame] | 118 | currency=frappe.get_cached_value('Company', gl_map[0].company, "default_currency")) |
Anand Doshi | 602e825 | 2015-11-16 19:05:46 +0530 | [diff] [blame] | 119 | |
Nabin Hait | e2c200a | 2015-05-28 13:00:37 +0530 | [diff] [blame] | 120 | debit_credit_diff = 0.0 |
| 121 | for entry in gl_map: |
| 122 | entry.debit = flt(entry.debit, precision) |
| 123 | entry.credit = flt(entry.credit, precision) |
| 124 | debit_credit_diff += entry.debit - entry.credit |
Anand Doshi | 602e825 | 2015-11-16 19:05:46 +0530 | [diff] [blame] | 125 | |
Nabin Hait | e2c200a | 2015-05-28 13:00:37 +0530 | [diff] [blame] | 126 | debit_credit_diff = flt(debit_credit_diff, precision) |
Rushabh Mehta | 708e47a | 2018-08-08 16:37:31 +0530 | [diff] [blame] | 127 | |
Nabin Hait | d2a966e | 2017-05-05 10:41:16 +0530 | [diff] [blame] | 128 | if gl_map[0]["voucher_type"] in ("Journal Entry", "Payment Entry"): |
Nabin Hait | fb24a27 | 2016-02-18 19:18:07 +0530 | [diff] [blame] | 129 | allowance = 5.0 / (10**precision) |
| 130 | else: |
Nabin Hait | d2a966e | 2017-05-05 10:41:16 +0530 | [diff] [blame] | 131 | allowance = .5 |
Rushabh Mehta | 708e47a | 2018-08-08 16:37:31 +0530 | [diff] [blame] | 132 | |
Nabin Hait | fb24a27 | 2016-02-18 19:18:07 +0530 | [diff] [blame] | 133 | if abs(debit_credit_diff) >= allowance: |
Nabin Hait | e2c200a | 2015-05-28 13:00:37 +0530 | [diff] [blame] | 134 | frappe.throw(_("Debit and Credit not equal for {0} #{1}. Difference is {2}.") |
| 135 | .format(gl_map[0].voucher_type, gl_map[0].voucher_no, debit_credit_diff)) |
Anand Doshi | 602e825 | 2015-11-16 19:05:46 +0530 | [diff] [blame] | 136 | |
Nabin Hait | e2c200a | 2015-05-28 13:00:37 +0530 | [diff] [blame] | 137 | elif abs(debit_credit_diff) >= (1.0 / (10**precision)): |
| 138 | make_round_off_gle(gl_map, debit_credit_diff) |
Anand Doshi | 602e825 | 2015-11-16 19:05:46 +0530 | [diff] [blame] | 139 | |
Nabin Hait | e2c200a | 2015-05-28 13:00:37 +0530 | [diff] [blame] | 140 | def make_round_off_gle(gl_map, debit_credit_diff): |
Nabin Hait | 2e4de83 | 2017-09-19 14:53:16 +0530 | [diff] [blame] | 141 | round_off_account, round_off_cost_center = get_round_off_account_and_cost_center(gl_map[0].company) |
Zarrar | 3523b77 | 2018-08-14 16:28:14 +0530 | [diff] [blame] | 142 | round_off_account_exists = False |
Nabin Hait | 80069a6 | 2015-05-28 19:19:59 +0530 | [diff] [blame] | 143 | round_off_gle = frappe._dict() |
Zarrar | 3523b77 | 2018-08-14 16:28:14 +0530 | [diff] [blame] | 144 | for d in gl_map: |
| 145 | if d.account == round_off_account: |
| 146 | round_off_gle = d |
| 147 | if d.debit_in_account_currency: |
| 148 | debit_credit_diff -= flt(d.debit_in_account_currency) |
| 149 | else: |
| 150 | debit_credit_diff += flt(d.credit_in_account_currency) |
| 151 | round_off_account_exists = True |
| 152 | |
| 153 | if not round_off_gle: |
| 154 | for k in ["voucher_type", "voucher_no", "company", |
| 155 | "posting_date", "remarks", "is_opening"]: |
| 156 | round_off_gle[k] = gl_map[0][k] |
Anand Doshi | 602e825 | 2015-11-16 19:05:46 +0530 | [diff] [blame] | 157 | |
Nabin Hait | e2c200a | 2015-05-28 13:00:37 +0530 | [diff] [blame] | 158 | round_off_gle.update({ |
| 159 | "account": round_off_account, |
Nabin Hait | d4507ac | 2016-01-20 16:14:27 +0530 | [diff] [blame] | 160 | "debit_in_account_currency": abs(debit_credit_diff) if debit_credit_diff < 0 else 0, |
| 161 | "credit_in_account_currency": debit_credit_diff if debit_credit_diff > 0 else 0, |
Nabin Hait | e2c200a | 2015-05-28 13:00:37 +0530 | [diff] [blame] | 162 | "debit": abs(debit_credit_diff) if debit_credit_diff < 0 else 0, |
| 163 | "credit": debit_credit_diff if debit_credit_diff > 0 else 0, |
Nabin Hait | 3c67146 | 2015-05-28 13:19:01 +0530 | [diff] [blame] | 164 | "cost_center": round_off_cost_center, |
| 165 | "party_type": None, |
| 166 | "party": None, |
| 167 | "against_voucher_type": None, |
| 168 | "against_voucher": None |
Nabin Hait | e2c200a | 2015-05-28 13:00:37 +0530 | [diff] [blame] | 169 | }) |
Anand Doshi | 602e825 | 2015-11-16 19:05:46 +0530 | [diff] [blame] | 170 | |
Zarrar | 3523b77 | 2018-08-14 16:28:14 +0530 | [diff] [blame] | 171 | if not round_off_account_exists: |
| 172 | gl_map.append(round_off_gle) |
Nabin Hait | e2c200a | 2015-05-28 13:00:37 +0530 | [diff] [blame] | 173 | |
Nabin Hait | 2e4de83 | 2017-09-19 14:53:16 +0530 | [diff] [blame] | 174 | def get_round_off_account_and_cost_center(company): |
Rushabh Mehta | 708e47a | 2018-08-08 16:37:31 +0530 | [diff] [blame] | 175 | round_off_account, round_off_cost_center = frappe.get_cached_value('Company', company, |
Nabin Hait | 2e4de83 | 2017-09-19 14:53:16 +0530 | [diff] [blame] | 176 | ["round_off_account", "round_off_cost_center"]) or [None, None] |
| 177 | if not round_off_account: |
| 178 | frappe.throw(_("Please mention Round Off Account in Company")) |
| 179 | |
| 180 | if not round_off_cost_center: |
| 181 | frappe.throw(_("Please mention Round Off Cost Center in Company")) |
| 182 | |
| 183 | return round_off_account, round_off_cost_center |
| 184 | |
Anand Doshi | 652bc07 | 2014-04-16 15:21:46 +0530 | [diff] [blame] | 185 | def delete_gl_entries(gl_entries=None, voucher_type=None, voucher_no=None, |
Nabin Hait | 2e296fa | 2013-08-28 18:53:11 +0530 | [diff] [blame] | 186 | adv_adj=False, update_outstanding="Yes"): |
Anand Doshi | 652bc07 | 2014-04-16 15:21:46 +0530 | [diff] [blame] | 187 | |
Nabin Hait | 53822ae | 2014-03-03 19:18:17 +0530 | [diff] [blame] | 188 | from erpnext.accounts.doctype.gl_entry.gl_entry import validate_balance_type, \ |
Nabin Hait | 11f4195 | 2013-09-24 14:36:55 +0530 | [diff] [blame] | 189 | check_freezing_date, update_outstanding_amt, validate_frozen_account |
Anand Doshi | 652bc07 | 2014-04-16 15:21:46 +0530 | [diff] [blame] | 190 | |
Nabin Hait | 2e296fa | 2013-08-28 18:53:11 +0530 | [diff] [blame] | 191 | if not gl_entries: |
Nabin Hait | 56548cb | 2016-07-01 15:58:39 +0530 | [diff] [blame] | 192 | gl_entries = frappe.db.sql(""" |
Rohit Waghchaure | b1391ca | 2016-10-03 12:25:04 +0530 | [diff] [blame] | 193 | select account, posting_date, party_type, party, cost_center, fiscal_year,voucher_type, |
| 194 | voucher_no, against_voucher_type, against_voucher, cost_center, company |
Nabin Hait | 56548cb | 2016-07-01 15:58:39 +0530 | [diff] [blame] | 195 | from `tabGL Entry` |
Nabin Hait | 2e296fa | 2013-08-28 18:53:11 +0530 | [diff] [blame] | 196 | where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no), as_dict=True) |
Nabin Hait | 56548cb | 2016-07-01 15:58:39 +0530 | [diff] [blame] | 197 | |
Nabin Hait | 27994c2 | 2013-08-26 16:53:30 +0530 | [diff] [blame] | 198 | if gl_entries: |
| 199 | check_freezing_date(gl_entries[0]["posting_date"], adv_adj) |
Anand Doshi | 652bc07 | 2014-04-16 15:21:46 +0530 | [diff] [blame] | 200 | |
| 201 | frappe.db.sql("""delete from `tabGL Entry` where voucher_type=%s and voucher_no=%s""", |
Nabin Hait | 2e296fa | 2013-08-28 18:53:11 +0530 | [diff] [blame] | 202 | (voucher_type or gl_entries[0]["voucher_type"], voucher_no or gl_entries[0]["voucher_no"])) |
Anand Doshi | 652bc07 | 2014-04-16 15:21:46 +0530 | [diff] [blame] | 203 | |
Nabin Hait | 9b09c95 | 2013-08-21 17:47:11 +0530 | [diff] [blame] | 204 | for entry in gl_entries: |
Nabin Hait | 11f4195 | 2013-09-24 14:36:55 +0530 | [diff] [blame] | 205 | validate_frozen_account(entry["account"], adv_adj) |
Nabin Hait | 53822ae | 2014-03-03 19:18:17 +0530 | [diff] [blame] | 206 | validate_balance_type(entry["account"], adv_adj) |
Nabin Hait | 1e1b236 | 2018-01-29 16:45:43 +0530 | [diff] [blame] | 207 | if not adv_adj: |
| 208 | validate_expense_against_budget(entry) |
Rushabh Mehta | 708e47a | 2018-08-08 16:37:31 +0530 | [diff] [blame] | 209 | |
Nabin Hait | 1e1b236 | 2018-01-29 16:45:43 +0530 | [diff] [blame] | 210 | if entry.get("against_voucher") and update_outstanding == 'Yes' and not adv_adj: |
Nabin Hait | 3225102 | 2014-08-29 11:18:32 +0530 | [diff] [blame] | 211 | update_outstanding_amt(entry["account"], entry.get("party_type"), entry.get("party"), entry.get("against_voucher_type"), |
Rushabh Mehta | c38fc71 | 2014-04-16 17:21:25 +0530 | [diff] [blame] | 212 | entry.get("against_voucher"), on_cancel=True) |