added a few notes, fixed a few erroneous logging calls to something other than log.X

master
dtookey 4 years ago
parent 418fc5f7f2
commit 695eab1276

@ -50,7 +50,7 @@ func createCsvWriter(pathlike string) *csv.Writer {
if os.IsNotExist(err) {
file, err = os.Create(pathlike)
if err != nil {
panic(err)
log.Fatal(err)
}
} else {
file, err = os.OpenFile(pathlike, os.O_RDWR, 0777)
@ -80,24 +80,20 @@ func processFile(pathlike *string) *[]*BillingLine {
for idx, recordRow := range records {
serviceName := recordRow[BillingCode]
if idx < 2 || strings.ToLower(serviceName) == "total" {
continue //every ignorable row basically starts with "TOTAL"
continue //every ignorable row starts with "TOTAL"
} else if len(serviceName) > 0 {
// this will set the currentBillingCode to "smear" down the column to fill in the fields that QB refuses
currentBillingCode = serviceName
continue
}
txnDate := recordRow[Date]
acctNum := recordRow[InvoiceNumber]
acctName := recordRow[AccountName]
billClass := recordRow[BillingClass]
total := recordRow[Amount]
lineItem := BillingLine{
BillingCode: currentBillingCode,
Date: convertDateToSqlDate(txnDate),
InvoiceNumber: acctNum,
AccountName: acctName,
Class: billClass,
Amount: total,
Date: convertDateToSqlDate(recordRow[Date]),
InvoiceNumber: recordRow[InvoiceNumber],
AccountName: recordRow[AccountName],
Class: recordRow[BillingClass],
Amount: recordRow[Amount],
}
if err != nil {
@ -112,7 +108,7 @@ func processFile(pathlike *string) *[]*BillingLine {
func convertDateToSqlDate(datelike string) string {
parts := strings.Split(datelike, "/")
return fmt.Sprintf("%s-%s-%s", parts[2], parts[1], parts[0])
return fmt.Sprintf("%s-%s-%s", parts[2], parts[0], parts[1])
}
func enumFiles(pathlikebase string) *[]*string {

Loading…
Cancel
Save