@@ -164,6 +164,8 @@ def mkPoolSource(x):
164
164
return "CollectedRental"
165
165
case "现金" | "Cash" | "现金回款" | "CollectedCash" :
166
166
return "CollectedCash"
167
+ case "费用" | "Fee" | "现金回款" | "CollectedFeePaid" :
168
+ return "CollectedFeePaid"
167
169
case "新增违约" | "Defaults" :
168
170
return "NewDefaults"
169
171
case "新增拖欠" | "Delinquencies" :
@@ -1131,6 +1133,20 @@ def mkAccRule(x):
1131
1133
case _ :
1132
1134
raise RuntimeError (f"Failed to match { x } :mkAccRule" )
1133
1135
1136
+ def mkInvoiceFeeType (x ):
1137
+ match x :
1138
+ case ("Fixed" , amt ) | ("固定" , amt ):
1139
+ return mkTag (("FixedFee" , vNum (amt )))
1140
+ case ("FixedRate" , rate ) | ("固定比例" , rate ):
1141
+ return mkTag (("FixedRateFee" , vNum (rate )))
1142
+ case ("FactorFee" , rate , days , rnd ) | ("周期计费" , rate , days , rnd ):
1143
+ return mkTag (("FactorFee" , [vNum (rate ), vInt (days ), mkRoundingType (rnd )]))
1144
+ case ("AdvanceRate" , rate ) | ("提前比例" , rate ):
1145
+ return mkTag (("AdvanceFee" , vNum (rate )))
1146
+ case ("CompoundFee" , * fs ) | ("复合计费" , * fs ):
1147
+ return mkTag (("CompoundFee" , lmap (mkInvoiceFeeType , fs )))
1148
+ case _:
1149
+ raise RuntimeError (f"Failed to match { x } :mkInvoiceFeeType" )
1134
1150
1135
1151
def mkCapacity (x ):
1136
1152
match x :
@@ -1231,6 +1247,12 @@ def mkAsset(x):
1231
1247
,"period" :freqMap [p ],"accRule" :mkAccRule (ar )
1232
1248
,"capacity" :mkCapacity (cap )} | mkTag ("FixedAssetInfo" )
1233
1249
,vInt (rt )]))
1250
+ case ["Invoice" , {"start" :sd ,"originBalance" :ob ,"originAdvance" :oa ,"dueDate" :dd ,"feeType" :ft },{"status" :status }] :
1251
+ return mkTag (("Invoice" ,[{"startDate" :vDate (sd ),"originBalance" :vNum (ob ),"originAdvance" :vNum (oa ),"dueDate" :vDate (dd ),"feeType" :mkInvoiceFeeType (ft )} | mkTag ("ReceivableInfo" )
1252
+ ,mkAssetStatus (status )]))
1253
+ case ["Invoice" , {"start" :sd ,"originBalance" :ob ,"originAdvance" :oa ,"dueDate" :dd },{"status" :status }] :
1254
+ return mkTag (("Invoice" ,[{"startDate" :vDate (sd ),"originBalance" :vNum (ob ),"originAdvance" :vNum (oa ),"dueDate" :vDate (dd ),"feeType" :None } | mkTag ("ReceivableInfo" )
1255
+ ,mkAssetStatus (status )]))
1234
1256
case _:
1235
1257
raise RuntimeError (f"Failed to match { x } :mkAsset" )
1236
1258
@@ -1254,6 +1276,8 @@ def id_by_pool_assets(z):
1254
1276
return "RDeal"
1255
1277
case {"assets" : [{'tag' : 'FixedAsset' }, * rest ]}:
1256
1278
return "FDeal"
1279
+ case {"assets" : [{'tag' : 'Invoice' }, * rest ]}:
1280
+ return "VDeal"
1257
1281
case _:
1258
1282
raise RuntimeError (f"Failed to identify deal type { z } " )
1259
1283
y = None
@@ -1311,6 +1335,8 @@ def mkAssumpDefault(x):
1311
1335
return mkTag (("DefaultCDR" , vNum (r )))
1312
1336
case {"ByAmount" : (bal , rs )}:
1313
1337
return mkTag (("DefaultByAmt" , (vNum (bal ), vList (rs ,float ))))
1338
+ case "DefaultAtEnd" :
1339
+ return mkTag (("DefaultAtEnd" ))
1314
1340
case _ :
1315
1341
raise RuntimeError (f"failed to match { x } " )
1316
1342
@@ -1428,6 +1454,10 @@ def mkExtraStress(y):
1428
1454
case ("Fixed" ,utilCurve ,priceCurve ):
1429
1455
return mkTag (("FixedAssetAssump" ,[mkTs ("RatioCurve" ,utilCurve )
1430
1456
,mkTs ("BalanceCurve" ,priceCurve )]))
1457
+ case ("Receivable" , md , mr , mes ):
1458
+ d = earlyReturnNone (mkAssumpDefault ,md )
1459
+ r = earlyReturnNone (mkAssumpRecovery ,mr )
1460
+ return mkTag (("ReceivableAssump" ,[d , r , mkExtraStress (mes )]))
1431
1461
case _:
1432
1462
raise RuntimeError (f"failed to match { x } " )
1433
1463
@@ -1467,6 +1497,8 @@ def mkAssetUnion(x):
1467
1497
return mkTag (("LS" , mkAsset (x )))
1468
1498
case "固定资产" | "FixedAsset" :
1469
1499
return mkTag (("FA" , mkAsset (x )))
1500
+ case "应收帐款" | "Invoice" :
1501
+ return mkTag (("RE" , mkAsset (x )))
1470
1502
case _:
1471
1503
raise RuntimeError (f"Failed to match AssetUnion { x } " )
1472
1504
@@ -1507,7 +1539,8 @@ def mkPoolComp(asOfDate, x, mixFlag) -> dict:
1507
1539
1508
1540
def mkPool (x : dict ):
1509
1541
mapping = {"LDeal" : "LPool" , "MDeal" : "MPool" ,
1510
- "IDeal" : "IPool" , "RDeal" : "RPool" , "FDeal" :"FPool" }
1542
+ "IDeal" : "IPool" , "RDeal" : "RPool" , "FDeal" :"FPool" ,
1543
+ "VDeal" : "VPool" }
1511
1544
match x :
1512
1545
case {"清单" : assets , "封包日" : d } | {"assets" : assets , "cutoffDate" : d }:
1513
1546
_pool = {"assets" : [mkAsset (a ) for a in assets ] , "asOfDate" : d }
0 commit comments