コード例 #1
0
        public void AddBuyerPayment(SalesDuePayment salesDuePayment, 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())
            {
                salesDuePayment.ConcernID    = concernId;
                salesDuePayment.Creator      = userId;
                salesDuePayment.CreationDate = today;
                salesDuePayment.Code         = code;
                _context.SalesDuePayments.Add(salesDuePayment);
                _context.SaveChanges();

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

                transaction.Commit();
            }
        }
コード例 #2
0
        public void AddExpense(Expense expense, 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())
            {
                expense.Creator      = userId;
                expense.CreationDate = today;
                expense.ExpensesCode = code;
                expense.ConcernId    = concernId;
                _context.Expenses.Add(expense);
                _context.SaveChanges();

                Journal journalCash = new Journal();
                journalCash.DebitAccountsHeadId  = 5;
                journalCash.CreditAccountsHeadId = 10;
                journalCash.DebitJournalAmount   = expense.Payment;
                journalCash.CreditJournalAmount  = expense.Payment;
                journalCash.JournalEntryDate     = today;
                journalCash.VoucherCode          = code;
                journalCash.Description          = "Expense Payment";
                _journal.AddJournal(journalCash, userId, concernId);

                transaction.Commit();
            }
        }
コード例 #3
0
        public JsonResult AddJournal(Journal journal)
        {
            var concernId = Convert.ToInt32(Session["ConcernId"]);
            var userId    = Convert.ToInt32(Session["UserId"]);

            _journal.AddJournal(journal, userId, concernId);
            return(Json("added succes", JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        public void AddSalesInvoice(SessionInvoice sessionInvoice, int userId, int concernId)
        {
            List <SalesInvoice> salesInvoices = new List <SalesInvoice>();
            var sessionData = _context.SessionInvoices.Where(m => m.ConcernID == concernId && m.UserID == userId);
            var dateString  = DateTime.Now;

            using (var transaction = _context.Database.BeginTransaction())
            {
                foreach (var item in sessionData)
                {
                    salesInvoices.Add(new SalesInvoice()
                    {
                        BuyerID          = item.BuyerID,
                        CashPayment      = sessionInvoice.CashPayment,
                        ConcernID        = concernId,
                        CreationDate     = dateString,
                        Creator          = userId,
                        Description      = sessionInvoice.Description,
                        Discount         = sessionInvoice.Discount,
                        DuePayment       = item.DuePayment,
                        IsDelete         = item.IsDelete,
                        ProductID        = item.ProductID,
                        Quantity         = item.Quantity,
                        SalesDate        = item.Date,
                        SalesInvoiceCode = sessionInvoice.Code,
                        SalesUnitPrice   = item.UnitPrice
                    });
                }
                //Sales Invoice Data Insert
                _context.SalesInvoices.AddRange(salesInvoices);
                _context.SaveChanges();
                if (sessionInvoice.DuePayment > 0)
                {
                    //Journal Input-- Cash
                    Journal journalCash = new Journal();
                    journalCash.DebitAccountsHeadId  = 10;
                    journalCash.CreditAccountsHeadId = 1;
                    journalCash.DebitJournalAmount   = sessionInvoice.CashPayment;
                    journalCash.CreditJournalAmount  = sessionInvoice.CashPayment;
                    journalCash.JournalEntryDate     = dateString;
                    journalCash.VoucherCode          = sessionInvoice.Code;
                    journalCash.Description          = "Sales";
                    _journal.AddJournal(journalCash, userId, concernId);

                    //Journal Input-- Due
                    Journal journalDue = new Journal();
                    journalDue.DebitAccountsHeadId  = 7;
                    journalDue.CreditAccountsHeadId = 1;
                    journalDue.DebitJournalAmount   = sessionInvoice.DuePayment;
                    journalDue.CreditJournalAmount  = sessionInvoice.DuePayment;
                    journalDue.JournalEntryDate     = dateString;
                    journalDue.VoucherCode          = sessionInvoice.Code;
                    journalDue.Description          = "Sales";
                    _journal.AddJournal(journalDue, userId, concernId);
                }
                else
                {
                    //Journal Input-- Cash
                    Journal journalCash = new Journal();
                    journalCash.DebitAccountsHeadId  = 10;
                    journalCash.CreditAccountsHeadId = 1;
                    journalCash.DebitJournalAmount   = sessionInvoice.CashPayment;
                    journalCash.CreditJournalAmount  = sessionInvoice.CashPayment;
                    journalCash.JournalEntryDate     = dateString;
                    journalCash.VoucherCode          = sessionInvoice.Code;
                    journalCash.Description          = "Sales";
                    _journal.AddJournal(journalCash, userId, concernId);
                }
                //Remove Session Data
                _context.SessionInvoices.RemoveRange(sessionData);
                _context.SaveChanges();
                transaction.Commit();
            }
        }
コード例 #5
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();
            }
        }
コード例 #6
0
        public void AddSalesReturnInvoice(SessionInvoice sessionInvoice, int userId, int concernId)
        {
            List <SalesReturnInvoice> salesInvoices = new List <SalesReturnInvoice>();
            var sessionData = _context.SessionInvoices.Where(m => m.ConcernID == concernId && m.UserID == userId);
            var dateString  = DateTime.Now;

            //var invoiceCode = DateTime.Now.ToString("mmddfff");
            using (var transaction = _context.Database.BeginTransaction())
            {
                SalesDuePayment salesDue = new SalesDuePayment();
                salesDue.PaymentDate   = dateString;
                salesDue.CreationDate  = dateString;
                salesDue.BuyerID       = sessionInvoice.BuyerID;
                salesDue.Description   = "Sales Return Code : " + " " + sessionInvoice.Code;
                salesDue.Code          = sessionInvoice.Code;
                salesDue.IsDelete      = 0;
                salesDue.PaymentAmount = sessionInvoice.DuePayment;
                salesDue.ConcernID     = concernId;
                salesDue.Creator       = userId;
                _context.SalesDuePayments.Add(salesDue);
                _context.SaveChanges();
                foreach (var item in sessionData)
                {
                    salesInvoices.Add(new SalesReturnInvoice()
                    {
                        SRBuyerID     = item.BuyerID,
                        SRCashPayment = sessionInvoice.CashPayment,
                        ConcernID     = concernId,
                        CreationDate  = dateString,
                        Creator       = userId,
                        Description   = sessionInvoice.Description,
                        SRDiscount    = sessionInvoice.Discount,
                        SRDuePayment  = item.DuePayment,
                        IsDelete      = item.IsDelete,
                        SRProductID   = item.ProductID,
                        SRQuantity    = item.Quantity,
                        SRDate        = item.Date,
                        SRInvoiceCode = sessionInvoice.Code,
                        SRUnitPrice   = item.UnitPrice
                    });
                }
                _context.SalesReturnInvoices.AddRange(salesInvoices);
                _context.SaveChanges();
                //Journal

                if (sessionInvoice.DuePayment > 0)
                {
                    //Journal Input-- Due
                    Journal journalCash = new Journal();
                    journalCash.DebitAccountsHeadId  = 3;
                    journalCash.CreditAccountsHeadId = 7;
                    journalCash.DebitJournalAmount   = sessionInvoice.CashPayment;
                    journalCash.CreditJournalAmount  = sessionInvoice.CashPayment;
                    journalCash.JournalEntryDate     = dateString;
                    journalCash.VoucherCode          = sessionInvoice.Code;
                    journalCash.Description          = "Sales Return";
                    _journal.AddJournal(journalCash, userId, concernId);

                    //Journal Input-- Cash
                    Journal journalDue = new Journal();
                    journalDue.DebitAccountsHeadId  = 3;
                    journalDue.CreditAccountsHeadId = 10;
                    journalDue.DebitJournalAmount   = sessionInvoice.DuePayment;
                    journalDue.CreditJournalAmount  = sessionInvoice.DuePayment;
                    journalDue.JournalEntryDate     = dateString;
                    journalDue.VoucherCode          = sessionInvoice.Code;
                    journalDue.Description          = "Sales Return";
                    _journal.AddJournal(journalDue, userId, concernId);
                }
                else
                {
                    Journal journalCash = new Journal();
                    journalCash.DebitAccountsHeadId  = 3;
                    journalCash.CreditAccountsHeadId = 7;
                    journalCash.DebitJournalAmount   = sessionInvoice.CashPayment;
                    journalCash.CreditJournalAmount  = sessionInvoice.CashPayment;
                    journalCash.JournalEntryDate     = dateString;
                    journalCash.VoucherCode          = sessionInvoice.Code;
                    journalCash.Description          = "Sales Return";
                    _journal.AddJournal(journalCash, userId, concernId);
                }

                _context.SessionInvoices.RemoveRange(sessionData);
                _context.SaveChanges();
                transaction.Commit();
            }
        }