Exemple #1
0
        public static void AddInHand(InHandAndBank inHand, int?takenFromBank)
        {
            var existingMoney = GetAllhandMoney();

            inHand.RealInvestment = (existingMoney.RealInvestment + takenFromBank);
            InsertSingleObjectToSingleJson(JsonFilePath, inHand);
        }
        public static void AddOrUpdateDaily(DailyCollectionDetail dailyCol)
        {
            var list = ReadFileAsObjects <DailyCollectionDetail>(JsonFilePath);

            if (list != null && list.Count > 0)
            {
                var data = list.Where(w => w.Date == dailyCol.Date).ToList().FirstOrDefault();

                if (data != null) // Update
                {
                    //data.BankTxnOut = dailyCol.BankTxnOut;
                    //data.ClosedAccounts = dailyCol.ClosedAccounts;
                    //data.CollectionAmount = dailyCol.CollectionAmount;
                    data.Comments = dailyCol.Comments;
                    //data.Date = dailyCol.Date;
                    //data.GivenAmount = dailyCol.GivenAmount;
                    //data.InBank = dailyCol.InBank;
                    //data.Interest = dailyCol.Interest;
                    //data.OpenedAccounts = dailyCol.OpenedAccounts;
                    //data.OtherExpenditire = dailyCol.OtherExpenditire;
                    //data.OtherInvestment = dailyCol.OtherInvestment;
                    //data.SentFromUSA = dailyCol.SentFromUSA;
                    //data.TakenFromBank = dailyCol.TakenFromBank;
                    //data.TodayInHand = dailyCol.TodayInHand;
                    //data.TomorrowDiff = dailyCol.TomorrowDiff;
                    //data.TomorrowNeed = dailyCol.TomorrowNeed;
                    //data.YesterdayAmountInHand = dailyCol.YesterdayAmountInHand;

                    WriteObjectsToFile(list, JsonFilePath);
                }
                else // New (Insert)
                {
                    InsertSingleObjectToListJson(JsonFilePath, dailyCol);

                    // Update In Hand and In Bank amount.
                    var inhand = new InHandAndBank()
                    {
                        Date         = dailyCol.Date,
                        InBank       = dailyCol.InBank.Value,
                        InHandAmount = dailyCol.TodayInHand.Value
                    };

                    InHandAndBank.AddInHand(inhand, dailyCol.TakenFromBank);
                }
            }
        }