public void NoOverlappingIndentifierShouldPass()
        {
            // Assert
            var start = new DateTime(1999, 1, 1);
            var finish = new DateTime(2020, 12, 31);
            var validity = new DateRange(start, finish);
            var system = new SourceSystem { Name = "Test" };
            var expectedPartyRole = new PartyRole() { PartyRoleType = "PartyRole" };
            var expected = new PartyRoleMapping { System = system, MappingValue = "1", Validity = validity, PartyRole = expectedPartyRole };
            var list = new List<PartyRoleMapping> { expected };
            var repository = new Mock<IRepository>();
            repository.Setup(x => x.Queryable<PartyRoleMapping>()).Returns(list.AsQueryable());
            repository.Setup(x => x.FindOne<PartyRole>(It.IsAny<int>())).Returns(expectedPartyRole);

            var identifier = new EnergyTrading.Mdm.Contracts.MdmId
            {
                SystemName = "Test",
                Identifier = "1",
                StartDate = start.AddHours(-10),
                EndDate = start.AddHours(-5)
            };

            var request = new CreateMappingRequest() { EntityId = 1, Mapping = identifier };
            var rule = new PartyRoleCreateMappingdNoOverlappingRule<PartyRole, PartyRoleMapping>(repository.Object);

            // Act
            var result = rule.IsValid(request);

            // Assert
            repository.Verify(x => x.FindOne<PartyRole>(It.IsAny<int>()));
            Assert.IsTrue(result, "Rule failed");
        }
コード例 #2
0
        public void AddRightRoleIntoRelationship_FailTest()
        {
            var husbandType = new PartyRoleType("Husband");
            var husbandRole = new PartyRole(husbandType);

            var whifeType = new PartyRoleType("Whife");
            var whifeRole = new PartyRole(whifeType);

            var familyRelationshipTyp = new PartyRelationshipType("Family");
            var famalyCanHasHusband   = new PartyRelationshipConstraint(husbandType);

            familyRelationshipTyp.AddConstraint(famalyCanHasHusband);
            var famalyCanHasWhife = new PartyRelationshipConstraint(whifeType);

            familyRelationshipTyp.AddConstraint(famalyCanHasWhife);

            var familyRelationship = new PartyRelationship(familyRelationshipTyp);

            familyRelationship.AddRole(husbandRole);
            familyRelationship.AddRole(whifeRole);

            var john = new Person()
            {
                Birthdate = new DateTime(1972, 11, 4)
            };

            familyRelationship.Assign(husbandRole, john);
            var marry = new Person()
            {
                Birthdate = new DateTime(1976, 4, 16)
            };

            familyRelationship.Assign(whifeRole, marry);

            Assert.AreEqual(2, familyRelationship.Roles.Count());
            Assert.AreEqual(1, familyRelationship.GetRoles(john).Count());
            Assert.AreEqual(1, familyRelationship.GetRoles(marry).Count());
        }
コード例 #3
0
        public void AddWrongRoleIntoRelationship_FailTest()
        {
            var husbandType = new PartyRoleType("Husband");
            var husbandRole = new PartyRole(husbandType);

            var whifeType = new PartyRoleType("Whife");
            var whifeRole = new PartyRole(whifeType);

            var familyRelationshipTyp = new PartyRelationshipType("Family");
            var famalyCanHasHusband   = new PartyRelationshipConstraint(husbandType);

            familyRelationshipTyp.AddConstraint(famalyCanHasHusband);
            var famalyCanHasWhife = new PartyRelationshipConstraint(whifeType);

            familyRelationshipTyp.AddConstraint(famalyCanHasWhife);

            var familyRelationship = new PartyRelationship(familyRelationshipTyp);

            familyRelationship.AddRole(husbandRole);

            var familyRelationshipType2 = new PartyRelationshipType("Family2");
            var familyRelationship2     = new PartyRelationship(familyRelationshipType2);

            familyRelationship2.AddRole(whifeRole);

            var john = new Person()
            {
                Birthdate = new DateTime(1972, 11, 4)
            };

            familyRelationship.Assign(husbandRole, john);
            var marry = new Person()
            {
                Birthdate = new DateTime(1976, 4, 16)
            };

            familyRelationship.Assign(whifeRole, marry);
        }
コード例 #4
0
        public void AddCommunications_SuccessTest()
        {
            var customerRoleType         = new PartyRoleType("Customer");
            var customerRole             = new PartyRole(customerRoleType);
            var customerRelationshipType = new PartyRelationshipType("Customers relationship");
            var customerRelationship     = new PartyRelationship(customerRelationshipType);

            customerRelationship.AddRole(customerRole);

            var vlad = new Person();

            customerRelationship.Assign(customerRole, vlad);
            var ilona = new Person();

            customerRelationship.Assign(customerRole, ilona);

            var customerServiceRepresentativeRoleType = new PartyRoleType("CustomerServiceRepresentative");
            var customerServiceRepresentativeRole     = new PartyRole(customerServiceRepresentativeRoleType);
            var communicationRelationshipType         = new PartyRelationshipType("Communication relationship");
            var communicationRelationship             = new Communication(communicationRelationshipType);

            communicationRelationship.AddRole(customerServiceRepresentativeRole);

            communicationRelationship.Assign(customerServiceRepresentativeRole, vlad);
            communicationRelationship.Assign(customerServiceRepresentativeRole, ilona);

            var customerCommunicationManager = new CustomerCommunicationManager();
            var customerServiceCase          = new CustomerServiceCase(new CustomerServiceCaseIdentifier(Guid.NewGuid()));

            customerCommunicationManager.AddCustomerServiceCases(customerServiceCase);
            var thread1 = new CommunicationThread();

            customerServiceCase.AddThread(thread1);
            var communication = new Communication(communicationRelationshipType);

            thread1.AddCommunication(communicationRelationship);
        }
コード例 #5
0
        public void ValidContractIsSaved()
        {
            // Arrange
            var validatorFactory = new Mock<IValidatorEngine>();
            var mappingEngine = new Mock<IMappingEngine>();
            var repository = new Mock<IRepository>();
            var searchCache = new Mock<ISearchCache>();

            var service = new PartyRoleService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object);

            var partyrole = new PartyRole();
            var contract = new EnergyTrading.MDM.Contracts.Sample.PartyRole();

            validatorFactory.Setup(x => x.IsValid(It.IsAny<EnergyTrading.MDM.Contracts.Sample.PartyRole>(), It.IsAny<IList<IRule>>())).Returns(true);
            mappingEngine.Setup(x => x.Map<EnergyTrading.MDM.Contracts.Sample.PartyRole, PartyRole>(contract)).Returns(partyrole);

            // Act
            var expected = service.Create(contract);

            // Assert
            Assert.AreSame(expected, partyrole, "PartyRole differs");
            repository.Verify(x => x.Add(partyrole));
            repository.Verify(x => x.Flush());
        }
コード例 #6
0
        public void ValidContractIsSaved()
        {
            // Arrange
            var validatorFactory = new Mock <IValidatorEngine>();
            var mappingEngine    = new Mock <IMappingEngine>();
            var repository       = new Mock <IRepository>();
            var searchCache      = new Mock <ISearchCache>();

            var service = new PartyRoleService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object);

            var partyrole = new PartyRole();
            var contract  = new EnergyTrading.MDM.Contracts.Sample.PartyRole();

            validatorFactory.Setup(x => x.IsValid(It.IsAny <EnergyTrading.MDM.Contracts.Sample.PartyRole>(), It.IsAny <IList <IRule> >())).Returns(true);
            mappingEngine.Setup(x => x.Map <EnergyTrading.MDM.Contracts.Sample.PartyRole, PartyRole>(contract)).Returns(partyrole);

            // Act
            var expected = service.Create(contract);

            // Assert
            Assert.AreSame(expected, partyrole, "PartyRole differs");
            repository.Verify(x => x.Add(partyrole));
            repository.Verify(x => x.Flush());
        }
コード例 #7
0
 public PartyRoleViewModel(IViewModelDependencies appCtx, IZetboxContext dataCtx, ViewModel parent,
                           PartyRole obj)
     : base(appCtx, dataCtx, parent, obj)
 {
     this.PartyRole = obj;
 }
コード例 #8
0
        public static AgreementRole CreateAgreementRole(Agreement agreement, PartyRole partyRole)
        {
            AgreementRole agreeRole = new AgreementRole();
            agreeRole.Agreement = agreement;
            agreeRole.PartyRole = partyRole;

            return agreeRole;
        }
コード例 #9
0
        public static Collateral HandleCreate(Asset asset, PartyRole customerPartyRole)
        {
            var jewelryOthers = new JewelryCollateral();
            jewelryOthers.AssetId = asset.Id;
            jewelryOthers.type = asset.AssetType;
            jewelryOthers.AcquisitionCost = asset.AcquisitionCost ?? 0;
            jewelryOthers.Description = asset.Description;

            return jewelryOthers;
        }
コード例 #10
0
        private void CreateMortgagee(Asset asset, DateTime today)
        {
            //if isMortgaged is true, provide Mortgagee
            if (this.IsPropertyMortgage)
            {
                var mortgageRoleType = RoleType.GetType(RoleType.AssetRoleType, RoleType.MortgageeType);

                PartyRole mortgagee = new PartyRole();
                mortgagee.PartyId = this.MortgageeId;
                mortgagee.RoleTypeId = mortgageRoleType.Id;
                mortgagee.EffectiveDate = today;

                AssetRole assetRole = new AssetRole();
                assetRole.Asset = asset;
                assetRole.PartyRole = mortgagee;
                Context.PartyRoles.AddObject(mortgagee);
            }
        }
コード例 #11
0
 public static Collateral CreateCollateral(Asset asset, PartyRole customerPartyRole)
 {
     Collateral collateral = null;
     if (asset.AssetTypeId == AssetType.BankAccountType.Id)
         collateral = BankAccountCollateral.HandleCreate(asset, customerPartyRole);
     else if (asset.AssetTypeId == AssetType.LandType.Id)
         collateral = LandCollateral.HandleCreate(asset, customerPartyRole);
     else if (asset.AssetTypeId == AssetType.JewelryType.Id)
         collateral = JewelryCollateral.HandleCreate(asset, customerPartyRole);
     else if (asset.AssetTypeId == AssetType.MachineType.Id)
         collateral = MachineCollateral.HandleCreate(asset, customerPartyRole);
     else if (asset.AssetTypeId == AssetType.VehicleType.Id)
         collateral = VehicleCollateral.HandleCreate(asset, customerPartyRole);
     else if (asset.AssetTypeId == AssetType.OthersType.Id)
         collateral = JewelryCollateral.HandleCreate(asset, customerPartyRole);
     Init(asset, collateral);
     collateral.IsNew = false;
     return collateral;
 }
コード例 #12
0
        public static Collateral HandleCreate(Asset asset, PartyRole customerPartyRole)
        {
            //throw new NotImplementedException();
            var vehicle = new VehicleCollateral();
            Vehicle va = asset.Vehicle;
            vehicle.VehicleTypeId = va.VehicleTypeId;
            vehicle.Brand = va.Brand;
            vehicle.Model = va.Model;
            vehicle.AcquisitionCost = asset.AcquisitionCost ?? 0;

            return vehicle;
        }
コード例 #13
0
        public static Collateral HandleCreate(Asset asset, PartyRole customerPartyRole)
        {
            //throw new NotImplementedException();
            var machine = new MachineCollateral();
            Machine ma = asset.Machine;
            machine.MachineName = ma.MachineName;
            machine.Brand = ma.Brand;
            machine.Model = ma.Model;
            machine.Capacity = ma.Capacity;
            machine.AcquisitionCost = asset.AcquisitionCost ?? 0;

            return machine;
        }
コード例 #14
0
        public void ValidDetailsSaved()
        {
            var validatorFactory = new Mock <IValidatorEngine>();
            var mappingEngine    = new Mock <IMappingEngine>();
            var repository       = new Mock <IRepository>();
            var searchCache      = new Mock <ISearchCache>();

            // Contract
            var cd = new EnergyTrading.MDM.Contracts.Sample.PartyRoleDetails {
                Name = "PartyRole 1"
            };
            var nexus = new EnergyTrading.Mdm.Contracts.SystemData {
                StartDate = new DateTime(2012, 1, 1)
            };
            var identifier = new EnergyTrading.Mdm.Contracts.MdmId {
                SystemName = "Test", Identifier = "A"
            };
            var contract = new EnergyTrading.MDM.Contracts.Sample.PartyRole {
                Details = cd, MdmSystemData = nexus
            };

            contract.Identifiers.Add(identifier);

            // Domain
            var system = new SourceSystem {
                Name = "Test"
            };
            var mapping = new PartyRoleMapping {
                System = system, MappingValue = "A"
            };
            var d1 = new PartyRoleDetails {
                Id = 1, Name = "PartyRole 1", Timestamp = 74UL.GetVersionByteArray()
            };
            var entity = new PartyRole {
                Party = new Party {
                    Id = 999
                }
            };

            entity.AddDetails(d1);

            var d2 = new PartyRoleDetails {
                Name = "PartyRole 1"
            };
            var range = new DateRange(new DateTime(2012, 1, 1), DateTime.MaxValue);

            validatorFactory.Setup(x => x.IsValid(It.IsAny <CreateMappingRequest>(), It.IsAny <IList <IRule> >())).Returns(true);
            validatorFactory.Setup(x => x.IsValid(It.IsAny <EnergyTrading.MDM.Contracts.Sample.PartyRole>(), It.IsAny <IList <IRule> >())).Returns(true);

            repository.Setup(x => x.FindOne <PartyRole>(1)).Returns(entity);

            mappingEngine.Setup(x => x.Map <EnergyTrading.MDM.Contracts.Sample.PartyRoleDetails, PartyRoleDetails>(cd)).Returns(d2);
            mappingEngine.Setup(x => x.Map <EnergyTrading.Mdm.Contracts.SystemData, DateRange>(nexus)).Returns(range);
            mappingEngine.Setup(x => x.Map <EnergyTrading.Mdm.Contracts.MdmId, PartyRoleMapping>(identifier)).Returns(mapping);

            var service = new PartyRoleService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object);

            // Act
            service.Update(1, 74, contract);

            // Assert
            Assert.AreEqual(2, entity.Details.Count, "Details count differs");
            Assert.AreEqual(1, entity.Mappings.Count, "Mapping count differs");
            repository.Verify(x => x.Save(entity));
            repository.Verify(x => x.Flush());
        }
コード例 #15
0
        private LoanModification CreateLoanModification(PartyRole role, LoanModificationType type)
        {
            LoanModification loanModification = new LoanModification();
            loanModification.PartyRole = role;
            loanModification.LoanModificationType = type;

            return loanModification;
        }
コード例 #16
0
        private FinancialAccountRole CreateFinancialAccountRole(FinancialAccount financialAccount, PartyRole role)
        {
            FinancialAccountRole financialAccountRole = new FinancialAccountRole();
            financialAccountRole.FinancialAccount = financialAccount;
            financialAccountRole.PartyRole = role;

            return financialAccountRole;
        }
コード例 #17
0
        private AgreementRole CreateAgreementRole(Agreement agreement, PartyRole role)
        {
            AgreementRole agreementRole = new AgreementRole();
            agreementRole.Agreement = agreement;
            agreementRole.PartyRole = role;

            return agreementRole;
        }
コード例 #18
0
        private void ChequeModelPrepareForSave(FinancialAccount financialAccount, PartyRole customerPartyRole, int employeePartyRoleId, DateTime today, ChequeModel model)
        {
            if (model.IsNew)
            {
                var application = financialAccount.Agreement.Application;
                var loanAccount = financialAccount.LoanAccount;

                //new payment
                Payment payment = CreatePayment(customerPartyRole, employeePartyRoleId, model, today);

                //new cheque
                Cheque newCheck = new Cheque();
                newCheck.BankPartyRoleId = model.BankId;
                newCheck.CheckDate = model.ChequeDate;
                newCheck.Payment = payment;

                //new cheque association
                ChequeApplicationAssoc chequeAssoc = new ChequeApplicationAssoc();
                chequeAssoc.Cheque = newCheck;
                chequeAssoc.Application = application;

                //new cheque loan association
                ChequeLoanAssoc chequeLoanAssoc = new ChequeLoanAssoc();
                chequeLoanAssoc.Cheque = newCheck;
                chequeLoanAssoc.LoanAccount = loanAccount;

                //new receipt
                Receipt newReceipt = CreateReceipt(customerPartyRole, payment, model);

                //new receipt payment assoc
                ReceiptPaymentAssoc newReceiptAssoc = CreateReceiptPaymentAssoc(payment, newReceipt);

                //new receipt status
                CreateReceiptStatus(newReceipt, model, today);

                //new cheque status
                CreateChequeStatus(newCheck, model, today);

                Context.Cheques.AddObject(newCheck);
            }
            else if (model.ToBeDeleted)
            {
                //throw new NotImplementedException();
                var payment = Context.Payments.SingleOrDefault(entity => entity.Id == model.PaymentId);
                var receiptPaymentAssoc = Context.ReceiptPaymentAssocs.SingleOrDefault(entity => entity.PaymentId == payment.Id);
                var receipts = receiptPaymentAssoc.Receipt;
                var cheque = Context.Cheques.SingleOrDefault(entity => entity.Id == model.ChequeId && entity.PaymentId == payment.Id);

                var assoc = Context.ChequeApplicationAssocs.SingleOrDefault(entity => entity.ChequeId == cheque.Id);

                Context.ReceiptPaymentAssocs.DeleteObject(receiptPaymentAssoc);
                Context.Receipts.DeleteObject(receipts);
                Context.ChequeApplicationAssocs.DeleteObject(assoc);
                Context.Cheques.DeleteObject(cheque);
                Context.Payments.DeleteObject(payment);
            }
        }
コード例 #19
0
        public Receipt CreateReceipt(PartyRole customerPartyRole, Payment payment, ChequeModel model)
        {
            Receipt newReceipt = new Receipt();
            newReceipt.ReceiptBalance = model.Amount;
            Context.Receipts.AddObject(newReceipt);

            return newReceipt;
        }
コード例 #20
0
        public Payment CreatePayment(PartyRole customerPartyRole, int employeePartyRoleId, ChequeModel model, DateTime today)
        {
            //Payment newPayment = new Payment();
            //newPayment.ProcessedByPartyRoleId = employeePartyRoleId;
            //newPayment.ProcessedToPartyRoleId = customerPartyRole.Id;
            //newPayment.PaymentType = PaymentType.Receipt;
            //newPayment.PaymentMethodType = PaymentMethodType.PersonalCheckType;
            //newPayment.TransactionDate = model.TransactionDate.Date;
            //newPayment.EntryDate = today;
            //newPayment.TotalAmount = model.Amount;
            //newPayment.PaymentReferenceNumber = model.ChequeNumber;

            Payment newPayment = Payment.CreatePayment(today, model.TransactionDate.Date, customerPartyRole.Id,
                                                        employeePartyRoleId, model.Amount, PaymentType.Receipt,
                                                        PaymentMethodType.PersonalCheckType, SpecificPaymentType.LoanPaymentType,
                                                        model.ChequeNumber);

            Context.Payments.AddObject(newPayment);

            return newPayment;
        }
コード例 #21
0
 public void Update(string id, PartyRole contract)
 {
     this.UpdateHandler(id, contract);
 }
コード例 #22
0
        public override void PrepareForSave(LoanApplication loanApplication, PartyRole customerPartyRole, DateTime today)
        {
            //throw new NotImplementedException();
            if (this.IsNew)
            {
                var asset = AddAsset(loanApplication, today);

                foreach (PropertyOwner owner in PropertyOwners)
                {
                    owner.Add(asset, today);
                }

                Land land = new Land();
                land.Asset = asset;
                land.UomId = this.LandUOM;
                land.LandTypeId = this.LandType;
                land.OctTctNumber = this.TCTNumber;
                land.LandArea = this.LandArea;

                //add property location
                var borrowerParty = Context.Parties.SingleOrDefault(entity => entity.Id == customerPartyRole.PartyId);
                var propertyLocation = PostalAddress.CreatePostalAddress(borrowerParty, PostalAddressType.PropertyLocationType, today);
                propertyLocation.StreetAddress = this.StreetAddress;
                propertyLocation.Barangay = this.Barangay;
                propertyLocation.Municipality = this.Municipality;
                propertyLocation.CountryId = this.CountryId;
                propertyLocation.City = this.City;
                propertyLocation.Province = this.Province;
                propertyLocation.PostalCode = this.PostalCode;
                propertyLocation.Address.Asset = asset;
            }
            else if (this.ToBeDeleted)
            {
                Asset asset = Context.Assets.SingleOrDefault(entity => entity.Id == this.AssetId);
                RemoveCurrentMortgagee(asset, today);

                foreach (PropertyOwner owner in PropertyOwners)
                {
                    owner.Remove(today);
                }

                var borrowerParty = Context.Parties.SingleOrDefault(entity => entity.Id == customerPartyRole.PartyId);
                var propertyLocation = PostalAddress.GetCurrentPostalAddress(borrowerParty, PostalAddressType.PropertyLocationType, asset);

                if (asset.Land != null)
                {
                    Address address = propertyLocation.Address;
                    Context.Lands.DeleteObject(asset.Land);
                    Context.PostalAddresses.DeleteObject(propertyLocation);
                    Context.Addresses.DeleteObject(address);
                }

                Context.Assets.DeleteObject(asset);
            }
            else if (this.IsEdited)
            {
                Asset asset = Context.Assets.SingleOrDefault(entity => entity.Id == this.AssetId);
                UpdateAsset(asset, today);

                Land land = asset.Land;
                land.UomId = this.LandUOM;
                land.LandTypeId = this.LandType;
                land.OctTctNumber = this.TCTNumber;
                land.LandArea = this.LandArea;

                //add property location
                var borrowerParty = Context.Parties.SingleOrDefault(entity => entity.Id == customerPartyRole.PartyId);
                var currentPropertyLocation = PostalAddress.GetCurrentPostalAddress(borrowerParty, PostalAddressType.PropertyLocationType, asset);
                var propertyLocation = new PostalAddress();
                propertyLocation.StreetAddress = this.StreetAddress;
                propertyLocation.Barangay = this.Barangay;
                propertyLocation.Municipality = this.Municipality;
                propertyLocation.CountryId = this.CountryId;
                propertyLocation.City = this.City;
                propertyLocation.Province = this.Province;
                propertyLocation.PostalCode = this.PostalCode;

                PostalAddress.CreateOrUpdatePostalAddress(currentPropertyLocation, propertyLocation, today);

                foreach (PropertyOwner owner in PropertyOwners)
                {
                    owner.Save(asset, today);
                }
            }else if(this.IsNew == false && this.ToBeDeleted == false && this.IsEdited == false)
            {
                if (this.AssetId == 0)
                {
                    var asset = AddAsset(loanApplication, today);

                    foreach (PropertyOwner owner in PropertyOwners)
                    {
                        owner.Add(asset, today);
                    }

                    Land land = new Land();
                    land.Asset = asset;
                    land.UomId = this.LandUOM;
                    land.LandTypeId = this.LandType;
                    land.OctTctNumber = this.TCTNumber;
                    land.LandArea = this.LandArea;

                    //add property location
                    var borrowerParty = Context.Parties.SingleOrDefault(entity => entity.Id == customerPartyRole.PartyId);
                    //var currentPropertyLocation = PostalAddress.GetCurrentPostalAddress(borrowerParty, PostalAddressType.PropertyLocationType, asset);
                    var propertyLocation = PostalAddress.CreatePostalAddress(borrowerParty, PostalAddressType.PropertyLocationType, today);
                    propertyLocation.StreetAddress = this.StreetAddress;
                    propertyLocation.Barangay = this.Barangay;
                    propertyLocation.Municipality = this.Municipality;
                    propertyLocation.CountryId = this.CountryId;
                    propertyLocation.City = this.City;
                    propertyLocation.Province = this.Province;
                    propertyLocation.PostalCode = this.PostalCode;
                    propertyLocation.Address.Asset = asset;
                }
            }
        }
コード例 #23
0
 public void Create(PartyRole contract)
 {
     this.CreateHandler(contract);
 }
コード例 #24
0
        public void Add(Asset asset, DateTime today)
        {
            //var ownerPartyRole = Context.PartyRoles.SingleOrDefault(entity => entity.PartyId == this.PartyId);
            RoleType roleType = RoleType.PartiallyOwnType;
            if (this.PercentOwned == 100)
                roleType = RoleType.FullyOwnType;
            PartyRole propertyOwner = new PartyRole();
            propertyOwner.PartyId = this.PartyId;
            propertyOwner.PartyRoleType = roleType.PartyRoleType;
            propertyOwner.EffectiveDate = today;

            AssetRole propertyOwnerAssetRole = new AssetRole();
            propertyOwnerAssetRole.Asset = asset;
            propertyOwnerAssetRole.PartyRole = propertyOwner;
            propertyOwnerAssetRole.EquityValue = this.PercentOwned;

            Context.PartyRoles.AddObject(propertyOwner);
            Context.AssetRoles.AddObject(propertyOwnerAssetRole);
        }
コード例 #25
0
ファイル: Field.cs プロジェクト: VirtuFinancial/FixClient
 public Field(int tag, PartyRole value)
     : this(tag, ((char)value).ToString())
 {
 }
コード例 #26
0
        public void PrepareForSave(LoanApplication loanApplication, PartyRole customerPartyRole, int employeePartyRole, DateTime today)
        {
            if (this.IsNew)
            {
                var assoc = Context.ChequeApplicationAssocs.Where(e => e.ApplicationId == loanApplication.ApplicationId);
                if (assoc != null)
                {
                    foreach (var item in assoc)
                    {
                        var cheque = Context.Cheques.SingleOrDefault(entity => entity.Id == item.ChequeId);
                        var payments = Payment.GetById(cheque.PaymentId);
                        var rpAssoc = Context.ReceiptPaymentAssocs.SingleOrDefault(entity => entity.PaymentId == payments.Id);
                        Receipt receipts = Context.Receipts.SingleOrDefault(entity => entity.Id == rpAssoc.ReceiptId);

                        Context.ChequeApplicationAssocs.DeleteObject(item);
                        Context.Cheques.DeleteObject(cheque);
                        Context.Receipts.DeleteObject(receipts);
                        Context.Payments.DeleteObject(payments);
                        Context.ReceiptPaymentAssocs.DeleteObject(rpAssoc);
                    }
                }

                //create Payment
                var transactionDate = DateTime.Today;
                Payment payment = Payment.CreatePayment(today, transactionDate, customerPartyRole.Id, employeePartyRole,
                    this.Amount, PaymentType.Receipt, PaymentMethodType.PersonalCheckType,
                    SpecificPaymentType.LoanPaymentType, this.ChequeNumber);
                Context.Payments.AddObject(payment);

                //create cheque
                Cheque newCheck = new Cheque();
                newCheck.BankPartyRoleId = this.BankId;
                newCheck.CheckDate = this.ChequeDate;
                newCheck.Payment = payment;
                Context.Cheques.AddObject(newCheck);

                //create cheque association
                ChequeApplicationAssoc chequeAssoc = new ChequeApplicationAssoc();
                chequeAssoc.Cheque = newCheck;
                chequeAssoc.Application = loanApplication.Application;

                //create receipt and receipt payment assoc
                Receipt receipt = Receipt.CreateReceipt(null, this.Amount);
                Receipt.CreateReceiptPaymentAssoc(receipt, payment);

                //Context.SaveChanges();
            }
            else if (this.ToBeDeleted)
            {
                var payment = Payment.GetById(this.PaymentId);
                //TODO:: Changed to new payment
                var cheque = Context.Cheques.SingleOrDefault(entity => entity.Id == this.ChequeId && entity.PaymentId == payment.Id);
                var rpAssoc = Context.ReceiptPaymentAssocs.SingleOrDefault(entity => entity.PaymentId == payment.Id);

                var assoc = Context.ChequeApplicationAssocs.SingleOrDefault(entity => entity.ChequeId == cheque.Id);
                //TODO:: Changed to new payment
                Context.ChequeApplicationAssocs.DeleteObject(assoc);
                Context.Cheques.DeleteObject(cheque);
                Context.Receipts.DeleteObject(rpAssoc.Receipt);
                Context.Payments.DeleteObject(rpAssoc.Payment);
                Context.ReceiptPaymentAssocs.DeleteObject(rpAssoc);
            }

            else if (this.IsNew == false && this.ToBeDeleted == false)
            {
                var payment = Context.Payments.SingleOrDefault(entity => entity.Id == this.PaymentId);
                payment.TransactionDate = this.TransactionDate;
                payment.PaymentReferenceNumber = this.ChequeNumber;

                var cheque = Context.Cheques.SingleOrDefault(entity => entity.Id == this.ChequeId && entity.PaymentId == payment.Id);
                cheque.BankPartyRoleId = this.BankId;
            }
        }
コード例 #27
0
ファイル: Field.cs プロジェクト: VirtuFinancial/FixClient
 public Field(Dictionary.Field definition, PartyRole value)
     : this(definition.Tag, value)
 {
     Definition = definition;
 }
コード例 #28
0
 public abstract void PrepareForSave(LoanApplication loanApplication, PartyRole customerPartyRole, DateTime today);
コード例 #29
0
        public void ValidateEntityValueConstraine_SuccessTest()
        {
            var husbandType = new PartyRoleType("Husband");
            var husbendMustBeOlderThen18 = new RuleSet(new Func <object, bool>((x) =>
            {
                var person = x as Person;
                if (person.Age > 18)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }));

            husbandType.AddRule(husbendMustBeOlderThen18);
            var husbandRole = new PartyRole(husbandType);

            var whifeType = new PartyRoleType("Whife");
            var whifeMustBeOlderThen16 = new RuleSet(new Func <object, bool>((x) =>
            {
                var person = x as Person;
                if (person.Age > 16)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }));

            whifeType.AddRule(whifeMustBeOlderThen16);
            var whifeRole = new PartyRole(whifeType);

            var childrenType = new PartyRoleType("Children");
            var childrenMustBeYangerThenParents = new RuleSet(new Func <object, bool>((x) =>
            {
                return(true);
            }));

            childrenType.AddRule(childrenMustBeYangerThenParents);
            var childrenRole = new PartyRole(childrenType);

            var familyRelationshipTyp = new PartyRelationshipType("Family");
            var famalyCanHasHusband   = new PartyRelationshipConstraint(husbandType);

            familyRelationshipTyp.AddConstraint(famalyCanHasHusband);
            var famalyCanHasWhife = new PartyRelationshipConstraint(whifeType);

            familyRelationshipTyp.AddConstraint(famalyCanHasWhife);
            var famalyCanHasChildren = new PartyRelationshipConstraint(childrenType);

            familyRelationshipTyp.AddConstraint(famalyCanHasChildren);

            var familyRelationship = new PartyRelationship(familyRelationshipTyp);

            familyRelationship.AddRole(husbandRole);
            familyRelationship.AddRole(whifeRole);
            familyRelationship.AddRole(childrenRole);

            Assert.AreEqual(3, familyRelationship.Roles.Count());
            Assert.AreEqual(1, husbandRole.Type.Rules.Count());

            Assert.AreEqual(3, familyRelationship.Roles.Count());
            Assert.AreEqual(1, whifeRole.Type.Rules.Count());

            Assert.AreEqual(3, familyRelationship.Roles.Count());
            Assert.AreEqual(1, childrenRole.Type.Rules.Count());

            var john = new Person()
            {
                Birthdate = new DateTime(1972, 11, 4)
            };

            familyRelationship.Assign(husbandRole, john);
            var marry = new Person()
            {
                Birthdate = new DateTime(1976, 4, 16)
            };

            familyRelationship.Assign(whifeRole, marry);
            var gimmy = new Person()
            {
                Birthdate = new DateTime(1996, 4, 16)
            };

            familyRelationship.Assign(childrenRole, gimmy);

            Assert.AreEqual(3, familyRelationship.Roles.Count());
            Assert.AreEqual(1, familyRelationship.GetRoles(john).Count());
            Assert.AreEqual(1, familyRelationship.GetRoles(marry).Count());
            Assert.AreEqual(1, familyRelationship.GetRoles(gimmy).Count());
        }
コード例 #30
0
        public static Collateral HandleCreate(Asset asset, PartyRole customerPartyRole)
        {
            var bankAccount = new BankAccountCollateral();
            BankAccount ba = asset.BankAccount;
            bankAccount.BankAccountType = ba.BankAccountTypeId;
            bankAccount.BankPartyRoleId = ba.BankPartyRoleId ?? 0;
            bankAccount.BankAccountNumber = ba.AccountNumber;
            bankAccount.BankAccountName = ba.AccountName;
            PartyRole partyRole = PartyRole.GetById(bankAccount.BankPartyRoleId);
            bankAccount.BankName = partyRole.Party.Organization.OrganizationName;

            return bankAccount;
        }
コード例 #31
0
 public void UpdateRoleTabs(PartyRole newRole)
 {
     // I'm so sorry, but PropertyGroups is a reaonly collection
 }
コード例 #32
0
        public override void PrepareForSave(LoanApplication loanApplication, PartyRole customerPartyRole, DateTime today)
        {
            //throw new NotImplementedException();
            if (this.IsNew)
            {
                var asset = AddAsset(loanApplication, today);
                asset.Description = this.Description;
                asset.AcquisitionCost = this.AcquisitionCost;

                foreach (PropertyOwner owner in PropertyOwners)
                {
                    owner.Add(asset, today);
                }

            }
            else if (this.ToBeDeleted)
            {
                Asset asset = Context.Assets.SingleOrDefault(entity => entity.Id == this.AssetId);
                RemoveCurrentMortgagee(asset, today);

                foreach (PropertyOwner owner in PropertyOwners)
                {
                    owner.Remove(today);
                }

                var borrowerParty = Context.Parties.SingleOrDefault(entity => entity.Id == customerPartyRole.PartyId);

                if (asset.Vehicle != null)
                {
                    Context.Vehicles.DeleteObject(asset.Vehicle);
                }

                Context.Assets.DeleteObject(asset);
            }
            else if (this.IsEdited)
            {
                Asset asset = Context.Assets.SingleOrDefault(entity => entity.Id == this.AssetId);
                UpdateAsset(asset, today);

                foreach (PropertyOwner owner in PropertyOwners)
                {
                    owner.Save(asset, today);
                }
            }
            else if (this.IsNew == false && this.IsEdited == false && this.ToBeDeleted == false)
            {
                if (this.AssetId == 0)
                {
                    var asset = AddAsset(loanApplication, today);
                    asset.Description = this.Description;
                    asset.AcquisitionCost = this.AcquisitionCost;

                    foreach (PropertyOwner owner in PropertyOwners)
                    {
                        owner.Add(asset, today);
                    }
                }
            }
        }
コード例 #33
0
        public void SuccessMatch()
        {
            // Arrange
            var validatorFactory = new Mock <IValidatorEngine>();
            var mappingEngine    = new Mock <IMappingEngine>();
            var repository       = new Mock <IRepository>();
            var searchCache      = new Mock <ISearchCache>();

            var service = new PartyRoleService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object);

            // Domain details
            var start  = new DateTime(1999, 12, 31);
            var finish = new DateTime(2020, 1, 1);
            var system = new SourceSystem {
                Name = "Endur"
            };
            var mapping = new PartyRoleMapping
            {
                System       = system,
                MappingValue = "A"
            };
            var details = new PartyRoleDetails
            {
                Name     = "PartyRole 1",
                Validity = new DateRange(start, finish)
            };
            var party = new PartyRole
            {
                Id    = 1,
                Party = new Party {
                    Id = 999
                }
            };

            party.AddDetails(details);
            party.ProcessMapping(mapping);

            // Contract details
            var identifier = new EnergyTrading.Mdm.Contracts.MdmId
            {
                SystemName = "Endur",
                Identifier = "A"
            };
            var cDetails = new EnergyTrading.MDM.Contracts.Sample.PartyRoleDetails
            {
                Name = "PartyRole 1"
            };

            mappingEngine.Setup(x => x.Map <PartyRoleMapping, EnergyTrading.Mdm.Contracts.MdmId>(mapping)).Returns(identifier);
            mappingEngine.Setup(x => x.Map <PartyRoleDetails, EnergyTrading.MDM.Contracts.Sample.PartyRoleDetails>(details)).Returns(cDetails);
            validatorFactory.Setup(x => x.IsValid(It.IsAny <MappingRequest>(), It.IsAny <IList <IRule> >())).Returns(true);

            var list = new List <PartyRoleMapping> {
                mapping
            };

            repository.Setup(x => x.Queryable <PartyRoleMapping>()).Returns(list.AsQueryable());

            var request = new MappingRequest
            {
                SystemName = "Endur",
                Identifier = "A",
                ValidAt    = SystemTime.UtcNow(),
                Version    = 1
            };

            // Act
            var response  = service.Map(request);
            var candidate = response.Contract;

            // Assert
            repository.Verify(x => x.Queryable <PartyRoleMapping>());

            Assert.IsTrue(response.IsValid);
            Assert.IsNotNull(candidate, "Contract null");

            mappingEngine.Verify(x => x.Map <PartyRoleMapping, EnergyTrading.Mdm.Contracts.MdmId>(mapping));
            mappingEngine.Verify(x => x.Map <PartyRoleDetails, EnergyTrading.MDM.Contracts.Sample.PartyRoleDetails>(details));

            Assert.AreEqual(2, candidate.Identifiers.Count, "Identifier count incorrect");
            // NB This is order dependent
            Assert.AreSame(identifier, candidate.Identifiers[1], "Different identifier assigned");
            Assert.AreSame(cDetails, candidate.Details, "Different details assigned");
            Assert.AreEqual(start, candidate.MdmSystemData.StartDate, "Start date differs");
            Assert.AreEqual(finish, candidate.MdmSystemData.EndDate, "End date differs");
        }
コード例 #34
0
        //if customer has no outstandling loans
        private static bool CheckIfHasNoOutstandingLoans(RoleType borrowerRoleType, PartyRole customerPartyRole)
        {
            var financialAccountRoles = Context.FinancialAccountRoles.Where(entity => entity.PartyRoleId == customerPartyRole.Id);

            if(financialAccountRoles.Count() == 0)
                return true;

            var all = from far in financialAccountRoles
                      join fa in Context.FinancialAccounts on far.FinancialAccountId equals fa.Id
                      join agreement in Context.Agreements on fa.AgreementId equals agreement.Id
                      join agreementRole in Context.AgreementRoles on agreement.Id equals agreementRole.AgreementId
                      join pr in Context.PartyRoles on agreementRole.PartyRoleId equals pr.Id
                      join prt in Context.RoleTypes on pr.PartyRoleType.RoleType.Id equals prt.Id
                      join ams in Context.AmortizationSchedules on agreement.Id equals ams.AgreementId
                      join amsi in Context.AmortizationScheduleItems on ams.Id equals amsi.AmortizationScheduleId
                      where ams.EndDate == null && agreement.EndDate == null && prt.Id == RoleType.BorrowerAgreementType.Id
                      select far;

            return all.Count() == 0;
        }
コード例 #35
0
        public static Collateral HandleCreate(Asset asset, PartyRole customerPartyRole)
        {
            LandCollateral collateral = new LandCollateral();
            Land land = asset.Land;
            collateral.LandUOM = land.UomId;
            collateral.LandType = land.LandTypeId;
            collateral.TCTNumber = land.OctTctNumber;
            collateral.LandArea = land.LandArea;

            //add property location
            var borrowerParty = Context.Parties.SingleOrDefault(entity => entity.Id == customerPartyRole.PartyId);
            var propertyLocation = PostalAddress.GetCurrentPostalAddress(borrowerParty,
                PostalAddressType.PropertyLocationType, asset);
            if (propertyLocation != null)
            {
                collateral.StreetAddress = propertyLocation.StreetAddress;
                collateral.Barangay = propertyLocation.Barangay;
                collateral.Municipality = propertyLocation.Municipality;
                collateral.CountryId = propertyLocation.CountryId ?? 0;
                collateral.City = propertyLocation.City;
                collateral.Province = propertyLocation.Province;
                collateral.PostalCode = propertyLocation.PostalCode;
            }
            return collateral;
        }
コード例 #36
0
        public async Task <long> Handle(CreateOfficialFromIntegrationEventCommand command, CancellationToken cancellationToken)
        {
            var now = _dateTimeService.Now;

            var tenantPartyRoleId = await _context.PartyRoles
                                    .Where(t => t.PartyRoleTypeId == (int)PartyRoleTypeEnum.Tenant)
                                    .Select(t => t.Id)
                                    // Extra conditions to filter the specific tenant you want, not first async
                                    .FirstAsync();

            var organizationPartyRole = await _context.PartyRoles
                                        .Where(t => t.PartyRoleTypeId == (int)PartyRoleTypeEnum.Organization && (t.Party.ExternalId == command.OrganizationExternalId || t.Party.Organization.Code == command.OrganizationCode) &&
                                               t.IsActive == true)
                                        .FirstOrDefaultAsync();

            if (organizationPartyRole == null)
            {
                var organizationName = command.JobTitle.Split(',');
                if (organizationName.Length > 2 && !string.IsNullOrWhiteSpace(organizationName[2]))
                {
                    organizationPartyRole = await Helpers.CreateOrganization(_context, now, command.OrganizationCode, organizationName[2], command.OrganizationExternalId);
                }
            }

            var partyRole = new PartyRole
            {
                IsActive        = true,
                PartyRoleTypeId = (int)PartyRoleTypeEnum.Member,
                ValidFrom       = now,
                JobCode         = command.JobTitle.Substring(0, command.JobTitle.IndexOf(',', StringComparison.Ordinal)),
                JobTitle        = command.JobTitle,
                Party           = new Party
                {
                    GlobalId   = Guid.NewGuid(),
                    ExternalId = command.OfficialExternalId,
                    ExternalIdIdentificationSchemaId = 3,
                    Individual = new Individual
                    {
                        GivenName       = command.FirstName,
                        FamilyName      = command.LastName,
                        Username        = command.Username,
                        AliveDuringFrom = now
                    }
                }
            };

            partyRole.PartyRoleAssociationPartyRoleInvolves.Add(new PartyRoleAssociation()
            {
                PartyRoleInvolvedWithId = tenantPartyRoleId,
                IsActive  = true,
                ValidFrom = now,
                PartyRoleAssociationTypeId = (int)PartyRoleAssociationTypeEnum.EntityObjectAccess
            });

            partyRole.PartyRoleAssociationPartyRoleInvolves.Add(new PartyRoleAssociation()
            {
                PartyRoleInvolvedWith = organizationPartyRole,
                IsActive  = true,
                ValidFrom = now,
                PartyRoleAssociationTypeId = (int)PartyRoleAssociationTypeEnum.Membership
            });

            _context.PartyRoles.Add(partyRole);

            await _context.SaveChangesAsync(cancellationToken);

            return(partyRole.Id);
        }
コード例 #37
0
 private void SetRole(string role)
 {
     _commonSharedSteps.WhenTheUserSelectsTheOptionFromTheDropdown(_browsers[_c.CurrentUser].Driver, AddParticipantsPage.RoleDropdown, PartyRole.FromString(role).Name);
 }
コード例 #38
0
        public static IIdentifiable Create(string name)
        {
            switch (name)
            {
            case "Broker":
                var broker = new Broker {
                    PartyRoleType = "Broker"
                };
                var brokerDetails = Create <BrokerDetails>();
                broker.Party            = Create <Party>();
                brokerDetails.PartyRole = broker;
                broker.Details.Add(brokerDetails);
                return(broker);

            case "BrokerDetails":
                return(new BrokerDetails
                {
                    Name = "Name" + Guid.NewGuid(),
                    Fax = "01302111111",
                    Phone = "01302222222",
                    Rate = 1.1m
                });

            case "Counterparty":
                var counterparty = new Counterparty {
                    PartyRoleType = "Counterparty"
                };
                var counterpartyDetails = Create <CounterpartyDetails>();
                counterparty.Party            = Create <Party>();
                counterpartyDetails.PartyRole = counterparty;
                counterparty.Details.Add(counterpartyDetails);
                return(counterparty);

            case "CounterpartyDetails":
                return(new CounterpartyDetails
                {
                    Name = "Name" + Guid.NewGuid(),
                    Fax = "01302111111",
                    Phone = "01302222222",
                    ShortName = "sh",
                    //TaxLocation = Create<Location>()
                });

            case "Exchange":
                var exchange = new Exchange {
                    PartyRoleType = "Exchange", Party = Create <Party>()
                };
                var exchangeDetails = Create <ExchangeDetails>();
                exchangeDetails.PartyRole = exchange;
                exchange.Details.Add(exchangeDetails);
                return(exchange);

            case "ExchangeDetails":
                return
                    (new ExchangeDetails
                {
                    Name = "Name" + Guid.NewGuid(),
                    Phone = "118118"
                });


            case "LegalEntity":
                var legalEntity = new LegalEntity {
                    PartyRoleType = "LegalEntity"
                };
                var legalEntityDetails = Create <LegalEntityDetails>();
                legalEntity.Party            = Create <Party>();
                legalEntityDetails.PartyRole = legalEntity;
                legalEntity.Details.Add(legalEntityDetails);
                return(legalEntity);

            case "LegalEntityDetails":
                return(new LegalEntityDetails
                {
                    Name = "Name" + Guid.NewGuid(),
                    RegisteredName = "RegisteredName",
                    RegistrationNumber = "RegistrationNumber",
                    Address = "123 Fake St",
                    Website = "http://test.com",
                    CountryOfIncorporation = "Germany",
                    Email = "*****@*****.**",
                    Fax = "020 1234 5678",
                    Phone = "020 3469 1256",
                    PartyStatus = "Active",
                    CustomerAddress = "456 Wrong Road",
                    InvoiceSetup = "Customer",
                    VendorAddress = "789 Right Road"
                });

            case "Location":
                return(new Location
                {
                    Type = "LocationType" + Guid.NewGuid(),
                    Name = "Location" + Guid.NewGuid(),
                });

            case "Party":
                var partyDetails = Create <PartyDetails>();
                var party        = new Party();
                party.Details.Add(partyDetails);
                partyDetails.Party = party;
                return(party);

            case "PartyDetails":
                var ptDetails = new PartyDetails
                {
                    Name  = "Name" + Guid.NewGuid(),
                    Phone = "020 8823 1234",
                    Fax   = "020 834 1237",
                    Role  = "Trader"
                };
                return(ptDetails);

            case "PartyRole":
                var partyRole = new PartyRole {
                    PartyRoleType = "SomeRole", Party = Create <Party>()
                };
                partyRole.Details.Add(Create <PartyRoleDetails>());
                return(partyRole);

            case "PartyRoleDetails":
                return
                    (new PartyRoleDetails
                {
                    Name = "Name" + Guid.NewGuid(),
                });

            case "Person":
                var personDetails = Create <PersonDetails>();
                var person        = new Person();
                person.Details.Add(personDetails);
                return(person);

            case "PersonDetails":
                var psDetails = new PersonDetails
                {
                    FirstName = "Firstname" + Guid.NewGuid(),
                    LastName  = "Lastname" + Guid.NewGuid(),
                    Email     = "*****@*****.**"
                };
                return(psDetails);

            case "SourceSystem":
                return(new SourceSystem
                {
                    Name = "SourceSystem" + Guid.NewGuid()
                });

            default:
                throw new NotImplementedException("No OM for " + name);
            }
        }
コード例 #39
0
        public override void PrepareForSave(LoanApplication loanApplication, PartyRole customerPartyRole, DateTime today)
        {
            if (this.IsNew)
            {
                var asset = AddAsset(loanApplication, today);

                foreach (PropertyOwner owner in PropertyOwners)
                {
                    owner.Add(asset, today);
                }

                BankAccount bank = new BankAccount();
                bank.Asset = asset;
                bank.BankAccountTypeId = this.BankAccountType;
                bank.BankPartyRoleId = this.BankPartyRoleId;
                bank.AccountNumber = this.BankAccountNumber;
                bank.AccountName = this.BankAccountName;
            }
            else if (this.ToBeDeleted)
            {
                Asset asset = Context.Assets.SingleOrDefault(entity => entity.Id == this.AssetId);
                RemoveCurrentMortgagee(asset, today);

                foreach (PropertyOwner owner in PropertyOwners)
                {
                    owner.Remove(today);
                }

                if (asset.BankAccount != null)
                    Context.BankAccounts.DeleteObject(asset.BankAccount);

                Context.Assets.DeleteObject(asset);
            }
            else if (this.IsEdited)
            {
                Asset asset = Context.Assets.SingleOrDefault(entity => entity.Id == this.AssetId);
                UpdateAsset(asset, today);
                BankAccount bank = asset.BankAccount;
                bank.BankAccountTypeId = this.BankAccountType;
                bank.BankPartyRoleId = this.BankPartyRoleId;
                bank.AccountNumber = this.BankAccountNumber;
                bank.AccountName = this.BankAccountName;

                foreach (PropertyOwner owner in PropertyOwners)
                {
                    owner.Save(asset, today);
                }
            }
            else if (this.IsNew == false && this.ToBeDeleted == false && this.IsEdited == false)
            {
                if (this.AssetId == 0)
                {
                    var asset = AddAsset(loanApplication, today);

                    foreach (PropertyOwner owner in PropertyOwners)
                    {
                        owner.Add(asset, today);
                    }

                    BankAccount bank = new BankAccount();
                    bank.Asset = asset;
                    bank.BankAccountTypeId = this.BankAccountType;
                    bank.BankPartyRoleId = this.BankPartyRoleId;
                    bank.AccountNumber = this.BankAccountNumber;
                    bank.AccountName = this.BankAccountName;
                }
            }
        }
コード例 #40
0
 protected static void SetAdditionalData(PartyRole entity)
 {
     entity.Party         = IntegrationTests.Party.PartyData.PostBasicEntity().ToMdmId().ToEntityId();
     entity.PartyRoleType = "SettlementContact";
 }
コード例 #41
0
        public void SuccessMatchCurrentVersion()
        {
            // Arrange
            var validatorFactory = new Mock <IValidatorEngine>();
            var mappingEngine    = new Mock <IMappingEngine>();
            var repository       = new Mock <IRepository>();
            var searchCache      = new Mock <ISearchCache>();

            var service = new PartyRoleService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object);

            // Domain details
            var start  = new DateTime(1999, 12, 31);
            var finish = new DateTime(2020, 1, 1);
            var system = new SourceSystem {
                Name = "Endur"
            };
            var mapping = new PartyRoleMapping
            {
                System       = system,
                MappingValue = "A"
            };
            var details = new PartyRoleDetails
            {
                Name     = "PartyRole 1",
                Validity = new DateRange(start, finish)
            };
            var party = new PartyRole
            {
                Id = 1
            };

            party.AddDetails(details);
            party.ProcessMapping(mapping);

            // Contract details
            var identifier = new EnergyTrading.Mdm.Contracts.MdmId
            {
                SystemName = "Endur",
                Identifier = "A"
            };
            var cDetails = new EnergyTrading.MDM.Contracts.Sample.PartyRoleDetails
            {
                Name = "PartyRole 1"
            };

            mappingEngine.Setup(x => x.Map <PartyRoleMapping, EnergyTrading.Mdm.Contracts.MdmId>(mapping)).Returns(identifier);
            mappingEngine.Setup(x => x.Map <PartyRoleDetails, EnergyTrading.MDM.Contracts.Sample.PartyRoleDetails>(details)).Returns(cDetails);
            validatorFactory.Setup(x => x.IsValid(It.IsAny <MappingRequest>(), It.IsAny <IList <IRule> >())).Returns(true);

            var list = new List <PartyRoleMapping> {
                mapping
            };

            repository.Setup(x => x.Queryable <PartyRoleMapping>()).Returns(list.AsQueryable());

            var request = new MappingRequest
            {
                SystemName = "Endur",
                Identifier = "A",
                ValidAt    = SystemTime.UtcNow(),
                Version    = 0
            };

            // Act
            var response = service.Map(request);

            // Assert
            repository.Verify(x => x.Queryable <PartyRoleMapping>());

            Assert.IsNull(response.Contract, "Contract not null");
            Assert.IsTrue(response.IsValid);
            Assert.AreEqual(0UL, response.Version);
        }