Skip to content

Instantly share code, notes, and snippets.

@abel-masila
Created June 13, 2018 07:54
Show Gist options
  • Save abel-masila/c3ca09a24951bbdc8d1615e668a384bd to your computer and use it in GitHub Desktop.
Save abel-masila/c3ca09a24951bbdc8d1615e668a384bd to your computer and use it in GitHub Desktop.
const getInsurerValue = (insurer, conveyance, packaging, icc) => {
var value = 0;
var is_containerised = packaging === 'CONTAINERISED';
if (icc === 'ICC-A') {
if (conveyance === Config.CONVEYANCE.AIR) {
value = insurer.icc_a.air_value;
} else if (conveyance === Config.CONVEYANCE.SEA && is_containerised) {
value = insurer.icc_a.sea_containerised_value;
} else if (conveyance === Config.CONVEYANCE.SEA && !is_containerised) {
value = insurer.icc_a.sea_non_containerised_value;
}
} else if (icc === 'ICC-B') {
if (conveyance === Config.CONVEYANCE.AIR) {
value = insurer.icc_b.air_value;
} else if (conveyance === Config.CONVEYANCE.SEA && is_containerised) {
value = insurer.icc_b.sea_containerised_value;
} else if (conveyance === Config.CONVEYANCE.SEA && !is_containerised) {
value = insurer.icc_b.sea_non_containerised_value;
}
} else if (icc === 'ICC-C') {
if (conveyance === Config.CONVEYANCE.AIR) {
value = insurer.icc_c.air_value;
} else if (conveyance === Config.CONVEYANCE.SEA && is_containerised) {
value = insurer.icc_c.sea_containerised_value;
} else if (conveyance === Config.CONVEYANCE.SEA && !is_containerised) {
value = insurer.icc_c.sea_non_containerised_value;
}
}
return value;
};
@abel-masila
Copy link
Author

const filteredInsurers = quotes.filter((insurer, key) => {
      const premium = revisedPremiumCalculation(
        insurer,
        selected_goods,
        conveyance,
        packaging,
        transshipment,
        warehousing,
        currency_rate.rate,
        other_rates,
        icc_class
      ).premium;

      if (!isNaN(premium)) {
        return insurer;
      }
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment