コード例 #1
0
        private static void AddStockAdjustmentDecrementLedgerTransactionToDatabase(ERPContext context, StockAdjustmentTransaction stockAdjustmentTransaction, decimal totalCOGSAdjustment)
        {
            var ledgerTransaction = new LedgerTransaction();

            if (!LedgerTransactionHelper.AddTransactionToDatabase(context, ledgerTransaction, UtilityMethods.GetCurrentDate().Date,
                                                                  stockAdjustmentTransaction.StockAdjustmentTransactionID, "Stock Adjustment (Decrement)"))
            {
                return;
            }
            context.SaveChanges();
            LedgerTransactionHelper.AddTransactionLineToDatabase(context, ledgerTransaction, "Cost of Goods Sold", "Debit", totalCOGSAdjustment);
            LedgerTransactionHelper.AddTransactionLineToDatabase(context, ledgerTransaction, "Inventory", "Credit", totalCOGSAdjustment);
        }
コード例 #2
0
        private static void RecordPurchaseLedgerTransactionInDatabaseContext(ERPContext context, PurchaseTransaction purchaseTransaction)
        {
            var purchaseLedgerTransaction = new LedgerTransaction();
            var accountsPayableName       = purchaseTransaction.Supplier.Name + " Accounts Payable";

            if (!LedgerTransactionHelper.AddTransactionToDatabase(context, purchaseLedgerTransaction, UtilityMethods.GetCurrentDate().Date, purchaseTransaction.PurchaseID, "Purchase Transaction"))
            {
                return;
            }
            context.SaveChanges();
            LedgerTransactionHelper.AddTransactionLineToDatabase(context, purchaseLedgerTransaction, "Inventory", "Debit", purchaseTransaction.Total);
            LedgerTransactionHelper.AddTransactionLineToDatabase(context, purchaseLedgerTransaction, accountsPayableName, "Credit", purchaseTransaction.Total);
            context.SaveChanges();
        }
コード例 #3
0
        private static void RecordPaymentLedgerTransactionInDatabaseContext(ERPContext context, PurchaseTransaction purchaseTransaction, decimal paymentAmount, string paymentMode)
        {
            var accountsPayableName      = purchaseTransaction.Supplier.Name + " Accounts Payable";
            var paymentLedgerTransaction = new LedgerTransaction();

            if (!LedgerTransactionHelper.AddTransactionToDatabase(context, paymentLedgerTransaction, UtilityMethods.GetCurrentDate().Date, purchaseTransaction.PurchaseID, "Purchase Payment"))
            {
                return;
            }
            context.SaveChanges();

            LedgerTransactionHelper.AddTransactionLineToDatabase(context, paymentLedgerTransaction, accountsPayableName, "Debit", paymentAmount);
            LedgerTransactionHelper.AddTransactionLineToDatabase(context, paymentLedgerTransaction, paymentMode, "Credit", paymentAmount);
            context.SaveChanges();
        }
コード例 #4
0
        private static void AddPurchaseReturnTransactionLedgerTransactionToDatabaseContext(ERPContext context, PurchaseReturnTransaction purchaseReturnTransaction, decimal totalCOGS)
        {
            var purchaseReturnLedgerTransaction = new LedgerTransaction();

            if (!LedgerTransactionHelper.AddTransactionToDatabase(context, purchaseReturnLedgerTransaction, UtilityMethods.GetCurrentDate(), purchaseReturnTransaction.PurchaseReturnTransactionID, "Purchase Return"))
            {
                return;
            }
            context.SaveChanges();
            LedgerTransactionHelper.AddTransactionLineToDatabase(context, purchaseReturnLedgerTransaction,
                                                                 $"{purchaseReturnTransaction.PurchaseTransaction.Supplier.Name} Accounts Payable", "Debit", purchaseReturnTransaction.NetTotal);
            if (totalCOGS - purchaseReturnTransaction.NetTotal > 0)
            {
                LedgerTransactionHelper.AddTransactionLineToDatabase(context, purchaseReturnLedgerTransaction, "Cost of Goods Sold", "Debit", totalCOGS - purchaseReturnTransaction.NetTotal);
            }
            LedgerTransactionHelper.AddTransactionLineToDatabase(context, purchaseReturnLedgerTransaction, "Inventory", "Credit", totalCOGS);
            context.SaveChanges();
        }
コード例 #5
0
        private static void RecordEditedPurchaseTransactionTotalCOGSChangedLedgerTransactionInDatabaseContext(
            ERPContext context, PurchaseTransaction editedPurchaseTransaction, decimal totalCOGSChanged)
        {
            var purchaseTransactionTotalCOGSChangedLedgerTransaction = new LedgerTransaction();

            LedgerTransactionHelper.AddTransactionToDatabase(context, purchaseTransactionTotalCOGSChangedLedgerTransaction, UtilityMethods.GetCurrentDate().Date, editedPurchaseTransaction.PurchaseID, "Purchase Transaction Adjustment (COGS)");
            context.SaveChanges();

            if (totalCOGSChanged > 0)
            {
                LedgerTransactionHelper.AddTransactionLineToDatabase(context, purchaseTransactionTotalCOGSChangedLedgerTransaction, "Cost of Goods Sold", "Debit", totalCOGSChanged);
                LedgerTransactionHelper.AddTransactionLineToDatabase(context, purchaseTransactionTotalCOGSChangedLedgerTransaction, "Inventory", "Credit", totalCOGSChanged);
            }
            else
            {
                LedgerTransactionHelper.AddTransactionLineToDatabase(context, purchaseTransactionTotalCOGSChangedLedgerTransaction, "Inventory", "Debit", -totalCOGSChanged);
                LedgerTransactionHelper.AddTransactionLineToDatabase(context, purchaseTransactionTotalCOGSChangedLedgerTransaction, "Cost of Goods Sold", "Credit", -totalCOGSChanged);
            }
            context.SaveChanges();
        }
コード例 #6
0
        private static void AddSalesReturnTransactionLedgerTransactionsToDatabaseContext(ERPContext context,
                                                                                         SalesReturnTransaction salesReturnTransaction)
        {
            var totalCOGS =
                salesReturnTransaction.SalesReturnTransactionLines.ToList()
                .Sum(salesReturnTransactionLine => salesReturnTransactionLine.CostOfGoodsSold);

            // Record the corresponding ledger transactions in the database
            var ledgerTransaction1 = new LedgerTransaction();
            var ledgerTransaction2 = new LedgerTransaction();

            if (
                !LedgerTransactionHelper.AddTransactionToDatabase(context, ledgerTransaction1,
                                                                  UtilityMethods.GetCurrentDate().Date, salesReturnTransaction.SalesReturnTransactionID,
                                                                  "Sales Return"))
            {
                return;
            }
            context.SaveChanges();
            LedgerTransactionHelper.AddTransactionLineToDatabase(context, ledgerTransaction1,
                                                                 "Sales Returns and Allowances", "Debit", salesReturnTransaction.NetTotal);
            LedgerTransactionHelper.AddTransactionLineToDatabase(context, ledgerTransaction1,
                                                                 "Cash", "Credit", salesReturnTransaction.NetTotal);

            if (
                !LedgerTransactionHelper.AddTransactionToDatabase(context, ledgerTransaction2,
                                                                  UtilityMethods.GetCurrentDate().Date, salesReturnTransaction.SalesReturnTransactionID,
                                                                  "Sales Return"))
            {
                return;
            }
            context.SaveChanges();
            LedgerTransactionHelper.AddTransactionLineToDatabase(context, ledgerTransaction2, "Inventory", "Debit",
                                                                 totalCOGS);
            LedgerTransactionHelper.AddTransactionLineToDatabase(context, ledgerTransaction2, "Cost of Goods Sold",
                                                                 "Credit", totalCOGS);

            context.SaveChanges();
        }
コード例 #7
0
        private static void RecordEditedPurchaseTransactionNetTotalChangedLedgerTransactionInDatabaseContext(ERPContext context, PurchaseTransaction editedPurchaseTransaction, decimal valueChanged)
        {
            var purchaseTransactionNetTotalChangedLedgerTransaction = new LedgerTransaction();

            LedgerTransactionHelper.AddTransactionToDatabase(context, purchaseTransactionNetTotalChangedLedgerTransaction,
                                                             UtilityMethods.GetCurrentDate().Date, editedPurchaseTransaction.PurchaseID, "Purchase Transaction Adjustment");
            context.SaveChanges();

            if (valueChanged > 0)
            {
                LedgerTransactionHelper.AddTransactionLineToDatabase(context, purchaseTransactionNetTotalChangedLedgerTransaction, "Inventory",
                                                                     "Debit", valueChanged);
                LedgerTransactionHelper.AddTransactionLineToDatabase(context, purchaseTransactionNetTotalChangedLedgerTransaction,
                                                                     $"{editedPurchaseTransaction.Supplier.Name} Accounts Payable", "Credit", valueChanged);
            }
            else
            {
                LedgerTransactionHelper.AddTransactionLineToDatabase(context, purchaseTransactionNetTotalChangedLedgerTransaction,
                                                                     $"{editedPurchaseTransaction.Supplier.Name} Accounts Payable", "Debit", -valueChanged);
                LedgerTransactionHelper.AddTransactionLineToDatabase(context, purchaseTransactionNetTotalChangedLedgerTransaction, "Inventory",
                                                                     "Credit", -valueChanged);
            }
            context.SaveChanges();
        }