public void AddSupplierPayment(PurchaseDuePayment purchaseDuePayment, int concernId, int userId)
        {
            var today = DateTime.Now;
            var date  = DateTime.Now.ToString("mmddfff");
            var code  = "4" + date + "5";

            using (var transaction = _context.Database.BeginTransaction())
            {
                purchaseDuePayment.CreationDate = DateTime.Now;
                purchaseDuePayment.Creator      = userId;
                purchaseDuePayment.ConcernID    = concernId;
                purchaseDuePayment.Code         = code;
                _context.PurchaseDuePayments.Add(purchaseDuePayment);
                _context.SaveChanges();

                Journal journalCash = new Journal();
                journalCash.DebitAccountsHeadId  = 8;
                journalCash.CreditAccountsHeadId = 10;
                journalCash.DebitJournalAmount   = purchaseDuePayment.PaymentAmount;
                journalCash.CreditJournalAmount  = purchaseDuePayment.PaymentAmount;
                journalCash.JournalEntryDate     = today;
                journalCash.VoucherCode          = code;
                journalCash.Description          = "Supplier Payment";
                _journal.AddJournal(journalCash, userId, concernId);

                transaction.Commit();
            }
        }
예제 #2
0
        public JsonResult AddSupplierPayment(PurchaseDuePayment DuePayment)
        {
            var concernId = Convert.ToInt32(Session["ConcernId"]);
            var userId    = Convert.ToInt32(Session["UserId"]);

            _payment.AddSupplierPayment(DuePayment, concernId, userId);
            return(Json("Added", JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public void AddPurchaseInvoice(SessionInvoice sessionInvoice, int userId, int concernId)
        {
            List <PurchaseReturnInvoice> purchaseInvoices = new List <PurchaseReturnInvoice>();
            var sessionData = _context.SessionInvoices.Where(m => m.ConcernID == concernId && m.UserID == userId);
            var dateString  = DateTime.Now;

            //var invoiceCode = DateTime.Now.ToString("mmddfff") + "" + userId + "" + concernId;
            using (var transaction = _context.Database.BeginTransaction())
            {
                PurchaseDuePayment purchaseDue = new PurchaseDuePayment();
                purchaseDue.PaymentDate   = dateString;
                purchaseDue.CreationDate  = dateString;
                purchaseDue.SupplierID    = sessionInvoice.BuyerID;
                purchaseDue.Description   = "Sales Return Code : " + " " + sessionInvoice.Code;
                purchaseDue.IsDelete      = 0;
                purchaseDue.Code          = sessionInvoice.Code;
                purchaseDue.PaymentAmount = sessionInvoice.DuePayment;
                purchaseDue.ConcernID     = concernId;
                purchaseDue.Creator       = userId;
                _context.PurchaseDuePayments.Add(purchaseDue);
                _context.SaveChanges();
                foreach (var item in sessionData)
                {
                    purchaseInvoices.Add(new PurchaseReturnInvoice()
                    {
                        PRSupplierID        = sessionInvoice.BuyerID,
                        PRCashPayment       = sessionInvoice.CashPayment,
                        ConcernID           = concernId,
                        CreationDate        = dateString,
                        Creator             = userId,
                        Description         = sessionInvoice.Description,
                        PRDiscount          = sessionInvoice.Discount,
                        IsDelete            = item.IsDelete,
                        PRProductID         = item.ProductID,
                        PRQuantity          = item.Quantity,
                        PRDate              = item.Date,
                        PurchaseInvoiceCode = sessionInvoice.Code,
                        PRUnitPrice         = item.UnitPrice,
                        PRInvoiceCode       = sessionInvoice.Code
                    });
                }
                if (sessionInvoice.DuePayment > 0)
                {
                    Journal journalCash = new Journal();
                    journalCash.DebitAccountsHeadId  = 10;
                    journalCash.CreditAccountsHeadId = 4;
                    journalCash.DebitJournalAmount   = sessionInvoice.CashPayment;
                    journalCash.CreditJournalAmount  = sessionInvoice.CashPayment;
                    journalCash.JournalEntryDate     = dateString;
                    journalCash.VoucherCode          = sessionInvoice.Code;
                    journalCash.Description          = "Purchase Return";
                    _journal.AddJournal(journalCash, userId, concernId);

                    //Journal Input-- Cash
                    Journal journalDue = new Journal();
                    journalDue.DebitAccountsHeadId  = 8;
                    journalDue.CreditAccountsHeadId = 4;
                    journalDue.DebitJournalAmount   = sessionInvoice.DuePayment;
                    journalDue.CreditJournalAmount  = sessionInvoice.DuePayment;
                    journalDue.JournalEntryDate     = dateString;
                    journalDue.VoucherCode          = sessionInvoice.Code;
                    journalDue.Description          = "Purchase Return";
                    _journal.AddJournal(journalDue, userId, concernId);
                }
                else
                {
                    Journal journalCash = new Journal();
                    journalCash.DebitAccountsHeadId  = 10;
                    journalCash.CreditAccountsHeadId = 4;
                    journalCash.DebitJournalAmount   = sessionInvoice.CashPayment;
                    journalCash.CreditJournalAmount  = sessionInvoice.CashPayment;
                    journalCash.JournalEntryDate     = dateString;
                    journalCash.VoucherCode          = sessionInvoice.Code;
                    journalCash.Description          = "Purchase Return";
                    _journal.AddJournal(journalCash, userId, concernId);
                }
                _context.PurchaseReturnInvoices.AddRange(purchaseInvoices);
                _context.SaveChanges();
                _context.SessionInvoices.RemoveRange(sessionData);
                _context.SaveChanges();
                transaction.Commit();
            }
        }