Skip to content

Commit

Permalink
stable version
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzobracciale committed Mar 2, 2014
1 parent 3dff9df commit 22f9006
Show file tree
Hide file tree
Showing 17 changed files with 735 additions and 116 deletions.
18 changes: 9 additions & 9 deletions fusolab2_0/apps/bar/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ def get_bar_summary(closing):
d['expected_balance']+=d['opening_amount']

if Receipt.objects.total_between(closing.parent.date,closing.date):
d['receipt_count'] = Receipt.objects.total_between(closing.parent.date,closing.date)
d['receipt_amount'] = Receipt.objects.total_between(closing.parent.date,closing.date)
else:
d['receipt_count'] = 0
d['expected_balance']+=d['receipt_count']
d['receipt_amount'] = 0
d['expected_balance']+=d['receipt_amount']

try:
opening_transactions = BarBalance.objects.get_transactions_for(closing.parent)
Expand Down Expand Up @@ -229,11 +229,11 @@ def get_small_summary(checkpoint):
receipts = receipts.exclude(date__range=[o[0],o[1]])

if receipts:
d['receipt_count'] = receipts.aggregate(Sum('total'))['total__sum']
d['receipt_amount'] = receipts.aggregate(Sum('total'))['total__sum']
else:
d['receipt_count'] = 0
d['receipt_amount'] = 0

d['expected_checkpoint'] += d['receipt_count']
d['expected_checkpoint'] += d['receipt_amount']

d[DEPOSIT] = 0
d[PAYMENT] = 0
Expand All @@ -243,23 +243,23 @@ def get_small_summary(checkpoint):
d[transaction.operation]+=transaction.amount
notes.append(transaction.get_operation_display() + " " + str(transaction.amount))
if transaction.operation in [DEPOSIT]:
d['expected_balance']+=transaction.amount
d['expected_checkpoint']+=transaction.amount
if transaction.subtype:
notes.append(" "+get_deposit_display(transaction.subtype))
if transaction.note:
notes.append(" "+transaction.note.replace("\r\n"," ")+"\n")
else:
notes.append("\n")
elif transaction.operation in [PAYMENT]:
d['expected_balance']-=transaction.amount
d['expected_checkpoint']-=transaction.amount
if transaction.subtype:
notes.append(" "+get_payment_display(transaction.subtype))
if transaction.note:
notes.append(" "+transaction.note.replace("\r\n"," ")+"\n")
else:
notes.append("\n")
elif transaction.operation in [WITHDRAW]:
d['expected_balance']-=transaction.amount
d['expected_checkpoint']-=transaction.amount
if transaction.note:
notes.append(" "+transaction.note.replace("\r\n"," ")+"\n")
else:
Expand Down
2 changes: 1 addition & 1 deletion fusolab2_0/apps/bar/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def bar_handler(sender, **kwargs):
if saved_balance.operation == CLOSING:
d = get_bar_summary(saved_balance)
if ('warning' in d):
template = get_template('closing_mail.html')
template = get_template('base/bar_mail.html')
context = Context(d)
content = template.render(context)
subject = 'WARNING riepilogo bar '+saved_balance.parent.date.strftime("%d/%m/%Y")
Expand Down
16 changes: 14 additions & 2 deletions fusolab2_0/apps/base/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@ def is_polite(txt):
"""
Search for profanities
"""
r = re.compile(r'porco\s?d\w+|madonna|coop|cazzo|culo|stronz|puttana|troia|coglion', re.IGNORECASE)
return not r.search(txt)
text_to_check = txt
# parole da controllare senza gli spazi
r1 = re.compile(r'porc\s?d\w+|madonna|coop|cazzo|culo|stronz|puttana|troia|coglion|piscio|cacca|merda|frocio|puppa|succhi|mortacci', re.IGNORECASE) #profanities
# parole da controllare con gli spazi
r2 = re.compile(r'fica|sorca|pene|vagin|anal|pussy|cock|cumshot|cum', re.IGNORECASE) #profanities
# 3l33t speech
text_to_check = text_to_check.replace("1", "i") #
text_to_check = text_to_check.replace("0", "o") #
text_to_check = text_to_check.replace("3", "e") #
text_to_check = text_to_check.replace("2", "l") #
text_to_check = text_to_check.replace("5", "s") #
text_to_check = text_to_check.replace("8", "otto") #

return (not r1.search(text_to_check) ) and (not r2.search(text_to_check.replace(" ", "")))


9 changes: 6 additions & 3 deletions fusolab2_0/apps/ingresso/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,14 @@ def get_entrance_summary(closing):
except(IndexError, EntranceBalance.DoesNotExist):
pass
#send_mail('allarme chiusura bar', 'errore tragico #1', '[email protected]',NOTIFICATION_ADDRESS_LIST, fail_silently=False)
if Entrance.objects.total_between(closing.parent.date,closing.date):
d['receipt_count'] = Entrance.objects.total_between(closing.parent.date,closing.date)

if Entrance.objects.count_between(closing.parent.date,closing.date) > 0:
d['receipt_count'] = Entrance.objects.count_between(closing.parent.date,closing.date)
d['receipt_amount'] = Entrance.objects.total_between(closing.parent.date,closing.date)
else:
d['receipt_count'] = 0
d['expected_balance']+=d['receipt_count']
d['receipt_amount'] = 0
d['expected_balance']+=d['receipt_amount']

d[DEPOSIT] = 0
d[PAYMENT] = 0
Expand Down
2 changes: 1 addition & 1 deletion fusolab2_0/apps/ingresso/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def entrance_handler(sender, **kwargs):
d = get_entrance_summary(saved_balance)
if ('warning' in d):
subject = ''
template = get_template('closing_mail.html')
template = get_template('base/entrance_mail.html')
context = Context(d)
content = template.render(context)
subject = 'WARNING riepilogo ingresso '+saved_balance.parent.date.strftime("%d/%m/%Y")
Expand Down
2 changes: 1 addition & 1 deletion fusolab2_0/apps/ingresso/templatetags/ingressotags.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def alcoholic_l():
alcoholic_lt = 0.0
for alcholic in alcoholic_list:
alcoholic_lt += PurchasedProduct.objects.filter(receipt__date__gte=open_date, name__icontains=alcholic['name'] ).count() * alcholic['lt']
return alcohol_lt
return alcoholic_lt
else:
return 0

Expand Down
5 changes: 3 additions & 2 deletions fusolab2_0/apps/reports/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,19 @@ def get_stats(request,what,yyyy=None,mm=None,dd=None):
counter_serie.append( [ int(e.date.strftime('%s')+'000') , counter ] )
amount_serie.append( [ int(e.date.strftime('%s')+'000') , e.cost ] )

data.append( {"key" : "Euro" ,"bar": true, "values" : amount_serie } )
data.append( {"key" : "Euro" ,"bar": True, "values" : amount_serie } )
data.append( {"key" : "Numerico" , "values" : counter_serie } )

buffer = simplejson.dumps( data, cls=FuckYeahEncoder )
return HttpResponse(buffer, mimetype = "application/json" )

if what == "total":


values = []
values.append( {"label": "Bar", "value" : Receipt.objects.total_between(start_time,end_time)})
values.append( {"label": "Ingresso", "value" : Entrance.objects.total_between(start_time,end_time)})
data = { "key" : "Cumulative Return" , "values" : values }
data.append({ "key" : "Cumulative Return" , "values" : values })
buffer = simplejson.dumps( data, cls=FuckYeahEncoder )
return HttpResponse(buffer, mimetype = "application/json" )
else:
Expand Down
6 changes: 3 additions & 3 deletions fusolab2_0/apps/reports/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def excel(request, what, from_day, from_month, from_year, to_day, to_month, to_y
sheet.write(rowx, 4, data['pa'],money_format)
sheet.write(rowx, 5, data['closing_amount'],money_format)

sheet.write(rowx, 6, data['receipt_count'],money_format)
sheet.write(rowx, 6, data['receipt_amount'],money_format)
if rowx > 1:
sheet.write(rowx,7,'=B'+str(rowx+1)+'-F'+str(rowx),money_format)
sheet.write(rowx,8,'=K'+str(rowx+1)+'-J'+str(rowx+1),money_format)
Expand Down Expand Up @@ -146,7 +146,7 @@ def excel(request, what, from_day, from_month, from_year, to_day, to_month, to_y
sheet.write(rowx, 4, data['pa'],money_format)
sheet.write(rowx, 5, data['closing_amount'],money_format)

sheet.write(rowx, 6, data['receipt_count'],money_format)
sheet.write(rowx, 6, data['receipt_amount'],money_format)
if rowx > 1:
sheet.write(rowx,7,'=B'+str(rowx+1)+'-F'+str(rowx),money_format)
sheet.write(rowx,8,'=K'+str(rowx+1)+'-J'+str(rowx+1),money_format)
Expand Down Expand Up @@ -225,7 +225,7 @@ def excel(request, what, from_day, from_month, from_year, to_day, to_month, to_y
sheet.write(rowx, 2, data['wi'],money_format)
sheet.write(rowx, 3, data['de'],money_format)
sheet.write(rowx, 4, data['pa'],money_format)
sheet.write(rowx, 5, data['receipt_count'],money_format)
sheet.write(rowx, 5, data['receipt_amount'],money_format)
sheet.write(rowx, 6, data['expected_checkpoint'],money_format)
sheet.write(rowx, 7, data['checkpoint'],money_format)
sheet.write(rowx, 8, data['check'],money_format)
Expand Down
4 changes: 3 additions & 1 deletion fusolab2_0/common/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ <h4><a href="index.html">Fusolab<strong>2.0</strong></a></h4>
<script src="{{ STATIC_URL }}light-blue/lib/nvd3/src/models/lineChart.js"></script>
<script src="{{ STATIC_URL }}light-blue/lib/nvd3/stream_layers.js"></script>
<script src="{{ STATIC_URL }}light-blue/lib/nvd3/src/models/pie.js"></script>
<script src="{{ STATIC_URL }}light-blue/lib/nvd3/src/models/pieChartTotal.js"></script>
<script src="{{ STATIC_URL }}light-blue/lib/nvd3/src/models/linePlusBarChart.js"></script>
<script src="{{ STATIC_URL }}light-blue/lib/nvd3/src/models/historicalBar.js"></script>
<script src="{{ STATIC_URL }}light-blue/lib/nvd3/src/models/pieChart.js"></script>


<!--backbone and friends -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<td>{{ date }}</td>
<td>{{ cashier }}</td>
<td>{{ opening_amount }}</td>
<td>{{ receipt_count }}</td>
<td>{{ receipt_amount }}</td>
<td>{{ de }}</td>
<td>{{ wi }}</td>
<td>{{ pa }}</td>
Expand Down
54 changes: 54 additions & 0 deletions fusolab2_0/common/templates/base/entrance_mail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<html>
<body>
<table>
<tr>
<th></th>
<th>ultima chiusura</th>
<th>apertura</th>
</tr>
<tr>
<td>{% if opening_warning %}WARNING{% endif %}
</td>
<td>{{ last_closing_amount }}</td>
<td>{{ opening_amount }}</td>
</tr>
<tr>
<th></th>
<th>chiusura attesa</th>
<th>in cassa</th>
</tr>
<tr>
<td>{% if closing_warning %}WARNING{% endif %}
</td>
<td>{{ expected_balance }}</td>
<td>{{ closing_amount }}</td>
</tr>
</table>
<table>
<tr>
<th>data</th>
<th>cassiere</th>
<th>apertura</th>
<th>ricevute</th>
<th>depositi</th>
<th>prelievi</th>
<th>pagamenti</th>
<th>chiusura</th>
</tr>
<tr>
<td>{{ date }}</td>
<td>{{ cashier }}</td>
<td>{{ opening_amount }}</td>
<td>{{ receipt_amount }}</td>
<td>{{ de }}</td>
<td>{{ wi }}</td>
<td>{{ pa }}</td>
<td>{{ closing_amount }}</td>
</tr>
</table>
{% for i in notes %}
<div>{{ i }}</div>
{% endfor %}

</body>
</html>
2 changes: 1 addition & 1 deletion fusolab2_0/common/templates/base/smallbalance_mail.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<td>{{ date }}</td>
<td>{{ cashier }}</td>
<td>{{ last_checkpoint }}</td>
<td>{{ receipt_count }}</td>
<td>{{ receipt_amount }}</td>
<td>{{ de }}</td>
<td>{{ wi }}</td>
<td>{{ pa }}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ <h4>
<label class="control-label" for="normal-field">{{ form.born_date.label }}</label>
<div class="controls form-group">
<div class="col-sm-8">
<input type="text" id="{{ form.born_date.id_for_label }}" name="{{ form.born_date.html_name }}" value="{{ form.born_date.value |default_if_none:"" }}" class="form-control date-picker parsley-validated {% if form.born_date.errors %}parsley-error{% endif %}" placeholder="Ad es. 31/01/1987" pattern="[0-9]{2}\/[0-9]{2}\/[0-9]{4}" data-trigger="change" {% if form.born_date.field.required %}required="required"{% endif %} readonly="" data-date-minviewmode="days" data-date-viewmode="years" data-date-format="dd/mm/yyyy">
<!-- input type="text" id="{{ form.born_date.id_for_label }}" name="{{ form.born_date.html_name }}" value="{{ form.born_date.value |default_if_none:"" }}" class="form-control date-picker parsley-validated {% if form.born_date.errors %}parsley-error{% endif %}" placeholder="Ad es. 31/01/1987" pattern="[0-9]{2}\/[0-9]{2}\/[0-9]{4}" data-trigger="change" {% if form.born_date.field.required %}required="required"{% endif %} readonly="" data-date-minviewmode="days" data-date-viewmode="years" data-date-format="dd/mm/yyyy" -->
<input type="text" id="{{ form.born_date.id_for_label }}" name="{{ form.born_date.html_name }}" value="{{ form.born_date.value |default_if_none:"" }}" class="form-control parsley-validated {% if form.born_date.errors %}parsley-error{% endif %}" placeholder="Ad es. 31/01/1987" pattern="[0-9]{2}\/[0-9]{2}\/[0-9]{4}" data-trigger="change" {% if form.born_date.field.required %}required="required"{% endif %}>
{% if form.born_date.errors %}
<ul class="parsley-error-list" style="display: block;">
<li class="type" style="display: list-item;">{{ form.born_date.errors.as_text }}</li>
Expand Down
Loading

0 comments on commit 22f9006

Please sign in to comment.