/// <summary> /// Επιστρέφει μία λίστα με αντικείμενα SalaryAmounts. Το καθε SalaryAmount /// έχει ένα κωδικό, ένα description και το ποσό. /// </summary> /// <param name="incomes">Η λίστα των incomes</param> /// <param name="type">αν προκειται για amoibes "gr", erg.eisfores "et", krathseis "de"</param> /// <param name="code">το attribute του element που κραταει το ποσο, "kae" για αμοιβές, "code" για κρατήσεις ή εργ.εισφ.</param> /// <returns>Επιστρέφει μία λίστα με αντικείμενα SalaryAmounts. Το καθε SalaryAmount /// έχει ένα κωδικό, ένα description και το ποσό. /// </returns> public static IList <SalaryAmounts> GetSalaryAmounts(IEnumerable <XElement> incomes, string type, string code) { IList <SalaryAmounts> amounts = new List <SalaryAmounts>(); IList <string> gfh = new List <string>(); // διπλο grouping των Incomes ως προς το code var amoibesIncomes = (from tInc in incomes.Descendants(nsDefault + type) group tInc by tInc.Attribute(code) into amoibes group amoibes by(amoibes.Key as XAttribute).Value into totals select new { key = totals.Key, value = totals.ToList() }).ToList(); foreach (var inc in amoibesIncomes) { var kae = inc.key; string descr = ""; switch (type) { case "gr": descr = DisplayNameHelper.GetEnumDescription((TyposAmoibhsKAE)Convert.ToInt32(kae.Right(3))); break; case "de": descr = DisplayNameHelper.GetEnumDescription((ForeisKrathshs)Convert.ToInt32(kae)); break; case "et": descr = DisplayNameHelper.GetEnumDescription((ForeisKrathshs)Convert.ToInt32(kae)) + " Εργοδ."; kae = ((inc.value).First().SingleOrDefault() as XElement).Attribute("kae").Value; break; default: descr = "NotSet"; break; } var amount = inc.value.Sum(s => Convert.ToDecimal((s.First() as XElement).Attribute("amount").Value)); SalaryAmounts amoibh = new SalaryAmounts(kae, descr, amount); amounts.Add(amoibh); } return(amounts); }
/// <summary> /// Επιστρέφει τα σύνολο για ΑΜΟΙΒΕΣ, ΚΡΑΤΗΣΕΙΣ, ΕΡΓΟΔΟΤΙΚΕΣ για /// τα income Τακτικής Μισθοδοσίας /// </summary> /// <param name="incomestaktikhs">Όλα τα income τακτικής</param> /// <returns>Ενα SalaryEmployeeDetails για τακτικη</returns> public static SalaryEmployeeDetails GetPaymentTaktikisAmounts(IList <XElement> incomestaktikhs, int incomeType) { SalaryEmployeeDetails employeeItm = null; if (incomestaktikhs.Count() > 0) { employeeItm = new SalaryEmployeeDetails(); employeeItm.Amoibes = new List <SalaryAmounts>(); employeeItm.ErgEisfores = new List <SalaryAmounts>(); employeeItm.Krathseis = new List <SalaryAmounts>(); // εφόσον ειναι Τακτική, καθαρίζουμε τις τιμές // στα properties για την περίπτωση αναδρομικού // TODO ΟΛΕΣ ΤΙΣ ΠΕΡΙΠΤΩΣΕΙΣ.... employeeItm.Type = 444; switch (incomeType) { case 0: employeeItm.Type = 0; break; case 1: employeeItm.Type = 1; employeeItm.EndDate = Convert.ToDateTime(incomestaktikhs.First().Attribute("endDate").Value).ToString("dd/M/yyyy"); employeeItm.StartDate = Convert.ToDateTime(incomestaktikhs.First().Attribute("startDate").Value).ToString("dd/M/yyyy"); employeeItm.PeriodCount = null; break; case 2: employeeItm.Type = 2; break; case 3: employeeItm.Type = 3; break; case 4: employeeItm.Type = 4; break; case 5: employeeItm.Type = 5; break; case 6: employeeItm.Type = 6; break; } employeeItm.TypeDescriptionText = DisplayNameHelper.GetEnumStringValue((TyposEisodhmatos)employeeItm.Type); employeeItm.TypeDisplayText = DisplayNameHelper.GetEnumVocativeDescription((TyposEisodhmatos)employeeItm.Type); employeeItm.Amoibes = EapXMLTool.GetSalaryAmounts(incomestaktikhs, "gr", "kae"); employeeItm.ErgEisfores = EapXMLTool.GetSalaryAmounts(incomestaktikhs, "et", "code"); employeeItm.Krathseis = EapXMLTool.GetSalaryAmounts(incomestaktikhs, "de", "code"); } return(employeeItm); }