public void AddUnPaidPurchaseScaleExpenses(int scaleId) { // Search for all expenses that matches scaleId. ExpensesRequestLibrary lib = new ExpensesRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); string refTableName = new Model.Scale().GetType().Name; IEnumerable <ExpensesRequest> expenses = lib.GetAllPurchasingExepneseByRefTableAndRefId(scaleId, refTableName, new[] { "Payment", "Paid_Party_To" }); ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); foreach (var item in expenses) { // If scale expense already exists. if (TempEntityList.FirstOrDefault(m => m.ID == item.ID) == null) { // Get scale entity Scale scale = scaleLib.GetByID(item.Reference_ID.ToString(), new string[] { "Dispatch_Request_No" }); if (item.Paid_Party_To == null) { item.Paid_Party_To = new Party(); } // Add eexpense to TempList. TempEntityList.Add(item); // Add dispatcher expense. if (scale.Dispatch_Request_No != null && scale.Dispatch_Request_No.ID > 0) { AddUnPaidPurchaseDispatcherExpenses(scale.Dispatch_Request_No.ID); } } } }
private void AddNonInvoiceSellingDispatcherExpenses(int bookingId, string containerNo) { // Search for expenses that matches dispatcher id. DispatcherRequestLibrary dispathcerRequestLib = new DispatcherRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <DispatcherRequest> dispatcherReqs = dispathcerRequestLib.GetDispatcherByBookingAndContainerNo(bookingId, containerNo, new string[] { "Booking_Ref_No", "Container" }); foreach (DispatcherRequest dispatcherReq in dispatcherReqs) { ExpensesRequestLibrary lib = new ExpensesRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); string refTableName = new Model.DispatcherRequest().GetType().Name; IEnumerable <ExpensesRequest> expenses = lib.GetAllPurchasingExepneseByRefTableAndRefId(dispatcherReq.ID, refTableName, new[] { "Payment", "Paid_Party_To", "Invoice" }); foreach (var item in expenses) { // If expense already exists. if (TempEntityList.FirstOrDefault(m => m.ID == item.ID) == null) { // If party is null. if (item.Paid_Party_To == null) { item.Paid_Party_To = new Party(); } // Add to TempList. TempEntityList.Add(item); } } } }
//[HttpPost] //public void RemoveUnPaidSellingExpenses(string bookingId) { // // If TEmpEntityList has no Items. // if (TempEntityList != null) { // int intBookingId = Convert.ToInt32(bookingId); // if (intBookingId > 0) { // // Get all scale exepenses. // IEnumerable<ExpensesRequest> scaleExps = from exp in TempEntityList // where exp.Reference_Table == "Scale" && exp.Reference_ID == intBookingId // select exp; // if (scaleExps != null) { // IList<ExpensesRequest> removeExpenses = new List<ExpensesRequest>(); // ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); // foreach (var item in scaleExps) { // // Get scale entity. // Scale scale = scaleLib.GetByID(item.Reference_ID.ToString(), new string[] { "Dispatch_Request_No" }); // if (scale != null && scale.Dispatch_Request_No != null && scale.Dispatch_Request_No.ID > 0) { // // Get dispatcher id. // int dispatcherId = scale.Dispatch_Request_No.ID; // // Get all dispatcher expenses. // IEnumerable<ExpensesRequest> dispatcherExps = from exp in TempEntityList // where exp.Reference_Table == "DispatcherRequest" && exp.Reference_ID == dispatcherId // select exp; // if (dispatcherExps != null) { // foreach (var dispExp in dispatcherExps) { // // Add dispatcher expense in removeExpense list. // removeExpenses.Add(dispExp); // } // } // } // // Add scale expense in removeExpense list. // removeExpenses.Add(item); // } // // Delete scale and dispatcher expense. // foreach (var removeExp in removeExpenses) { // TempEntityList.Remove(removeExp); // } // } // } // } //} public void AddNonInvoiceSellingScaleExpenses(int bookingId) { TempEntityList.Clear(); ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <Scale> scales = scaleLib.GetScalesByBookingId(bookingId); // Search for all expenses that matches scaleId. ExpensesRequestLibrary lib = new ExpensesRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); string refTableName = new Model.Scale().GetType().Name; foreach (var scale in scales) { IEnumerable <ExpensesRequest> expenses = lib.GetAllSellingExepneseByRefTableAndRefId(scale.ID, refTableName, new[] { "Payment", "Paid_Party_To", "Invoice" }); foreach (var expense in expenses) { // If scale expense already exists. if (TempEntityList.FirstOrDefault(m => m.ID == expense.ID) == null) { if (expense.Paid_Party_To == null) { expense.Paid_Party_To = new Party(); } // Add eexpense to TempList. TempEntityList.Add(expense); // Add dispatcher expense. } } AddNonInvoiceSellingDispatcherExpenses(bookingId, scale.ContainerNo); } }
private string GetTotalExpenseDueAmount(int partyId, int bookingId = 0) { string dbContextConnectionString = ConfigurationHelper.GetsmARTDBContextConnectionString(); ExpensesRequestLibrary lib = new ExpensesRequestLibrary(); lib.Initialize(dbContextConnectionString); return(lib.GetTotalDueAmount(partyId, bookingId).ToString()); }
protected override ActionResult Display(GridCommand command, string id, bool isNew) { int totalRows = 0; IEnumerable <ExpensesRequest> resultList; // = ((IParentChildLibrary<TEntity>)Library).GetAllByPagingByParentID(out totalRows, int.Parse(id.ToString()), command.Page, command.PageSize==0?20:command.PageSize, "", "Asc", IncludePredicates); if (isNew || id == "0") { resultList = TempEntityList; totalRows = TempEntityList.Count; } else { ExpensesRequestLibrary lib = new ExpensesRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); resultList = lib.GetAllByPagingByPaymentID(out totalRows, int.Parse(id.ToString()), command.Page, command.PageSize == 0 ? 20 : command.PageSize, "", "Asc", new string[] { "Paid_Party_To", "Payment" }); } return(View(new GridModel { Data = resultList, Total = totalRows })); }
public ActionResult GetUnPaidExpenses(GridCommand command, string partyId, string bookingId = "0") { TempEntityList.Clear(); if (Convert.ToInt32(partyId) > 0) { string dbContextConnectionString = ConfigurationHelper.GetsmARTDBContextConnectionString(); ExpensesRequestLibrary lib = new ExpensesRequestLibrary(); lib.Initialize(dbContextConnectionString); IEnumerable <ExpensesRequest> results = lib.GetUnPaidExpenses(new string[] { "Paid_Party_To", "Scale_Ref", "Dispatcher_Request_Ref.Booking_Ref_No", "Dispatcher_Request_Ref.Container" }, int.Parse(partyId), int.Parse(bookingId) ); if (results != null && results.Count() > 0) { PaymentReceiptDetails paymentDetails; int id = 0; foreach (var item in results) { id += 1; paymentDetails = new PaymentReceiptDetails() { ID = id, ExpenseRequest = item, Balance_Amount = Convert.ToDecimal(item.Amount_Paid - item.Amount_Paid_Till_Date), PaymentReceipt = new PaymentReceipt() }; if (paymentDetails.Settlement != null) { paymentDetails.Settlement.Scale = null; } if (paymentDetails.ExpenseRequest.Dispatcher_Request_Ref != null) { paymentDetails.ExpenseRequest.Dispatcher_Request_Ref.TruckingCompany = null; } TempEntityList.Add(paymentDetails); } } } return(Display(command, "0", true)); }
private void AddUnPaidPurchaseDispatcherExpenses(int dispathcerId) { // Search for expenses that matches dispatcher id. ExpensesRequestLibrary lib = new ExpensesRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); string refTableName = new Model.DispatcherRequest().GetType().Name; IEnumerable <ExpensesRequest> expenses = lib.GetAllPurchasingExepneseByRefTableAndRefId(dispathcerId, refTableName, new[] { "Payment", "Paid_Party_To" }); foreach (var item in expenses) { // If expense already exists. if (TempEntityList.FirstOrDefault(m => m.ID == item.ID) == null) { // If party is null. if (item.Paid_Party_To == null) { item.Paid_Party_To = new Party(); } // Add to TempList. TempEntityList.Add(item); } } }
protected override void DeleteChildEntities(string[] childEntityList, string parentID) { foreach (string ChildEntity in childEntityList) { switch (ChildEntity) { #region /* Case Statements - All child grids */ case "PaymentDetails": if (Convert.ToInt32(parentID) > 0) { PaymentReceiptDetailsLibrary PaymentReceiptDetailsLibrary = new PaymentReceiptDetailsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <PaymentReceiptDetails> resultList = PaymentReceiptDetailsLibrary.GetAllByParentID(Convert.ToInt32(parentID), new string[] { "Settlement", "PaymentReceipt", "ExpenseRequest" }); foreach (PaymentReceiptDetails PaymentReceiptDetails in resultList) { PaymentReceiptDetailsLibrary.Delete(PaymentReceiptDetails.ID.ToString()); } } break; case "PaymentNotes": if (Convert.ToInt32(parentID) > 0) { PaymentReceiptNotesLibrary PaymentReceiptNotesLibrary = new PaymentReceiptNotesLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <PaymentReceiptNotes> resultList = PaymentReceiptNotesLibrary.GetAllByParentID(Convert.ToInt32(parentID)); foreach (PaymentReceiptNotes PaymentReceiptNote in resultList) { PaymentReceiptNotesLibrary.Delete(PaymentReceiptNote.ID.ToString()); } } break; case "PaymentAttachments": if (Convert.ToInt32(parentID) > 0) { PaymentReceiptAttachmentsLibrary PaymentReceiptLibrary = new PaymentReceiptAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <PaymentReceiptAttachments> resultList = PaymentReceiptLibrary.GetAllByParentID(Convert.ToInt32(parentID)); foreach (PaymentReceiptAttachments PaymentReceiptAttachment in resultList) { PaymentReceiptLibrary.Delete(PaymentReceiptAttachment.ID.ToString()); } } break; case "PaymentExpense": if (Convert.ToInt32(parentID) > 0) { ExpensesRequestLibrary lib = new ExpensesRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <ExpensesRequest> resultList = lib.GetAllByParentID(Convert.ToInt32(parentID)); foreach (ExpensesRequest expReq in resultList) { lib.Delete(expReq.ID.ToString()); } // Update payment Id IEnumerable <ExpensesRequest> paymentExps = lib.GetAllByPaymentID(Convert.ToInt32(parentID), new[] { "Payment" }); foreach (ExpensesRequest expReq in paymentExps) { expReq.Payment.ID = 0; lib.Modify(expReq, new[] { "Payment" }); } } break; #endregion } } }