private ContractTrackingReference CreateContractTrackingReference(long contractId, Guid itemReference,
                                                                          ContractTrackingState state   = ContractTrackingState.ActionsPending,
                                                                          ContractStatus contractStatus = ContractStatus.AvailableForApproval)
        {
            var contract = FluentContract
                           .Create()
                           .ApplyDefaults()
                           .ContractStatus(contractStatus)
                           .Save(this);

            var trackingReference = new ContractTrackingReference()
            {
                ContractId = contract.Id, ItemReference = itemReference.ToString(), State = state
            };

            var roleIds           = Enumerable.Empty <long>();
            var changeSet         = base.contractTrackingReferenceRecordType.GetNewChangeSet() as ChangeSet <long, ContractTrackingReference>;
            var changeSetSettings = new ProcessChangeSetSettings(username: MrAdmin.Name);
            var itemRef           = 1L;

            changeSet.AddCreate(itemRef, trackingReference, roleIds, roleIds);

            var processResult = contractTrackingReferenceRecordType.ProcessChangeSet(PreliminaryContractDataService, changeSet, changeSetSettings);

            return(processResult.SuccessfullyCreatedItems[processResult.SuccessfullyCreated[itemRef]] as ContractTrackingReference);
        }
        public void Registering_a_valid_contract_should_succeed()
        {
            var contract = FluentContract
                           .Create()
                           .ApplyDefaults()
                           .Save(this);

            var expectedResponse = new RegistrationAPIResponse(Guid.NewGuid());

            var ruleProcessor = GetRuleProcessor(_ruleProcessorUrl, expectedResponse);

            var response = ruleProcessor.RegisterContractItem(contract);

            Assert.AreEqual(RegistrationAPIState.Registered, response.State);
            Assert.AreEqual(expectedResponse.RegistrationReference, response.RegistrationReference);

            var trackingReferences = PreliminaryContractRepository.GetAll <ContractTrackingReference>().ToList();

            Assert.AreEqual(1, trackingReferences.Count);
            Assert.AreEqual(expectedResponse.RegistrationReference.ToString(), trackingReferences[0].ItemReference);
            Assert.AreEqual(ContractTrackingState.EvaluationPending, trackingReferences[0].State);
            Assert.AreNotEqual(0, trackingReferences[0].Id);
            Assert.AreNotEqual(default(DateTime), trackingReferences[0].CreatedAt);
            Assert.AreNotEqual(default(DateTime), trackingReferences[0].UpdatedAt);
        }
Beispiel #3
0
 public ContractInvoiceModule()
 {
     unitOfWork      = new UnitOfWork();
     ContractInvoice = new FluentContractInvoice(unitOfWork);
     Contract        = new FluentContract(unitOfWork);
     Invoice         = new FluentInvoice(unitOfWork);
 }
Beispiel #4
0
 public JobPhaseModule()
 {
     unitOfWork  = new UnitOfWork();
     JobPhase    = new FluentJobPhase(unitOfWork);
     JobMaster   = new FluentJobMaster(unitOfWork);
     Contract    = new FluentContract(unitOfWork);
     JobCostType = new FluentJobCostType(unitOfWork);
 }
Beispiel #5
0
 public JobMasterModule()
 {
     unitOfWork  = new UnitOfWork();
     JobMaster   = new FluentJobMaster(unitOfWork);
     AddressBook = new FluentAddressBook(unitOfWork);
     Customer    = new FluentCustomer(unitOfWork);
     Contract    = new FluentContract(unitOfWork);
     JobPhase    = new FluentJobPhase(unitOfWork);
     JobCostType = new FluentJobCostType(unitOfWork);
 }
 public ServiceInformationModule()
 {
     unitOfWork                = new UnitOfWork();
     ServiceInformation        = new FluentServiceInformation(unitOfWork);
     ServiceInformationInvoice = new FluentServiceInformationInvoice(unitOfWork);
     LocationAddress           = new FluentLocationAddress(unitOfWork);
     AddressBook               = new FluentAddressBook(unitOfWork);
     Customer      = new FluentCustomer(unitOfWork);
     Contract      = new FluentContract(unitOfWork);
     Udc           = new FluentUdc(unitOfWork);
     ScheduleEvent = new FluentScheduleEvent(unitOfWork);
 }
        public void Registering_a_contract_when_the_client_returns_null_should_fail()
        {
            var contract = FluentContract
                           .Create()
                           .ApplyDefaults()
                           .Save(this);

            var ruleProcessor = GetRuleProcessor(_ruleProcessorUrl, null, false);

            var response = ruleProcessor.RegisterContractItem(contract);

            Assert.AreEqual(RegistrationAPIState.Failed, response.State);
            Assert.AreEqual("Failed to register contract item: Communication with the rules engine failed", response.Messages[0]);
        }
        public void Registering_a_contract_when_the_client_fails_should_fail()
        {
            var contract = FluentContract
                           .Create()
                           .ApplyDefaults()
                           .Save(this);

            var ruleProcessor = GetRuleProcessor(_ruleProcessorUrl);

            var response = ruleProcessor.RegisterContractItem(contract);

            Assert.AreEqual(RegistrationAPIState.Failed, response.State);
            Assert.AreEqual($"Failed to register contract item: {_clientFailureMsg}", response.Messages[0]);
        }
        public void Registering_a_contract_when_the_system_is_not_registered_should_fail()
        {
            var contract = FluentContract
                           .Create()
                           .ApplyDefaults()
                           .Save(this);

            var ruleProcessor = GetRuleProcessor(_ruleProcessorUrl, null, true, false);

            var response = ruleProcessor.RegisterContractItem(contract);

            Assert.AreEqual(RegistrationAPIState.Failed, response.State);
            Assert.AreEqual("Failed to register contract item: System is not registered with the rules engine", response.Messages[0]);
        }
Beispiel #10
0
        public void Registering_a_contract_that_is_on_hold_should_fail()
        {
            var contract = FluentContract
                           .Create()
                           .ApplyDefaults()
                           .OnHold(true)
                           .Save(this);

            var ruleProcessor = GetRuleProcessor(_ruleProcessorUrl, null, false);

            var response = ruleProcessor.RegisterContractItem(contract);

            Assert.AreEqual(RegistrationAPIState.Failed, response.State);
            Assert.AreEqual("Failed to register contract items: The file is flagged as 'Hold From Approval'", response.Messages[0]);
        }
Beispiel #11
0
 public CustomerModule()
 {
     unitOfWork         = new UnitOfWork();
     Customer           = new FluentCustomer(unitOfWork);
     CustomerLedger     = new FluentCustomerLedger(unitOfWork);
     AccountsReceivable = new FluentAccountReceivable(unitOfWork);
     CustomerClaim      = new FluentCustomerClaim(unitOfWork);
     Contract           = new FluentContract(unitOfWork);
     Email           = new FluentEmail(unitOfWork);
     Phone           = new FluentPhone(unitOfWork);
     LocationAddress = new FluentLocationAddress(unitOfWork);
     ScheduleEvent   = new FluentScheduleEvent(unitOfWork);
     Invoice         = new FluentInvoice(unitOfWork);
     AddressBook     = new FluentAddressBook(unitOfWork);
 }
Beispiel #12
0
 public PurchaseOrderModule()
 {
     unitOfWork          = new UnitOfWork();
     PurchaseOrder       = new FluentPurchaseOrder(unitOfWork);
     PurchaseOrderDetail = new FluentPurchaseOrderDetail(unitOfWork);
     ChartOfAccount      = new FluentChartOfAccount(unitOfWork);
     Supplier            = new FluentSupplier(unitOfWork);
     Contract            = new FluentContract(unitOfWork);
     AddressBook         = new FluentAddressBook(unitOfWork);
     POQuote             = new FluentPOQuote(unitOfWork);
     Buyer             = new FluentBuyer(unitOfWork);
     TaxRatesByCode    = new FluentTaxRatesByCode(unitOfWork);
     AccountReceivable = new FluentAccountReceivable(unitOfWork);
     Udc = new FluentUdc(unitOfWork);
 }
Beispiel #13
0
 public ContractItemModule()
 {
     unitOfWork   = new UnitOfWork();
     ContractItem = new FluentContractItem(unitOfWork);
     Contract     = new FluentContract(unitOfWork);
 }