コード例 #1
0
        private static void UpdateAgencyCurrency(CustomFormData stageDetails, string agencyCurrency)
        {
            JObject stageDetailsObj = JObject.Parse(stageDetails.Data);

            stageDetailsObj["agencyCurrency"] = agencyCurrency;
            stageDetails.Data = stageDetailsObj.ToString();
        }
コード例 #2
0
        public void InitData()
        {
            var cost            = new Cost();
            var paymentCurrency = new Currency();
            var project         = new Project();

            var agency  = new Agency();
            var country = new Country();
            var owner   = new CostOwner();
            var notificationSubscribers = new NotificationSubscriber();
            var userBusinessRoles       = new List <UserBusinessRole>();


            var costStages               = new List <CostStage>();
            var costStageRevisions       = new List <CostStageRevision>();
            var selectRevisionTravelCost = new TravelCost();
            var oeRevisionTravelCost     = new TravelCost();
            var region              = new Region();
            var payments            = new List <CostStageRevisionPaymentTotal>();
            var cli                 = new List <CostLineItem>();
            var stageDetails        = new CustomObjectData();
            var productionDetails   = new CustomObjectData();
            var supportingDocuments = new List <SupportingDocument>();
            var lstObjectData       = new List <CustomObjectData>();
            var costFormDetails     = new List <CostFormDetails>();
            var customFormData      = new CustomFormData();
            var approvals           = new List <Approval>();
            var approvalMembers     = new List <ApprovalMember>();
        }
コード例 #3
0
        public bool GetIsCostSectionCurrencyLocked(int currentStageOrder, CustomFormData stageDetails)
        {
            // this is called on CreateVersion to determine if the cost sections should have their currencies locked
            // if we are creating a version of the first stage with cost line items (Original Estimate)
            var stageDetailsForm = JsonConvert.DeserializeObject <PgStageDetailsForm>(stageDetails.Data);

            return(!(currentStageOrder == 1 || (currentStageOrder == 2 && stageDetailsForm.IsAIPE)));
        }
 //Parsing: &first-name=tom&item-0=blah&item-1-delete=1
 public object Post(CustomFormData request)
 {
     return(new CustomFormDataResponse
     {
         FirstName = Request.FormData["first-name"],
         Item0 = Request.FormData["item-0"],
         Item1Delete = Request.FormData["item-1-delete"]
     });
 }
コード例 #5
0
 //Parsing: &first-name=tom&item-0=blah&item-1-delete=1
 public object Post(CustomFormData request)
 {
     return new CustomFormDataResponse
     {
         FirstName = Request.FormData["first-name"],
         Item0 = Request.FormData["item-0"],
         Item1Delete = Request.FormData["item-1-delete"]
     };
 }
コード例 #6
0
        //Parsing: &first-name=tom&item-0=blah&item-1-delete=1
        public object Post(CustomFormData request)
        {
            var httpReq = base.RequestContext.Get <IHttpRequest>();

            return(new CustomFormDataResponse
            {
                FirstName = httpReq.FormData["first-name"],
                Item0 = httpReq.FormData["item-0"],
                Item1Delete = httpReq.FormData["item-1-delete"]
            });
        }
コード例 #7
0
		//Parsing: &first-name=tom&item-0=blah&item-1-delete=1
		public object Post(CustomFormData request)
		{
			var httpReq = base.RequestContext.Get<IHttpRequest>();

			return new CustomFormDataResponse
			{
				FirstName = httpReq.FormData["first-name"],
				Item0 = httpReq.FormData["item-0"],
				Item1Delete = httpReq.FormData["item-1-delete"]
			};
		}
コード例 #8
0
        private static void UpdateDpvCurrency(CustomFormData productionDetails, Guid dpvCurrencyId)
        {
            JObject productionDetailsObj = JObject.Parse(productionDetails.Data);

            productionDetailsObj["directPaymentVendor"]["currencyId"] = dpvCurrencyId;
            foreach (var node in productionDetailsObj)
            {
                // Update productionCompany or postProductionCompany or digitalDevelopmentCompany and so on...
                if (node.Key.IndexOf("company", StringComparison.OrdinalIgnoreCase) > 0)
                {
                    node.Value["currencyId"] = dpvCurrencyId;
                }
            }
            productionDetails.Data = productionDetailsObj.ToString();
        }
コード例 #9
0
        public async Task <IUpdateCostResponse> UpdateCost(UserIdentity userIdentity, Guid costId, Guid latestRevisionId, CostType costType, IStageDetails stageDetails,
                                                           IProductionDetails productionDetails)
        {
            var currentCost = await _efContext.Cost
                              .Include(c => c.LatestCostStageRevision)
                              .ThenInclude(c => c.CostStage)
                              .Include(c => c.LatestCostStageRevision)
                              .ThenInclude(x => x.StageDetails)
                              .Include(c => c.LatestCostStageRevision)
                              .ThenInclude(x => x.ProductDetails)
                              .Where(c => c.Id == costId)
                              .FirstAsync();

            var oldStageForm             = JsonConvert.DeserializeObject <PgStageDetailsForm>(currentCost.LatestCostStageRevision.StageDetails.Data);
            var oldProductionForm        = JsonConvert.DeserializeObject <PgProductionDetailsForm>(currentCost.LatestCostStageRevision.ProductDetails.Data);
            var newStageDetailsForm      = stageDetails.Data.ToModel <PgStageDetailsForm>();
            var newProductionDetailsForm = productionDetails.Data.ToModel <PgProductionDetailsForm>();

            var newProductionDetails = new CustomFormData {
                Data = JsonConvert.SerializeObject(productionDetails.Data)
            };
            var newStageDetails = new CustomFormData {
                Data = JsonConvert.SerializeObject(stageDetails.Data)
            };
            var costStageModel = currentCost.LatestCostStageRevision.CostStage.StageOrder == 1
                ? await BuildCostFirstStageModel(newStageDetailsForm, userIdentity.Id, costType, stageDetails)
                : null;

            //var newCurrency = await _currencyService.GetCurrency(stageDetailsForm, productionDetailsForm);
            var newCurrency = await _currencyService.GetCurrencyIfChanged(oldStageForm, oldProductionForm, newStageDetailsForm, newProductionDetailsForm);

            var response = new UpdateCostResponse
            {
                Approvals         = await GetApprovals(costType, stageDetails, userIdentity.Id, latestRevisionId, costId),
                ProductionDetails = newProductionDetails,
                StageDetails      = newStageDetails,
                // Re-generate first stage model only. It can't be changed later
                CurrentCostStageModel = costStageModel,
                NewCurrency           = newCurrency,
                DpvSelected           = newProductionDetailsForm.DirectPaymentVendor != null && oldProductionForm?.DirectPaymentVendor == null,
                AipeSelected          = newStageDetailsForm.IsAIPE && (oldStageForm == null || !oldStageForm.IsAIPE)
            };

            return(response);
        }
コード例 #10
0
        public async Task Process_Cost_Production_Aipe_False_DoesNothing()
        {
            var data           = "{\"smoId\": null, \"title\": \"ADC - 2006 Aipe true(1)\", \"isAIPE\": false, \"campaign\": \"Aquafresh Campaign\", \"costType\": \"Production\", \"projectId\": \"5a16841442eba4001f6f5f6b\", \"contentType\": {\"id\": \"5c168fa6-8264-48db-9786-e19ecd6242e4\", \"key\": \"Video\", \"value\": \"Video\", \"visible\": true, \"projects\": null, \"dictionaryId\": \"27582bdd-fb57-4349-aa39-b992cac4add6\"}, \"description\": \"ADC - 2006 Aipe true(1)\", \"budgetRegion\": {\"id\": \"27582bdd-fb57-4349-aa39-b992cac4add6\", \"key\": \"NORTHERN AMERICA AREA\", \"name\": \"North America\"}, \"organisation\": {\"id\": \"27582bdd-fb57-4349-aa39-b992cac4add6\", \"key\": \"RBU\", \"value\": \"RBU\", \"visible\": true, \"projects\": null, \"dictionaryId\": \"27582bdd-fb57-4349-aa39-b992cac4add6\"}, \"initialBudget\": 65432, \"agencyCurrency\": \"GBP\", \"agencyProducer\": [\"Aaron Royer(Grey)\"], \"productionType\": {\"id\": \"27582bdd-fb57-4349-aa39-b992cac4add6\", \"key\": \"Full Production\", \"value\": \"Full Production\"}, \"IsCurrencyChanged\": false, \"agencyTrackingNumber\": \"1234567890\"}";
            var customFormData = new CustomFormData
            {
                Data = data
            };
            var revision = new CostStageRevision
            {
                StageDetails = customFormData
            };
            var cost = new Cost
            {
                CostType = CostType.Production,
                LatestCostStageRevision = revision
            };

            await _target.Process(_user, cost);

            _activityLogServiceMock.Verify(s => s.Log(It.IsAny <IActivityLogEntry>()), Times.Never);
        }
コード例 #11
0
        public void Setup()
        {
            _target = new CostLineItemUpdater(_efContextMock.Object,
                                              _revisionServiceMock.Object,
                                              _templateServiceMock.Object,
                                              new CostSectionFinder(),
                                              _costExchangeRateServiceMock.Object);
            var cost = new Cost();
            var costStageRevision = new CostStageRevision()
            {
                CostLineItems = new List <CostLineItem> {
                    new CostLineItem {
                    }
                }
            };
            var costTemplateVersion = new CostTemplateVersion();
            var costTemplate        = new CostTemplate();
            var fieldDefinitions    = new CustomFormData();
            var usd  = new Currency();
            var euro = new Currency();
            var gbp  = new Currency();

            cost.Id = _costId;
            costStageRevision.Id = _costStageRevisionId;

            cost.LatestCostStageRevision   = costStageRevision;
            cost.LatestCostStageRevisionId = _costStageRevisionId;
            cost.CostTemplateVersion       = costTemplateVersion;
            cost.CostTemplateVersionId     = _costTemplateVersionId;

            costTemplateVersion.CostTemplate = costTemplate;
            costTemplateVersion.Id           = _costTemplateVersionId;

            costTemplate.FieldDefinitions = fieldDefinitions;

            euro.Code = "EUR";
            usd.Code  = "USD";
            gbp.Code  = "GBP";

            euro.Id = Guid.NewGuid();
            usd.Id  = _usdCurrencyId;
            gbp.Id  = _gbpCurrencyId;

            var costs = new List <Cost> {
                cost
            };

            _costStageRevisions = new List <CostStageRevision> {
                costStageRevision
            };
            var currencies = new List <Currency> {
                euro, usd, gbp
            };

            _efContextMock.MockAsyncQueryable(costs.AsQueryable(), c => c.Cost);
            _efContextMock.MockAsyncQueryable(_costStageRevisions.AsQueryable(), c => c.CostStageRevision);
            _efContextMock.MockAsyncQueryable(currencies.AsQueryable(), c => c.Currency);

            var stageDetails = new PgStageDetailsForm
            {
                ContentType = new core.Builders.DictionaryValue
                {
                    Id    = Guid.NewGuid(),
                    Key   = "Video",
                    Value = "Video"
                },
                CostType       = dataAccess.Entity.CostType.Production.ToString(),
                ProductionType = new core.Builders.DictionaryValue
                {
                    Id    = Guid.NewGuid(),
                    Key   = "Full Production",
                    Value = "Full Production"
                },
                Title = "Cost Title"
            };

            _revisionServiceMock.Setup(csr => csr.GetStageDetails <PgStageDetailsForm>(_costStageRevisionId)).ReturnsAsync(stageDetails);

            var costTemplateVersionModel   = new CostTemplateVersionModel();
            var productionDetailCollection = new List <ProductionDetailsTemplateModel>();
            var productionDetails          = new ProductionDetailsTemplateModel();

            _form = new ProductionDetailsFormDefinitionModel
            {
                Name           = FormName,
                Label          = "Full production",
                ProductionType = Constants.ProductionType.FullProduction
            };
            var section = new CostLineItemSectionTemplateModel();
            var item    = new CostLineItemSectionTemplateItemModel();

            section.Name = SectionName;
            item.Name    = ItemName;

            section.Items = new List <CostLineItemSectionTemplateItemModel> {
                item
            };
            _form.CostLineItemSections = new List <CostLineItemSectionTemplateModel> {
                section
            };
            productionDetails.Forms = new List <ProductionDetailsFormDefinitionModel> {
                _form
            };
            productionDetails.Type = "Video";

            productionDetailCollection.Add(productionDetails);
            costTemplateVersionModel.ProductionDetails = productionDetailCollection;
            _templateServiceMock.Setup(ts => ts.GetCostTemplateVersionModel(It.IsAny <Guid>())).ReturnsAsync(costTemplateVersionModel);

            _userIdentity = new UserIdentity
            {
                Id        = _userId,
                IpAddress = "127.0.0.1"
            };

            var expectedExchangeRates = new List <ExchangeRate>()
            {
                new ExchangeRate {
                    FromCurrency = _usdCurrencyId,
                    Rate         = 1
                },
            };

            _costExchangeRateServiceMock.Setup(cer => cer.GetExchangeRatesByDefaultCurrency(It.IsAny <Guid>()))
            .ReturnsAsync(expectedExchangeRates);
        }
コード例 #12
0
        public void Setup()
        {
            _target = new CostCurrencyUpdater(_efContextMock.Object, _revisionServiceMock.Object);

            var costTemplateVersion = new CostTemplateVersion();
            var costTemplate        = new CostTemplate();
            var fieldDefinitions    = new CustomFormData();
            var usd  = new Currency();
            var euro = new Currency();

            _cost.Id = _costId;
            _costStageRevision.Id             = _costStageRevisionId;
            _costStageRevision.StageDetailsId = Guid.NewGuid();


            _cost.LatestCostStageRevision   = _costStageRevision;
            _cost.LatestCostStageRevisionId = _costStageRevisionId;
            _cost.CostTemplateVersion       = costTemplateVersion;
            _cost.CostTemplateVersionId     = _costTemplateVersionId;

            costTemplateVersion.CostTemplate = costTemplate;
            costTemplateVersion.Id           = _costTemplateVersionId;

            costTemplate.FieldDefinitions = fieldDefinitions;

            euro.Code = "EUR";
            usd.Code  = "USD";

            euro.Id = Guid.NewGuid();
            usd.Id  = Guid.NewGuid();

            var customFormData =
                "{\"costNumber\":\"AC1489594599188\",\"isAIPE\":false,\"projectId\":\"58c968410c885409aca51028\",\"title\":\"Full Prod\",\"description\":\"58c968410c885409aca51028\",\"contentType\":{\"id\":\"17cc6250-099a-11e7-84b7-1bf5c65c8e1a\",\"name\":\"Video\"},\"productionType\":{\"id\":\"17bec46a-099a-11e7-84b2-137a2ddbf0ee\",\"name\":\"Full Production\"},\"agencyProducer\":[\"Agency Producer 1\"],\"initialBudget\":1231231,\"budgetRegionId\":\"0f701f02-099a-11e7-945b-4b7e51cf96b3\",\"budgetRegion\":\"GREATER CHINA AREA\",\"organisation\":\"Other\",\"agencyCurrency\":\"USD\",\"campaign\":\"ad58c968410c885409aca51028\",\"agencyTrackingNumber\":\"58c968410c885409aca51028\"}";

            _stageFormData.Data = customFormData;
            _stageFormData.Id   = _costStageRevision.StageDetailsId;

            var costs = new List <Cost> {
                _cost
            };
            var costStageRevisions = new List <CostStageRevision> {
                _costStageRevision
            };
            var currencies = new List <Currency> {
                euro, usd
            };

            _efContextMock.MockAsyncQueryable(costs.AsQueryable(), c => c.Cost);
            _efContextMock.MockAsyncQueryable(costStageRevisions.AsQueryable(), c => c.CostStageRevision);
            _efContextMock.MockAsyncQueryable(currencies.AsQueryable(), c => c.Currency);
            _efContextMock.MockAsyncQueryable(new[] { _stageFormData }.AsQueryable(), d => d.CustomFormData);

            _stageDetails.ContentType = new core.Builders.DictionaryValue
            {
                Id    = Guid.NewGuid(),
                Key   = "Video",
                Value = "Video"
            };
            _stageDetails.CostType       = CostType.Production.ToString();
            _stageDetails.ProductionType = new core.Builders.DictionaryValue
            {
                Id    = Guid.NewGuid(),
                Key   = "Production",
                Value = "Production"
            };
            _stageDetails.Title = "Cost Title";

            _revisionServiceMock.Setup(csr => csr.GetStageDetails <PgStageDetailsForm>(_costStageRevisionId)).ReturnsAsync(_stageDetails);
            _revisionServiceMock.Setup(csr => csr.GetProductionDetails <PgProductionDetailsForm>(_costStageRevisionId)).ReturnsAsync(_productionDetails);
        }