Accept flexible loan payloads and nest related info on lending responses.
Widen loan_orders.region in the init migration and share common relation helpers across loan APIs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
0098422798
commit
6683826662
13 files changed
+591
-346
No files matched your search
@@ -0,0 +1,38 @@
|
||||
package loanorders_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"online-back/internal/lending/loanorders"
|
||||
)
|
||||
|
||||
func TestCreateLoanOrderDTOBindMobilePayload(t *testing.T) {
|
||||
raw := []byte(`{
|
||||
"source":"mobile","loanType":"1","region":"Ahal","branchId":"1",
|
||||
"customerName":"Kerim","customerSurname":"Atayew",
|
||||
"passportAddress":"Ashgabat","realAddress":"Ashgabat",
|
||||
"passportSerie":"I-AG","passportId":"101010",
|
||||
"passportGivenAt":"2017-01-15","passportGivenBy":"Police",
|
||||
"bornPlace":"Ashgabat","bornAt":"1989-03-21",
|
||||
"phone":"+993 61 92 92 48","education":"higher","marriageStatus":"married",
|
||||
"passportOne":"a.jpg","passportTwo":"b.jpg","passportThree":"c.jpg","passportFour":"d.jpg",
|
||||
"satisfiable":"yes","guarantorNote":"Brother","loanAmount":"20000"
|
||||
}`)
|
||||
var dto loanorders.CreateLoanOrderDTO
|
||||
if err := json.Unmarshal(raw, &dto); err != nil {
|
||||
t.Fatalf("unmarshal: %v", err)
|
||||
}
|
||||
if dto.LoanType.Int64() != 1 || dto.BranchId.Int64() != 1 {
|
||||
t.Fatalf("ids: loanType=%d branchId=%d", dto.LoanType.Int64(), dto.BranchId.Int64())
|
||||
}
|
||||
if dto.Region != "Ahal" {
|
||||
t.Fatalf("region=%q", dto.Region)
|
||||
}
|
||||
if dto.BornAt.Time().Format("2006-01-02") != "1989-03-21" {
|
||||
t.Fatalf("bornAt=%v", dto.BornAt.Time())
|
||||
}
|
||||
if dto.PassportGivenAt.Time().Format("2006-01-02") != "2017-01-15" {
|
||||
t.Fatalf("passportGivenAt=%v", dto.PassportGivenAt.Time())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user