Example #1
0
 public List <Product> GetAll(int type)
 {
     if (type == 0)
     {
         return(service.GetAll(a => a.IsActive == true).ToList());
     }
     //return service.GetAll();
     return(service.GetAll(a => a.IsActive == true && a.ProductTypeId == type).ToList());
 }
Example #2
0
 public List <TempSalesMaster> GetUnAurhorizedSales()
 {
     try
     {
         return(serviceTempSalesMaster.GetAll(a => a.IsActive == true).ToList());
     }
     catch (Exception)
     {
         return(new List <TempSalesMaster>());
     }
 }
Example #3
0
        public bool Save(List <StockOutRequest> stockOuts, string invoiceNo, string Notes)
        {
            var balance        = 0.0m;
            var inventoryLists = stockOuts.Select(a => a.InventoryId).ToList();
            var existingItem   = inventory.GetAll(a => inventoryLists.Contains(a.Id) && a.IsActive == true).ToList();

            if (existingItem.Count > 0)
            {
                var stocks = new List <StockOut>();
                foreach (var inv in existingItem)
                {
                    var qty   = stockOuts.Where(a => a.InventoryId == inv.Id).Sum(a => a.Qty);
                    var stock = new StockOut()
                    {
                        AlreadyProcessed = false,
                        BaleQty          = qty,
                        ProductId        = inv.ProductId,
                        IsActive         = true,
                        InvoiceNo        = invoiceNo,
                        Notes            = Notes,
                        SupplierId       = inv.SupplierId,
                        WarehouseId      = inv.WarehouseId,
                        CreatedBy        = CurrentSession.GetCurrentSession().UserName,
                        CreatedDate      = DateTime.Now,
                        SizeId           = inv.SizeId,
                        SizeName         = inv.Size.Name,
                        BrandId          = inv.BrandId,
                        BrandName        = inv.Brand.BrandName,
                        APIId            = inv.APIId,
                        InventoryId      = inv.Id,
                        Rate             = inv.PurchasePrice,
                        StockOutPrice    = inv.PurchasePrice * qty,
                        ProductionDate   = DateTime.Now
                    };
                    inv.UpdatedDate    = DateTime.Now;
                    inv.UpdatedBy      = CurrentSession.GetCurrentSession().UserName;
                    inv.ProductionOut += qty;
                    inv.BalanceQty     = inv.BalanceQty - qty;
                    balance            = inv.BalanceQty;
                    inventory.Update(inv, inv.Id);
                    stocks.Add(stock);
                    var invTransaction = new InventoryTransaction()
                    {
                        APIId         = stock.APIId,
                        BalanceQty    = balance,
                        BrandId       = stock.BrandId,
                        CreatedBy     = CurrentSession.GetCurrentSession().UserName,
                        CreatedDate   = DateTime.Now,
                        GoodsType     = "Finished Goods",
                        InventoryGuid = Guid.NewGuid().ToString(),
                        InvoiceNo     = "",
                        IsActive      = true,
                        ProductId     = stock.ProductId ?? 0,
                        PurchasePrice = 0,
                        Qty           = stock.BaleQty,
                        SalesPrice    = 0,
                        SizeId        = stock.SizeId,
                        SupplierId    = stock.SupplierId ?? 0,

                        TransactionType = (int)Util.TransactionType.ProductionOut,
                        WarehouseId     = stock.WarehouseId ?? 0
                    };
                    _invTransactionService.Save(invTransaction);
                }
                service.Save(stocks);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
 public List <Employee> GetAll()
 {
     return(service.GetAll(a => a.IsActive == true).ToList());
 }
Example #5
0
 public List <Brand> GetAll()
 {
     return(service.GetAll());
 }
Example #6
0
 public List <SalesDelivery> GetAll()
 {
     return(service.GetAll());
 }
Example #7
0
        public List <PartyAgeingReportResponse> AgeingReportSummary(DateTime fromDate, DateTime toDate)
        {
            List <PartyAgeingReportResponse> ageingReport = new List <PartyAgeingReportResponse>();
            var customers = _customerService.GetAll().ToList();
            var ids       = customers.Select(a => a.LedgerId);
            var list      = service.GetAll(a => ids.Contains(a.LedgerId) && a.FinancialYearId == yearId).ToList();
            //firstSlab
            int i = 0;

            foreach (var item in customers)
            {
                i++;
                DateTime fDate = fromDate;
                DateTime tDate = toDate;

                PartyAgeingReportResponse customerWiseAgeing = new PartyAgeingReportResponse();
                customerWiseAgeing.SI        = i;
                customerWiseAgeing.PartyName = item.Name;
                //total Receivable
                var transactions = list.Where(a => a.LedgerId == item.LedgerId).ToList();
                if (transactions != null)
                {
                    var credit = transactions.Sum(a => a.Credit ?? 0);
                    var debit  = transactions.Sum(a => a.Debit ?? 0);

                    customerWiseAgeing.Receivable         = Math.Abs(credit - debit);
                    customerWiseAgeing.ReceivableWithType = credit > debit ? customerWiseAgeing.Receivable + "Cr" : customerWiseAgeing.Receivable + "Dr";
                }

                //upto 0-30 Receivable
                tDate = fDate.AddDays(-30);
                var uppTo30Days = transactions.Where(a => a.PostingDate.Value.Date <fDate.Date && a.PostingDate.Value.Date> tDate.Date).ToList();
                if (uppTo30Days != null)
                {
                    var credit = uppTo30Days.Sum(a => a.Credit ?? 0);
                    var debit  = uppTo30Days.Sum(a => a.Debit ?? 0);

                    customerWiseAgeing.FirstSlab         = Math.Abs(credit - debit);
                    customerWiseAgeing.FirstSlabWithType = credit > debit ? customerWiseAgeing.Receivable + "Cr" : customerWiseAgeing.Receivable + "Dr";
                }
                //upto 30-60 Receivable
                fDate = tDate;
                tDate = fDate.AddDays(-30);
                var uppTo60Days = transactions.Where(a => a.PostingDate.Value.Date <fDate.Date && a.PostingDate.Value.Date> tDate.Date).ToList();
                if (uppTo60Days != null)
                {
                    var credit = uppTo60Days.Sum(a => a.Credit ?? 0);
                    var debit  = uppTo60Days.Sum(a => a.Debit ?? 0);

                    customerWiseAgeing.SecondSlab         = Math.Abs(credit - debit);
                    customerWiseAgeing.SecondSlabWithType = credit > debit ? customerWiseAgeing.Receivable + "Cr" : customerWiseAgeing.Receivable + "Dr";
                }
                //upto 61-90 Receivable
                fDate = tDate;
                tDate = fDate.AddDays(-30);
                var uppTo90Days = transactions.Where(a => a.PostingDate.Value.Date <fDate.Date && a.PostingDate.Value.Date> tDate.Date).ToList();
                if (uppTo90Days != null)
                {
                    var credit = uppTo90Days.Sum(a => a.Credit ?? 0);
                    var debit  = uppTo90Days.Sum(a => a.Debit ?? 0);

                    customerWiseAgeing.ThirdSlab         = Math.Abs(credit - debit);
                    customerWiseAgeing.ThirdSlabWithType = credit > debit ? customerWiseAgeing.Receivable + "Cr" : customerWiseAgeing.Receivable + "Dr";
                }

                //upto 90-180 Receivable
                fDate = tDate;
                tDate = fDate.AddDays(-90);
                var uppTo180Days = transactions.Where(a => a.PostingDate.Value.Date <fDate.Date && a.PostingDate.Value.Date> tDate.Date).ToList();
                if (uppTo180Days != null)
                {
                    var credit = uppTo180Days.Sum(a => a.Credit ?? 0);
                    var debit  = uppTo180Days.Sum(a => a.Debit ?? 0);

                    customerWiseAgeing.FourthSlab         = Math.Abs(credit - debit);
                    customerWiseAgeing.FourthSlabWithType = credit > debit ? customerWiseAgeing.Receivable + "Cr" : customerWiseAgeing.Receivable + "Dr";
                }
                //upto 180 and above Receivable

                fDate = tDate;
                var restOf = transactions.Where(a => a.PostingDate.Value.Date < fDate.Date).ToList();
                if (restOf != null)
                {
                    var credit = restOf.Sum(a => a.Credit ?? 0);
                    var debit  = restOf.Sum(a => a.Debit ?? 0);
                    customerWiseAgeing.FourthSlab         = Math.Abs(credit - debit);
                    customerWiseAgeing.FourthSlabWithType = credit > debit ? customerWiseAgeing.Receivable + "Cr" : customerWiseAgeing.Receivable + "Dr";
                }
                ageingReport.Add(customerWiseAgeing);
            }
            return(ageingReport);
        }
Example #8
0
 public List <Size> GetAll()
 {
     return(service.GetAll());
 }
Example #9
0
        public ReceiveMaster Save(ReceiveMaster cus, List <AdditionalCost> additionalCosts, int wareHouseId, int goodsType)
        {
            var avgAdditionalCost = cus.AdditionalCost / cus.ReceiveDetails.Select(a => a.Qty).Sum();
            var avgCostPrice      = 0.0m;
            var supplier          = supplierService.GetById(cus.SupplierID);

            cus.YearId = financialYearId;
            var result = service.Save(cus);

            if (result != null || result.Id > 0)
            {
                foreach (var item in cus.ReceiveDetails)
                {
                    var balance      = 0.0m;
                    var existingItem = _inventoryService.GetAll(a => a.ProductId == item.ProductId && a.IsActive == true && a.WarehouseId == wareHouseId && a.SizeId == item.SizeId && a.BrandId == item.BrandId && a.APIId == item.APIId).ToList();
                    if (existingItem.Count > 0)
                    {
                        foreach (var inv in existingItem)
                        {
                            var existingCosting = inv.BalanceQty * inv.Costprice ?? 0;
                            var totalAmount     = item.Amount + avgAdditionalCost * item.Qty + existingCosting;
                            avgCostPrice      = totalAmount / (item.Qty + inv.BalanceQty);
                            inv.Costprice     = avgCostPrice;
                            inv.PurchasePrice = item.Rate;
                            inv.UpdatedDate   = DateTime.Now;
                            inv.UpdatedBy     = "";
                            inv.BalanceQty    = inv.BalanceQty + item.Qty;
                            inv.ReceiveQty    = inv.ReceiveQty ?? 0 + item.Qty;
                            _inventoryService.Update(inv, inv.Id);
                            balance = inv.BalanceQty;
                        }
                    }
                    else
                    {
                        Inventory inv = new Inventory();
                        inv.IsActive      = true;
                        inv.CreatedDate   = DateTime.Now;
                        inv.CreatedBy     = "";
                        inv.ProductId     = item.ProductId;
                        inv.ReceiveQty    = item.Qty;
                        inv.SupplierId    = cus.SupplierID;
                        inv.WarehouseId   = wareHouseId;
                        inv.BrandId       = item.BrandId;
                        inv.SizeId        = item.SizeId;
                        inv.APIId         = item.APIId;
                        inv.Faulty        = 0;
                        inv.OpeningQty    = 0;
                        inv.BalanceQty    = item.Qty;
                        inv.PurchasePrice = item.Rate;
                        inv.Costprice     = avgCostPrice;
                        inv.SalesPrice    = 0;
                        inv.GoodsType     = goodsType.ToString();
                        _inventoryService.Save(inv);
                        balance = item.Qty;
                    }

                    var invTransaction = new InventoryTransaction()
                    {
                        APIId           = item.APIId,
                        BalanceQty      = balance,
                        BrandId         = item.BrandId,
                        CreatedBy       = CurrentSession.GetCurrentSession().UserName,
                        CreatedDate     = DateTime.Now,
                        GoodsType       = goodsType.ToString(),
                        InventoryGuid   = Guid.NewGuid().ToString(),
                        InvoiceNo       = cus.InvoiceNo,
                        IsActive        = true,
                        ProductId       = item.ProductId,
                        PurchasePrice   = item.Rate,
                        CostPrice       = avgCostPrice,
                        Qty             = item.Qty,
                        SalesPrice      = 0,
                        SizeId          = item.SizeId,
                        SupplierId      = cus.SupplierID,
                        TransactionType = (int)Util.TransactionType.ReceiveQty,
                        WarehouseId     = item.WarehouseId ?? 0
                    };
                    _invTransactionService.Save(invTransaction);
                }
                // Ledger posting debit to purchase account

                var ledgerObj = new LedgerPosting();
                ledgerObj.VoucherTypeId = (int)VoucherTypeEnum.PurchaseInvoice;
                ledgerObj.VoucherNo     = result.InvoiceNoPaper;
                ledgerObj.PostingDate   = cus.InvoiceDate;
                ledgerObj.LedgerId      = (int)DefaultLedger.PurchaseAccount;
                ledgerObj.InvoiceNo     = cus.InvoiceNo;
                ledgerObj.Credit        = 0;
                ledgerObj.Debit         = cus.GrandTotal;
                ledgerObj.MasterId      = result.Id;
                var save = ledgerService.Save(ledgerObj);

                //Ledger posting to customer ledger credit
                var detailsLedger = new LedgerPosting();
                detailsLedger.VoucherTypeId = (int)VoucherTypeEnum.PurchaseInvoice;
                detailsLedger.VoucherNo     = result.InvoiceNoPaper;
                detailsLedger.PostingDate   = cus.InvoiceDate;
                detailsLedger.LedgerId      = supplier.LedgerId;
                detailsLedger.InvoiceNo     = cus.InvoiceNo;
                detailsLedger.Credit        = cus.TotalAmount - cus.BillDiscount;
                detailsLedger.Debit         = 0;
                detailsLedger.MasterId      = result.Id;
                var detailsLedgerResult = ledgerService.Save(detailsLedger);

                //save addisitonalCost
                if (additionalCosts != null && additionalCosts.Count > 0)
                {
                    foreach (var item in additionalCosts)
                    {
                        item.CreatedBy     = CurrentSession.GetCurrentSession().UserId;
                        item.CreatedDate   = DateTime.Now;
                        item.LedgerId      = supplier.LedgerId;
                        item.VoucherNo     = cus.InvoiceNo;
                        item.Extra1        = cus.AdditionalCostPurpose;
                        item.VoucherTypeId = (int)VoucherTypeEnum.PurchaseInvoice;
                        var isSaved = _addCostService.Save(item);
                    }
                    //
                    var additionalCost = new LedgerPosting();
                    additionalCost.VoucherTypeId = (int)VoucherTypeEnum.AdditionalCost;
                    additionalCost.VoucherNo     = result.InvoiceNoPaper;
                    additionalCost.PostingDate   = cus.InvoiceDate;
                    additionalCost.LedgerId      = (int)DefaultLedger.AdditionalCost;
                    additionalCost.InvoiceNo     = cus.InvoiceNo;
                    additionalCost.Credit        = cus.AdditionalCost;
                    additionalCost.Debit         = 0;
                    additionalCost.MasterId      = result.Id;
                    var _ = ledgerService.Save(additionalCost);
                }

                var party = new PartyBalance();
                party.InvoiceNo       = result.InvoiceNo;
                party.LedgerId        = supplier.LedgerId ?? 0;
                party.Credit          = cus.TotalAmount - cus.BillDiscount;
                party.CreditPeriod    = 60;
                party.Debit           = 0;
                party.MasterId        = result.Id;
                party.FinancialYearId = CurrentSession.GetCurrentSession().FinancialYear;
                party.PostingDate     = cus.InvoiceDate;
                party.VoucherTypeId   = (int)VoucherTypeEnum.PurchaseInvoice;
                party.VoucherNo       = result.InvoiceNo;
                party.extra1          = "Purchase Invoice: " + cus.InvoiceNo + " Paper Invoice No:" + cus.InvoiceNoPaper;
                party.extra2          = result.Id.ToString();
                partyBalanceService.Save(party);
            }
            return(cus);
        }
Example #10
0
 public List <ReceiveMaster> GetAll()
 {
     return(service.GetAll());
 }
Example #11
0
        public int Delete(ReceiveMaster master)
        {
            try
            {
                var salesdetails = serviceDetails.GetAll(a => a.ReceiveMasterId == master.Id).ToList();
                foreach (var item in salesdetails)
                {
                    try
                    {
                        var isdetails = new DBService <ReceiveDetail>().Delete(item.Id);
                    }
                    catch (Exception ex)
                    {
                    }
                }

                var isDeleted = service.Delete(master.Id);
                foreach (var item in master.ReceiveDetails)
                {
                    var existingItem = _inventoryService.GetAll(a => a.ProductId == item.ProductId && a.IsActive == true && a.WarehouseId == item.WarehouseId).ToList();
                    if (existingItem.Count > 0)
                    {
                        foreach (var inv in existingItem)
                        {
                            inv.UpdatedDate = DateTime.Now;
                            inv.UpdatedBy   = "";
                            inv.BalanceQty  = inv.BalanceQty - item.Qty;
                            inv.ReceiveQty  = inv.ReceiveQty ?? 0 - item.Qty;
                            _inventoryService.Update(inv, inv.Id);
                        }
                    }
                }
                var supplier = supplierService.GetById(master.SupplierID);

                foreach (LedgerPosting item in this.ledgerService.GetAllByInvoice(master.InvoiceNo, true))
                {
                    item.IsActive = false;
                    this.ledgerService.Update(item, item.Id);
                }
                PartyBalanceService partyBalanceService = this.partyBalanceService;
                int?         ledgerId   = supplier.LedgerId;
                PartyBalance paymentObj = partyBalanceService.GetByInvoiceNo(supplier.LedgerId ?? 0, master.InvoiceNo);
                this.partyBalanceService.Delete(paymentObj.PartyBalanceId);

                // Ledger Saves credit
                //var ledgerObj = new LedgerPosting();
                //ledgerObj.VoucherTypeId = (int)VoucherType.PurchaseInvoice;
                //ledgerObj.VoucherNo = master.InvoiceNoPaper;
                //ledgerObj.PostingDate = master.InvoiceDate;
                //ledgerObj.LedgerId = (int)DefaultLedger.PurchaseAccount;
                //ledgerObj.InvoiceNo = master.InvoiceNo;
                //ledgerObj.Debit = 0;
                //ledgerObj.Credit = master.GrandTotal;
                //ledgerObj.Extra1 = "Purchase Invoice Deleted: " + master.InvoiceNo;

                //var save = ledgerService.Save(ledgerObj);

                //Ledger posting to customer ledger credit
                //var detailsLedger = new LedgerPosting();
                //detailsLedger.VoucherTypeId = (int)VoucherType.PurchaseInvoice;
                //detailsLedger.VoucherNo = master.InvoiceNoPaper;
                //detailsLedger.PostingDate = master.InvoiceDate;
                //detailsLedger.LedgerId = supplier.LedgerId;
                //detailsLedger.InvoiceNo = master.InvoiceNo;
                //detailsLedger.Debit = master.GrandTotal;
                //detailsLedger.Credit = 0;
                //detailsLedger.Extra1 = "Purchase Invoice Deleted: " + master.InvoiceNo;
                //var detailsLedgerResult = ledgerService.Save(detailsLedger);

                //var party = new PartyBalance();
                //party.InvoiceNo = master.InvoiceNo;
                //party.LedgerId = supplier.LedgerId ?? 0;
                //party.Debit = master.GrandTotal;
                //party.CreditPeriod = 60;
                //party.Credit = 0;
                //party.FinancialYearId =CurrentSession.GetCurrentSession().FinancialYear;
                //party.PostingDate = master.InvoiceDate;
                //party.VoucherTypeId = (int)VoucherType.PurchaseInvoice;
                //party.extra1 = "Purchase Invoice Deleted: " + master.InvoiceNo;
                //partyBalanceService.Save(party);

                return(1);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Example #12
0
        public List <SalaryPackageResponse> GetAllPackage()
        {
            var payHeads = _salaryPackageservice.GetAll();

            return(AutoMapper.Mapper.Map <List <SalaryPackageResponse> >(payHeads));
        }
Example #13
0
        public List <PayHeadViewModel> GetAll()
        {
            var payHeads = service.GetAll();

            return(AutoMapper.Mapper.Map <List <PayHeadViewModel> >(payHeads));
        }
Example #14
0
 public List <Department> GetAll()
 {
     return(service.GetAll().ToList());
 }
Example #15
0
 public List <Picture> GetAll()
 {
     return(service.GetAll());
 }
Example #16
0
 public List <RoleWiseScreenPermission> GetRoleWiseService()
 {
     return(roleService.GetAll());
 }
Example #17
0
 public List <AccountLedger> GetAll()
 {
     return(service.GetAll().ToList());
 }
Example #18
0
 public List <Tax> GetAll()
 {
     return(service.GetAll());
 }
Example #19
0
        public StockIn Save(StockIn stockIn)
        {
            var balance      = 0.0m;
            var existingItem = inventory.GetAll(a => a.ProductId == stockIn.ProductId && a.BrandId == stockIn.BrandId && a.SizeId == stockIn.SizeId && a.APIId == stockIn.APIId && a.IsActive == true && a.WarehouseId == stockIn.WarehouseId).ToList();

            if (existingItem.Count > 0)
            {
                foreach (var inv in existingItem)
                {
                    inv.UpdatedDate  = DateTime.Now;
                    inv.UpdatedBy    = "";
                    inv.BalanceQty   = inv.BalanceQty + stockIn.BaleQty ?? 0;
                    inv.ProductionIn = inv.ProductionIn ?? 0 + stockIn.BaleQty ?? 0;
                    inventory.Update(inv, inv.Id);
                    balance = inv.BalanceQty;
                }
            }
            else
            {
                Inventory result      = new Inventory();
                Inventory FinalResult = new Inventory();

                result.ProductId     = (int)stockIn.ProductId;
                result.SupplierId    = stockIn.SupplierId ?? 0;
                result.WarehouseId   = (int)stockIn.WarehouseId;
                result.ProductionIn  = stockIn.BaleQty;
                result.PurchasePrice = stockIn.Rate;
                result.BrandId       = stockIn.BrandId;
                result.SizeId        = stockIn.SizeId;
                result.BalanceQty    = stockIn.BaleQty ?? 0;
                result.Notes         = stockIn.Notes;
                result.GoodsType     = "2";
                result.CreatedBy     = CurrentSession.GetCurrentSession().UserName;
                result.CreatedDate   = DateTime.Now;
                result.IsActive      = true;
                FinalResult          = inventory.Save(result);
                balance = result.BalanceQty;
            }
            var invTransaction = new InventoryTransaction()
            {
                APIId           = stockIn.APIId,
                BalanceQty      = balance,
                BrandId         = stockIn.BrandId,
                CreatedBy       = CurrentSession.GetCurrentSession().UserName,
                CreatedDate     = DateTime.Now,
                GoodsType       = "Finished Goods",
                InventoryGuid   = Guid.NewGuid().ToString(),
                InvoiceNo       = "",
                IsActive        = true,
                ProductId       = stockIn.ProductId ?? 0,
                PurchasePrice   = stockIn.Rate,
                Qty             = stockIn.BaleQty,
                SalesPrice      = 0,
                SizeId          = stockIn.SizeId,
                SupplierId      = stockIn.SupplierId ?? 0,
                TransactionType = (int)Util.TransactionType.ProductionIn,
                WarehouseId     = stockIn.WarehouseId ?? 0
            };

            _invTransactionService.Save(invTransaction);
            return(service.Save(stockIn));
        }
Example #20
0
 public List <LedgerPosting> GetAll()
 {
     return(service.GetAll().ToList());
 }
Example #21
0
 public List <PartyBalance> GetAll()
 {
     return(service.GetAll(a => a.FinancialYearId == yearId).ToList());
 }
Example #22
0
 public List <PaymentMaster> GetAllPendingPayment()
 {
     return(_paymentMaster.GetAll(a => a.IsApproved == false).ToList());
 }
Example #23
0
 public List <Supplier> GetAll()
 {
     //return service.GetAll();
     return(service.GetAll(a => a.IsActive == true).ToList());
 }
Example #24
0
 public List <BonusDeduction> GetAll(int year, int month)
 {
     return(service.GetAll(a => a.Year == year && a.Month == month).ToList());
 }
Example #25
0
 public List <AccountGroup> GetAll()
 {
     return(service.GetAll().ToList());
 }
Example #26
0
 public List <Category> GetAll()
 {
     return(service.GetAll(a => a.IsActive == true).ToList());
 }
Example #27
0
 public List <StockOut> GetAll()
 {
     return(service.GetAll());
 }
Example #28
0
 public List <Company> GetAll()
 {
     return(service.GetAll());
 }
Example #29
0
 public List <WareHouse> GetAll()
 {
     //return service.GetAll();
     return(service.GetAll(a => a.IsActive == true).ToList());
 }
Example #30
0
 public List <User> GetAll()
 {
     return(service.GetAll());
 }