Merge pull request #2393 from nabinhait/fix1
Credit days and payment tool fixes
This commit is contained in:
commit
8c842af172
@ -310,22 +310,19 @@ class JournalVoucher(AccountsController):
|
|||||||
self.total_amount_in_words = money_in_words(amt, company_currency)
|
self.total_amount_in_words = money_in_words(amt, company_currency)
|
||||||
|
|
||||||
def check_credit_days(self):
|
def check_credit_days(self):
|
||||||
date_diff = 0
|
|
||||||
if self.cheque_date:
|
if self.cheque_date:
|
||||||
date_diff = (getdate(self.cheque_date)-getdate(self.posting_date)).days
|
for d in self.get("entries"):
|
||||||
|
if flt(d.credit) > 0 and d.against_invoice \
|
||||||
if date_diff <= 0: return
|
and frappe.db.get_value("Account", d.account, "master_type")=='Customer':
|
||||||
|
posting_date = frappe.db.get_value("Sales Invoice", d.against_invoice, "posting_date")
|
||||||
# Get List of Customer Account
|
|
||||||
acc_list = filter(lambda d: frappe.db.get_value("Account", d.account,
|
|
||||||
"master_type")=='Customer', self.get('entries'))
|
|
||||||
|
|
||||||
for d in acc_list:
|
|
||||||
credit_days = self.get_credit_days_for(d.account)
|
credit_days = self.get_credit_days_for(d.account)
|
||||||
# Check credit days
|
if credit_days:
|
||||||
if credit_days > 0 and not self.get_authorized_user() and cint(date_diff) > credit_days:
|
date_diff = (getdate(self.cheque_date) - getdate(posting_date)).days
|
||||||
msgprint(_("Maximum allowed credit is {0} days after posting date").format(credit_days),
|
if date_diff > flt(credit_days):
|
||||||
raise_exception=1)
|
msgprint(_("Note: Reference Date exceeds allowed credit days by {0} days for {1}")
|
||||||
|
.format(date_diff - flt(credit_days), d.account))
|
||||||
|
if not self.get_authorized_user():
|
||||||
|
raise frappe.ValidationError
|
||||||
|
|
||||||
def get_credit_days_for(self, ac):
|
def get_credit_days_for(self, ac):
|
||||||
if not self.credit_days_for.has_key(ac):
|
if not self.credit_days_for.has_key(ac):
|
||||||
@ -333,8 +330,7 @@ class JournalVoucher(AccountsController):
|
|||||||
|
|
||||||
if not self.credit_days_for[ac]:
|
if not self.credit_days_for[ac]:
|
||||||
if self.credit_days_global==-1:
|
if self.credit_days_global==-1:
|
||||||
self.credit_days_global = cint(frappe.db.get_value("Company",
|
self.credit_days_global = cint(frappe.db.get_value("Company", self.company, "credit_days"))
|
||||||
self.company, "credit_days"))
|
|
||||||
|
|
||||||
return self.credit_days_global
|
return self.credit_days_global
|
||||||
else:
|
else:
|
||||||
@ -343,10 +339,7 @@ class JournalVoucher(AccountsController):
|
|||||||
def get_authorized_user(self):
|
def get_authorized_user(self):
|
||||||
if self.is_approving_authority==-1:
|
if self.is_approving_authority==-1:
|
||||||
self.is_approving_authority = 0
|
self.is_approving_authority = 0
|
||||||
|
approving_authority = frappe.db.get_value("Accounts Settings", None, "credit_controller")
|
||||||
# Fetch credit controller role
|
|
||||||
approving_authority = frappe.db.get_value("Accounts Settings", None,
|
|
||||||
"credit_controller")
|
|
||||||
|
|
||||||
# Check logged-in user is authorized
|
# Check logged-in user is authorized
|
||||||
if approving_authority in frappe.user.get_roles():
|
if approving_authority in frappe.user.get_roles():
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _, scrub
|
from frappe import _
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
import json
|
import json
|
||||||
@ -93,7 +93,7 @@ def get_orders_to_be_billed(party_type, party_name):
|
|||||||
and docstatus = 1
|
and docstatus = 1
|
||||||
and ifnull(status, "") != "Stopped"
|
and ifnull(status, "") != "Stopped"
|
||||||
and ifnull(grand_total, 0) > ifnull(advance_paid, 0)
|
and ifnull(grand_total, 0) > ifnull(advance_paid, 0)
|
||||||
and ifnull(per_billed, 0) < 100.0
|
and abs(100 - ifnull(per_billed, 0)) > 0.01
|
||||||
""" % (voucher_type, 'customer' if party_type == "Customer" else 'supplier', '%s'),
|
""" % (voucher_type, 'customer' if party_type == "Customer" else 'supplier', '%s'),
|
||||||
party_name, as_dict = True)
|
party_name, as_dict = True)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user