public ServerTeam(DateTime shiftDate) { ShiftDate = shiftDate; CheckOuts = new List <Checkout>(); CheckoutHasBeenRun = false; TipOutCalculator = new TipOutCalculator(); EarningCalculator = new ServerEarningCalculator(); TipOut = new TipOut(shiftDate, LunchOrDinner, "server"); }
public BarTeam(DateTime shiftDate, string lunchOrDinner) { ShiftDate = shiftDate; LunchOrDinner = lunchOrDinner; Checkouts = new List <Checkout>(); TipOutCalculatorFactory factory = new TipOutCalculatorFactory(); TipOutCalculator = new TipOutCalculator(); TipOut = new TipOut(shiftDate, LunchOrDinner, "bartender"); EarningsCalculator = new BarEarningsCalculator(); }
public List <Earnings> CalculateEarnings(List <Checkout> checkouts, TipOut tipout, DateTime shiftDate, string lunchOrDinner) { decimal teamTotalTipout = tipout.BarTipOut + tipout.SaTipOut; decimal teamTotalCcTips = 0; decimal teamTotalAutoGrat = 0; decimal teamTotalCashTips = 0; foreach (Checkout c in checkouts) { teamTotalCcTips += c.CcTips + c.CashAutoGrat; teamTotalAutoGrat += c.CcAutoGrat; teamTotalCashTips += c.CashTips; } Earnings individualEarnings = new Earnings(shiftDate, "server", lunchOrDinner); if (teamTotalCcTips >= teamTotalTipout) { decimal TeamCcTipsAfterCheckout = teamTotalCcTips - teamTotalTipout; individualEarnings.CcTips = Math.Round(TeamCcTipsAfterCheckout / checkouts.Count, 2); individualEarnings.AutoGratuity = Math.Round(teamTotalAutoGrat / checkouts.Count, 2); individualEarnings.CashTips = Math.Round(teamTotalCashTips / checkouts.Count, 2); individualEarnings.TotalTipsForPayroll = Math.Round(individualEarnings.CcTips + individualEarnings.CashTips + individualEarnings.AutoGratuity, 2); } else if (teamTotalCcTips + teamTotalAutoGrat > teamTotalTipout) { individualEarnings.CcTips = 0; decimal combinedAutoGratAndCC = teamTotalCcTips + teamTotalAutoGrat; individualEarnings.AutoGratuity = Math.Round(combinedAutoGratAndCC - teamTotalTipout, 2); individualEarnings.CashTips = Math.Round(teamTotalCashTips / checkouts.Count, 2); individualEarnings.TotalTipsForPayroll = Math.Round(individualEarnings.CashTips + individualEarnings.AutoGratuity, 2); } else { decimal teamTotalCCandAutoG = teamTotalCcTips + teamTotalAutoGrat; decimal remainingTipOutOwed = teamTotalTipout - teamTotalCCandAutoG; decimal remaingTeamCashTips = teamTotalCashTips - remainingTipOutOwed; individualEarnings.CcTips = 0; individualEarnings.AutoGratuity = 0; individualEarnings.OwedCashForTipOut = true; individualEarnings.CashPayedForTipOut = remainingTipOutOwed; individualEarnings.CashTips = Math.Round(remaingTeamCashTips / checkouts.Count, 2); individualEarnings.TotalTipsForPayroll = (individualEarnings.CashTips); } List <Earnings> teamEarnings = new List <Earnings>(); foreach (Checkout c in checkouts) { teamEarnings.Add(individualEarnings); } return(teamEarnings); }
{ //Dont forget to update TipOuts across the board with BarBackTipOut public List <Earnings> CalculateEarnings(List <Checkout> checkouts, TipOut tipout, decimal serverTips, DateTime shiftDate, string lunchOrDinner) { var teamEarnings = new List <Earnings>(); decimal totalTips = serverTips; decimal totalAutoGratuity = 0; decimal totalCashTips = 0; decimal totalTeamHours = 0; // Add up all the total team numbers foreach (Checkout c in checkouts) { totalTips += c.CcAutoGrat + c.CcTips + c.CashAutoGrat; totalAutoGratuity += c.CcAutoGrat; totalCashTips += c.CashTips; totalTeamHours += c.Hours; } //Take out the tipout and split up auto grat and cc decimal totalNetTips = totalTips - tipout.BarBackTipOut; totalNetTips = totalNetTips - totalAutoGratuity; //Determine team hourly pay decimal teamCcHourly = Math.Round(totalNetTips / totalTeamHours, 2); decimal teamAutoGHourly = Math.Round(totalAutoGratuity / totalTeamHours, 2); decimal teamCashHourly = Math.Round(totalCashTips / totalTeamHours, 2); foreach (Checkout c in checkouts) { var earning = new Earnings(shiftDate, "bartender", lunchOrDinner) { CcTips = Math.Round(c.Hours * teamCcHourly, 2), CashTips = Math.Round(c.Hours * teamCashHourly, 2), AutoGratuity = Math.Round(c.Hours * teamAutoGHourly, 2), StaffMember = c.StaffMember }; earning.TotalTipsForPayroll = earning.CcTips + earning.AutoGratuity + earning.CashTips; teamEarnings.Add(earning); } return(teamEarnings); }