public static Cashflow CalculateLoanCashflow(Loan loan)
        {
            Cashflow cashflow = new Cashflow();

            if (loan.Duration <= 0 || loan.Rate <= 0 || loan.Amount <= 0)
            {
                throw new ArgumentOutOfRangeException("please ensure that none of your entered values are zero or less");
            }

            decimal totalMonthlyPayment = (loan.Amount * (loan.Rate / 1200)) / ((decimal)(1 - (Math.Pow(((double)(1 + loan.Rate / 1200)), -loan.Duration))));
            decimal remainingBalance    = loan.Amount;

            for (int month = 1; month <= loan.Duration; month++)
            {
                decimal interest  = remainingBalance * (loan.Rate / 1200);
                decimal principal = totalMonthlyPayment - interest;
                remainingBalance = remainingBalance - principal;
                cashflow.MonthlyPayments.Add(new MonthlyPayment()
                {
                    Interest         = interest,
                    Principal        = principal,
                    RemainingBalance = remainingBalance,
                    month            = month
                });
            }

            return(cashflow);
        }
Пример #2
0
        public static List <Cashflow> GetMonthlyCashflows(this List <AssetBase> assets)
        {
            List <ActivityBase> activities = new List <ActivityBase>();
            List <Cashflow>     result     = new List <Cashflow>();

            foreach (var asset in assets)
            {
                activities.AddRange(asset.GetActivitiesSync());
            }

            List <string> months = new List <string>();

            for (int i = 1; i <= 12; i++)
            {
                var time = DateTime.Now.AddMonths(i - 12);
                months.Add(time.ToString("MMM-yyyy"));
            }

            var activityGroups = activities.GroupBy(ac => ac.ActivityDate.ToString("MMM-yyyy"));

            foreach (var monthly in months)
            {
                Cashflow flow = new Cashflow()
                {
                    Expenses = activityGroups.Any(ac => ac.Key == monthly) ? activityGroups.Where(ac => ac.Key == monthly).Sum(ac => ac.Sum(m => m.Expenses.Sum(ex => ex.Amount))) : 0,
                    Income   = activityGroups.Any(ac => ac.Key == monthly) ? activityGroups.Where(ac => ac.Key == monthly).Sum(ac => ac.Sum(m => m.Incomes.Sum(inc => inc.Amount))) : 0,
                    Month    = monthly.Split('-').First()
                };
                result.Add(flow);
            }
            return(result);
        }
Пример #3
0
        public static Cashflow[] Aggregate(Cashflow[] cf1, Cashflow[] cf2)
        {
            if (cf1 == null)
            {
                return(cf2);
            }
            if (cf2 == null)
            {
                return(cf1);
            }

            var cf1Dict = cf1.ToDictionary(cf => cf.ToCfKey(), cf => cf);
            var cf2Dict = cf2.ToDictionary(cf => cf.ToCfKey(), cf => cf);

            foreach (var key in cf2Dict.Keys)
            {
                if (cf1Dict.ContainsKey(key))
                {
                    var cf = new Cashflow(cf1Dict[key])
                    {
                        PaymentAmount = cf1Dict[key].PaymentAmount + cf2Dict[key].PaymentAmount
                    };
                    cf1Dict[key] = cf;
                }
                else
                {
                    cf1Dict[key] = cf2Dict[key];
                }
            }

            return(cf1Dict.Select(x => x.Value).ToArray());
        }
Пример #4
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            if (!txtId.Text.Equals(""))
            {
                MessageBox.Show("A caixa de Id deve estar vazia, aperte em resetar para limpa-la.");
                return;
            }
            else if (allFullfilled())
            {
                var     productId  = Convert.ToInt64(cbProduct.SelectedValue);
                Product Product    = (Product)productService.GetById(productId);
                Storage newStorage = new Storage(dtValidity.Value, dtExpiration.Value, Convert.ToDouble(txtCost.Text), Convert.ToInt32(txtQuantity.Text), Convert.ToInt32(txtLot.Text), dtPurchase.Value)
                {
                    ProductId = productId
                };

                storageService.Insert(newStorage);

                Payment newPayment = new Payment(newStorage.Total, dtPurchase.Value, dtExpiration.Value, newStorage.StorageId);

                paymentService.Insert(newPayment);

                Cashflow newCashflow = new Cashflow()
                {
                    PaymentId = newPayment.PaymentId,
                    EarningId = null
                };

                cashflowService.Insert(newCashflow);

                resetForm();

                refreshDataGridView();
            }
        }
Пример #5
0
        private void btnPay_Click(object sender, EventArgs e)
        {
            if (txtId.Text.Trim().Equals(String.Empty))
            {
                MessageBox.Show("A caixa de Id não deve estar vazia, selecione um dono antes de alterar.");
                return;
            }
            else
            {
                Cashflow cashflow = cashflowService.GetById(Convert.ToInt64(txtId.Text));

                cashflow.Paid = true;

                if (cashflow.Earning != null)
                {
                    cashflow.Earning.Paid = true;
                    earningService.Alter(cashflow.Earning);
                }
                else if (cashflow.Payment != null)
                {
                    cashflow.Payment.Paid = true;
                    paymentService.Alter(cashflow.Payment);
                }

                cashflowService.Alter(cashflow);

                refreshDataGridViewCashflow();
                resetForm();
            }
        }
Пример #6
0
        public bool Delete(List <int> ids)
        {
            bool   result = false;
            string title;
            string message;

            if (ids.Count() == 0)
            {
                throw new Exception("Delete Cashflow: nothing to delete");
            }

            if (ids.Count() == 1)
            {
                title = "Delete Cashflow";
                Cashflow entity = this.cashflowRepository.Read(ids[0]);
                message = String.Format("Please confirm deletion of cashflow: {0}", entity.Name);
            }
            else
            {
                title   = "Delete Cashflows";
                message = String.Format("Please confirm deletion of {0} cashflows?", ids.Count());
            }


            if (this.dialogService.ShowMessageBox(title, message, MessageBoxButtonEnum.YesNo) == MessageBoxResultEnum.Yes)
            {
                result = this.cashflowRepository.Delete(ids);
            }

            return(result);
        }
Пример #7
0
        public bool InsertUpdate(Cashflow cashflow, OfficeManagementDbContext OfficeManagementDbContext)
        {
            bool isStatus = false;

            try
            {
                if (cashflow.Id > 0)
                {
                    Cashflow cashflowtemp = OfficeManagementDbContext.CashflowDbSet.Where(x => x.Id == cashflow.Id).FirstOrDefault();
                    if (cashflowtemp != null)
                    {
                        cashflowtemp.Direction      = cashflow.Direction;
                        cashflowtemp.Description    = cashflow.Description;
                        cashflowtemp.Amount         = cashflow.Amount;
                        cashflowtemp.IsActive       = cashflow.IsActive;
                        cashflowtemp.IsDeleted      = cashflow.IsDeleted;
                        cashflowtemp.Loggeddatetime = cashflow.Loggeddatetime;
                        cashflowtemp.ModifiedBy     = cashflow.ModifiedBy;
                        cashflowtemp.ModifiedDate   = cashflow.ModifiedDate;
                        OfficeManagementDbContext.CashflowDbSet.Update(cashflowtemp);
                        OfficeManagementDbContext.SaveChanges();
                    }
                }
                else
                {
                    OfficeManagementDbContext.CashflowDbSet.Add(cashflow);
                    OfficeManagementDbContext.SaveChanges();
                }
                isStatus = true;
            }
            catch (Exception ex)
            {
            }
            return(isStatus);
        }
Пример #8
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            if (!txtId.Text.Equals(String.Empty))
            {
                MessageBox.Show("O campo id deve estar vazio para fazer um novo registro de venda, resete o formulário para limpar os campos e tente novamente.");
            }
            else
            {
                var newSale = new Sale(dtSale.Value, dtExpiration.Value);
                newSale.ExpirationDate = dtExpiration.Value;
                saleService.Insert(newSale);

                var newEarning = new Earning(0, newSale.Date, newSale.ExpirationDate, newSale.SaleId);
                earningService.Insert(newEarning);

                var newCashflow = new Cashflow()
                {
                    EarningId = newEarning.EarningId,
                    PaymentId = null
                };

                cashflowService.Insert(newCashflow);

                resetForm();
            }
        }
        public decimal GetCashflowAmountAt(Cashflow cashflow, DateTime date, bool net)
        {
            if (cashflow.Type == Type.AOW)
            {
                return(CalculateAOW(date, net));
            }

            return(_getAmount.GetAmount(cashflow, date, net));
        }
Пример #10
0
        public Cashflow GetById(int Id, OfficeManagementDbContext OfficeManagementDbContext)
        {
            Cashflow cashflow = new Cashflow();

            try
            {
                cashflow = OfficeManagementDbContext.CashflowDbSet.Where(x => x.Id == Id).FirstOrDefault();
            }
            catch (Exception ex)
            {
            }
            return(cashflow);
        }
Пример #11
0
        public CashflowEditorViewModel(
            ICashflowRepository cashflowRepository,
            IBankAccountRepository bankAccountRepository,
            Cashflow entity
            )
        {
            this.cashflowRepository    = cashflowRepository;
            this.bankAccountRepository = bankAccountRepository;
            this.entity = entity;

            this.OpeningBalance.PropertyChanged += (s, e) =>
            {
                base.Validate();
            };
            base.ValidationHelper.AddInstance(this.OpeningBalance);
        }
        public void Initialize()
        {
            //IBankAccountRepository bankAccountRepo;
            //ITransferRepository transferRepo;


            List <CashflowProjectionTransfer> cashflowProjectionTransfers = null;

            //mockIProjectionTransferGenerator = new Mock<IProjectionTransferGenerator>();


            mockIProjectionTransferGenerator
            .Setup(s => s.GenerateCashflowProjectionTransfersAsync(
                       It.IsAny <List <CashflowBankAccount> >(),
                       It.IsAny <DateTime>(),
                       It.IsAny <DateTime>()
                       )
                   )
            .Returns(Task.Factory.StartNew(() => cashflowProjectionTransfers));

            //fakeBankAccountRepository = new FakeBankAccountRepository();

            //mockTransferFrequencyDateCalculatorFactory = new Mock<IScheduleFrequencyCalculatorFactory>();
            //mockTransferDirectionGenerator = new Mock<ITransferDirectionGenerator>();

            //mockTransferFrequencyDateCalculatorMonthly = new Mock<IScheduleFrequencyCalculator>();

            //mockTransferFrequencyDateCalculatorMonthly.Setup(s => s.CalculateNextDate(It.IsAny<Schedule>(), It.IsAny<DateTime>()))
            //    .Returns((Transfer t, DateTime d) => d.AddMonths(1));


            sut = new Cashflow(new CashflowProjection(mockIProjectionTransferGenerator.Object, null))
            {
                OpeningBalance       = 5000,
                StartDate            = new DateTime(2015, 08, 1),
                CashflowBankAccounts = new List <CashflowBankAccount>()
                {
                    new CashflowBankAccount()
                    {
                        BankAccount = new BankAccount()
                        {
                            BankAccountId = 1
                        }
                    }
                }
            };
        }
Пример #13
0
        private void Add()
        {
            int id = this.cashflowAgent.Add();

            if (id > 0)
            {
                Cashflow entity = this.cashflowRepository.Read(id);

                this.cashflows.Add(entity.CashflowId, entity);

                var vm = new CashflowItemViewModel(entity);

                base.DataList.Add(vm);
                base.DataList.ToList().ForEach(i => i.IsSelected = false);
                vm.IsSelected = true;
            }
        }
Пример #14
0
        /// <summary>
        /// Insert new Cashflow object into db
        /// </summary>
        /// <param name="cashflow">Cashflow object (CashflowID = 0)</param>
        /// <returns>New Id (also set CashflowID)</returns>
        public int InsertCashflow(CommonData.Cashflow cashflow)
        {
            Cashflow db_cashflow = new Cashflow()
            {
                CashflowID = cashflow.CashflowID,
                Summa      = cashflow.Summa,
                Time       = StorageLib.ToDbTime(cashflow.Time),
                TradeID    = cashflow.TradeID,
                Spend      = (byte)cashflow.Spend,
                AccountID  = cashflow.AccountID
            };

            _da.DbContext.Insert(db_cashflow);
            cashflow.CashflowID = db_cashflow.CashflowID;

            return(cashflow.CashflowID);
        }
Пример #15
0
        private async Task <Guid?> HandleCashflow(Request request, CancellationToken cancellationToken)
        {
            if (request.Cashflow is null)
            {
                return(null);
            }

            var cashflowRequest = request.Cashflow;
            var cashflow        = Cashflow.Create(cashflowRequest.EffectiveDate, cashflowRequest.IntervalType,
                                                  cashflowRequest.Frequency, cashflowRequest.Recurrence, request.Amount, request.Description,
                                                  request.CategoryId, request.AccountId, _userContext.UserId);

            cashflow = cashflow.SetTags(request.Tags);

            await _cashflowRepository.SaveAsync(cashflow, cancellationToken);

            return(cashflow.Id);
        }
Пример #16
0
    public async Task SaveAsync(Cashflow cashflow, CancellationToken cancellationToken)
    {
        var transaction = _context.Transaction;

        var id     = cashflow.Id;
        var userId = cashflow.UserId;

        var entity = await transaction.FindByIdAsync <CashflowEntity>(new { Id = id, UserId = userId });

        if (entity is null)
        {
            await transaction.InsertAsync(_cashflowMapper.MapToEntity(cashflow))
            .ConfigureAwait(false);
        }
        else
        {
            await transaction.UpdateAsync(_cashflowMapper.MapToEntity(cashflow)).ConfigureAwait(false);
        }
    }
Пример #17
0
        public bool Delete(int Id, OfficeManagementDbContext OfficeManagementDbContext)
        {
            bool isStatus = false;

            try
            {
                Cashflow cashflow = OfficeManagementDbContext.CashflowDbSet.Where(x => x.Id == Id).FirstOrDefault();
                cashflow.IsDeleted    = true;
                cashflow.ModifiedBy   = 1;
                cashflow.ModifiedDate = DateTime.Now;
                OfficeManagementDbContext.CashflowDbSet.Update(cashflow);
                OfficeManagementDbContext.SaveChanges();
                isStatus = true;
            }
            catch (Exception ex)
            {
            }
            return(isStatus);
        }
Пример #18
0
    public CashflowEntity MapToEntity(Cashflow model)
    {
        var entity = new CashflowEntity
        {
            Id            = model.Id,
            AccountId     = model.AccountId,
            Amount        = model.Amount,
            CategoryId    = model.CategoryId,
            Description   = model.Description,
            EffectiveDate = model.EffectiveDate,
            Frequency     = model.Frequency,
            Inactive      = model.Inactive,
            IntervalType  = model.IntervalType,
            Recurrence    = model.Recurrence,
            Tags          = _tagsMapper.Map(model.Tags),
            UserId        = model.UserId
        };

        return(entity);
    }
Пример #19
0
        public bool Edit(int id)
        {
            bool result = false;

            Cashflow entity = this.cashflowRepository.Read(id);

            var editor = this.cashflowEditorViewModelFactory.Create(entity);

            editor.InitializeForAddEdit(false);

            while (this.dialogService.ShowDialogView(editor))
            {
                result = this.cashflowRepository.Update(entity);
                if (result)
                {
                    break;
                }
            }

            this.cashflowEditorViewModelFactory.Release(editor);
            this.cashflowFactory.Release(entity);

            return(result);
        }
Пример #20
0
    public Cashflow?MapToModelOrNull(CashflowEntity?entity)
    {
        if (entity is null)
        {
            return(null);
        }

        var model = new Cashflow()
        {
            Id            = entity.Id,
            AccountId     = entity.AccountId,
            Amount        = entity.Amount,
            CategoryId    = entity.CategoryId,
            Description   = entity.Description,
            EffectiveDate = entity.EffectiveDate,
            Frequency     = entity.Frequency,
            Inactive      = entity.Inactive,
            IntervalType  = entity.IntervalType,
            Recurrence    = entity.Recurrence,
            UserId        = entity.UserId
        };

        return(model.SetTags(_tagsMapper.Map(entity.Tags)));
    }
Пример #21
0
        public async Task <IActionResult> AddOperatingExpense([FromBody] OperatingExpense operatingExpense)
        {
            var orgId = getOrg();

            if (operatingExpense != null)
            {
                operatingExpense.Id             = Guid.NewGuid();
                operatingExpense.OrganisationId = orgId;

                var expenseType = _context.Expenses.Where(x => x.Id == operatingExpense.ExpenseId).FirstOrDefault().ExpenseType;
                if (expenseType == null)
                {
                    expenseType = "Others";
                }


                try
                {
                    _context.Add(operatingExpense);
                    _context.SaveChanges();

                    Cashflow credit = new Cashflow()
                    {
                        Id             = Guid.NewGuid(),
                        FlowType       = "OE",
                        FlowTypeId     = operatingExpense.Id,
                        DebitCredit    = "C",
                        FlowDetails    = "Operating Expenses - " + expenseType + " " + operatingExpense.Description,
                        Amount         = operatingExpense.Amount,
                        OrganisationId = orgId
                    };

                    _context.Add(credit);
                    await _context.SaveChangesAsync();

                    Transaction tCredit = new Transaction()
                    {
                        Id = Guid.NewGuid(),
                        TransactionType    = "OE",
                        TransactionId      = operatingExpense.Id,
                        DebitCredit        = "C",
                        TransactionDetails = "Operating Expenses - " + expenseType + " " + operatingExpense.Description,
                        Amount             = operatingExpense.Amount,
                        OrganisationId     = orgId
                    };

                    _context.Add(tCredit);
                    await _context.SaveChangesAsync();



                    return(Json(new
                    {
                        msg = "Success"
                    }));
                }
                catch
                {
                    return(Json(new
                    {
                        msg = "Failed"
                    }));
                }
            }

            return(Json(new
            {
                msg = "No Data"
            }));
        }
Пример #22
0
 public CashflowItemViewModel(Cashflow entity)
 {
     this.entity = entity;
 }
Пример #23
0
 /// <summary>
 /// Adds a cashflow for the given product number and simulation number
 /// </summary>
 /// <param name="productNumber">The product number.</param>
 /// <param name="pathNumber">The path number.</param>
 /// <param name="cf">The cashflow.</param>
 public void Add(int productNumber, int pathNumber, Cashflow cf)
 {
     allCFs[productNumber][pathNumber].Add(cf);
 }
Пример #24
0
 public decimal GetAmount(Cashflow cashflow, DateTime date, bool net)
 {
     return(2);
 }
Пример #25
0
        public static async Task <HttpResponseMessage> Run(
            [HttpTrigger(
                 AuthorizationLevel.Function,
                 "post",
                 Route = "cashflows/add/{login}/")
            ] HttpRequestMessage req,
            string login,
            [Table("ExpensesApp")] ICollector <Cashflow> outTable,
            [Table("ExpensesApp", "user_{login}", "user_{login}")] UserLogInData user,
            [Queue("expenses-addcashflow")] CloudQueue queue,
            [Table("ExpensesApp")] CloudTable table,
            TraceWriter log)
        {
            AddCashFlowDto dto = null;

            try
            {
                log.Info($"json dto: " + req.Content);
                dto = await req.Content.ReadAsDeserializedJson <AddCashFlowDto>();
            }
            catch
            {
                log.Info("AddCashFlow response: BadRequest - cannot read dto object");
                return(req.CreateResponse(
                           statusCode: HttpStatusCode.BadRequest,
                           value: "Please pass a valid dto object in the request content"));
            }
            if (login == null)
            {
                log.Info("AddCashFlow response: BadRequest - login is null");
                return(req.CreateResponse(
                           statusCode: HttpStatusCode.BadRequest,
                           value: "Please pass a login on the query string or in the request body"));
            }
            if (user == null)
            {
                log.Info($"AddCashFlow response: BadRequest - user does not exist");
                return(req.CreateResponse(
                           statusCode: HttpStatusCode.BadRequest,
                           value: "User with given login does not exist"
                           ));
            }

            var cashflowBase = new Cashflow()
            {
                DateTime     = dto.DateTime,
                CategoryGuid = dto.CategoryGuid,
                Amount       = JsonConvert.SerializeObject(dto.Amount),
                Details      = JsonConvert.SerializeObject(dto.Details),
                WalletGuid   = dto.WalletGuid
            };
            var dateTimeInverted = RowKeyUtils.GetInvertedDateString(dto.DateTime);
            var guid             = Guid.NewGuid();

            if (user.BelongsToGroup)
            {
                var cashflowHousehold = new Cashflow(cashflowBase)
                {
                    PartitionKey = user.HouseholdId,
                    RowKey       = $"householdCashflow_{dateTimeInverted}_{guid}"
                };
                outTable.Add(cashflowHousehold);
                log.Info($"Added cashflowHousehold PK={cashflowHousehold.PartitionKey} RK={cashflowHousehold.RowKey}");
            }
            var cashflowUser = new Cashflow(cashflowBase)
            {
                PartitionKey = user.HouseholdId,
                RowKey       = $"userCashflow_{login}_{dateTimeInverted}_{guid}"
            };

            outTable.Add(cashflowUser);
            log.Info($"Added cashflowHousehold PK={cashflowUser.PartitionKey} RK={cashflowUser.RowKey}");

            //var cashflowHouseholdCategory = new Cashflow(cashflowBase)
            //{
            //    PartitionKey = user.HouseholdId,
            //    RowKey = $"householdCategoryCashflow_{dto.CategoryGuid}_{dateTimeInverted}_{guid}"
            //};
            //outTable.Add(cashflowHouseholdCategory);
            //log.Info($"Added cashflowHousehold PK={cashflowHouseholdCategory.PartitionKey} RK={cashflowHouseholdCategory.RowKey}");

            //var cashflowUserCategory = new Cashflow(cashflowBase)
            //{
            //    PartitionKey = user.HouseholdId,
            //    RowKey = $"userCategoryCashflow_{login}_{dto.CategoryGuid}_{dateTimeInverted}_{guid}"
            //};
            //outTable.Add(cashflowUserCategory);
            //log.Info($"Added cashflowHousehold PK={cashflowUserCategory.PartitionKey} RK={cashflowUserCategory.RowKey}");

            var addMessageDto = new AddMessageToAddCashflowQueueDto()
            {
                Amount             = dto.Amount,
                HouseholdPk        = user.HouseholdId,
                HouseholdRk        = user.HouseholdId,
                WalletGuid         = dto.WalletGuid,
                CategoryGuid       = dto.CategoryGuid,
                UserBelongsToGroup = user.BelongsToGroup,
                Login = login
            };

            if (user.BelongsToGroup)
            {
                var message = JsonConvert.SerializeObject(addMessageDto);
                await queue.AddMessageAsync(new CloudQueueMessage(message));

                log.Info($"Enqueued message {message}");
            }
            else
            {
                log.Info("User does not belong to a group. Only his wallet will be updated");
                await UpdateUsersWallet(addMessageDto, table, log);
            }

            return(req.CreateResponse(HttpStatusCode.OK));
        }
Пример #26
0
 public void NetIncome_CorrectCalculation()
 {
     Assert.AreEqual(15000f, Cashflow.NetIncome(25000, 10000));
 }
Пример #27
0
 public void SavingsRatio_CorrectCalculation()
 {
     Assert.AreEqual(0.8f, Cashflow.SavingsRatio(25000, 5000));
 }
Пример #28
0
 public void ExpenseRatio_CorrectCalculation()
 {
     Assert.AreEqual(0.2f, Cashflow.ExpenseRatio(5000, 25000));
 }
        public async Task <IActionResult> AddNewStock([FromBody] NewInventory newInventory)
        {
            var orgId = getOrg();

            if (newInventory != null)
            {
                var stockRecord = _context.StockRecords.Where(x => x.ProductServiceId == newInventory.ProductServiceId).FirstOrDefault();

                newInventory.Id             = Guid.NewGuid();
                newInventory.OrganisationId = orgId;

                var product = _context.ProductServices.Where(x => x.Id == newInventory.ProductServiceId).FirstOrDefault();

                try
                {
                    _context.Add(newInventory);
                    await _context.SaveChangesAsync();

                    float remainQuantity = stockRecord.QuantityRemain;
                    float unitPrice      = stockRecord.CostPrice;
                    float totalprice     = remainQuantity * unitPrice;

                    stockRecord.QuantityRemain  = remainQuantity + newInventory.Quantity;
                    stockRecord.AllTimeQuantity = stockRecord.AllTimeQuantity + newInventory.Quantity;
                    stockRecord.CostPrice       = (totalprice + (newInventory.TotalPrice)) / stockRecord.QuantityRemain;

                    _context.Update(stockRecord);
                    await _context.SaveChangesAsync();

                    Transaction tCredit = new Transaction()
                    {
                        Id = Guid.NewGuid(),
                        TransactionType    = "IT",
                        TransactionId      = newInventory.Id,
                        DebitCredit        = "C",
                        TransactionDetails = "Inventory - " + newInventory.Quantity + " pcs " + product.ProductServiceName,
                        Amount             = newInventory.TotalPrice,
                        OrganisationId     = orgId
                    };

                    _context.Add(tCredit);
                    await _context.SaveChangesAsync();

                    Cashflow credit = new Cashflow()
                    {
                        Id             = Guid.NewGuid(),
                        FlowType       = "IT",
                        FlowTypeId     = newInventory.Id,
                        DebitCredit    = "C",
                        FlowDetails    = "Inventory - " + newInventory.Quantity + " pcs " + product.ProductServiceName,
                        Amount         = newInventory.TotalPrice,
                        OrganisationId = orgId
                    };

                    _context.Add(credit);
                    await _context.SaveChangesAsync();


                    return(Json(new
                    {
                        msg = "Success"
                    }));
                }
                catch
                {
                    return(Json(new
                    {
                        msg = "Failed"
                    }));
                }


                //StatusMessage = "New Vendor successfully created.";
            }

            //StatusMessage = "Error! Check fields...";
            //ViewData["StatusMessage"] = StatusMessage;
            return(Json(new
            {
                msg = "No Data"
            }));
        }
Пример #30
0
 //carrega os dados do cashflow selecionado nos controles
 private void loadCashflowData(Cashflow cashflow)
 {
     txtId.Text = Convert.ToString(cashflow.CashflowId);
 }