public JsonCalculateTotalModel(OfferCost cost) { var currency = Persistent.Currencies.GetById(cost.CurrencyID); ProductPrice = $"{cost.CustomerCost} {currency.Symbol}"; FuelPrice = $"{cost.IntegerRealCost} Fuel"; }
public OfferCost GetOfferCost(MarketOffer offer, int amount, Region destinationRegion, bool useFuel) { var destinationCountry = destinationRegion.Country; OfferCost cost = new OfferCost(); var sellerRegion = offer.Company.Entity.GetCurrentRegion(); if (useFuel) { var buyerRegion = destinationRegion; var path = regionService.GetPathBetweenRegions(buyerRegion, sellerRegion, new TradeRegionSelector(offer.Company.Region.Country, destinationCountry, embargoRepository)); if (path == null) { return(null); } cost.FuelCost = GetFuelCostForOffer(offer, path, amount); } cost.Set(CalculateProductCost(amount, offer.Price, offer.Company.Region.CountryID, destinationCountry.ID, (ProductTypeEnum)offer.ProductID)); cost.CurrencyID = offer.CurrencyID; cost.FuelCost = Math.Round(cost.FuelCost, 2); return(cost); }
public OfferCost GetOfferCost(MarketOfferModel offer, Entity buyer, int amount) { OfferCost cost = new OfferCost(); var sellerRegion = Persistent.Regions.GetById(offer.CompanyRegionID); var sellerCountry = Persistent.Countries.GetById(offer.CompanyCountryID); if (CanUseFuel(buyer)) { var buyerRegion = buyer.GetCurrentRegion(); var path = regionService.GetPathBetweenRegions(buyerRegion, sellerRegion, new TradeRegionSelector(sellerCountry, buyer.GetCurrentCountry(), embargoRepository)); if (path == null) { return(null); } cost.FuelCost = GetFuelCostForOffer(offer, path, amount); } cost.Set(CalculateProductCost(amount, offer.Price, offer.CompanyCountryID, buyer.GetCurrentCountry().ID, (ProductTypeEnum)offer.ProductID)); cost.CurrencyID = offer.CurrencyID; cost.FuelCost = Math.Round(cost.FuelCost, 2); return(cost); }
private void UseFuelInBuyProcess(int eqID, OfferCost cost) { equipmentRepository.RemoveEquipmentItem(eqID, (int)ProductTypeEnum.Fuel, 1, cost.IntegerRealCost); }
private TransactionResult makeLocalCountryTransactionForBuy(MarketOffer offer, Entity buyer, Entity sellerEntity, Country localCountry, OfferCost cost, Currency currency, int amount, int walletID) { if (cost.VatCost.HasValue == false || cost.VatCost == 0) { return(TransactionResult.Success); } var localCountryMoney = new Money() { Amount = (decimal)(cost.VatCost), Currency = currency }; var localCountryTransaction = new Transaction() { Arg1 = "Local Country Cost - Market", Arg2 = string.Format("{0}({1}) bought {2} {3} from {4}({5})", buyer.Name, buyer.EntityID, amount, ((ProductTypeEnum)offer.ProductID).ToHumanReadable(), sellerEntity.Name, sellerEntity.EntityID), DestinationEntityID = localCountry.ID, Money = localCountryMoney, SourceEntityID = sellerEntity.EntityID, TransactionType = TransactionTypeEnum.MarketOfferCost, SourceWalletID = walletID }; return(transactionService.MakeTransaction(localCountryTransaction)); }
private TransactionResult makeCompanyTransactionForBuy(MarketOffer offer, Entity buyer, Entity sellerEntity, OfferCost cost, Currency currency, int amount, int walletID) { var companyMoney = new Money() { Amount = (decimal)(cost.BasePrice), Currency = currency }; var companyTransaction = new Transaction() { Arg1 = "Company Cost - Market", Arg2 = string.Format("{0}({1}) bought {2} {3} from {4}({5})", buyer.Name, buyer.EntityID, amount, ((ProductTypeEnum)offer.ProductID).ToHumanReadable(), sellerEntity.Name, sellerEntity.EntityID), DestinationEntityID = sellerEntity.EntityID, Money = companyMoney, SourceEntityID = buyer.EntityID, TransactionType = TransactionTypeEnum.MarketOfferCost, SourceWalletID = walletID }; return(transactionService.MakeTransaction(companyTransaction)); }
private TransactionResult makeExportTransactionForBuy(MarketOffer offer, Entity buyer, Entity sellerEntity, OfferCost cost, int amount, int walletID) { var exportCountry = buyer.GetCurrentCountry(); var exportTransaction = new Transaction() { Arg1 = "Export Tax Cost - Market", Arg2 = string.Format("{0}({1}) bought {2} {3} from {4}({5})", buyer.Name, buyer.EntityID, amount, ((ProductTypeEnum)offer.ProductID).ToHumanReadable(), sellerEntity.Name, sellerEntity.EntityID), DestinationEntityID = exportCountry.ID, Money = cost.ExportMoney, SourceEntityID = buyer.EntityID, TransactionType = TransactionTypeEnum.MarketOfferCost, SourceWalletID = walletID }; return(transactionService.MakeTransaction(exportTransaction)); }
public override void FillCongressVotingArguments(CongressVoting voting) { voting.Argument1 = OfferCost.ToString(); }