/// <summary> /// Find or create a shift tender line. /// </summary> /// <param name="shiftTenderLines">Shift tender lines.</param> /// <param name="tenderLine">Tender line.</param> /// <returns>Returns the shift tender line.</returns> private static ShiftTenderLine FindOrCreate(this IList <ShiftTenderLine> shiftTenderLines, ShiftTenderLine tenderLine) { string tenderTypeId = tenderLine.TenderTypeId; string tenderCurrency = tenderLine.TenderCurrency; string tenderTypeName = tenderLine.TenderTypeName; ShiftTenderLine shiftTenderLine = shiftTenderLines.FirstOrDefault(p => p.TenderTypeId == tenderTypeId && p.TenderCurrency == tenderCurrency); if (shiftTenderLine == null) { shiftTenderLine = new ShiftTenderLine { TenderTypeId = tenderTypeId, CardTypeId = string.Empty, TenderCurrency = tenderCurrency, TenderTypeName = tenderTypeName }; shiftTenderLines.Add(shiftTenderLine); } return(shiftTenderLine); }
/// <summary> /// Sets the tender line tender amounts. /// </summary> /// <param name="currentShift">Current shift data.</param> /// <param name="shiftTenderLines">Shift tender lines that contains the end of day amount.</param> private static void SetShiftTenderLineTenderAmounts(Shift currentShift, IEnumerable <ShiftTenderLine> shiftTenderLines) { foreach (var shiftTenderLine in shiftTenderLines) { ShiftTenderLine tenderLine = currentShift.TenderLines.FindOrCreate(shiftTenderLine); tenderLine.CountingRequired = shiftTenderLine.CountingRequired; tenderLine.TenderCurrency = shiftTenderLine.TenderCurrency; tenderLine.ChangeLine = shiftTenderLine.ChangeLine; if (tenderLine.ChangeLine) { tenderLine.ChangeAmountOfTenderCurrency = decimal.Negate(shiftTenderLine.TenderedAmountOfTenderCurrency); tenderLine.ChangeAmountOfStoreCurrency = decimal.Negate(shiftTenderLine.TenderedAmountOfStoreCurrency); } else { tenderLine.TenderedAmountOfTenderCurrency = shiftTenderLine.TenderedAmountOfTenderCurrency; tenderLine.TenderedAmountOfStoreCurrency = shiftTenderLine.TenderedAmountOfStoreCurrency; tenderLine.Count = shiftTenderLine.Count; } } }