コード例 #1
0
ファイル: parse_ods.go プロジェクト: mehulsbhatt/broke
func ProcessNewFormat(table ods.Table) {
	for _, row := range table.Strings() {
		if len(row) < 2 || row[0] == "" || shouldSkip(newSkipTerms, row[0]) {
			continue
		}
		if strings.Index(row[0], "Billing Cycle") == 0 {
			logger.Info(row[0])
			continue
		}
		biller := row[0]
		date := row[1]
		if date == "" {
			continue
		}
		var debit, credit float64
		if len(row) >= 3 {
			var err error
			debit, err = parseMoney(row[2])
			printErr(err)
		}
		if len(row) >= 4 {
			var err error
			credit, err = parseMoney(row[3])
			printErr(err)
		}

		if credit != 0 || debit != 0 {
			if DEBUG {
				logger.Debugf("%35s; %11s; %10.2f; %5.2f", biller, date, debit, credit)
			}
		} else {
			logger.Debugf("********** %s [%s] had no values", biller, date)
		}
	}
}
コード例 #2
0
ファイル: processors.go プロジェクト: mehulsbhatt/broke
// Print out the data in a table.
func (p BaseProcessor) Print(table ods.Table) {
	for _, row := range table.Strings() {
		if len(row) == 0 || row[0] == "" {
			continue
		}
		sep := ""
		for _, field := range row {
			fmt.Print(sep, strconv.Quote(field))
			sep = "\t"
		}
		fmt.Print("\n")
	}
}
コード例 #3
0
ファイル: parse_ods.go プロジェクト: mehulsbhatt/broke
func ProcessOldFormat(table ods.Table) {
	for _, row := range table.Strings() {
		if shouldSkip(oldSkipTerms, row[0]) {
			continue
		}
		if strings.Index(row[0], "Billing Cycle") == 0 {
			logger.Infof("*** %s", row[0])
			continue
		}
		biller := row[0]
		date := row[1]
		if date == "" {
			continue
		}
		var amount float64
		var err error
		if len(row) >= 3 {
			amount, err = parseMoney(row[2])
			if printErr(err) {
				continue
			}
		}
		var credit, debit float64
		if amount < 0 || biller != "Paycheck" {
			credit = math.Abs(amount)
		} else {
			debit = math.Abs(amount)
		}

		if credit != 0 || debit != 0 {
			if DEBUG {
				logger.Debugf("%35s; %11s; %10.2f; %5.2f", biller, date, debit, credit)
			}
		} else {
			if DEBUG {
				logger.Debugf("%s [%s] had no values", biller, date)
			}
		}
	}
}