Add tax base to invoices exported ODS file
Accountants asks for that information, too.
This commit is contained in:
parent
f1534e6cd2
commit
01807de5ca
|
@ -28,6 +28,7 @@ type InvoiceEntry struct {
|
||||||
Slug string
|
Slug string
|
||||||
Date time.Time
|
Date time.Time
|
||||||
Number string
|
Number string
|
||||||
|
Subtotal string
|
||||||
Total string
|
Total string
|
||||||
CustomerName string
|
CustomerName string
|
||||||
Tags []string
|
Tags []string
|
||||||
|
@ -71,6 +72,7 @@ func mustCollectInvoiceEntries(ctx context.Context, conn *Conn, locale *Locale,
|
||||||
, invoice.tags
|
, invoice.tags
|
||||||
, invoice.invoice_status
|
, invoice.invoice_status
|
||||||
, isi18n.name
|
, isi18n.name
|
||||||
|
, to_price(subtotal, decimal_digits)
|
||||||
, to_price(total, decimal_digits)
|
, to_price(total, decimal_digits)
|
||||||
from invoice
|
from invoice
|
||||||
join contact using (contact_id)
|
join contact using (contact_id)
|
||||||
|
@ -86,7 +88,7 @@ func mustCollectInvoiceEntries(ctx context.Context, conn *Conn, locale *Locale,
|
||||||
var entries []*InvoiceEntry
|
var entries []*InvoiceEntry
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
entry := &InvoiceEntry{}
|
entry := &InvoiceEntry{}
|
||||||
if err := rows.Scan(&entry.ID, &entry.Slug, &entry.Date, &entry.Number, &entry.CustomerName, &entry.Tags, &entry.Status, &entry.StatusLabel, &entry.Total); err != nil {
|
if err := rows.Scan(&entry.ID, &entry.Slug, &entry.Date, &entry.Number, &entry.CustomerName, &entry.Tags, &entry.Status, &entry.StatusLabel, &entry.Subtotal, &entry.Total); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
entries = append(entries, entry)
|
entries = append(entries, entry)
|
||||||
|
|
|
@ -55,14 +55,15 @@ func extractTaxIDs(taxColumns map[int]string) []int {
|
||||||
|
|
||||||
func mustWriteInvoicesOds(invoices []*InvoiceEntry, vatin map[int]string, lastCollectionDate map[int]time.Time, taxes map[int]taxMap, taxColumns map[int]string, locale *Locale, company *Company) []byte {
|
func mustWriteInvoicesOds(invoices []*InvoiceEntry, vatin map[int]string, lastCollectionDate map[int]time.Time, taxes map[int]taxMap, taxColumns map[int]string, locale *Locale, company *Company) []byte {
|
||||||
taxIDs := extractTaxIDs(taxColumns)
|
taxIDs := extractTaxIDs(taxColumns)
|
||||||
columns := make([]string, 8+len(taxIDs))
|
columns := make([]string, 9+len(taxIDs))
|
||||||
columns[0] = "Date"
|
columns[0] = "Date"
|
||||||
columns[1] = "Invoice Num."
|
columns[1] = "Invoice Num."
|
||||||
columns[2] = "Customer"
|
columns[2] = "Customer"
|
||||||
columns[3] = pgettext("title", "VAT number", locale)
|
columns[3] = pgettext("title", "VAT number", locale)
|
||||||
columns[4] = "Payment Date"
|
columns[4] = "Payment Date"
|
||||||
columns[5] = "Status"
|
columns[5] = "Status"
|
||||||
i := 6
|
columns[6] = "Tax Base"
|
||||||
|
i := 7
|
||||||
for _, taxID := range taxIDs {
|
for _, taxID := range taxIDs {
|
||||||
columns[i] = taxColumns[taxID]
|
columns[i] = taxColumns[taxID]
|
||||||
i++
|
i++
|
||||||
|
@ -80,6 +81,7 @@ func mustWriteInvoicesOds(invoices []*InvoiceEntry, vatin map[int]string, lastCo
|
||||||
writeCellString(sb, "")
|
writeCellString(sb, "")
|
||||||
}
|
}
|
||||||
writeCellString(sb, invoice.StatusLabel)
|
writeCellString(sb, invoice.StatusLabel)
|
||||||
|
writeCellFloat(sb, invoice.Subtotal, locale, company)
|
||||||
writeTaxes(sb, taxes[invoice.ID], taxIDs, locale, company)
|
writeTaxes(sb, taxes[invoice.ID], taxIDs, locale, company)
|
||||||
writeCellFloat(sb, invoice.Total, locale, company)
|
writeCellFloat(sb, invoice.Total, locale, company)
|
||||||
writeCellString(sb, strings.Join(invoice.Tags, ","))
|
writeCellString(sb, strings.Join(invoice.Tags, ","))
|
||||||
|
|
Loading…
Reference in New Issue