|
|
|
@@ -21,7 +21,7 @@ type AiDecodeIncome struct { |
|
|
|
} |
|
|
|
|
|
|
|
type DecodeIncomeDetails struct { |
|
|
|
Funders []loan.FunderType |
|
|
|
Funders []loan.LenderType |
|
|
|
AAA []PayInAAARow |
|
|
|
Connective_ANZ []ConnectiveRow |
|
|
|
Connective_BOC []ConnectiveRow |
|
|
|
@@ -43,7 +43,7 @@ func (m *AiDecodeIncome) decodeUploadToPayIn(ulMeta loan.Uploads, allowCachedRes |
|
|
|
m.Input = ulMeta |
|
|
|
m.ul.Upload = ulMeta |
|
|
|
m.PayIn = make([]loan.PayIn, 0, 100) // finalized payIns, generated |
|
|
|
m.Funders = make([]loan.FunderType, 0, 50) // array of valid funders |
|
|
|
m.Funders = make([]loan.LenderType, 0, 50) // array of valid funders |
|
|
|
|
|
|
|
if allowCachedResult { |
|
|
|
e = m.ReadJson() |
|
|
|
@@ -126,8 +126,8 @@ func (m *AiDecodeIncome) decodePdf() (e error) { |
|
|
|
|
|
|
|
raw := string(out) |
|
|
|
switch m.detectFunder(raw) { |
|
|
|
case loan.Funder_AAA: |
|
|
|
m.Funders = append(m.Funders, loan.Funder_AAA) |
|
|
|
case loan.Lender_AAA: |
|
|
|
m.Funders = append(m.Funders, loan.Lender_AAA) |
|
|
|
e = m.decodeAAAPdf(raw) |
|
|
|
// regardless of error, we pump in all available row successed so far |
|
|
|
for _, row := range m.AAA { |
|
|
|
@@ -135,7 +135,7 @@ func (m *AiDecodeIncome) decodePdf() (e error) { |
|
|
|
pi.Id = 0 |
|
|
|
pi.Ts = row.Period |
|
|
|
pi.Amount = row.LoanAmount |
|
|
|
pi.Lender = loan.Funder_AAA |
|
|
|
pi.Lender = loan.Lender_AAA |
|
|
|
pi.Settlement = row.Settlement |
|
|
|
pi.Balance = row.Balance |
|
|
|
pi.OffsetBalance = -1 |
|
|
|
@@ -145,8 +145,8 @@ func (m *AiDecodeIncome) decodePdf() (e error) { |
|
|
|
} |
|
|
|
log.Println("AAA final result", m.AAA) |
|
|
|
break |
|
|
|
case loan.Funder_Unknown: |
|
|
|
e = errors.New(loan.Funder_Unknown) |
|
|
|
case loan.Lender_Unknown: |
|
|
|
e = errors.New(loan.Lender_Unknown) |
|
|
|
break // not able to detect Funder |
|
|
|
} |
|
|
|
return |
|
|
|
@@ -157,12 +157,12 @@ func (m *AiDecodeIncome) decodeXls() (e error) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func (m *AiDecodeIncome) detectFunder(raw string) loan.FunderType { |
|
|
|
func (m *AiDecodeIncome) detectFunder(raw string) loan.LenderType { |
|
|
|
if m.isAAA(raw) { |
|
|
|
return loan.Funder_AAA |
|
|
|
return loan.Lender_AAA |
|
|
|
} |
|
|
|
|
|
|
|
return loan.Funder_Unknown |
|
|
|
return loan.Lender_Unknown |
|
|
|
} |
|
|
|
|
|
|
|
func (m *AiDecodeIncome) isAAA(raw string) bool { |