<commit_before>package filings

import "errors"

// TODO this will need a walk script that'll go through raw reports and parse these.
// there should be an option to only create new and to override all
type FinancialReport struct {
	CIK, Year, Quarter                                               int64
	Revenue, OperatingExpense, NetIncome                             int64
	CurrentAssets, TotalAssets, CurrentLiabilities, TotalLiabilities int64
	OperatingCash, CapitalExpenditures                               int64
}

func (fr *FinancialReport) IsValid() error {
	missingFields := ""

	// not looping through every struct field because some may be optional
	if fr.Revenue == 0 {
		missingFields += "Revenue,"
	}

	if fr.OperatingExpense == 0 {
		missingFields += "OperatingExpense,"
	}

	if fr.NetIncome == 0 {
		missingFields += "NetIncome,"
	}

	if fr.TotalAssets == 0 {
		missingFields += "TotalAssets,"
	}

	// if(fr.TotalLiabilities == 0) {
	// 	missingFields += "TotalLiabilities,"
	// }

	if len(missingFields) > 0 {
		return errors.New(missingFields)
	} else {
		return nil
	}
}

type FinancialReportRaw struct {
	CIK, Year, Quarter int64
	RawFields          map[string]int64
}

func (frr *FinancialReportRaw) GetPreviousQuarter() (int64, int64) {
	if frr.Quarter == 1 {
		return frr.Year - 1, 4
	} else {
		return frr.Year, frr.Quarter - 1
	}
}
<commit_msg>validate all fields for an rp<commit_after>package filings

import "errors"

// TODO this will need a walk script that'll go through raw reports and parse these.
// there should be an option to only create new and to override all
type FinancialReport struct {
	CIK, Year, Quarter                                               int64
	Revenue, OperatingExpense, NetIncome                             int64
	CurrentAssets, TotalAssets, CurrentLiabilities, TotalLiabilities int64
	OperatingCash, CapitalExpenditures                               int64
}

func (fr *FinancialReport) IsValid() error {
	missingFields := ""

	// not looping through every struct field because some may be optional
	if fr.Revenue == 0 {
		missingFields += "Revenue,"
	}

	if fr.OperatingExpense == 0 {
		missingFields += "OperatingExpense,"
	}

	if fr.NetIncome == 0 {
		missingFields += "NetIncome,"
	}

	if fr.TotalAssets == 0 {
		missingFields += "TotalAssets,"
	}

	if fr.TotalLiabilities == 0 {
		missingFields += "TotalLiabilities,"
	}

	if fr.CurrentAssets == 0 {
		missingFields += "CurrentAssets,"
	}

	if fr.CurrentLiabilities == 0 {
		missingFields += "CurrentLiabilities,"
	}

	if fr.OperatingCash == 0 {
		missingFields += "OperatingCash,"
	}

	if fr.CapitalExpenditures == 0 {
		missingFields += "CapitalExpenditures,"
	}

	if len(missingFields) > 0 {
		return errors.New(missingFields)
	} else {
		return nil
	}
}

type FinancialReportRaw struct {
	CIK, Year, Quarter int64
	RawFields          map[string]int64
}

func (frr *FinancialReportRaw) GetPreviousQuarter() (int64, int64) {
	if frr.Quarter == 1 {
		return frr.Year - 1, 4
	} else {
		return frr.Year, frr.Quarter - 1
	}
}

{'fraction_non_alphanumeric': 0.0973044049967127, 'fraction_numerical': 0.018408941485864562, 'mean_word_length': 2.8518987341772153, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4907663', 'n_tokens_mistral': 1037, 'n_tokens_neox': 939, 'n_words': 280}