nicolaswill / ch-paystub-verify

GNU General Public License v3.0
3 stars 1 forks source link

ESPP gain heuristics too conservative #13

Open nicolaswill opened 6 months ago

nicolaswill commented 6 months ago

I wonder if The ESPP gain is larger than a 10% discount of the max ESPP contribution should be more aggressive tho. Right now, you are checking that for a given payslip, the ESPP gain is more than 25000/9, which is about 2.7K (USD or CHF in this case).

But the ESPP gain is reported quarterly. So, should this:

Something like `25000/4 * 0.15%? (i.e. 10% discount, plus eventual USDCHF conversion change)

Even better, if the user would input their ESPP contribution, this would be easier to verify (modulo adjusting the contribution for December in case we overflow 25K). WDYT?

Originally posted by @nicocanali in https://github.com/kraiouchkine/ch-paystub-verify/issues/12#issuecomment-2081584337

nicolaswill commented 6 months ago

@nicocanali Good catch. There are some edge cases, such as bonus payments and extremely high base salaries. For example, someone earning 660k CHF annually, or 55k CHF monthly, would be able to reach the 25k USD annual contribution limit within three months given the current CHF->USD conversion rate.

That's not applicable to most cases though, so perhaps the heuristic's bounds could be tightened with something like the following?

potential_bonus = annual_salary * 0.3 // assuming 30% of annual salary max
quarterly_salary = annual_salary / 4
max_plausible_contribution = (quarterly_salary + potential_bonus) * 0.15
max_plausible_gain = min(25000/9, max_plausible_contribution/9)
nicocanali commented 6 months ago

Sounds good to me! Except the last line should be

max_plausible_gain = min(25000/9/4, max_plausible_contribution/9), right?

nicolaswill commented 6 months ago

Sounds good to me! Except the last line should be

max_plausible_gain = min(25000/9/4, max_plausible_contribution/9), right?

I don't think so, because it's possible that someone contributes 25,000 USD within 3 months. The max_plausible_contribution could be smaller than that if the quarterly base salary + highest plausible bonus is smaller than 25,000.

I think it's easier to think of this statement as min(25000, max_plausible_contribution) / 9.

nicocanali commented 6 months ago

Ah! Makes sense! 🙏

Indeed, with the quarterly_salary and bonus calculation it already has a quarterly safety net.

nicolaswill commented 6 months ago

Correction: the max_plausible_contribution could be smaller than that if 15% of the sum of the quarterly base salary and the highest plausible bonus is smaller than 25,000.