public ActionResult AddIncomeJournalSave(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 = 0; lposting.VoucherNo = voucherNo; lposting.LedgerId = item.LedgerId; lposting.Debit = item.Debit ?? 0 + item.Credit ?? 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 = TotalAmount; posting.Debit = 0; posting.Extra1 = "Voucher:" + voucherNo + " " + notes; postingService.Save(posting); return(Json("", JsonRequestBehavior.AllowGet)); }
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)); }
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 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)); }
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)); } }
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)); }
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)); }
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); }
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)); }