Skip to content

Commit

Permalink
added date, tax_code, name to summary
Browse files Browse the repository at this point in the history
  • Loading branch information
simone-campagna committed Dec 15, 2017
1 parent 395817b commit 6446cf6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 32 deletions.
17 changes: 15 additions & 2 deletions invoice/invoice_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
from .ee import snow


MReport = collections.namedtuple("MReport", ["number", "fee", "refunds", "cpa", "taxable_income", "vat", "empty", "deduction", "taxes", "income"])
MReport = collections.namedtuple("MReport", ["number", "date", "tax_code", "name", "fee", "refunds", "cpa", "taxable_income", "vat", "empty", "deduction", "taxes", "income"])

class FileDateTimes(object):
def __init__(self):
Expand Down Expand Up @@ -557,17 +557,21 @@ def impl_summary(self, *, year=None, table_mode=None, output_filename=None, head
all_field_names = MReport._fields

#"number", "fee", "cpa", "taxable_income", "vat", "empty", "deduction", "income"
header = ["N.DOC.", "COMPENSO", "RIMBORSI", "C.P.A.", "IMPONIBILE IVA", "IVA 22%", "ES.IVA ART.10", "R.A.", "BOLLI", "TOTALE"]
header = ["N.DOC.", "DATA", "CODICE FISCALE", "NOME", "COMPENSO", "RIMBORSI", "C.P.A.", "IMPONIBILE IVA", "IVA 22%", "ES.IVA ART.10", "R.A.", "BOLLI", "TOTALE"]
total_keys = 'fee', 'refunds', 'cpa', 'taxable_income', 'vat', 'deduction', 'taxes', 'income'

general_info = load_info()['general']
summary_prologue = general_info['summary_prologue']
summary_epilogue = general_info['summary_epilogue']
number_fields = {"fee", "refunds", "cpa", "taxable_income", "vat", "deduction", "taxes", "income"}
number_cols = []
date_fields = {"date"}
date_cols = []
for c, field in enumerate(MReport._fields):
if field in number_fields:
number_cols.append(c)
elif field in date_fields:
date_cols.append(c)

align = conf.ALIGN.copy()
for key in total_keys:
Expand All @@ -576,6 +580,7 @@ def impl_summary(self, *, year=None, table_mode=None, output_filename=None, head
with document(file=self.get_doc_file(output_filename), mode=table_mode, logger=self.logger) as doc:
doc.define_format("bold", {"bold": True})
doc.define_format("bold_yellow", {"bold": True, "bg_color": "yellow"})
doc.define_format("date_value", {"align": "right", "num_format": "dd/mm/yyyy"})
doc.define_format("money_value", {"align": "right", "num_format": "0.00"})
doc.define_format("money_value_total", {"align": "right", "num_format": "0.00", "bold": True, "bg_color": "yellow"})
page_template = doc.create_page_template(field_names=all_field_names, header=header, align=align)
Expand Down Expand Up @@ -606,6 +611,9 @@ def impl_summary(self, *, year=None, table_mode=None, output_filename=None, head
for invoice in invoices:
mreport = MReport(
number=invoice.number,
date=invoice.date,
tax_code=invoice.tax_code,
name=invoice.name,
fee=invoice.fee,
refunds=invoice.refunds,
taxes=invoice.taxes,
Expand All @@ -619,13 +627,18 @@ def impl_summary(self, *, year=None, table_mode=None, output_filename=None, head
rows.append(mreport)
for col in number_cols:
doc_formats.add_format("money_value", row=row_offset + len(rows), col=col)
for col in date_cols:
doc_formats.add_format("date_value", row=row_offset + len(rows), col=col)
for key in total_keys:
val = getattr(mreport, key)
if val is not None:
total[key] += val
row_end = row_offset + len(rows)
total["number"] = "TOTALE"
total["empty"] = ""
total["date"] = ""
total["tax_code"] = ""
total["name"] = ""
row_begin = row_offset
if header:
nh = 1
Expand Down
60 changes: 30 additions & 30 deletions tests/unittests/test_invoice_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,47 +292,47 @@ def _test_invoice_main_summary(self, table_mode, pdata):
print(p.string())
self.assertEqual(p.string(), """\
=== Gennaio ===
N.DOC. COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
1 50.0 0.0 1.0 51.0 0.0 0.0 0.0 51.0
2 75.0 0.0 1.5 76.5 0.0 0.0 0.0 76.5
3 100.0 0.0 2.0 102.0 0.0 0.0 5.0 107.0
4 50.0 0.0 1.0 51.0 0.0 0.0 0.0 51.0
5 150.0 0.0 3.0 153.0 0.0 0.0 2.0 155.0
TOTALE 425.0 0.0 8.5 433.5 0.0 0.0 7.0 440.5
N.DOC. DATA CODICE FISCALE NOME COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
1 2014-01-03 WNYBRC01G01H663S Bruce Wayne 50.0 0.0 1.0 51.0 0.0 0.0 0.0 51.0
2 2014-01-03 PRKPRT01G01H663M Peter B. Parker 75.0 0.0 1.5 76.5 0.0 0.0 0.0 76.5
3 2014-01-22 BNNBRC01G01H663S Robert Bruce Banner 100.0 0.0 2.0 102.0 0.0 0.0 5.0 107.0
4 2014-01-25 WNYBRC01G01H663S Bruce Wayne 50.0 0.0 1.0 51.0 0.0 0.0 0.0 51.0
5 2014-01-29 KNTCRK01G01H663X Clark Kent 150.0 0.0 3.0 153.0 0.0 0.0 2.0 155.0
TOTALE 425.0 0.0 8.5 433.5 0.0 0.0 7.0 440.5
=== Febbraio ===
N.DOC. COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
6 120.0 30.0 3.0 153.0 33.66 30.0 30.0 246.66
TOTALE 120.0 30.0 3.0 153.0 33.66 30.0 30.0 246.66
N.DOC. DATA CODICE FISCALE NOME COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
6 2014-02-28 KNTCRK01G01H663X Clark Kent 120.0 30.0 3.0 153.0 33.66 30.0 30.0 246.66
TOTALE 120.0 30.0 3.0 153.0 33.66 30.0 30.0 246.66
=== Marzo ===
N.DOC. COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
N.DOC. DATA CODICE FISCALE NOME COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
=== Aprile ===
N.DOC. COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
N.DOC. DATA CODICE FISCALE NOME COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
=== Maggio ===
N.DOC. COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
N.DOC. DATA CODICE FISCALE NOME COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
=== Giugno ===
N.DOC. COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
N.DOC. DATA CODICE FISCALE NOME COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
=== Luglio ===
N.DOC. COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
N.DOC. DATA CODICE FISCALE NOME COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
=== Agosto ===
N.DOC. COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
N.DOC. DATA CODICE FISCALE NOME COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
=== Settembre ===
N.DOC. COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
N.DOC. DATA CODICE FISCALE NOME COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
=== Ottobre ===
N.DOC. COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
N.DOC. DATA CODICE FISCALE NOME COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
=== Novembre ===
N.DOC. COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
N.DOC. DATA CODICE FISCALE NOME COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
=== Dicembre ===
N.DOC. COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
N.DOC. DATA CODICE FISCALE NOME COMPENSO RIMBORSI C.P.A. IMPONIBILE IVA IVA 22% ES.IVA ART.10 R.A. BOLLI TOTALE
TOTALE 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
""")

def test_invoice_main_summary_text(self):
Expand Down

0 comments on commit 6446cf6

Please sign in to comment.