diff --git a/fusolab2_0/apps/bar/models.py b/fusolab2_0/apps/bar/models.py index 1aabca3..b137408 100644 --- a/fusolab2_0/apps/bar/models.py +++ b/fusolab2_0/apps/bar/models.py @@ -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) @@ -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 @@ -243,7 +243,7 @@ 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: @@ -251,7 +251,7 @@ def get_small_summary(checkpoint): 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: @@ -259,7 +259,7 @@ def get_small_summary(checkpoint): 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: diff --git a/fusolab2_0/apps/bar/signals.py b/fusolab2_0/apps/bar/signals.py index d66bcf4..c6c110c 100644 --- a/fusolab2_0/apps/bar/signals.py +++ b/fusolab2_0/apps/bar/signals.py @@ -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") diff --git a/fusolab2_0/apps/base/utils.py b/fusolab2_0/apps/base/utils.py index e158aa9..27555b8 100644 --- a/fusolab2_0/apps/base/utils.py +++ b/fusolab2_0/apps/base/utils.py @@ -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(" ", ""))) diff --git a/fusolab2_0/apps/ingresso/models.py b/fusolab2_0/apps/ingresso/models.py index def72a4..594f147 100644 --- a/fusolab2_0/apps/ingresso/models.py +++ b/fusolab2_0/apps/ingresso/models.py @@ -83,11 +83,14 @@ def get_entrance_summary(closing): except(IndexError, EntranceBalance.DoesNotExist): pass #send_mail('allarme chiusura bar', 'errore tragico #1', 'cassafusolab@gmail.com',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 diff --git a/fusolab2_0/apps/ingresso/signals.py b/fusolab2_0/apps/ingresso/signals.py index bb76575..08ed7fd 100644 --- a/fusolab2_0/apps/ingresso/signals.py +++ b/fusolab2_0/apps/ingresso/signals.py @@ -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") diff --git a/fusolab2_0/apps/ingresso/templatetags/ingressotags.py b/fusolab2_0/apps/ingresso/templatetags/ingressotags.py index 96c0f95..b00a5bc 100644 --- a/fusolab2_0/apps/ingresso/templatetags/ingressotags.py +++ b/fusolab2_0/apps/ingresso/templatetags/ingressotags.py @@ -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 diff --git a/fusolab2_0/apps/reports/stats.py b/fusolab2_0/apps/reports/stats.py index 754626b..ef64bca 100644 --- a/fusolab2_0/apps/reports/stats.py +++ b/fusolab2_0/apps/reports/stats.py @@ -75,7 +75,7 @@ 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 ) @@ -83,10 +83,11 @@ def get_stats(request,what,yyyy=None,mm=None,dd=None): 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: diff --git a/fusolab2_0/apps/reports/views.py b/fusolab2_0/apps/reports/views.py index 4424e43..3a5fc8c 100644 --- a/fusolab2_0/apps/reports/views.py +++ b/fusolab2_0/apps/reports/views.py @@ -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) @@ -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) @@ -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) diff --git a/fusolab2_0/common/templates/base.html b/fusolab2_0/common/templates/base.html index c33a5ae..6bca5b2 100644 --- a/fusolab2_0/common/templates/base.html +++ b/fusolab2_0/common/templates/base.html @@ -162,7 +162,9 @@

Fusolab2.0

- + + + diff --git a/fusolab2_0/common/templates/closing_mail.html b/fusolab2_0/common/templates/base/bar_mail.html similarity index 96% rename from fusolab2_0/common/templates/closing_mail.html rename to fusolab2_0/common/templates/base/bar_mail.html index 63b2b02..03323e0 100644 --- a/fusolab2_0/common/templates/closing_mail.html +++ b/fusolab2_0/common/templates/base/bar_mail.html @@ -39,7 +39,7 @@ {{ date }} {{ cashier }} {{ opening_amount }} - {{ receipt_count }} + {{ receipt_amount }} {{ de }} {{ wi }} {{ pa }} diff --git a/fusolab2_0/common/templates/base/entrance_mail.html b/fusolab2_0/common/templates/base/entrance_mail.html new file mode 100644 index 0000000..03323e0 --- /dev/null +++ b/fusolab2_0/common/templates/base/entrance_mail.html @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + +
ultima chiusuraapertura
{% if opening_warning %}WARNING{% endif %} + {{ last_closing_amount }}{{ opening_amount }}
chiusura attesain cassa
{% if closing_warning %}WARNING{% endif %} + {{ expected_balance }}{{ closing_amount }}
+ + + + + + + + + + + + + + + + + + + + + +
datacassiereaperturaricevutedepositiprelievipagamentichiusura
{{ date }}{{ cashier }}{{ opening_amount }}{{ receipt_amount }}{{ de }}{{ wi }}{{ pa }}{{ closing_amount }}
+{% for i in notes %} +
{{ i }}
+{% endfor %} + + + diff --git a/fusolab2_0/common/templates/base/smallbalance_mail.html b/fusolab2_0/common/templates/base/smallbalance_mail.html index c07470f..360d0f0 100644 --- a/fusolab2_0/common/templates/base/smallbalance_mail.html +++ b/fusolab2_0/common/templates/base/smallbalance_mail.html @@ -28,7 +28,7 @@ {{ date }} {{ cashier }} {{ last_checkpoint }} - {{ receipt_count }} + {{ receipt_amount }} {{ de }} {{ wi }} {{ pa }} diff --git a/fusolab2_0/common/templates/registration/registration_form.html b/fusolab2_0/common/templates/registration/registration_form.html index 0ea542f..6c0e01d 100644 --- a/fusolab2_0/common/templates/registration/registration_form.html +++ b/fusolab2_0/common/templates/registration/registration_form.html @@ -56,7 +56,8 @@

- + + {% if form.born_date.errors %}