complete first version of journal
This commit is contained in:
parent
fcc4d96660
commit
46e3dccd2a
|
|
@ -58,6 +58,7 @@ var balanceYear = "UNDEFINED"
|
||||||
var profit float64 = 0.0
|
var profit float64 = 0.0
|
||||||
|
|
||||||
const reportTitle = "Jahresrechnung - nbit Informatik GmbH"
|
const reportTitle = "Jahresrechnung - nbit Informatik GmbH"
|
||||||
|
const journalTitle = "Journal - nbit Informatik GmbH"
|
||||||
const MWST_ACCOUNT = "2201"
|
const MWST_ACCOUNT = "2201"
|
||||||
const defaultFontSize = 12
|
const defaultFontSize = 12
|
||||||
const smallFontSize = 8
|
const smallFontSize = 8
|
||||||
|
|
@ -70,6 +71,7 @@ const widthAmount = 28
|
||||||
const dashCorrectionXleft = 1.2
|
const dashCorrectionXleft = 1.2
|
||||||
const dashCorrectionXright = -1.3
|
const dashCorrectionXright = -1.3
|
||||||
const dashCorrectionY = 3.5
|
const dashCorrectionY = 3.5
|
||||||
|
const avoidMinusZero = 0.00001
|
||||||
|
|
||||||
func roundRappen(f float64) float64 {
|
func roundRappen(f float64) float64 {
|
||||||
return (math.Round(f*100) / 100)
|
return (math.Round(f*100) / 100)
|
||||||
|
|
@ -653,6 +655,53 @@ func outputMwst(whatquarter string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func doAdd(isDebit bool, account string) bool {
|
||||||
|
account_type := accountType(account)
|
||||||
|
|
||||||
|
if (account_type == "A") || (account_type == "E") || (account_type == "L") {
|
||||||
|
return isDebit
|
||||||
|
} else {
|
||||||
|
return !isDebit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func outputAccount(account string) {
|
||||||
|
fmt.Printf("START ACCOUNT %s (%s), Balance: %.2f\n", account, accounts[account], account_balance[account].balance_start+avoidMinusZero)
|
||||||
|
var current_balance float64 = account_balance[account].balance_start
|
||||||
|
var document_numbers []int
|
||||||
|
for k := range transactions {
|
||||||
|
document_numbers = append(document_numbers, int(k))
|
||||||
|
}
|
||||||
|
sort.Ints(document_numbers)
|
||||||
|
for _, k := range document_numbers {
|
||||||
|
for _, item := range transactions[uint16(k)].Items {
|
||||||
|
if item.Debit == account || item.Credit == account {
|
||||||
|
if doAdd(item.Debit == account, account) {
|
||||||
|
current_balance = current_balance + item.Amount
|
||||||
|
} else {
|
||||||
|
current_balance = current_balance - item.Amount
|
||||||
|
}
|
||||||
|
fmt.Printf("%-5d %s %-4v %-4v %-80v %11.2f %-5v %11.2f %11.2f\n", k, transactions[uint16(k)].Date.Format("02.01.2006"), item.Debit, item.Credit, item.Description, item.Amount, item.Vat_code, item.Amount_Vat, current_balance+avoidMinusZero)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
fmt.Printf("END ACCOUNT %s (%s), Balance: %.2f\n\n", account, accounts[account], account_balance[account].balance_end+avoidMinusZero)
|
||||||
|
}
|
||||||
|
|
||||||
|
func outputJournal() {
|
||||||
|
fmt.Printf("%s - YEAR: %s\n", journalTitle, balanceYear)
|
||||||
|
fmt.Printf("Created at: %s\n\n", time.Now().Format("02.01.2006 15:04:05"))
|
||||||
|
var active_accounts []string
|
||||||
|
for k := range account_balance {
|
||||||
|
active_accounts = append(active_accounts, k)
|
||||||
|
}
|
||||||
|
sort.Strings(active_accounts)
|
||||||
|
for _, k := range active_accounts {
|
||||||
|
outputAccount(k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func usage() {
|
func usage() {
|
||||||
fmt.Fprintf(os.Stderr, "usage: bookkeeper <action> <accounts file> <transactions file>\n")
|
fmt.Fprintf(os.Stderr, "usage: bookkeeper <action> <accounts file> <transactions file>\n")
|
||||||
fmt.Fprintf(os.Stderr, "\n")
|
fmt.Fprintf(os.Stderr, "\n")
|
||||||
|
|
@ -681,6 +730,7 @@ func main() {
|
||||||
createBalanceSheet()
|
createBalanceSheet()
|
||||||
case "journal":
|
case "journal":
|
||||||
fmt.Fprintln(os.Stderr, "INFO: Create Journal")
|
fmt.Fprintln(os.Stderr, "INFO: Create Journal")
|
||||||
|
outputJournal()
|
||||||
case "mwst1", "mwst2", "mwst3", "mwst4":
|
case "mwst1", "mwst2", "mwst3", "mwst4":
|
||||||
fmt.Fprintln(os.Stderr, "INFO: Create Mwst Quarterly Report")
|
fmt.Fprintln(os.Stderr, "INFO: Create Mwst Quarterly Report")
|
||||||
outputMwst(action)
|
outputMwst(action)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue