diff --git a/apiV1PayIn.go b/apiV1PayIn.go index 6a3e455..09b632f 100644 --- a/apiV1PayIn.go +++ b/apiV1PayIn.go @@ -33,7 +33,14 @@ func apiV1PayInPost(w http.ResponseWriter, r *http.Request, ss *loan.Session) { log.Error("cannot save basic loan", e.Error()) apiV1Client404Error(w, r, ss) } else { - apiV1SendJson(input, w, r, ss) + piEx := loan.PayInEx{} + e = piEx.Read(input.Id) + if e != nil { + log.Error("weird failed to read PayInEx after successfuly write PayIn", input, piEx, e.Error()) + apiV1Client404Error(w, r, ss) + } else { + apiV1SendJson(piEx, w, r, ss) + } } } diff --git a/apiV1UploadAnalysis.go b/apiV1UploadAnalysis.go index c00f52c..2664a8c 100644 --- a/apiV1UploadAnalysis.go +++ b/apiV1UploadAnalysis.go @@ -29,7 +29,7 @@ func apiV1UploadAnalysis(w http.ResponseWriter, r *http.Request, ss *loan.Sessio analysisMutex.Lock() ai := AiDecodeIncome{} - e = ai.decodeUploadToPayIn(ul, true) + e = ai.decodeUploadToPayIn(ul, false) analysisMutex.Unlock() if e != nil { log.Error("Invalid uploads Id cannot convert to integer", Id, e) diff --git a/pay-in-decode.go b/pay-in-decode.go index 54ba67a..6c56c1c 100644 --- a/pay-in-decode.go +++ b/pay-in-decode.go @@ -129,6 +129,7 @@ func (m *AiDecodeIncome) decodePdf() (e error) { case loan.Funder_AAA: m.Funders = append(m.Funders, loan.Funder_AAA) e = m.decodeAAAPdf(raw) + // regardless of error, we pump in all available row successed so far for _, row := range m.AAA { pi := loan.PayIn{} pi.Id = 0 @@ -140,7 +141,6 @@ func (m *AiDecodeIncome) decodePdf() (e error) { pi.OffsetBalance = -1 pi.IncomeAmount = row.InTrail pi.IncomeType = "Trail" - m.PayIn = append(m.PayIn, pi) } log.Println("AAA final result", m.AAA) diff --git a/pay-in-decode_test.go b/pay-in-decode_test.go index 81d5377..25852c4 100644 --- a/pay-in-decode_test.go +++ b/pay-in-decode_test.go @@ -10,6 +10,6 @@ func TestDecodePayInMain(t *testing.T) { ai := AiDecodeIncome{} ul := loan.Uploads{} ul.Read(30) - _ = ai.decodeUploadToPayIn(ul) + _ = ai.decodeUploadToPayIn(ul, false) log.Println(ai) }