예제 #1
0
        public ActionResult EmpSalarySave(List <SalaryPayment> salaryPayment, List <LedgerPosting> ledgerPosting)
        {
            foreach (var item in ledgerPosting)
            {
                LedgerPosting ledgersave = new LedgerPosting();
                ledgersave.VoucherTypeId = 6;
                ledgersave.LedgerId      = item.LedgerId;
                ledgersave.Debit         = item.Credit;
                ledgersave.Credit        = 0;
                ledgersave.ChequeNo      = item.ChequeNo;
                ledgersave.ChequeDate    = item.ChequeDate;
                lps.Save(ledgersave);
            }

            foreach (var i in salaryPayment)
            {
                SalaryPayment sp = new SalaryPayment();
                sp.EmployeeId   = i.EmployeeId;
                sp.SalaryAmount = i.SalaryAmount;
                sp.Bonus        = i.TotalAmount - i.SalaryAmount;
                sp.TotalAmount  = i.TotalAmount;
                sp.Date         = i.Date;
                sp.Month        = i.Month;
                salaryPaymentService.Save(sp);
            }

            return(Json("", JsonRequestBehavior.AllowGet));
        }
        public ActionResult AddExpenseJournalSave(string voucherNo, int CostHeadId, DateTime voucherDate, string notes, List <JournalDetail> journalDetails, decimal TotalAmount, string ChkNo)
        {
            JournalMaster jmaster = new JournalMaster();
            JournalDetail jd      = new JournalDetail();

            jmaster.InvoiceNo   = voucherNo;
            jmaster.LadgerDate  = voucherDate;
            jmaster.Narration   = notes;
            jmaster.TotalAmount = TotalAmount;
            journalPostingService.Save(jmaster);

            jd.LedgerId   = CostHeadId;
            jd.Credit     = TotalAmount;
            jd.Credit     = 0;
            jd.ChequeNo   = ChkNo;
            jd.ChequeDate = voucherDate;
            journalPostingService.Save(jd);
            foreach (var item in journalDetails)
            {
                JournalDetail jdetails = new JournalDetail();

                jdetails.LedgerId   = item.LedgerId;
                jdetails.Credit     = 0;
                jdetails.Debit      = item.Credit;
                jdetails.ChequeNo   = "";
                jdetails.ChequeDate = voucherDate;
                journalPostingService.Save(jdetails);
            }

            //credit
            foreach (var item in journalDetails)
            {
                LedgerPosting lposting = new LedgerPosting();
                lposting.Credit        = item.Debit ?? 0 + item.Credit ?? 0;;
                lposting.VoucherNo     = voucherNo;
                lposting.LedgerId      = item.LedgerId;
                lposting.Debit         = 0;
                lposting.PostingDate   = voucherDate;
                lposting.ChequeDate    = DateTime.Now;
                lposting.ChequeNo      = "";
                lposting.VoucherTypeId = 4;
                lposting.Extra1        = "Voucher:" + voucherNo + " " + notes;
                postingService.Save(lposting);
            }
            //debit
            LedgerPosting posting = new LedgerPosting();

            posting.ChequeDate    = DateTime.Now;
            posting.VoucherNo     = voucherNo;
            posting.ChequeNo      = "";
            posting.VoucherTypeId = 4;
            posting.LedgerId      = CostHeadId;
            posting.PostingDate   = voucherDate;
            posting.Credit        = 0;
            posting.Debit         = TotalAmount;
            posting.Extra1        = "Voucher:" + voucherNo + " " + notes;
            postingService.Save(posting);

            return(Json("", JsonRequestBehavior.AllowGet));
        }
 public ActionResult JournalSave(string voucherNo, DateTime voucherDate, string notes, List <LedgerPosting> ledgerPostion)
 {
     foreach (var item in ledgerPostion)
     {
         LedgerPosting ledgersave = new LedgerPosting();
         ledgersave.VoucherTypeId = 6;
         ledgersave.VoucherNo     = voucherNo;
         ledgersave.LedgerId      = item.LedgerId;
         int a = ledgersave.LedgerId ?? 0;
         if (a == 1 || a == 2 || a == 4 || a == 7 || a == 8 || a == 11 || a == 15 || a == 17 || a == 21 || a == 23)
         {
             ledgersave.Debit  = item.Credit;
             ledgersave.Credit = 0;
         }
         else
         {
             ledgersave.Credit = item.Credit;
             ledgersave.Debit  = 0;
         }
         ledgersave.InvoiceNo  = voucherNo;
         ledgersave.ChequeNo   = item.ChequeNo;
         ledgersave.ChequeDate = item.ChequeDate;
         postingService.Save(ledgersave);
     }
     return(Json("", JsonRequestBehavior.AllowGet));
 }
예제 #4
0
 public async Task <UpsertBaseLedgerPostingResponse> UpsertBaseLedgerPostingAsync(UpsertBaseLedgerPostingRequest request)
 {
     return(await Task.Run(() =>
     {
         UpsertBaseLedgerPostingResponse _response = new UpsertBaseLedgerPostingResponse();
         using (AsyncAutomateAccountingEntities _dbContext = new AsyncAutomateAccountingEntities())
         {
             if (request.BaseObject != null)
             {
                 try
                 {
                     LedgerPosting _ledgerPosting = request.BaseObject.ToLedgerPosting();
                     UpsertEntity <LedgerPosting>(request.BaseObject.Id, ref _ledgerPosting, _dbContext);
                     _response.BaseObject = _ledgerPosting.ToBaseLedgerPosting();
                 }
                 catch (Exception ex) { AssignStatusData(_response, false, string.Format("Some error occurred during DB interaction. Message is something like : \n{0}", ex.Message)); }
             }
             else
             {
                 AssignStatusData(_response, false, "No entity data recieved to insert/update.");
             }
         }
         return _response;
     }));
 }
예제 #5
0
        public ActionResult Create(AccountLedger category)
        {
            var result = category;

            if (ModelState.IsValid)
            {
                category.IsDefault = false;
                result             = service.Save(category);
                if (result != null && result.Id > 0)
                {
                    LedgerPosting post = new LedgerPosting();
                    post.InvoiceNo   = "";
                    post.LedgerId    = result.Id;
                    post.PostingDate = DateTime.Now;
                    if (category.CrOrDr == "Cr")
                    {
                        post.Credit = category.OpeningBalance;
                    }
                    if (category.CrOrDr == "Dr")
                    {
                        post.Debit = category.OpeningBalance;
                    }
                    post.VoucherTypeId = 1;
                    post.VoucherNo     = category.Id.ToString();
                    post.InvoiceNo     = category.Id.ToString();

                    var postingResult = postingService.Save(post);
                }
            }
            return(Json("Sucess", JsonRequestBehavior.AllowGet));
        }
예제 #6
0
        public ActionResult LocalPaymentSave(decimal TotalAmount, List <PartyBalance> partyBalanceList, List <LedgerPosting> ledgerPostingList)
        {
            decimal a, b;

            foreach (var item in partyBalanceList)
            {
                PartyBalance pb = new PartyBalance();
                pb.PostingDate   = item.PostingDate;
                pb.LedgerId      = item.LedgerId;
                pb.VoucherTypeId = 13;
                pb.InvoiceNo     = item.InvoiceNo;
                a         = item.Debit ?? 0;
                b         = item.Credit ?? 0;
                pb.Debit  = a + b;
                pb.Credit = item.Balance;
                partyBalanceService.Save(pb);
            }

            foreach (var li in ledgerPostingList)
            {
                LedgerPosting lp = new LedgerPosting();
                lp.VoucherNo     = li.VoucherNo;
                lp.PostingDate   = li.ChequeDate;
                lp.VoucherTypeId = 13;
                lp.LedgerId      = li.LedgerId;
                lp.Debit         = li.Credit;
                lp.InvoiceNo     = "";
                lp.ChequeNo      = li.ChequeNo;
                lp.ChequeDate    = li.ChequeDate;
                postingService.Save(lp);
            }
            return(Json("", JsonRequestBehavior.AllowGet));
        }
예제 #7
0
 public ActionResult LocalPayment(List <LocalMarketPayment> payments, LedgerPosting ledger)
 {
     foreach (var item in payments)
     {
     }
     return(Json("", JsonRequestBehavior.AllowGet));
 }
예제 #8
0
        public LedgerPosting Save(LedgerPosting ledger)
        {
            var ledgerDetails = ledgerService.GetById(ledger.LedgerId);
            // var isExists = service.GetAll().Where(a => a.InvoiceNo == ledger.InvoiceNo && a.LedgerId == ledger.LedgerId).FirstOrDefault();
            var max = service.LastRow().OrderByDescending(a => a.Id).FirstOrDefault();

            if (max == null)
            {
                ledger.Id = 1;
            }
            else
            {
                ledger.Id = max.Id + 1;
            }

            if (ledger.VoucherNo == null)
            {
                ledger.VoucherNo = max.VoucherNo + 1;
            }
            ledger.YearId   = CurrentSession.GetCurrentSession().FinancialYear;
            ledger.IsActive = true;
            var result = service.Save(ledger);

            return(result);
        }
        public SalesMaster SaveSalesMaster(SalesMaster salesMaster)
        {
            var result = serviceSalesMaster.Save(salesMaster);

            if (result != null || result.Id > 0)
            {
                foreach (var item in salesMaster.SalesDetails)
                {
                    var existingItem = inventory.GetAll(a => a.ProductId == item.ProductId && a.IsActive == true && a.QtyInBale == item.BaleQty).ToList();
                    if (existingItem.Count > 0)
                    {
                        foreach (var inv in existingItem)
                        {
                            inv.UpdatedDate = DateTime.Now;
                            inv.UpdatedBy   = "";
                            inv.BalanceQty  = inv.BalanceQty - item.BaleQty;
                            inventory.Update(inv, inv.Id);
                        }
                    }
                }
                // Ledger Saves
                var ledgerObj = new LedgerPosting();
                ledgerObj.YearId        = 1;
                ledgerObj.VoucherTypeId = 14;
                ledgerObj.VoucherNo     = result.SalesInvoice;
                ledgerObj.PostingDate   = result.SalesDate;
                ledgerObj.LedgerId      = 3;
                ledgerObj.InvoiceNo     = result.SalesInvoice;
                ledgerObj.Credit        = result.TotalAmount;
                ledgerObj.Debit         = result.TotalAmount;
                var save = ledgerService.Save(ledgerObj);
            }
            return(result);
        }
        public ActionResult AddContraSave(string voucherNo, int CostHeadId, DateTime voucherDate, string notes, List <LedgerPosting> ledgerPostion, string CostChkNo, decimal TotalAmount, string Radio)
        {
            if (Radio == "Debit")
            {
                LedgerPosting lp = new LedgerPosting();
                lp.VoucherNo     = voucherNo;
                lp.VoucherTypeId = 6;
                lp.LedgerId      = CostHeadId;
                lp.Debit         = TotalAmount;
                lp.Credit        = 0;
                lp.InvoiceNo     = voucherNo;
                lp.ChequeNo      = CostChkNo;
                lp.ChequeDate    = voucherDate;
                postingService.Save(lp);
                foreach (var item in ledgerPostion)
                {
                    LedgerPosting ledgersave = new LedgerPosting();
                    ledgersave.VoucherTypeId = 6;
                    ledgersave.VoucherNo     = voucherNo;
                    ledgersave.LedgerId      = item.LedgerId;
                    ledgersave.Debit         = 0;
                    ledgersave.Credit        = item.Credit;
                    ledgersave.InvoiceNo     = voucherNo;
                    ledgersave.ChequeNo      = "";
                    ledgersave.ChequeDate    = item.ChequeDate;
                    postingService.Save(ledgersave);
                }
            }
            else
            {
                LedgerPosting lp = new LedgerPosting();
                lp.VoucherNo     = voucherNo;
                lp.VoucherTypeId = 6;
                lp.LedgerId      = CostHeadId;
                lp.Debit         = TotalAmount;
                lp.Credit        = 0;
                lp.InvoiceNo     = voucherNo;
                lp.ChequeNo      = "";
                lp.ChequeDate    = voucherDate;
                postingService.Save(lp);
                foreach (var item in ledgerPostion)
                {
                    LedgerPosting ledgersave = new LedgerPosting();
                    ledgersave.VoucherTypeId = 6;
                    ledgersave.VoucherNo     = voucherNo;
                    ledgersave.LedgerId      = item.LedgerId;
                    ledgersave.Debit         = 0;
                    ledgersave.Credit        = item.Credit;
                    ledgersave.InvoiceNo     = voucherNo;
                    ledgersave.ChequeNo      = item.ChequeNo;
                    ledgersave.ChequeDate    = item.ChequeDate;
                    postingService.Save(ledgersave);
                }
            }

            return(Json("", JsonRequestBehavior.AllowGet));
        }
예제 #11
0
        public ActionResult PaymentDelete(int id)
        {
            ActionResult actionResult;

            try
            {
                LedgerPosting postingObj = this.postingService.GetById(new int?(id));
                foreach (LedgerPosting item in this.postingService.GetAll(postingObj.VoucherNo, true))
                {
                    item.IsActive = false;
                    this.postingService.Update(item, item.Id);
                }
                PartyBalanceService partyBalanceService = this.partyBalanceService;
                int?         ledgerId   = postingObj.LedgerId;
                PartyBalance paymentObj = partyBalanceService.GetByVoucher((ledgerId.HasValue ? ledgerId.GetValueOrDefault() : 0), postingObj.VoucherNo);
                this.partyBalanceService.Delete(paymentObj.PartyBalanceId);
                AccountLedger   customer        = this.accledgerService.GetById(postingObj.LedgerId);
                CustomerService customerService = new CustomerService();
                ledgerId = postingObj.LedgerId;
                rptIndividualLedger_Result due = customerService.GetBalance((ledgerId.HasValue ? ledgerId.GetValueOrDefault() : 0));
                string  balanceText            = "";
                decimal?balance = due.Balance;
                decimal num     = new decimal();
                if ((balance.GetValueOrDefault() < num ? !balance.HasValue : true))
                {
                    balance     = due.Balance;
                    balanceText = string.Concat("Balance with Dada Rice Tk=", string.Format("{0:#,#.}", decimal.Round((balance.HasValue ? balance.GetValueOrDefault() : decimal.Zero)), ""), "=");
                }
                else
                {
                    decimal minusOne = decimal.MinusOne;
                    balance     = due.Balance;
                    balanceText = string.Concat("Balance with Dada Rice Tk=", string.Format("{0:#,#.}", minusOne * decimal.Round((balance.HasValue ? balance.GetValueOrDefault() : decimal.Zero)), ""), "=");
                }
                var isSendSMS = false;
                if (isSendSMS)
                {
                    SMSEmailService sMSEmailService = new SMSEmailService();
                    string[]        ledgerName      = new string[] { "Dear ", customer.LedgerName, ",Tk=", null, null, null, null, null, null };
                    balance       = postingObj.Credit;
                    ledgerName[3] = string.Format("{0:#,#.}", decimal.Round((balance.HasValue ? balance.GetValueOrDefault() : decimal.Zero)), "");
                    ledgerName[4] = " payment was wrong posted. Your Ref No:";
                    ledgerName[5] = postingObj.VoucherNo;
                    ledgerName[6] = " has been deleted,";
                    ledgerName[7] = balanceText;
                    ledgerName[8] = " Dada Rice.";
                    sMSEmailService.SendOneToOneSingleSms("01739110321", string.Concat(ledgerName));
                }
                actionResult = base.Json("Sucess", 0);
            }
            catch (Exception exception)
            {
                actionResult = base.Json(exception.Message, 0);
            }
            return(actionResult);
        }
예제 #12
0
        public ActionResult JournalSave(string voucherNo, DateTime voucherDate, string notes, List <JournalRequest> ledgerPosting)
        {
            string invoiceNumber = DateTime.Now.Year +
                                   new GlobalClass().GetMaxId("Id", "LedgerPosting");

            voucherNo = "JV" + invoiceNumber;
            JournalMaster jmaster = new JournalMaster();

            jmaster.InvoiceNo   = voucherNo;
            jmaster.VoucherNo   = voucherNo;
            jmaster.LadgerDate  = voucherDate;
            jmaster.Narration   = notes;
            jmaster.TotalAmount = ledgerPosting.Where(a => a.DrOrCr == "Dr").Sum(a => a.Amount);
            journalPostingService.Save(jmaster);

            foreach (var item in ledgerPosting)
            {
                JournalDetail jdetails = new JournalDetail();

                jdetails.LedgerId = item.LedgerId;
                jdetails.ChequeNo = item.ChequeNo;

                //ledger posting
                LedgerPosting ledgersave = new LedgerPosting();
                ledgersave.VoucherTypeId = (int)BAL.VoucherTypeEnum.JournalVoucher;
                ledgersave.VoucherNo     = voucherNo;
                ledgersave.InvoiceNo     = voucherNo;
                ledgersave.Extra1        = notes;
                ledgersave.LedgerId      = item.LedgerId;
                int a = ledgersave.LedgerId ?? 0;
                if (item.DrOrCr == "Dr")
                {
                    ledgersave.Debit  = item.Amount;
                    ledgersave.Credit = 0;
                    jdetails.Debit    = item.Amount;
                }
                else
                {
                    ledgersave.Credit = item.Amount;
                    ledgersave.Debit  = 0;
                    jdetails.Credit   = item.Amount;
                }
                ledgersave.InvoiceNo   = voucherNo;
                ledgersave.ChequeNo    = item.ChequeNo;
                ledgersave.PostingDate = Convert.ToDateTime(voucherDate);
                if (!string.IsNullOrEmpty(item.ChequeDate))
                {
                    ledgersave.ChequeDate = Convert.ToDateTime(item.ChequeDate);
                    jdetails.ChequeDate   = Convert.ToDateTime(item.ChequeDate);
                }
                postingService.Save(ledgersave);
                journalPostingService.Save(jdetails);
            }
            return(Json("", JsonRequestBehavior.AllowGet));
        }
예제 #13
0
        public LedgerPosting Save(LedgerPosting cus)
        {
            var isExists = service.GetAll().Where(a => a.InvoiceNo == cus.InvoiceNo && a.LedgerId == cus.LedgerId).FirstOrDefault();

            if (isExists != null)
            {
                return(null);
            }
            service.Save(cus);
            return(cus);
        }
예제 #14
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;
            service.Save(cus);
            return(cus);
        }
        public ReceiveMaster Save(ReceiveMaster cus, int wareHouseId, int goodsType)
        {
            var result = service.Save(cus);

            if (result != null || result.Id > 0)
            {
                foreach (var item in cus.ReceiveDetails)
                {
                    var existingItem = inventory.GetAll(a => a.ProductId == item.ProductId && a.IsActive == true && a.WarehouseId == wareHouseId && a.SupplierId == cus.SupplierID && a.QtyInBale == item.QtyInBale).ToList();
                    if (existingItem.Count > 0)
                    {
                        foreach (var inv in existingItem)
                        {
                            inv.UpdatedDate = DateTime.Now;
                            inv.UpdatedBy   = "";
                            inv.BalanceQty  = inv.BalanceQty + item.TotalBale;
                            inv.ReceiveQty  = inv.ReceiveQty + item.QtyInBale;
                            inventory.Update(inv, inv.Id);
                        }
                    }
                    else
                    {
                        Inventory inv = new Inventory();
                        inv.IsActive    = true;
                        inv.ProductId   = item.ProductId;
                        inv.ReceiveQty  = item.TotalBale;
                        inv.QtyInBale   = item.QtyInBale;
                        inv.SupplierId  = cus.SupplierID;
                        inv.WarehouseId = wareHouseId;
                        inv.OpeningQty  = 0;
                        inv.BalanceQty  = item.TotalBale;
                        inv.GoodsType   = goodsType.ToString();
                        inventory.Save(inv);
                    }
                }
                // Ledger Saves
                var ledgerObj = new LedgerPosting();
                ledgerObj.YearId        = 1;
                ledgerObj.VoucherTypeId = 14;
                ledgerObj.VoucherNo     = result.InvoiceNoPaper;
                ledgerObj.PostingDate   = cus.InvoiceDate;
                ledgerObj.LedgerId      = 2;
                ledgerObj.InvoiceNo     = cus.InvoiceNo;
                ledgerObj.Credit        = cus.TotalAmount;
                ledgerObj.Debit         = cus.TotalAmount;
                var save = ledgerService.Save(ledgerObj);
            }
            return(cus);
        }
예제 #16
0
        public static BaseLedgerPostingModel ToBaseLedgerPosting(this LedgerPosting ledgerPosting)
        {
            BaseLedgerPostingModel _result = new BaseLedgerPostingModel();

            _result.Id              = ledgerPosting.Id;
            _result.Date            = ledgerPosting.Date;
            _result.VoucherTypeId   = ledgerPosting.VoucherTypeId;
            _result.VoucherNumber   = ledgerPosting.VoucherNumber;
            _result.LedgerId        = ledgerPosting.LedgerId;
            _result.Debit           = ledgerPosting.Debit;
            _result.Credit          = ledgerPosting.Credit;
            _result.DetailsId       = ledgerPosting.DetailsId;
            _result.FinancialYearId = ledgerPosting.FinancialYearId;
            _result.InvoiceNumber   = ledgerPosting.InvoiceNumber;
            _result.Text            = ledgerPosting.Text;
            _result.ChequeNumber    = ledgerPosting.ChequeNumber;
            _result.ChequeDate      = ledgerPosting.ChequeDate;
            _result.CreatedDate     = ledgerPosting.CreatedDate;
            _result.ModifiedDate    = ledgerPosting.ModifiedDate;
            return(_result);
        }
        public static LedgerPosting ToLedgerPosting(this BaseLedgerPostingModel ledgerPosting)
        {
            LedgerPosting _result = new LedgerPosting();

            if (ledgerPosting.Id.HasValue)
            {
                _result.Id = ledgerPosting.Id.GetValueOrDefault();
            }
            _result.Date            = ledgerPosting.Date;
            _result.VoucherTypeId   = ledgerPosting.VoucherTypeId;
            _result.LedgerId        = ledgerPosting.LedgerId;
            _result.Debit           = ledgerPosting.Debit;
            _result.Credit          = ledgerPosting.Credit;
            _result.DetailsId       = ledgerPosting.DetailsId;
            _result.FinancialYearId = ledgerPosting.FinancialYearId;
            _result.InvoiceNumber   = ledgerPosting.InvoiceNumber;
            _result.Text            = ledgerPosting.Text;
            _result.ChequeNumber    = ledgerPosting.ChequeNumber;
            _result.ChequeDate      = ledgerPosting.ChequeDate;

            return(_result);
        }
예제 #18
0
 public LedgerPosting Update(LedgerPosting t, int id)
 {
     return(service.Update(t, id));
 }
예제 #19
0
파일: SalesService.cs 프로젝트: sajidur/erp
        public SalesMaster SaveSalesMaster(SalesMaster salesMaster)
        {
            salesMaster.YearId     = yearId;
            salesMaster.IsLastYear = true;
            SalesMaster result = this.serviceSalesMaster.Save(salesMaster);

            if ((result != null ? true : result.Id > 0))
            {
                //foreach (SalesDetail salesDetail in salesMaster.SalesDetails)
                //{

                //}
                Customer      customer  = this.customerService.GetById(new int?(salesMaster.CustomerID));
                LedgerPosting ledgerObj = new LedgerPosting()
                {
                    VoucherTypeId = new int?(19),
                    VoucherNo     = result.SalesInvoice,
                    PostingDate   = salesMaster.SalesDate,
                    LedgerId      = (int)DefaultLedger.SalesAccount,
                    InvoiceNo     = result.SalesInvoice,
                    Credit        = new decimal?(result.GrandTotal)
                };
                decimal num = new decimal();
                ledgerObj.Debit = new decimal?(num);
                this.ledgerService.Save(ledgerObj);
                LedgerPosting detailsLedger = new LedgerPosting()
                {
                    VoucherTypeId = (int)VoucherTypeEnum.SalesInvoice,
                    VoucherNo     = result.SalesInvoice,
                    PostingDate   = salesMaster.SalesDate,
                    LedgerId      = customer.LedgerId,
                    InvoiceNo     = result.SalesInvoice
                };
                num = new decimal();
                detailsLedger.Credit = new decimal?(num);
                detailsLedger.Debit  = new decimal?(salesMaster.GrandTotal - salesMaster.Discount);
                this.ledgerService.Save(detailsLedger);
                if (salesMaster.Discount > 0)
                {
                    LedgerPosting detailsLedgerDiscount = new LedgerPosting()
                    {
                        VoucherTypeId = (int)VoucherTypeEnum.SalesInvoice,
                        VoucherNo     = result.SalesInvoice,
                        PostingDate   = salesMaster.SalesDate,
                        LedgerId      = customer.LedgerId,
                        InvoiceNo     = result.SalesInvoice
                    };
                    num = new decimal();
                    detailsLedger.Credit = new decimal?(num);
                    detailsLedger.Debit  = new decimal?(salesMaster.Discount);
                    this.ledgerService.Save(detailsLedgerDiscount);
                }
                PartyBalance balance = new PartyBalance()
                {
                    AgainstInvoiceNo     = result.SalesInvoice,
                    AgainstVoucherNo     = result.SalesInvoice,
                    AgainstVoucherTypeId = new int?(19),
                    VoucherNo            = result.SalesInvoice,
                    PostingDate          = salesMaster.SalesDate
                };
                PartyBalance partyBalance = balance;
                int?         ledgerId     = customer.LedgerId;
                partyBalance.LedgerId = (ledgerId.HasValue ? ledgerId.GetValueOrDefault() : 0);
                balance.InvoiceNo     = result.SalesInvoice;
                balance.Debit         = new decimal?(salesMaster.GrandTotal - salesMaster.Discount);
                num                   = new decimal();
                balance.Credit        = new decimal?(num);
                balance.VoucherTypeId = (int)VoucherTypeEnum.SalesInvoice;
                balance.extra1        = string.Concat("Sales Invoice: ", salesMaster.SalesInvoice, " Challan:", salesMaster.Coutha);
                balance.extra2        = result.Id.ToString();
                this.partyBalanceService.Save(balance);
            }
            return(result);
        }
예제 #20
0
        public SalesMaster SaveSalesMaster(SalesMaster salesMaster)
        {
            salesMaster.YearId = yearId;
            SalesMaster result = this.serviceSalesMaster.Save(salesMaster);

            if ((result != null ? true : result.Id > 0))
            {
                foreach (SalesDetail salesDetail in salesMaster.SalesDetails)
                {
                    List <Inventory> existingItem = this.inventory.GetAll((Inventory a) => a.ProductId == salesDetail.ProductId && a.IsActive && a.WarehouseId == salesDetail.WarehouseId).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);
                        }
                    }
                }
                Customer      customer  = this.customerService.GetById(new int?(salesMaster.CustomerID));
                LedgerPosting ledgerObj = new LedgerPosting()
                {
                    VoucherTypeId = new int?(19),
                    VoucherNo     = result.SalesInvoice,
                    PostingDate   = salesMaster.SalesDate,
                    LedgerId      = new int?(10),
                    InvoiceNo     = result.SalesInvoice,
                    Credit        = new decimal?(result.GrandTotal)
                };
                decimal num = new decimal();
                ledgerObj.Debit = new decimal?(num);
                this.ledgerService.Save(ledgerObj);
                LedgerPosting detailsLedger = new LedgerPosting()
                {
                    VoucherTypeId = new int?(19),
                    VoucherNo     = result.SalesInvoice,
                    PostingDate   = salesMaster.SalesDate,
                    LedgerId      = customer.LedgerId,
                    InvoiceNo     = result.SalesInvoice
                };
                num = new decimal();
                detailsLedger.Credit = new decimal?(num);
                detailsLedger.Debit  = new decimal?(salesMaster.GrandTotal);
                this.ledgerService.Save(detailsLedger);
                PartyBalance balance = new PartyBalance()
                {
                    AgainstInvoiceNo     = result.SalesInvoice,
                    AgainstVoucherNo     = result.SalesInvoice,
                    AgainstVoucherTypeId = new int?(19),
                    VoucherNo            = result.SalesInvoice,
                    PostingDate          = salesMaster.SalesDate
                };
                PartyBalance partyBalance = balance;
                int?         ledgerId     = customer.LedgerId;
                partyBalance.LedgerId = (ledgerId.HasValue ? ledgerId.GetValueOrDefault() : 0);
                balance.InvoiceNo     = result.SalesInvoice;
                balance.Debit         = new decimal?(salesMaster.GrandTotal);
                num                   = new decimal();
                balance.Credit        = new decimal?(num);
                balance.VoucherTypeId = 19;
                balance.extra1        = string.Concat("Sales Invoice: ", salesMaster.SalesInvoice, " Challan:", salesMaster.Coutha);
                balance.extra2        = result.Id.ToString();
                this.partyBalanceService.Save(balance);
            }
            return(result);
        }
예제 #21
0
        public ActionResult ReceivePayment(string voucherNo, int supplierId, DateTime voucherDate, string notes, List <LedgerPosting> ledgerPosting, bool isSendSMS)
        {
            decimal?credit;
            var     supplierInfo = supplierService.GetById(supplierId);

            if (supplierInfo == null)
            {
                return(Json("error", JsonRequestBehavior.AllowGet));
            }
            //credit
            foreach (var item in ledgerPosting)
            {
                item.Credit        = 0;
                item.VoucherNo     = voucherNo;
                item.PostingDate   = voucherDate;
                item.ChequeDate    = DateTime.Now;
                item.ChequeNo      = "";
                item.VoucherTypeId = (int)BAL.VoucherType.PaymentVoucher;
                item.Extra1        = "Voucher:" + voucherNo + " " + notes;
                postingService.Save(item);
            }
            //debit
            LedgerPosting posting = new LedgerPosting();

            posting.ChequeDate    = DateTime.Now;
            posting.VoucherNo     = voucherNo;
            posting.ChequeNo      = "";
            posting.VoucherTypeId = (int)BAL.VoucherType.PaymentVoucher;
            posting.LedgerId      = supplierInfo.LedgerId;
            posting.PostingDate   = voucherDate;
            posting.Credit        = ledgerPosting.Sum(a => a.Debit).Value;
            posting.Debit         = 0;
            posting.Extra1        = "Voucher:" + voucherNo + " " + notes;
            postingService.Save(posting);
            //balance
            //party balance
            PartyBalance balance = new PartyBalance();

            balance.AgainstVoucherTypeId = 4;
            balance.VoucherNo            = voucherNo;
            balance.PostingDate          = voucherDate;
            balance.LedgerId             = supplierInfo.LedgerId ?? 0;
            balance.Debit         = posting.Credit;
            balance.Credit        = 0;
            balance.VoucherTypeId = (int)BAL.VoucherType.PaymentVoucher;
            balance.extra1        = "Payment Invoice: " + voucherNo + " Notes:" + notes;
            balance.extra2        = posting.Id.ToString();

            partyBalanceService.Save(balance);

            if (isSendSMS)
            {
                SMSEmailService            sMSEmailService = new SMSEmailService();
                string                     phone           = supplierInfo.Phone;
                rptIndividualLedger_Result due             = customerService.GetBalance((supplierInfo.LedgerId ?? 0));

                string balanceText = "";
                credit = due.Balance;
                var num = new decimal();
                if ((credit.GetValueOrDefault() < num ? !credit.HasValue : true))
                {
                    credit      = due.Balance;
                    balanceText = string.Concat("Your Present Balance With Dada Rice Tk=", string.Format("{0:#,#.}", decimal.Round((credit.HasValue ? credit.GetValueOrDefault() : decimal.Zero)), ""), "/=.");
                }
                else
                {
                    decimal minusOne = decimal.MinusOne;
                    credit      = due.Balance;
                    balanceText = string.Concat("Your Present Balance With Dada Rice Tk=", string.Format("{0:#,#.}", minusOne * decimal.Round((credit.HasValue ? credit.GetValueOrDefault() : decimal.Zero)), ""), "/= Thanks.");
                }
                balanceText = "";
                string[] name = new string[] { "Dear ", supplierInfo.Name, " Tk=", null, null, null };
                credit  = balance.Credit;
                name[3] = string.Format("{0:#,#.}", decimal.Round((posting.Credit.HasValue ? posting.Credit.GetValueOrDefault() : decimal.Zero)), "");
                name[4] = "/- has been Deposited to your Account. Ref:No-" + voucherNo + ", Dated:" + voucherDate.ToString("dd-MM-yyyy") + ". Thanks with Dada Rice";
                sMSEmailService.SendOneToOneSingleSms("01979110321", string.Concat(string.Concat(name), balanceText), false);
            }
            return(Json("", JsonRequestBehavior.AllowGet));
        }
예제 #22
0
        public ActionResult Create(Customer customer, decimal OpeningBalance, string CrOrDr, int create)
        {
            var result = customer;

            if (ModelState.IsValid)
            {
                var sesssion = CurrentSession.GetCurrentSession();
                if (sesssion != null)
                {
                }
                var lastId = db.LastId();
                if (string.IsNullOrEmpty(customer.Area))
                {
                    return(Json(new { Id = 2, message = "Area Empty" }, JsonRequestBehavior.AllowGet));
                }
                customer.Code        = customer.District.Substring(0, 2).ToUpper() + "_" + customer.Area.Substring(0, 2).ToUpper() + "_" + db.LastId();
                customer.CreatedDate = DateTime.Now;
                customer.UpdatedDate = DateTime.Now;
                customer.CreatedBy   = CurrentSession.GetCurrentSession().UserName;
                customer.IsActive    = true;
                AccountLedger ledger       = new AccountLedger();
                var           accountGroup = new AccountGroupService().GetById(26); //sundry debitor
                ledger.AccountGroupId    = 26;
                ledger.Address           = customer.Address;
                ledger.BankAccountNumber = "";
                ledger.BillByBill        = true;
                ledger.BranchCode        = "";
                ledger.BranchName        = "";
                ledger.CreditLimit       = 0.0m;
                ledger.CreditPeriod      = 1;
                ledger.CrOrDr            = Accounts.CheckDrOrCr(accountGroup.Nature);
                ledger.Email             = customer.Email;
                ledger.IsDefault         = false;
                ledger.LedgerName        = customer.Name;
                ledger.Extra2            = customer.Code;
                ledger.Mobile            = customer.ContactPersonPhone;
                ledger.Phone             = customer.Phone;
                ledger.OpeningBalance    = OpeningBalance;
                var saved = Accounts.Save(ledger);
                customer.LedgerId = saved.Id;
                result            = db.Save(customer);
                if (ledger.OpeningBalance > 0.0m)
                {
                    var           party = new PartyBalance();
                    LedgerPosting post  = new LedgerPosting();
                    post.InvoiceNo   = "";
                    post.LedgerId    = customer.LedgerId;
                    post.PostingDate = DateTime.Now;
                    if (CrOrDr == "Cr")
                    {
                        post.Credit  = ledger.OpeningBalance;
                        party.Credit = ledger.OpeningBalance;
                    }
                    if (CrOrDr == "Dr")
                    {
                        party.Debit = ledger.OpeningBalance;
                        post.Debit  = ledger.OpeningBalance;
                    }
                    post.VoucherTypeId = 1;
                    post.VoucherNo     = ledger.Id.ToString();
                    post.InvoiceNo     = ledger.Id.ToString();
                    var postingResult = postingService.Save(post);

                    party.AgainstInvoiceNo = postingResult.Id.ToString();
                    party.LedgerId         = customer.LedgerId ?? 0;
                    party.CreditPeriod     = 60;
                    party.FinancialYearId  = CurrentSession.GetCurrentSession().FinancialYear;
                    party.PostingDate      = DateTime.Now;
                    party.VoucherTypeId    = 1;
                    party.extra1           = "Opening Balance";
                    partyBalanceService.Save(party);
                }
            }

            return(Json(new { Id = 1, message = "Customer Saved Sucess" }, JsonRequestBehavior.AllowGet));
        }
예제 #23
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 = inventory.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;
                            inventory.Update(inv, inv.Id);
                        }
                    }
                }
                var supplier = supplierService.GetById(master.SupplierID);

                // 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);
            }
        }
예제 #24
0
        public ReceiveMaster Save(ReceiveMaster cus, int wareHouseId, int goodsType)
        {
            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 product = productService.GetById(item.ProductId);
                    if (product != null)
                    {
                        goodsType = product.ProductTypeId ?? 1;
                    }
                    var existingItem = inventory.GetAll(a => a.ProductId == item.ProductId && a.IsActive == true && a.WarehouseId == 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;
                            inventory.Update(inv, inv.Id);
                        }
                    }
                    else
                    {
                        Inventory inv = new Inventory();
                        inv.IsActive    = true;
                        inv.ProductId   = item.ProductId;
                        inv.ReceiveQty  = item.Qty;
                        inv.QtyInBale   = 0;
                        inv.SupplierId  = cus.SupplierID;
                        inv.WarehouseId = wareHouseId;
                        inv.OpeningQty  = 0;
                        inv.BalanceQty  = item.Qty;
                        inv.GoodsType   = goodsType.ToString();
                        inventory.Save(inv);
                    }
                }
                // Ledger posting debit to purchase account

                var ledgerObj = new LedgerPosting();
                ledgerObj.VoucherTypeId = (int)VoucherType.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;
                var save = ledgerService.Save(ledgerObj);

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

                var party = new PartyBalance();
                party.InvoiceNo       = result.InvoiceNo;
                party.LedgerId        = supplier.LedgerId ?? 0;
                party.Credit          = cus.GrandTotal;
                party.CreditPeriod    = 60;
                party.Debit           = 0;
                party.FinancialYearId = CurrentSession.GetCurrentSession().FinancialYear;
                party.PostingDate     = cus.InvoiceDate;
                party.VoucherTypeId   = (int)VoucherType.PurchaseInvoice;
                party.VoucherNo       = result.InvoiceNo;
                party.extra1          = "Purchase Invoice: " + cus.InvoiceNo + " Coutha:" + cus.InvoiceNoPaper;
                partyBalanceService.Save(party);
            }
            return(cus);
        }
예제 #25
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);
        }
예제 #26
0
        public ActionResult Create(Supplier supplier, decimal OpeningBalance, string CrOrDr, int create)
        {
            try
            {
                var result = supplier;
                if (ModelState.IsValid)
                {
                    supplier.CreationDate = DateTime.Now;
                    supplier.UpdateDate   = DateTime.Now;
                    supplier.Creator      = CurrentSession.GetCurrentSession().UserName;
                    supplier.IsActive     = true;
                    AccountLedger ledger = new AccountLedger();

                    var accountGroup = new AccountGroupService().GetById(22); //sundry creditor
                    ledger.AccountGroupId    = 22;
                    ledger.Address           = supplier.Address;
                    ledger.BankAccountNumber = "";
                    ledger.BillByBill        = true;
                    ledger.BranchCode        = "";
                    ledger.BranchName        = "";
                    ledger.CreditLimit       = 0.0m;
                    ledger.CreditPeriod      = 1;
                    ledger.CrOrDr            = Accounts.CheckDrOrCr(accountGroup.Nature);
                    ledger.Email             = supplier.Email;
                    ledger.IsDefault         = false;
                    ledger.LedgerName        = supplier.Name;
                    ledger.Extra2            = supplier.Code;
                    ledger.Mobile            = supplier.ContactPersonPhone;
                    ledger.Phone             = supplier.Phone;
                    ledger.OpeningBalance    = OpeningBalance;
                    var saved = Accounts.Save(ledger);
                    supplier.LedgerId = saved.Id;
                    result            = db.Save(supplier);
                    if (ledger.OpeningBalance > 0.0m)
                    {
                        var           party = new PartyBalance();
                        LedgerPosting post  = new LedgerPosting();
                        post.InvoiceNo   = "";
                        post.LedgerId    = supplier.LedgerId;
                        post.PostingDate = DateTime.Now;
                        if (CrOrDr == "Cr")
                        {
                            post.Credit  = ledger.OpeningBalance;
                            party.Credit = ledger.OpeningBalance;
                        }
                        if (CrOrDr == "Dr")
                        {
                            party.Debit = ledger.OpeningBalance;
                            post.Debit  = ledger.OpeningBalance;
                        }
                        post.VoucherTypeId = 1;
                        post.VoucherNo     = ledger.Id.ToString();
                        post.InvoiceNo     = ledger.Id.ToString();
                        var postingResult = postingService.Save(post);

                        party.AgainstInvoiceNo = postingResult.Id.ToString();
                        party.LedgerId         = supplier.LedgerId ?? 0;
                        party.CreditPeriod     = 60;
                        party.FinancialYearId  = CurrentSession.GetCurrentSession().FinancialYear;
                        party.PostingDate      = DateTime.Now;
                        party.VoucherTypeId    = 1;
                        party.extra1           = "Opening Balance";
                        partyBalanceService.Save(party);
                    }
                }
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex, JsonRequestBehavior.AllowGet));
            }
        }
예제 #27
0
        public ActionResult ReceivePayment(string voucherNo, int supplierId, DateTime voucherDate, string notes, List <LedgerPosting> ledgerPosting, bool isSendSMS)
        {
            ActionResult actionResult;
            decimal      num;
            decimal?     credit;
            int?         ledgerId;
            DateTime     now;
            Customer     supplierInfo = this.supplierService.GetById(new int?(supplierId));

            if (supplierInfo != null)
            {
                foreach (LedgerPosting item in ledgerPosting)
                {
                    num                = new decimal();
                    item.Debit         = new decimal?(num);
                    item.PostingDate   = new DateTime?(voucherDate);
                    item.VoucherNo     = voucherNo;
                    item.VoucherTypeId = new int?(5);
                    item.Extra1        = string.Concat("Voucher:", voucherNo, " ", notes);
                    this.postingService.Save(item);
                    credit      = item.Credit;
                    this.Amount = (credit.HasValue ? credit.GetValueOrDefault() : decimal.Zero);
                    this.ChkNo  = item.ChequeNo;
                    ledgerId    = item.LedgerId;
                    if ((ledgerId.GetValueOrDefault() == 1 ? !ledgerId.HasValue : true))
                    {
                        string[] str = new string[] { "Ref:No- TT-DR", voucherNo, ",Dated:", null, null };
                        now        = DateTime.Now;
                        str[3]     = now.ToString("dd-MM-yyyy");
                        str[4]     = ".";
                        this.ChkNo = string.Concat(str);
                    }
                    else
                    {
                        string[] strArrays = new string[] { "Ref:No- Cash-DR", voucherNo, ",Dated:", null, null };
                        now          = DateTime.Now;
                        strArrays[3] = now.ToString("dd-MM-yyyy");
                        strArrays[4] = ".";
                        this.ChkNo   = string.Concat(strArrays);
                    }
                }
                string        smsmsg  = this.ChkNo;
                LedgerPosting posting = new LedgerPosting()
                {
                    ChequeDate    = new DateTime?(DateTime.Now),
                    VoucherNo     = voucherNo,
                    ChequeNo      = "",
                    VoucherTypeId = new int?(5),
                    LedgerId      = supplierInfo.LedgerId,
                    PostingDate   = new DateTime?(voucherDate)
                };
                LedgerPosting nullable = posting;
                credit         = ledgerPosting.Sum <LedgerPosting>((LedgerPosting a) => a.Credit);
                nullable.Debit = new decimal?(credit.Value);
                num            = new decimal();
                posting.Credit = new decimal?(num);
                posting.Extra1 = string.Concat("Voucher:", voucherNo, " ", notes);
                this.postingService.Save(posting);
                PartyBalance balance = new PartyBalance()
                {
                    AgainstVoucherTypeId = new int?(5),
                    VoucherNo            = voucherNo,
                    PostingDate          = new DateTime?(voucherDate)
                };
                PartyBalance partyBalance = balance;
                ledgerId = supplierInfo.LedgerId;
                partyBalance.LedgerId = (ledgerId.HasValue ? ledgerId.GetValueOrDefault() : 0);
                num                   = new decimal();
                balance.Debit         = new decimal?(num);
                balance.Credit        = posting.Debit;
                balance.VoucherTypeId = 5;
                balance.extra1        = string.Concat("Recipt Invoice: ", voucherNo, " Notes:", notes);
                balance.extra2        = posting.Id.ToString();
                this.partyBalanceService.Save(balance);
                if (isSendSMS)
                {
                    Customer        customer        = (new CustomerService()).GetById(new int?(supplierId));
                    CustomerService customerService = new CustomerService();
                    ledgerId = customer.LedgerId;
                    rptIndividualLedger_Result due = customerService.GetBalance((ledgerId.HasValue ? ledgerId.GetValueOrDefault() : 0));
                    string balanceText             = "";
                    credit = due.Balance;
                    num    = new decimal();
                    if ((credit.GetValueOrDefault() < num ? !credit.HasValue : true))
                    {
                        credit      = due.Balance;
                        balanceText = string.Concat("Your Present Balance With Dada Rice Tk=", string.Format("{0:#,#.}", decimal.Round((credit.HasValue ? credit.GetValueOrDefault() : decimal.Zero)), ""), "/=.");
                    }
                    else
                    {
                        decimal minusOne = decimal.MinusOne;
                        credit      = due.Balance;
                        balanceText = string.Concat("Your Present Balance With Dada Rice Tk=", string.Format("{0:#,#.}", minusOne * decimal.Round((credit.HasValue ? credit.GetValueOrDefault() : decimal.Zero)), ""), "/=.");
                    }
                    SMSEmailService sMSEmailService = new SMSEmailService();
                    string          phone           = supplierInfo.Phone;
                    string[]        name            = new string[] { "Dear ", customer.Name, " Tk=", null, null, null };
                    credit  = balance.Credit;
                    name[3] = string.Format("{0:#,#.}", decimal.Round((credit.HasValue ? credit.GetValueOrDefault() : decimal.Zero)), "");
                    name[4] = "/-Received With Thanks As ";
                    name[5] = smsmsg;
                    sMSEmailService.SendOneToOneSingleSms(phone, string.Concat(string.Concat(name), balanceText));
                }
                actionResult = Json("", 0);
            }
            else
            {
                actionResult = Json("error", 0);
            }
            return(actionResult);
        }
예제 #28
0
        public ActionResult Edit(Supplier model, decimal OpeningBalance, string CrOrDr, int create)
        {
            if (model == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Supplier supplier = db.GetById(model.Id);

            if (supplier == null)
            {
                return(HttpNotFound());
            }
            supplier.Address            = model.Address;
            supplier.City               = model.City;
            supplier.Code               = model.Code;
            supplier.Name               = model.Name;
            supplier.Phone              = model.Phone;
            supplier.ContactPersonName  = model.ContactPersonName;
            supplier.ContactPersonPhone = model.ContactPersonPhone;
            supplier.Email              = model.Email;
            supplier.IsActive           = true;
            supplier.UpdateDate         = DateTime.Now;
            supplier.UpdateBy           = CurrentSession.GetCurrentSession().UserName;
            db.Update(supplier, model.Id);

            //account ledger update
            AccountLedger ledger = new AccountLedgerService().GetById(supplier.LedgerId);

            ledger.Address           = supplier.Address;
            ledger.BankAccountNumber = "";
            ledger.BillByBill        = true;
            ledger.BranchCode        = "";
            ledger.BranchName        = "";
            ledger.CreditLimit       = 0.0m;
            ledger.CreditPeriod      = 1;
            ledger.Email             = supplier.Email;
            ledger.IsDefault         = false;
            ledger.LedgerName        = supplier.Name;

            ledger.Extra2         = supplier.Code;
            ledger.Mobile         = supplier.ContactPersonPhone;
            ledger.Phone          = supplier.Phone;
            ledger.OpeningBalance = OpeningBalance;
            var saved = Accounts.Update(ledger, supplier.LedgerId ?? 0);

            if (OpeningBalance > 0.0m)
            {
                var           party = new PartyBalanceService().GetAll().Where(a => a.VoucherTypeId == 1 && a.LedgerId == supplier.LedgerId).FirstOrDefault();
                LedgerPosting post  = new LedgerPostingService().GetAll().Where(a => a.VoucherTypeId == 1 && a.LedgerId == supplier.LedgerId).FirstOrDefault();
                if (post == null)
                {
                    if (party == null)
                    {
                        party = new PartyBalance();
                    }
                    post             = new LedgerPosting();
                    post.LedgerId    = supplier.LedgerId;
                    post.PostingDate = DateTime.Now;
                    if (CrOrDr == "Cr")
                    {
                        post.Credit  = ledger.OpeningBalance;
                        party.Credit = ledger.OpeningBalance;
                    }
                    if (CrOrDr == "Dr")
                    {
                        party.Debit = ledger.OpeningBalance;
                        post.Debit  = ledger.OpeningBalance;
                    }
                    post.VoucherTypeId = 1;
                    post.VoucherNo     = ledger.Id.ToString();
                    post.InvoiceNo     = ledger.Id.ToString();
                    var postingResult = postingService.Save(post);
                    party.AgainstInvoiceNo = postingResult.Id.ToString();
                }
                else
                {
                    if (party == null)
                    {
                        party = new PartyBalance();
                    }
                    if (CrOrDr == "Cr")
                    {
                        post.Credit  = ledger.OpeningBalance;
                        party.Credit = ledger.OpeningBalance;
                    }
                    if (CrOrDr == "Dr")
                    {
                        party.Debit = ledger.OpeningBalance;
                        post.Debit  = ledger.OpeningBalance;
                    }
                    postingService.Update(post, post.Id);
                }
                if (party == null || party.PartyBalanceId == 0)
                {
                    party = new PartyBalance();
                    if (CrOrDr == "Cr")
                    {
                        post.Credit  = ledger.OpeningBalance;
                        party.Credit = ledger.OpeningBalance;
                    }
                    if (CrOrDr == "Dr")
                    {
                        party.Debit = ledger.OpeningBalance;
                        post.Debit  = ledger.OpeningBalance;
                    }
                    party.LedgerId        = supplier.LedgerId ?? 0;
                    party.CreditPeriod    = 60;
                    party.FinancialYearId = CurrentSession.GetCurrentSession().FinancialYear;
                    party.PostingDate     = DateTime.Now;
                    party.VoucherTypeId   = 1;
                    party.extra1          = "Opening Balance";
                    partyBalanceService.Save(party);
                }
                else
                {
                    if (CrOrDr == "Cr")
                    {
                        post.Credit  = ledger.OpeningBalance;
                        party.Credit = ledger.OpeningBalance;
                    }
                    if (CrOrDr == "Dr")
                    {
                        party.Debit = ledger.OpeningBalance;
                        post.Debit  = ledger.OpeningBalance;
                    }

                    party.PostingDate = DateTime.Now;
                    party.Balance     = party.Balance + OpeningBalance;
                    partyBalanceService.Update(party, party.PartyBalanceId);
                }
            }
            return(Json("Updated", JsonRequestBehavior.AllowGet));
            //return View();
        }
예제 #29
0
        public ActionResult Authorize(PaymentAuthorizationRequest request)
        {
            var payment = _paymentService.GetPaymentById(request.Id);

            if (payment == null)
            {
                return(Json("Failed:Payment not found to authorized!!", JsonRequestBehavior.AllowGet));
            }
            decimal?credit;

            //credit
            foreach (var details in payment.PaymentDetails)
            {
                var item = new LedgerPosting();
                item.LedgerId      = details.LedgerId;
                item.CreatedBy     = CurrentSession.GetCurrentSession().UserId;
                item.Credit        = 0;
                item.Debit         = request.Amount;
                item.InvoiceNo     = payment.InvoiceNo;
                item.VoucherNo     = payment.VoucherNo;
                item.PostingDate   = payment.LedgerDate;
                item.ChequeDate    = details.ChequeDate;
                item.ChequeNo      = details.ChequeNo;
                item.VoucherTypeId = payment.VoucherTypeId;
                item.Extra1        = "Voucher:" + payment.VoucherNo + " " + payment.Narration + "|" + request.Notes;
                postingService.Save(item);
                break;
            }
            //debit
            LedgerPosting posting = new LedgerPosting();

            posting.ChequeDate    = DateTime.Now;
            posting.VoucherNo     = payment.VoucherNo;
            posting.ChequeNo      = "";
            posting.VoucherTypeId = (int)BAL.VoucherTypeEnum.PaymentVoucher;
            posting.LedgerId      = payment.LedgerId;
            posting.PostingDate   = payment.LedgerDate;
            posting.Credit        = request.Amount;
            posting.Debit         = 0;
            posting.Extra1        = "Voucher:" + payment.VoucherNo + " " + request.Notes;
            postingService.Save(posting);
            //balance
            //party balance
            PartyBalance balance = new PartyBalance();

            balance.AgainstVoucherTypeId = 4;
            balance.VoucherNo            = payment.VoucherNo;
            balance.PostingDate          = payment.LedgerDate;
            balance.LedgerId             = payment.LedgerId ?? 0;
            balance.Debit         = request.Amount;
            balance.Credit        = 0;
            balance.VoucherTypeId = (int)BAL.VoucherTypeEnum.PaymentVoucher;
            balance.extra1        = "Payment Invoice: " + payment.VoucherNo + " Notes:" + request.Notes;
            balance.extra2        = posting.Id.ToString();

            partyBalanceService.Save(balance);

            //isSendSMS = false;
            //if (isSendSMS)
            //{
            //    SMSEmailService sMSEmailService = new SMSEmailService();
            //    string phone = supplierInfo.Phone;
            //    rptIndividualLedger_Result due = customerService.GetBalance((supplierInfo.LedgerId ?? 0));

            //    string balanceText = "";
            //    credit = due.Balance;
            //    var num = new decimal();
            //    if ((credit.GetValueOrDefault() < num ? !credit.HasValue : true))
            //    {
            //        credit = due.Balance;
            //        balanceText = string.Concat("Your Present Balance With Dada Rice Tk=", string.Format("{0:#,#.}", decimal.Round((credit.HasValue ? credit.GetValueOrDefault() : decimal.Zero)), ""), "/=.");
            //    }
            //    else
            //    {
            //        decimal minusOne = decimal.MinusOne;
            //        credit = due.Balance;
            //        balanceText = string.Concat("Your Present Balance With Dada Rice Tk=", string.Format("{0:#,#.}", minusOne * decimal.Round((credit.HasValue ? credit.GetValueOrDefault() : decimal.Zero)), ""), "/= Thanks.");
            //    }
            //    balanceText = "";
            //    string[] name = new string[] { "Dear ", supplierInfo.Name, " Tk=", null, null, null };
            //    credit = balance.Credit;
            //    name[3] = string.Format("{0:#,#.}", decimal.Round((posting.Credit.HasValue ? posting.Credit.GetValueOrDefault() : decimal.Zero)), "");
            //    name[4] = "/- has been Deposited to your Account. Ref:No-" + voucherNo + ", Dated:" + voucherDate.ToString("dd-MM-yyyy") + ". Thanks with Dada Rice";
            //    sMSEmailService.SendOneToOneSingleSms("01979110321", string.Concat(string.Concat(name), balanceText), false);
            //}
            //updated au authorized
            payment.ApprovedBy    = DateTime.Now;
            payment.ApprovedNotes = request.Notes;
            payment.IsApproved    = true;
            _paymentService.Update(payment, payment.Id);
            foreach (var item in payment.PaymentDetails)
            {
                payment.ApprovedBy    = DateTime.Now;
                payment.ApprovedNotes = request.Notes;
                payment.IsApproved    = true;
                _paymentService.Update(item, item.Id);
            }
            return(Json("", JsonRequestBehavior.AllowGet));
        }