AssemblingErrors オブジェクトを通じてアセンブリ時の問題を報告します。最初のスクリプトでは、融資額に応じて必要な文書が異なります。2 つ目は、セットに想定される本人確認書類が含まれていることを確認します。
融資額に応じて必要書類を設定する
- パスポート
- 保証人の書類
- 共同借入人の書類
- 勤務先証明書
- 共同借入人名
- 融資額
| 融資額 | 必須書類 |
|---|---|
| 1 つ目のしきい値未満 | パスポート |
| 1 つ目のしきい値より大きく、2 つ目のしきい値より小さい | パスポートと勤務先証明書 |
| 2 つ目のしきい値より大きい | パスポート、勤務先証明書、保証人の書類 |
using System.Collections.Generic;
int creditSum = 0;
bool creditSumFound = false;
string cocreditor = "";
int formCount = 0;
string formName = "Borrower's form";
// ドキュメント セットで使用されるDocument Definitions
int referenceFromWorkCount = 0;
string referenceFromWorkName = "勤務先証明書";
int guaranteeDocsCount = 0;
string guaranteeDocsName = "Guarantor's documents";
int cocreditorDocsCount = 0;
string cocreditorDocsName = "Co-borrower's documents";
int passportCount = 0;
string passportName = "Passport";
foreach( IBatchItem item in BatchItems ) {
// フォームを検索してローンの合計金額を確認する
if (item.Type == TBatchItemType.BIT_Page)
{
if (item.AsPage.SectionName != formName)
AssemblingErrors.AddCustomError("Cannot contain the following sections: " + item.AsPage.SectionName, 1);
else
{
cocreditor = item.AsPage.Document.IndexedItemValue("Borrower's name").ToString();
string creditSumText = item.AsPage.Document.IndexedItemValue("融資額").ToString();
if (!int.TryParse(creditSumText, out creditSum))
AssemblingErrors.AddCustomError("融資額 was not recognized: " + creditSumText, 1);
else
creditSumFound = true;
formCount++;
}
}
// セット内のドキュメント数をカウントする
else if (item.Type == TBatchItemType.BIT_Document) {
if (item.AsDocument.TemplateName == referenceFromWorkName)
referenceFromWorkCount++;
else if (item.AsDocument.TemplateName == guaranteeDocsName)
guaranteeDocsCount++;
else if (item.AsDocument.TemplateName == passportName)
passportCount++;
else if (item.AsDocument.TemplateName == cocreditorDocsName)
cocreditorDocsCount++;
else
AssemblingErrors.AddCustomError("The ドキュメント セット cannot contain the document " + item.AsDocument.TemplateName, 1);
}
}
// セット内のセクション数とドキュメント数を確認する
if (formCount > 1)
AssemblingErrors.AddCustomError("There are too many documents of the type: " + formName, formCount);
else if (formCount < 1)
AssemblingErrors.AddCustomError("Missing the following documents: " + formName, 1);
if (passportCount > 1)
AssemblingErrors.AddCustomError("There are too many documents of the type: " + passportName, passportCount);
else if (passportCount < 1)
AssemblingErrors.AddCustomError("Missing the following documents: " + passportName, 1);
// フォームに共同借入人名が存在する場合、ドキュメント セットに共同借入人が含まれているか確認する
if (cocreditor != "" && cocreditorDocsCount < 1)
AssemblingErrors.AddCustomError("Missing the following documents: " + cocreditorDocsName, 1);
else if (cocreditor != "" && cocreditorDocsCount > 1)
AssemblingErrors.AddCustomError("There are too many documents of the type: " + cocreditorDocsName, cocreditorDocsCount);
else if (cocreditor == "" && cocreditorDocsCount > 0)
AssemblingErrors.AddCustomError("There are too many documents of the type: " + cocreditorDocsName, cocreditorDocsCount);
// ローン金額がいずれかの閾値を超えた場合に必要なすべてのドキュメントがドキュメント セットに含まれているか確認する
if (creditSumFound)
{
if (creditSum > 50000) // 雇用主の証明書が必要
{
if (referenceFromWorkCount > 1)
AssemblingErrors.AddCustomError("There are too many documents of the type: " + referenceFromWorkName, referenceFromWorkCount);
else if (referenceFromWorkCount < 1)
AssemblingErrors.AddCustomError("Missing the following documents: " + referenceFromWorkName, 1);
}
if (creditSum > 500000) // 保証人の書類が必要
{
if (guaranteeDocsCount > 1)
AssemblingErrors.AddCustomError("There are too many documents of the type: " + guaranteeDocsName, guaranteeDocsCount);
else if (guaranteeDocsCount < 1)
AssemblingErrors.AddCustomError("Missing the following documents: " + guaranteeDocsName, 1);
}
}
不足している文書や重複文書を確認する
- Passport
- Driver’s license
using System.Collections.Generic;
using System;
string docSetName = "Identification Documents";
int pagesCnt = 0;
// セットに含めることができるドキュメントの種類のリスト
List<string> allowed = new List<string> {"Passport", "Driver's license"};
// セット内の各種類のドキュメント数の上限
List<int> allowedCount = new List<int>{1,1};
// セット内で検出されたドキュメントの数
List<int> foundCount = new List<int>{0,0};
// セット内のドキュメント数とページ数をカウントする
foreach (IBatchItem item in BatchItems) {
if (item.Type == TBatchItemType.BIT_Document) {
if (item.AsDocument.TemplateName == docSetName)
AssemblingErrors.AddCustomError("Cannot contain a nested set", 1);
else if (allowed.Contains(item.AsDocument.TemplateName)) {
int i = allowed.IndexOf(item.AsDocument.TemplateName);
foundCount[i]++;
}
}
else if (item.Type == TBatchItemType.BIT_Page) pagesCnt++;
}
// ドキュメント数とページ数を確認する
if (foundCount[0] + foundCount[1] == 0)
AssemblingErrors.AddCustomError("At least one identification document is required", 1);
for (int i = 0; i < allowed.Count; i++) {
if (foundCount[i] > allowedCount[i])
AssemblingErrors.AddCustomError("Maximum number of documents: " + allowed[i] + ": " + allowedCount[i]);
}
if (pagesCnt > 0) AssemblingErrors.AddCustomError("The document set cannot contain pages that do not belong to a document", pagesCnt);
