- Billing Setting form description

- Date in invoice
This commit is contained in:
Setyo Nugroho 2022-09-20 06:05:57 +07:00
parent c5a56b4670
commit 64dffec3ae
12 changed files with 29 additions and 21 deletions

View file

@ -1,2 +1,3 @@
django-money==2.0.1
python-dateutil==2.8.2
Pillow>=6.2.0

View file

@ -38,6 +38,9 @@ class SettingForm(forms.SelfHandlingForm):
try:
result = ""
for k, v in data.items():
if k == 'company_logo' and v is None:
continue
result = self.USE_CASE.set_setting(
request=request,
key=k,

View file

@ -4,6 +4,9 @@
{% block modal-body-right %}
<h3>{% trans "Description:" %}</h3>
<p>{% trans 'Update a billing setting.' %}</p>
<p>{% trans '<b>Company Name</b> : Your Company Name that will be included in invoice' %}</p>
<p>{% trans '<b>Company Logo</b> : A logo that will be used in invoice' %}</p>
<p>{% trans '<b>Email Admin</b> : Used to send a notification related invoice and error' %}</p>
<p>{% trans '<b>Invoice Tax</b> : Tax that will be calculated for each invoice' %}</p>
{% endblock %}

View file

@ -11,6 +11,7 @@
# under the License.
from django import shortcuts
from django.urls import reverse_lazy
from django.utils.html import format_html
from django.utils.translation import ugettext_lazy as _
from horizon import views, exceptions, messages, tables, forms
@ -30,12 +31,11 @@ class IndexView(tables.DataTableView):
def get_data(self):
try:
setting_uc = self.setting_uc.get_setting_admin(self.request)
except Exception:
setting_uc = self.setting_uc.get_setting_admin(self.request, )
except Exception as e:
setting_uc = []
exceptions.handle(self.request,
_("Unable to retrieve data."))
_("Unable to retrieve data." + str(e)))
return setting_uc
def get_context_data(self, **kwargs):
@ -65,7 +65,9 @@ class UpdateSettingView(forms.ModalFormView):
def get_initial(self):
try:
setting_uc = dict(self.setting_uc.get_setting_admin(self.request))
setting_uc = dict(self.setting_uc.get_setting_admin(self.request, transform_logo=False))
# Remove company logo from initial data because we can't show image in the form
del setting_uc['company_logo']
except Exception:
setting_uc = None
exceptions.handle(self.request,

View file

@ -78,7 +78,7 @@
<div class="col-xs-6 text-right">
<address>
<strong>Invoice Month:</strong><br>
{{ invoice.start_date|date:"M Y" }}
{{ invoice.start_date|date:"d M Y" }}
<br>
<br>
<strong>Invoice State:</strong><br>

View file

@ -55,7 +55,7 @@ class IndexView(tables.DataTableView):
data.append({
'id': d['id'],
'project_id': project_id,
'date': formats.date_format(d['start_date'], 'M Y'),
'date': formats.date_format(d['start_date'], 'd M Y'),
'state': state_to_text(d['state']),
'total': d['total_money'] or d['subtotal_money']
})

View file

@ -5,10 +5,10 @@ from django.utils.html import format_html
class SettingUseCase:
def get_settings(self, request):
def get_settings(self, request, transform_logo=True):
response = yuyu_client.get(request, "settings/").json()
if response["company_logo"]:
if transform_logo and response["company_logo"]:
# convert base64 img
response['company_logo'] = format_html(
'<img height="50" src="data:;base64,{}">',
@ -22,10 +22,9 @@ class SettingUseCase:
"value": value
}).json()
def get_setting_admin(self, request):
keys_to_exclude = ['billing_enabled',
'email_notification']
response = self.get_settings(request)
def get_setting_admin(self, request, transform_logo=True):
keys_to_exclude = ['billing_enabled']
response = self.get_settings(request, transform_logo=transform_logo)
return [x for x in response.items() if x[0] not in keys_to_exclude]

View file

@ -3,6 +3,6 @@
{% block modal-body-right %}
<h3>{% trans "Description:" %}</h3>
<p>{% trans 'Update a billing setting.' %}</p>
<p>{% trans '<b>Email Notification</b> : will be used to send a notification related to your project such as new invoice' %}</p>
{% endblock %}

View file

@ -1,7 +1,7 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Create/Update Volume Price" %}{% endblock %}
{% block title %}{% trans "Billing Setting" %}{% endblock %}
{% block main %}
{% include "project/billing_setting/_form_setting.html" %}

View file

@ -78,7 +78,7 @@
<div class="col-xs-6 text-right">
<address>
<strong>Invoice Month:</strong><br>
{{ invoice.start_date|date:"M Y" }}
{{ invoice.start_date|date:"d M Y" }}
<br>
<br>
<strong>Invoice State:</strong><br>

View file

@ -4,7 +4,7 @@
<a class="btn btn-default" href="?print=true" target="_blank">Download PDF</a>
<br/>
<br/>
{% include 'admin/projects_invoice/base_invoice.html' %}
{% include 'project/invoice/base_invoice.html' %}
{% endblock %}
{% block js %}
{{ block.super }}

View file

@ -42,7 +42,7 @@ class IndexView(tables.DataTableView):
for d in self.invoice_uc.get_simple_list(self.request):
data.append({
'id': d['id'],
'date': formats.date_format(d['start_date'], 'M Y'),
'date': formats.date_format(d['start_date'], 'd M Y'),
'state': state_to_text(d['state']),
'total': d['total_money'] or d['subtotal_money']
})