Пример #1
0
 public SalesDelivery Save(SalesDelivery cus)
 {
     cus.CreatedDate = DateTime.Now;
     cus.CreatedBy   = CurrentSession.GetCurrentSession().UserName;
     service.Save(cus);
     return(cus);
 }
Пример #2
0
 public BonusDeduction Save(BonusDeduction cus)
 {
     cus.CreatedDate = DateTime.Now;
     cus.CreatedBy   = CurrentSession.GetCurrentSession().UserId;
     service.Save(cus);
     return(cus);
 }
Пример #3
0
 public PayHead Save(PayHead cus)
 {
     //cus.Active = true;
     cus.CreatedDate = DateTime.Now;
     cus.CreatedBy   = CurrentSession.GetCurrentSession().UserId;
     service.Save(cus);
     return(cus);
 }
Пример #4
0
 public Brand Save(Brand cus)
 {
     cus.Active      = true;
     cus.CreatedDate = DateTime.Now;
     cus.CreatedBy   = CurrentSession.GetCurrentSession().UserName;
     service.Save(cus);
     return(cus);
 }
Пример #5
0
        public Category Save(Category cus)
        {
            var isExists = service.GetAll().Where(a => a.CategoryName == cus.CategoryName || a.Code == cus.Code).FirstOrDefault();

            if (isExists != null)
            {
                return(null);
            }
            service.Save(cus);
            return(cus);
        }
Пример #6
0
        //public LedgerPosting Save(LedgerPosting cus)
        //{
        //    var isExists = service.GetAll().Where(a => a.LedgerId == cus.LedgerId && a.YearId == cus.YearId).FirstOrDefault();
        //    var max = service.LastRow().OrderByDescending(a => a.Id).FirstOrDefault().Id;
        //    cus.Id = max + 1;
        //    if (isExists != null)
        //    {
        //        return null;
        //    }
        //    cus.YearId = CurrentSession.GetCurrentSession().FinancialYear;
        //    cus.IsLastYear = true;
        //    service.Save(cus);
        //    return cus;

        //}
        public PaymentMaster SavePayment(PaymentMaster paymentMaster)
        {
            try
            {
                return(_paymentMaster.Save(paymentMaster));
            }
            catch (System.Exception ex)
            {
                throw;
            }
        }
Пример #7
0
 public SalaryPackage PackageSave(SalaryPackage cus)
 {
     //cus.Active = true;
     cus.CreateDate = DateTime.Now;
     cus.CreateBy   = CurrentSession.GetCurrentSession().UserName;
     foreach (var item in cus.SalaryPackageDetails)
     {
         item.SalaryPackageId = cus.Id;
     }
     _salaryPackageservice.Save(cus);
     return(cus);
 }
Пример #8
0
        public Department Save(Department cus)
        {
            var isExists = service.GetAll().Where(a => a.Name == cus.Name).FirstOrDefault();

            if (isExists != null)
            {
                return(null);
            }
            cus.CreatedDate = DateTime.Now;
            cus.Active      = true;
            service.Save(cus);
            return(cus);
        }
Пример #9
0
        public AccountGroup Save(AccountGroup cus)
        {
            var isExists = service.GetAll().Where(a => a.AccountGroupName == cus.AccountGroupName).FirstOrDefault();
            var max      = service.LastRow().OrderByDescending(a => a.Id).FirstOrDefault().Id;

            cus.Id = max + 1;
            if (isExists != null)
            {
                return(null);
            }
            service.Save(cus);
            return(cus);
        }
Пример #10
0
        public PartyBalance Save(PartyBalance partyBalance)
        {
            var isExists = service.GetAll().Where(a => a.LedgerId == partyBalance.LedgerId).OrderByDescending(a => a.PartyBalanceId).FirstOrDefault();
            var max      = service.LastRow().OrderByDescending(a => a.PartyBalanceId).FirstOrDefault();

            if (max == null)
            {
                partyBalance.PartyBalanceId = 1;
            }
            else
            {
                partyBalance.PartyBalanceId = max.PartyBalanceId + 1;
            }

            if (isExists != null)
            {
                if (partyBalance.Credit > 0)
                {
                    var newbalance = isExists.Balance + partyBalance.Credit;
                    partyBalance.Balance = newbalance;
                }
                if (partyBalance.Debit > 0)
                {
                    var newbalance = isExists.Balance - partyBalance.Debit;
                    partyBalance.Balance = newbalance;
                }
            }
            else
            {
                if (partyBalance.Credit > 0)
                {
                    partyBalance.Balance = partyBalance.Credit;
                }
                if (partyBalance.Debit > 0)
                {
                    partyBalance.Balance = (-1) * partyBalance.Debit;
                }
            }
            partyBalance.FinancialYearId = CurrentSession.GetCurrentSession().FinancialYear;
            partyBalance.IsLastYear      = true;
            service.Save(partyBalance);
            //if (partyBalance != null)
            //{
            //    SqlParameter param = new SqlParameter("@LedgerId", partyBalance.LedgerId);
            //    List<SqlParameter> paramss = new List<SqlParameter>();

            //    paramss.Add(param);
            //    service.ExecuteProcedure("Exec BalanceReconcilation " + partyBalance.LedgerId + "",paramss,true);
            //}
            return(partyBalance);
        }
Пример #11
0
        public Supplier Save(Supplier cus)
        {
            var max = service.LastRow().OrderByDescending(a => a.Id).FirstOrDefault();

            if (max == null)
            {
                cus.Id = 1;
            }
            else
            {
                cus.Id = max.Id + 1;
            }
            return(service.Save(cus));
        }
Пример #12
0
        public SalesDetail Update(SalesDetail salesDetail, int id)
        {
            var balance = 0.0m;
            List <Inventory> existingItem = this.inventory.GetAll((Inventory a) => a.ProductId == salesDetail.ProductId && a.IsActive && a.WarehouseId == salesDetail.WarehouseId && a.SizeId == salesDetail.SizeId && a.BrandId == salesDetail.BrandId && a.APIId == salesDetail.APIId).ToList <Inventory>();

            if (existingItem.Count > 0)
            {
                foreach (Inventory inv in existingItem)
                {
                    inv.UpdatedDate = new DateTime?(DateTime.Now);
                    inv.UpdatedBy   = "";
                    Inventory nullable = inv;
                    decimal?  salesQty = inv.SalesQty;
                    nullable.SalesQty = new decimal?((salesQty.HasValue ? salesQty.GetValueOrDefault() : salesDetail.Qty));
                    inv.BalanceQty    = inv.BalanceQty - salesDetail.Qty;
                    this.inventory.Update(inv, inv.Id);
                    balance = inv.BalanceQty;
                }
            }
            var invTransaction = new InventoryTransaction()
            {
                APIId         = salesDetail.APIId,
                BalanceQty    = balance,
                BrandId       = salesDetail.BrandId,
                CreatedBy     = CurrentSession.GetCurrentSession().UserName,
                CreatedDate   = DateTime.Now,
                GoodsType     = "Finished Goods",
                InventoryGuid = Guid.NewGuid().ToString(),
                InvoiceNo     = "",
                IsActive      = true,
                ProductId     = salesDetail.ProductId,
                PurchasePrice = salesDetail.Rate,
                Qty           = salesDetail.Qty,
                SalesPrice    = salesDetail.Rate,
                SizeId        = salesDetail.SizeId,
                SupplierId    = salesDetail.SalesMaster.CustomerID,

                TransactionType = (int)Util.TransactionType.SalesQty,
                WarehouseId     = salesDetail.WarehouseId
            };

            _invTransactionService.Save(invTransaction);
            return(salesDetailsService.Update(salesDetail, id));
        }
Пример #13
0
        public SalaryPayment Save(SalaryPayment SP)
        {
            var max = service.LastRow().OrderByDescending(a => a.Id).FirstOrDefault();

            SP.VoucherNo = max.VoucherNo;
            SP.LedgerId  = max.LedgerId;

            var Max = salaryPayment.LastRow().OrderByDescending(a => a.Id).FirstOrDefault();

            if (Max == null)
            {
                SP.Id = 1;
            }
            else
            {
                SP.Id = max.Id + 1;
            }
            var result = salaryPayment.Save(SP);

            return(result);
        }
Пример #14
0
        public JournalDetail Save(JournalDetail JDetails)
        {
            var max = journalDetails.LastRow().OrderByDescending(a => a.Id).FirstOrDefault();

            if (max == null)
            {
                JDetails.Id = 1;
            }
            else
            {
                JDetails.Id = max.Id + 1;
            }
            int value = int.Parse(journalMaster.LastRow().OrderByDescending(p => p.Id).Select(r => r.Id).First().ToString());

            JDetails.JournalMasterId = value;


            var result = journalDetails.Save(JDetails);

            return(result);
        }
Пример #15
0
        public JournalMaster Save(JournalMaster JMaster)
        {
            //    var ledgerDetails = ledgerService.GetById(ledger.LedgerId);
            //    var isExists = service.GetAll().Where(a => a.InvoiceNo == ledger.InvoiceNo && a.LedgerId == ledger.LedgerId).FirstOrDefault();
            var max = journalMaster.LastRow().OrderByDescending(a => a.Id).FirstOrDefault();

            if (max == null)
            {
                JMaster.Id = 1;
            }
            else
            {
                JMaster.Id = max.Id + 1;
            }
            var financialYear = CurrentSession.GetCurrentSession().FinancialYear;

            JMaster.YearId        = CurrentSession.GetCurrentSession().FinancialYear;
            JMaster.VoucherTypeId = 6;
            JMaster.UserId        = CurrentSession.GetCurrentSession().UserId;

            var result = journalMaster.Save(JMaster);

            return(result);
        }
Пример #16
0
 public Employee Save(Employee cus)
 {
     cus.CreationDate = DateTime.Now;
     return(service.Save(cus));
 }
Пример #17
0
        //public FinancialYear GetLatest()
        //{
        //    return service.GetAll().OrderByDescending(a=>a.Id).FirstOrDefault();
        //}

        public FinancialYear Save(FinancialYear cus)
        {
            return(service.Save(cus));
        }
Пример #18
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);
        }
Пример #19
0
 public Picture Save(Picture cus)
 {
     return(service.Save(cus));
 }
Пример #20
0
 public RoleWiseScreenPermission SaveRoleWisePermission(RoleWiseScreenPermission cus)
 {
     return(roleService.Save(cus));
 }
Пример #21
0
 public Size Save(Size cus)
 {
     service.Save(cus);
     return(cus);
 }
Пример #22
0
 public Company Save(Company cus)
 {
     service.Save(cus);
     return(cus);
 }
Пример #23
0
 public User Save(User cus)
 {
     return(service.Save(cus));
 }
Пример #24
0
 public Unit Save(Unit cus)
 {
     return(service.Save(cus));
 }
Пример #25
0
 public PriceSetup SavePrice(PriceSetup cus)
 {
     return(_priceSetupService.Save(cus));
 }
Пример #26
0
 public Customer Save(Customer cus)
 {
     return(service.Save(cus));
 }
Пример #27
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);
            }
        }
Пример #28
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));
        }
Пример #29
0
 public WareHouse Save(WareHouse cus)
 {
     return(service.Save(cus));
 }
Пример #30
0
 public Tax Save(Tax cus)
 {
     return(service.Save(cus));
 }