public ActionResult GetUnPaidTickets(GridCommand command, string partyId, string locationId = "0")
        {
            TempEntityList.Clear();
            if (Convert.ToInt32(partyId) > 0)
            {
                string            dbContextConnectionString = ConfigurationHelper.GetsmARTDBContextConnectionString();
                SettlementLibrary settlementLib             = new SettlementLibrary();
                settlementLib.Initialize(dbContextConnectionString);
                IEnumerable <Settlement> results = settlementLib.GetUnPaidTickets(new string[] { "Scale", "Scale.Party_ID", "Scale.Purchase_Order", "Scale.Party_Address" }, int.Parse(partyId), int.Parse(locationId));

                if (results != null && results.Count() > 0)
                {
                    PaymentReceiptDetails paymentDetails;
                    int id = 0;
                    foreach (var item in results)
                    {
                        //if (item.Scale != null && item.Scale.Purchase_Order == null) {
                        //  item.Scale.Purchase_Order = new PurchaseOrder();
                        //}
                        id            += 1;
                        paymentDetails = new PaymentReceiptDetails()
                        {
                            ID             = id,
                            Settlement     = item,
                            Balance_Amount = item.Amount - item.Amount_Paid_Till_Date,
                            PaymentReceipt = new PaymentReceipt()
                        };

                        TempEntityList.Add(paymentDetails);
                    }
                }
            }
            return(Display(command, "0", true));
        }
        //[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);
            }
        }
示例#3
0
        public ActionResult GetUnPaidInvoices(GridCommand command, string partyId)
        {
            int totalRows = 0;

            TempEntityList.Clear();
            if (Convert.ToInt32(partyId) > 0)
            {
                string         dbContextConnectionString = ConfigurationHelper.GetsmARTDBContextConnectionString();
                InvoiceLibrary lib = new InvoiceLibrary();
                lib.Initialize(dbContextConnectionString);
                IEnumerable <Invoice> results = lib.GetUnPaidInvoicesWithPaging(out totalRows,
                                                                                command.Page, command.PageSize == 0 ? 20 : command.PageSize,
                                                                                "", "Asc",
                                                                                new string[] { "Booking.Sales_Order_No.Party", "Sales_Order_No.Party" },
                                                                                null,
                                                                                int.Parse(partyId)
                                                                                );

                if (results != null && results.Count() > 0)
                {
                    PaymentReceiptDetails paymentDetails;
                    int id = 0;
                    foreach (var item in results)
                    {
                        id += 1;
                        if (item.Booking == null)
                        {
                            item.Booking = new Booking();
                        }
                        paymentDetails = new PaymentReceiptDetails()
                        {
                            ID             = id,
                            Invoice        = item,
                            Balance_Amount = item.Net_Amt - item.Amount_Paid_Till_Date,
                            PaymentReceipt = new PaymentReceipt()
                        };

                        TempEntityList.Add(paymentDetails);
                    }
                }
            }

            IEnumerable <PaymentReceiptDetails> resultList = TempEntityList;

            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));
        }