[fixes] email digest

This commit is contained in:
Rushabh Mehta
2015-10-15 16:31:16 +05:30
parent 3a519f269d
commit 2e7f9d2b8f
4 changed files with 69 additions and 46 deletions

View File

@@ -84,6 +84,8 @@ def get_balance_on(account=None, date=None, party_type=None, party=None, in_acco
if account:
acc = frappe.get_doc("Account", account)
if not frappe.flags.ignore_account_permission:
acc.check_permission("read")
# for pl accounts, get balance within a fiscal year

View File

@@ -23,6 +23,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
});
}, "icon-eye-open", "btn-default");
if(user==="Administrator") {
cur_frm.add_custom_button(__('Send Now'), function() {
doc = locals[dt][dn];
if(doc.__unsaved != 1) {
@@ -39,6 +40,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
msgprint(save_msg);
}
}, "icon-envelope", "btn-default");
}
}
cur_frm.cscript.addremove_recipients = function(doc, dt, dn) {

View File

@@ -69,6 +69,8 @@ class EmailDigest(Document):
def get_msg_html(self):
"""Build email digest content"""
frappe.flags.ignore_account_permission = True
context = frappe._dict()
context.update(self.__dict__)
@@ -84,6 +86,8 @@ class EmailDigest(Document):
if not (context.events or context.todo_list or context.notifications or context.cards):
return None
frappe.flags.ignore_account_permission = False
# style
return frappe.render_template("erpnext/setup/doctype/email_digest/templates/default.html",
context, is_path=True)
@@ -103,11 +107,13 @@ class EmailDigest(Document):
def set_style(self, context):
"""Set standard digest style"""
context.text_muted = '#8D99A6'
context.h1 = 'margin-bottom: 30px; margin-bottom: 0'
context.text_color = '#36414C'
context.h1 = 'margin-bottom: 30px; margin-bottom: 0; margin-top: 40px; font-weight: 400;'
context.label_css = '''display: inline-block; color: {text_muted};
padding: 3px 7px; margin-right: 7px;'''.format(text_muted = context.text_muted)
context.section_head = 'margin-top: 60px;'
context.line_item = 'padding: 7px 0px; margin: 0; border-bottom: 1px solid #d1d8dd;'
context.section_head = 'margin-top: 60px; font-size: 16px;'
context.line_item = 'padding: 5px 0px; margin: 0; border-bottom: 1px solid #d1d8dd;'
context.link_css = 'color: {text_color}; text-decoration: none;'.format(text_color = context.text_color)
def get_notifications(self):
@@ -154,10 +160,18 @@ class EmailDigest(Document):
def set_accounting_cards(self, context):
"""Create accounting cards if checked"""
cache = frappe.cache()
context.cards = []
for key in ("income", "expenses_booked", "income_year_to_date", "expense_year_to_date",
"invoiced_amount", "payables", "bank_balance"):
if self.get(key):
cache_key = "email_digest:card:" + key
card = cache.get(cache_key)
if card:
card = eval(card)
else:
card = frappe._dict(getattr(self, "get_" + key)())
# format values
@@ -174,6 +188,8 @@ class EmailDigest(Document):
card.value = self.fmt_money(card.value)
cache.setex(cache_key, card, 24 * 60 * 60)
context.cards.append(card)
def get_income(self):

View File

@@ -1,9 +1,9 @@
{% macro show_card(card) %}
<div style="width: 50%; float:left; min-height: 120px; padding-top: 20px;">
<h6 style="color: {{ text_muted }}">{{ card.label }}</h6>
<h4>{{ card.value }}</h4>
<div style="width: 50%; float:left; min-height: 80px; padding-top: 20px;">
<h6 style="color: {{ text_muted }}; font-size: 12px; margin-bottom: 0px; margin-top: 0px;">{{ card.label }}</h6>
<h4 style="margin-top: 7px; font-size: 16px;">{{ card.value }}</h4>
{% if card.diff %}
<p style="color: {{ text_muted }}">{{ card.diff }}%</p>
<p style="color: {{ text_muted }}; font-size: 12px;">{{ card.diff }}%</p>
{% endif %}
</div>
{% endmacro %}
@@ -12,7 +12,7 @@
{% if cards %}
<h1 style="{{ h1 }}">{{ title }}</h1>
<h4 style="font-weight: normal; color: {{ text_muted }}; margin-top: 7px">
<h4 style="font-weight: normal; color: {{ text_muted }}; margin-top: 7px; font-size: 16px; margin-top: 7px;">
<p>{% if frequency == "Daily "%}
{{ frappe.format_date(future_from_date) }}
{% else %}
@@ -31,6 +31,7 @@
{% endif %}
{% if events or todo_list or notifications %}
<h1 style="{{ h1 }}">{{ _("Pending Activities") }}</h1>
<!-- events -->
@@ -45,7 +46,7 @@
<table style="width: 100%;">
<tr>
<td>
<a href="{{ e.link }}">{{ e.subject }}</a>
<a style="{{ link_css }}" href="{{ e.link }}">{{ e.subject }}</a>
</td>
<td style="width: 40%; text-align: right">
<span style="{{ label_css }}">
@@ -72,7 +73,7 @@
<table style="width: 100%;">
<tr>
<td>
<a href="{{ t.link }}">{{ t.description }}</a>
<a style="{{ link_css }}" href="{{ t.link }}">{{ t.description }}</a>
</td>
<td style="width: 25%; text-align: right">
<span style="{{ label_css }}">
@@ -95,7 +96,7 @@
<table style="width: 100%;">
<tr>
<td>
<a href="n.link">{{ n.key }}</a>
<a style="{{ link_css }}" href="{{ n.link }}">{{ n.key }}</a>
</td>
<td style="width: 25%; text-align: right">
<span style="{{ label_css }}">
@@ -109,3 +110,5 @@
</div>
{% endif %}
</div>
{% endif %}