예제 #1
0
        public IList <ContractCurrency> GetContractCurrencies(int ContractId)
        {
            //lay tat ca cong viec cap 1 khong co lien danh
            var _tasks = _itemRepository.Table.Where(c => c.StatusId != (int)TaskStatus.Destroy && c.ContractId == ContractId && c.ParentId == null && c.TaskProcuringAgencyId == null)
                         .ToList();

            var _currencies = _tasks
                              .Select(t => new
            {
                t.CurrencyId,
                t.TotalMoney
            })
                              .GroupBy(g => g.CurrencyId)
                              .Select(x =>
            {
                var _contractCurrency        = new ContractCurrency();
                _contractCurrency.ContractId = ContractId;
                _contractCurrency.CurrencyId = x.Key.GetValueOrDefault(0);
                if (_contractCurrency.CurrencyId > 0)
                {
                    _contractCurrency.currency = _currencyService.GetCurrencyById(_contractCurrency.CurrencyId);
                }
                _contractCurrency.TotalAmount = x.Sum(s => s.TotalMoney).GetValueOrDefault(0);
                return(_contractCurrency);
            })
                              .OrderBy(o => o.currency.DisplayOrder)
                              .ToList();

            return(_currencies);
        }
예제 #2
0
 public void CreateContractCurrency(ContractCurrency entity)
 {
     using (var db = new LogistoDb())
     {
         db.InsertWithIdentity(entity);
     }
 }
예제 #3
0
 public void UpdateContractCurrency(ContractCurrency entity)
 {
     using (var db = new LogistoDb())
     {
         db.ContractCurrencies.Where(w => w.ContractId == entity.ContractId && w.CurrencyId == entity.CurrencyId)
         .Set(s => s.BankAccountId, entity.BankAccountId)
         .Set(s => s.OurBankAccountId, entity.OurBankAccountId)
         .Update();
     }
 }
예제 #4
0
 public virtual IActionResult _GetTotalAmountTask(ContractPaymentPlanModel model)
 {
     if (model.PercentNum > 100)
     {
         model.ckPercentNumNote = "Tỷ lệ phần trăm vượt quá 100%.";
         return(JsonSuccessMessage("ok", model));
     }
     if (model.SelectedTaskIds.Count > 0)
     {
         var items = _workTaskService.GetTaskbyListTaskIds(model.SelectedTaskIds.ToList());
         model.AmountSummary = "";
         var _currencies = items
                           .Select(t => new
         {
             t.CurrencyId,
             t.TotalMoney
         })
                           .GroupBy(g => g.CurrencyId)
                           .Select(x =>
         {
             var _contractCurrency        = new ContractCurrency();
             _contractCurrency.ContractId = model.ContractId;
             _contractCurrency.CurrencyId = x.Key.GetValueOrDefault(0);
             if (_contractCurrency.CurrencyId > 0)
             {
                 _contractCurrency.currency = _currencyService.GetCurrencyById(_contractCurrency.CurrencyId);
             }
             _contractCurrency.TotalAmount = x.Sum(s => s.TotalMoney).GetValueOrDefault(0);
             return(_contractCurrency);
         })
                           .OrderBy(o => o.currency.DisplayOrder)
                           .ToList();
         model.AmountSummary = String.Join(", ", _currencies.Select(c => _priceFormatter.FormatPrice(((c.TotalAmount * model.PercentNum) / 100), true, c.currency)));
         //model.AmountSummary = _currencies.ToAmountSummary(_currencySettings.PrimaryExchangeRateCurrencyId);
         //if (_currencies.Count > 1)
         //{
         //    int count = _currencies.Count;
         //    int i = 0;
         //    foreach (var currencie in _currencies)
         //    {
         //        i = i + 1;
         //        if (i == count)
         //        {
         //            model.AmountSummary = model.AmountSummary + ((currencie.TotalAmount * model.PercentNum) / 100).ToVNStringNumber() + " " + currencie.currency.CurrencyCode;
         //        }
         //        else
         //        {
         //            model.AmountSummary = model.AmountSummary + ((currencie.TotalAmount * model.PercentNum) / 100).ToVNStringNumber() + " " + currencie.currency.CurrencyCode + " ,";
         //        }
         //    }
         //}
         //else
         //{
         //    foreach (var currencie in _currencies)
         //    {
         //        model.AmountSummary = model.AmountSummary + ((currencie.TotalAmount * model.PercentNum) / 100).ToVNStringNumber() + " " + currencie.currency.CurrencyCode;
         //    }
         //}
         return(JsonSuccessMessage("ok", model));
     }
     else
     {
         model.AmountSummary = "";
         model.PercentNum    = 0;
         return(JsonSuccessMessage("ok", model));
     }
 }
예제 #5
0
 /// <summary>
 /// Creates a new contract initiated by the current token user with the specified parameters.
 /// Requires <see cref="APIPermission.CONTRACTS" />
 /// <summary>
 /// <param name="userId">The id of the other user to begin the contract with.</param>
 /// <param name="position">The current user's position in the contract.</param>
 /// <param name="terms">The terms of the contract.</param>
 /// <param name="yourProduct">The user's product.</param>
 /// <param name="yourCurrency">The user's currency.</param>
 /// <param name="yourAmount">The user's amount (and currency if ContractCurrency.OTHER).</param>
 /// <param name="theirProduct">The other user's product.</param>
 /// <param name="theirCurrency">The other user's currency.</param>
 /// <param name="theirAmount">The other user's amount (and currency if ContractCurrency.OTHER).</param>
 /// <param name="threadId">The id of the thread to link this contract to.</param>
 /// <param name="middlemanId">The user id of the middleman.</param>
 /// <param name="timeoutDays">The time (in days) that the contract will expire.</param>
 /// <param name="isPublic">Whether this is a public contract.</param>
 /// <param name="paymentAddress">The payment address.</param>
 public ContractResult ContractCreate(int userId, ContractPosition position, string terms, string yourProduct = null, ContractCurrency yourCurrency = ContractCurrency.NONE, string yourAmount = null, string theirProduct = null, ContractCurrency theirCurrency = ContractCurrency.NONE, string theirAmount = null, int threadId = 0, int middlemanId = 0, int timeoutDays = 0, bool isPublic = false, string paymentAddress = null) => ContractRequest.Create(Client, userId, position, terms, yourProduct, yourCurrency, yourAmount, theirProduct, theirCurrency, theirAmount, threadId, middlemanId, timeoutDays, isPublic, paymentAddress);
예제 #6
0
        /// <summary>
        /// Creates a new contract initiated by the current token user with the specified parameters.
        /// Requires <see cref="APIPermission.CONTRACTS" />
        /// <summary>
        /// <param name="client">The client to use to process this request.</param>
        /// <param name="userId">The id of the other user to begin the contract with.</param>
        /// <param name="position">The current user's position in the contract.</param>
        /// <param name="terms">The terms of the contract.</param>
        /// <param name="yourProduct">The user's product.</param>
        /// <param name="yourCurrency">The user's currency.</param>
        /// <param name="yourAmount">The user's amount (and currency if ContractCurrency.OTHER).</param>
        /// <param name="theirProduct">The other user's product.</param>
        /// <param name="theirCurrency">The other user's currency.</param>
        /// <param name="theirAmount">The other user's amount (and currency if ContractCurrency.OTHER).</param>
        /// <param name="threadId">The id of the thread to link this contract to.</param>
        /// <param name="middlemanId">The user id of the middleman.</param>
        /// <param name="timeoutDays">The time (in days) that the contract will expire.</param>
        /// <param name="isPublic">Whether this is a public contract.</param>
        /// <param name="paymentAddress">The payment address.</param>
        public static ContractResult Create(HttpClient client, int userId, ContractPosition position, string terms, string yourProduct = null, ContractCurrency yourCurrency = ContractCurrency.NONE, string yourAmount = null, string theirProduct = null, ContractCurrency theirCurrency = ContractCurrency.NONE, string theirAmount = null, int threadId = 0, int middlemanId = 0, int timeoutDays = 0, bool isPublic = false, string paymentAddress = null)
        {
            var request = new ContractRequest();

            request.Type = RequestType.Write;
            request.Parameters.Add("_action", "new");
            request.Parameters.Add("_uid", userId);
            request.Parameters.Add("_position", position);
            request.Parameters.Add("_terms", terms);
            if (yourProduct != null)
            {
                request.Parameters.Add("_yourproduct", yourProduct);
            }
            if (yourCurrency != ContractCurrency.NONE)
            {
                request.Parameters.Add("_yourcurrency", yourCurrency.ToString());
            }
            if (yourAmount != null)
            {
                request.Parameters.Add("_youramount", yourAmount);
            }
            if (theirProduct != null)
            {
                request.Parameters.Add("_theirproduct", theirProduct);
            }
            if (theirCurrency != ContractCurrency.NONE)
            {
                request.Parameters.Add("_theircurrency", theirCurrency.ToString());
            }
            if (theirAmount != null)
            {
                request.Parameters.Add("_theiramount", theirAmount);
            }
            if (threadId != 0)
            {
                request.Parameters.Add("_tid", threadId);
            }
            if (middlemanId != 0)
            {
                request.Parameters.Add("_muid", middlemanId);
            }
            if (timeoutDays != 0)
            {
                request.Parameters.Add("_timeout", timeoutDays);
            }
            if (isPublic != false)
            {
                request.Parameters.Add("_public", "yes");
            }
            if (paymentAddress != null)
            {
                request.Parameters.Add("_address", paymentAddress);
            }
            request.AddResultParameters();
            return(request.ProcessRequest <ContractResult>(client));
        }