[regional] ability to send gst reminders to all parties

This commit is contained in:
Rushabh Mehta
2017-06-27 17:31:41 +05:30
parent 51520f9de6
commit 00ae424cac
22 changed files with 432 additions and 71 deletions

View File

@@ -0,0 +1,37 @@
{% extends "templates/web.html" %}
{% block title %}Update GSTIN{% endblock %}
{% block header %}<h2>Update GSTIN</h2>{% endblock %}
{% block page_content %}
<h3>{{ party.name }}</h3>
{% if invalid_gstin %}
<p class='alert alert-danger' style='max-width: 300px;'>
Invalid GSTIN
</p>
<p>
<a href="?party={{ party.name }}">Edit Again</a>
</p>
{% elif updated %}
<p class='alert alert-success' style='max-width: 300px;'>
<i class='octicon octicon-check'></i> GSTIN Updated
</p>
<p>
<a href="?party={{ party.name }}">Edit Again</a>
</p>
{% else %}
<p class='text-muted'>Please update your GSTIN for us to issue correct tax invoice</p>
<form method='GET' action='/regional/india/update-gstin.html'>
<input type='hidden' value='{{ party.name }}' name='party'>
{% for address in party.__onload.addr_list %}
<div class='bordered' style='max-width: 300px; margin-bottom: 15px;'>
{{ address.display }}
<p><input type='text' class='form-control'
value='{{ address.gstin }}' name='{{ address.name }}' placeholder='GSTIN'></p>
</div>
{% endfor %}
<p><input type='submit' class='btn btn-primary' value='Update'></p>
</form>
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,40 @@
import frappe
from frappe import _
def get_context(context):
context.no_cache = 1
party = frappe.form_dict.party
try:
update_gstin(context)
except frappe.ValidationError:
context.invalid_gstin = 1
party_type = 'Customer'
party = frappe.db.get_value('Customer', party)
if not party:
party_type = 'Supplier'
party = frappe.db.get_value('Supplier', party)
if not party:
frappe.throw(_("Not Found"), frappe.DoesNotExistError)
context.party = frappe.get_doc(party_type, party)
context.party.onload()
def update_gstin(context):
dirty = False
for key, value in frappe.form_dict.items():
if key != 'party':
address_name = frappe.get_value('Address', key)
if address_name:
address = frappe.get_doc('Address', address_name)
address.gstin = value
address.save(ignore_permissions=True)
dirty = True
if dirty:
frappe.db.commit()
context.updated = True