Resolve annual bond finance news selectors
This commit is contained in:
parent
5e480a5f74
commit
a8f9365b10
5 changed files with 75 additions and 18 deletions
|
|
@ -3674,11 +3674,17 @@ pub fn runtime_annual_finance_news_family_candidate_label(
|
|||
RuntimeCompanyAnnualFinancePolicyAction::CreditorPressureBankruptcy
|
||||
| RuntimeCompanyAnnualFinancePolicyAction::DeepDistressBankruptcyFallback => Some("2881"),
|
||||
RuntimeCompanyAnnualFinancePolicyAction::BondIssue => {
|
||||
runtime_annual_bond_principal_flow_relation_label(
|
||||
match runtime_annual_bond_principal_flow_relation_label(
|
||||
retired_principal_total,
|
||||
issued_principal_total,
|
||||
)
|
||||
.map(|_| "2882_2886")
|
||||
) {
|
||||
Some("retired_equals_issued") => Some("2882"),
|
||||
Some("issued_exceeds_retired") => Some("2883"),
|
||||
Some("retired_exceeds_issued") => Some("2884"),
|
||||
Some("retired_only") => Some("2885"),
|
||||
Some("issued_only") => Some("2886"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
RuntimeCompanyAnnualFinancePolicyAction::StockRepurchase => {
|
||||
(repurchased_share_count > 0).then_some("2887")
|
||||
|
|
@ -8453,6 +8459,60 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn maps_annual_bond_news_selector_from_principal_flow_relation() {
|
||||
assert_eq!(
|
||||
runtime_annual_finance_news_family_candidate_label(
|
||||
RuntimeCompanyAnnualFinancePolicyAction::BondIssue,
|
||||
500_000,
|
||||
500_000,
|
||||
0,
|
||||
0,
|
||||
),
|
||||
Some("2882")
|
||||
);
|
||||
assert_eq!(
|
||||
runtime_annual_finance_news_family_candidate_label(
|
||||
RuntimeCompanyAnnualFinancePolicyAction::BondIssue,
|
||||
350_000,
|
||||
1_000_000,
|
||||
0,
|
||||
0,
|
||||
),
|
||||
Some("2883")
|
||||
);
|
||||
assert_eq!(
|
||||
runtime_annual_finance_news_family_candidate_label(
|
||||
RuntimeCompanyAnnualFinancePolicyAction::BondIssue,
|
||||
900_000,
|
||||
500_000,
|
||||
0,
|
||||
0,
|
||||
),
|
||||
Some("2884")
|
||||
);
|
||||
assert_eq!(
|
||||
runtime_annual_finance_news_family_candidate_label(
|
||||
RuntimeCompanyAnnualFinancePolicyAction::BondIssue,
|
||||
350_000,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
),
|
||||
Some("2885")
|
||||
);
|
||||
assert_eq!(
|
||||
runtime_annual_finance_news_family_candidate_label(
|
||||
RuntimeCompanyAnnualFinancePolicyAction::BondIssue,
|
||||
0,
|
||||
500_000,
|
||||
0,
|
||||
0,
|
||||
),
|
||||
Some("2886")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn annual_bond_policy_stays_eligible_for_repayment_without_new_issue() {
|
||||
let mut year_stat_family_qword_bits = vec![
|
||||
|
|
|
|||
|
|
@ -3288,7 +3288,7 @@ mod tests {
|
|||
.service_state
|
||||
.annual_finance_last_news_family_candidates
|
||||
.get(&24),
|
||||
Some(&"2882_2886".to_string())
|
||||
Some(&"2886".to_string())
|
||||
);
|
||||
assert_eq!(state.companies[0].current_cash, 100_000);
|
||||
assert_eq!(state.service_state.company_market_state[&24].bond_count, 1);
|
||||
|
|
@ -3324,8 +3324,7 @@ mod tests {
|
|||
.any(|event| event.kind == "annual_finance_policy"
|
||||
&& event.applied_effect_count == 1
|
||||
&& event.mutated_company_ids == vec![24]
|
||||
&& event.finance_news_family_candidates.get(&24)
|
||||
== Some(&"2882_2886".to_string()))
|
||||
&& event.finance_news_family_candidates.get(&24) == Some(&"2886".to_string()))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -3454,7 +3453,7 @@ mod tests {
|
|||
.service_state
|
||||
.annual_finance_last_news_family_candidates
|
||||
.get(&25),
|
||||
Some(&"2882_2886".to_string())
|
||||
Some(&"2885".to_string())
|
||||
);
|
||||
assert_eq!(state.companies[0].current_cash, 550_000);
|
||||
assert_eq!(state.companies[0].debt, 0);
|
||||
|
|
@ -3487,8 +3486,7 @@ mod tests {
|
|||
.any(|event| event.kind == "annual_finance_policy"
|
||||
&& event.applied_effect_count == 1
|
||||
&& event.mutated_company_ids == vec![25]
|
||||
&& event.finance_news_family_candidates.get(&25)
|
||||
== Some(&"2882_2886".to_string()))
|
||||
&& event.finance_news_family_candidates.get(&25) == Some(&"2885".to_string()))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -3618,7 +3616,7 @@ mod tests {
|
|||
.service_state
|
||||
.annual_finance_last_news_family_candidates
|
||||
.get(&26),
|
||||
Some(&"2882_2886".to_string())
|
||||
Some(&"2883".to_string())
|
||||
);
|
||||
assert_eq!(state.companies[0].current_cash, 250_000);
|
||||
assert_eq!(state.companies[0].debt, 1_000_000);
|
||||
|
|
@ -3663,8 +3661,7 @@ mod tests {
|
|||
.any(|event| event.kind == "annual_finance_policy"
|
||||
&& event.applied_effect_count == 1
|
||||
&& event.mutated_company_ids == vec![26]
|
||||
&& event.finance_news_family_candidates.get(&26)
|
||||
== Some(&"2882_2886".to_string()))
|
||||
&& event.finance_news_family_candidates.get(&26) == Some(&"2883".to_string()))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue