예제 #1
0
        public PartyBalance Update(PartyBalance t, int id)
        {
            var res = service.Update(t, id);

            if (t != null)
            {
                service.ExecuteNonQuery("Exec BalanceReconcilation " + t.LedgerId + "," + yearId + "");
            }
            return(res);
        }
예제 #2
0
        public AccountGroup Update(AccountGroup t, int id)
        {
            var existing = service.GetById(id);

            if (existing != null)
            {
                existing.AccountGroupName = t.AccountGroupName;
                return(service.Update(existing, id));
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
파일: SalesService.cs 프로젝트: sajidur/erp
        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));
        }
예제 #4
0
파일: LoginService.cs 프로젝트: sajidur/erp
 public RoleWiseScreenPermission UpdateRoleWisePermission(RoleWiseScreenPermission t, int id)
 {
     return(roleService.Update(t, id));
 }
예제 #5
0
 public AccountLedger Update(AccountLedger t, int id)
 {
     return(service.Update(t, id));
 }
예제 #6
0
 public PayHead Update(PayHead t, int id)
 {
     service.Update(t, id);
     return(t);
 }
예제 #7
0
 public Picture Update(Picture t, int id)
 {
     return(service.Update(t, id));
 }
예제 #8
0
 public SalesDelivery Update(SalesDelivery t, int id)
 {
     service.Update(t, id);
     return(t);
 }
예제 #9
0
 public Brand Update(Brand t, int id)
 {
     service.Update(t, id);
     return(t);
 }
예제 #10
0
 public PaymentDetail Update(PaymentDetail t, int id)
 {
     return(_paymentDetails.Update(t, id));
 }
예제 #11
0
 public StockIn Update(StockIn t, int id)
 {
     return(service.Update(t, id));
 }
예제 #12
0
 public LedgerPosting Update(LedgerPosting t, int id)
 {
     return(service.Update(t, id));
 }
예제 #13
0
 public PaymentMaster Update(PaymentMaster t, int id)
 {
     return(_paymentMaster.Update(t, id));
 }
예제 #14
0
 public Tax Update(Tax t, int id)
 {
     return(service.Update(t, id));
 }
예제 #15
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);
        }
예제 #16
0
 public ReceiveMaster Update(ReceiveMaster t, int id)
 {
     service.Update(t, id);
     return(t);
 }
예제 #17
0
 public Size Update(Size t, int id)
 {
     service.Update(t, id);
     return(t);
 }
예제 #18
0
 public Customer Update(Customer t, int id)
 {
     return(service.Update(t, id));
 }
예제 #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));
        }
예제 #20
0
 public BonusDeduction Update(BonusDeduction t, int id)
 {
     service.Update(t, id);
     return(t);
 }
예제 #21
0
파일: UnitService.cs 프로젝트: sajidur/erp
 public Unit Update(Unit t, int id)
 {
     return(service.Update(t, id));
 }
예제 #22
0
 public Employee Update(Employee t, int id)
 {
     return(service.Update(t, id));
 }
예제 #23
0
 public Supplier Update(Supplier t, int id)
 {
     return(service.Update(t, id));
 }
예제 #24
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);
            }
        }
예제 #25
0
 public Category Update(Category t, int id)
 {
     return(service.Update(t, id));
 }
예제 #26
0
 public Department Update(Department t, int id)
 {
     return(service.Update(t, id));
 }
예제 #27
0
 public StockOut Update(StockOut t, int id)
 {
     return(service.Update(t, id));
 }
예제 #28
0
 public Company Update(Company t, int id)
 {
     service.Update(t, id);
     return(t);
 }
예제 #29
0
 public WareHouse Update(WareHouse t, int id)
 {
     return(service.Update(t, id));
 }
예제 #30
0
파일: LoginService.cs 프로젝트: sajidur/erp
 public User Update(User t, int id)
 {
     return(service.Update(t, id));
 }