Wage: US-MN Unemployment WAGE_US_MN_UNEMP python result = (contract.futa_type != contract.FUTA_TYPE_BASIC) code rate = payslip.dict.get_rate('US_MN_UNEMP') year = payslip.dict.date_to.year ytd = payslip.sum('WAGE_US_MN_UNEMP', str(year) + '-01-01', str(year+1) + '-01-01') ytd += contract.external_wages remaining = rate.wage_limit_year - ytd if remaining <= 0.0: result = 0 elif remaining < categories.BASIC: result = remaining else: result = categories.BASIC ER: US-MN Unemployment ER_US_MN_UNEMP python result = (contract.futa_type != contract.FUTA_TYPE_BASIC) code rate = payslip.dict.get_rate('US_MN_UNEMP') result_rate = -rate.rate result = categories.WAGE_US_MN_UNEMP # result_rate of 0 implies 100% due to bug if result_rate == 0.0: result = 0.0 EE: US-MN Income Tax Withholding EE_US_MN_INC_WITHHOLD python result = contract.mn_w4mn_filing_status != 'exempt' code # Step 1 - Determine Employee's Total Wages for one payroll period. wages = categories.GROSS allowances = contract.mn_w4mn_allowances schedule_pay = contract.schedule_pay # Step 2 - Multiply the wages from step by number of payroll periods per year. This gives annual wage. pay_period = 0.0 pay_periods = { 'weekly': 52.0, 'bi-weekly': 26.0, 'semi-monthly': 24.0, 'monthly': 12.0 } if schedule_pay in pay_periods: pay_period = pay_periods[schedule_pay] else: raise Exception('Invalid schedule_pay="' + schedule_pay + '" for AR Income Withholding calculation') annual_wages = wages * pay_period # Step 3 - Multiple the number of employee's withholding allowances by $4,250 allowance_amount = 4250.00 * allowances # Step 4 - Subtract the result in step 3 from the result in step 2. taxable_wages = annual_wages - allowance_amount # Step 5 - Use the result in step 4 (taxable wages) and the tax chart to calculate step 5 amount. mn_w4_filing_status = contract.mn_w4mn_filing_status tax_table = [] if mn_w4_filing_status == 'single': tax_table = [ (28920, 2400, 5.35, 0.00), (89510, 28920, 7.05, 1418.82), (166290, 89510, 7.85, 5690.42), (float('inf'), 166290, 9.85, 11717.65) ] elif mn_w4_filing_status == 'married': tax_table = [ (47820, 9050, 5.35, 0.00), (163070, 47820, 7.05, 2074.20), (282200, 163070, 7.85, 10199.33), (float('inf'), 282200, 9.85, 19551.04) ] else: raise Exception('Invalid w4_filing_status="' + mn_w4_filing_status + '" for MN Income Withholding calculation') last = 0.0 result = 0.0 for row in tax_table: cap, subtract_amt, rate, flat_fee = row if cap > taxable_wages: taxed_amount = taxable_wages - subtract_amt result = ((rate / 100.00) * taxed_amount) + flat_fee break # Make the result per pay period once more. result = result / pay_period # Round Result - Make sign negative as well - Add additional withholding here as well result = -round(result) - contract.mn_w4mn_additional_wh