public decimal ConvertUnitValueToMainUnitValue(GoodUnit goodUnit, decimal value)
        {
            if (goodUnit.Parent == null)
                return value;

            return goodUnit.Coefficient * value;
        }
 public InvoiceItemCommand(decimal quantity, decimal fee, Good good, GoodUnit goodUnit, string description)
 {
     Quantity = quantity;
     Fee = fee;
     Good = good;
     GoodId = good.Id;
     GoodUnit = goodUnit;
     GoodUnitId = goodUnit.Id;
     Description = description;
 }
Exemple #3
0
        internal ScrapDetail(double rob, double price, Currency currency, Good good, GoodUnit unit, Tank tank, Scrap scrap,
            IScrapDomainService scrapDomainService, ITankDomainService tankDomainService, ICurrencyDomainService currencyDomainService,
            IGoodDomainService goodDomainService, IGoodUnitDomainService goodUnitDomainService)
            : this()
        {
            this.validateScrap(scrap, scrapDomainService);

            this.validateValues(rob, price, currency, good, unit, tank, scrap,
                tankDomainService, currencyDomainService, goodDomainService, goodUnitDomainService);

            this.ROB = rob;
            this.Price = price;
            this.Currency = currency;
            this.Good = good;
            this.Unit = unit;
            this.Tank = tank;
            this.Scrap = scrap;
        }
        internal OffhireDetail(decimal quantity, decimal feeInVoucherCurrency, decimal feeInMainCurrency, Good good, GoodUnit unit, Tank tank, Offhire offhire,
            IOffhireDomainService offhireDomainService, ITankDomainService tankDomainService, ICurrencyDomainService currencyDomainService,
            IGoodDomainService goodDomainService, IGoodUnitDomainService goodUnitDomainService)
            : this()
        {
            this.validateOffhire(offhire, offhireDomainService);

            this.validateValues(quantity, feeInVoucherCurrency, feeInMainCurrency, good, unit, tank, offhire, offhireDomainService,
                tankDomainService, currencyDomainService, goodDomainService, goodUnitDomainService);

            this.Quantity = quantity;
            this.FeeInVoucherCurrency = feeInVoucherCurrency;
            this.FeeInMainCurrency = feeInMainCurrency;
            this.Good = good;
            this.Unit = unit;
            this.Tank = tank;
            this.Offhire = offhire;
        }
 //================================================================================
 private OffhireDetail(
     decimal quantity,
     decimal feeInVoucherCurrency,
     decimal feeInMainCurrency,
     Good good,
     GoodUnit unit,
     Tank tank,
     Offhire offhire)
     : this()
 {
     //This constructor added to be used for insert into DB.
     this.Quantity = quantity;
     this.FeeInVoucherCurrency = feeInVoucherCurrency;
     this.FeeInMainCurrency = feeInMainCurrency;
     this.Good = good;
     this.Unit = unit;
     this.Tank = tank;
     this.Offhire = offhire;
 }
Exemple #6
0
        //================================================================================
        private ScrapDetail(
            double rob,
            double price,
            Currency currency,
            Good good,
            GoodUnit unit,
            Tank tank,
            Scrap scrap)
        {
            //This constructor added to be used for insert into DB.
            this.ROB = rob;
            this.Price = price;
            this.Currency = currency;
            this.Good = good;
            this.Unit = unit;
            this.Tank = tank;
            this.Scrap = scrap;

            this.isScrapSubmitRejected = new IsScrapSubmitRejected();

            //this.InventoryOperations = new List<InventoryOperation>();
        }
Exemple #7
0
        //================================================================================
        private void validateValues(double rob, double price, Currency currency, Good good, GoodUnit unit, Tank tank, Scrap scrap, ITankDomainService tankDomainService, ICurrencyDomainService currencyDomainService, IGoodDomainService goodDomainService, IGoodUnitDomainService goodUnitDomainService)
        {
            this.validateTank(tank, scrap, tankDomainService);

            this.validateGood(good, goodDomainService);
            this.validateGoodInTank(tank, good, scrap);
            this.validateGoodToBeUniqueInDetails(good, scrap);

            this.validateROB(rob);
            this.validatePrice(price);
            this.validateCurrency(currency, currencyDomainService);

            this.validateUnit(unit, goodUnitDomainService);
            this.validateGoodUnitInCompany(scrap.VesselInCompany.Company, good, unit);
        }
Exemple #8
0
        //================================================================================
        private void validateUnit(GoodUnit unit, IGoodUnitDomainService goodUnitDomainService)
        {
            if (unit == null)
                throw new BusinessRuleException("", "Unit must be selected.");

            if (goodUnitDomainService.Get(unit.Id) == null)
                throw new ObjectNotFound("Unit", unit.Id);
        }
Exemple #9
0
 //================================================================================
 private void validateGoodUnitInCompany(Company company, Good good, GoodUnit unit)
 {
     if (!(good.CompanyId == company.Id && good.GoodUnits.Count(gu => gu.Id == unit.Id) == 1))
         throw new BusinessRuleException("", string.Format("Selected Good '{0}' and Unit is not defined for Company.", good.Name));
 }
Exemple #10
0
        //================================================================================
        internal void Update(double rob, double price, Currency currency, Good good, GoodUnit unit, Tank tank,
            ITankDomainService tankDomainService, ICurrencyDomainService currencyDomainService,
            IGoodDomainService goodDomainService, IGoodUnitDomainService goodUnitDomainService)
        {
            this.validateValues(rob, price, currency, good, unit, tank, this.Scrap,
                 tankDomainService, currencyDomainService, goodDomainService, goodUnitDomainService);

            this.ROB = rob;
            this.Price = price;
            this.Currency = currency;
            this.Unit = unit;

            if (!this.isScrapSubmitRejected.IsSatisfiedBy(this.Scrap))
            {
                this.Good = good;
                this.Tank = tank;
            }
        }
Exemple #11
0
        //================================================================================
        public ScrapDetail UpdateDetail(long scrapDetailId, double rob, double price, Currency currency, Good good, GoodUnit unit, Tank tank,
            ITankDomainService tankDomainService, ICurrencyDomainService currencyDomainService,
            IGoodDomainService goodDomainService, IGoodUnitDomainService goodUnitDomainService)
        {
            var scrapDetailToUpdate = this.findDetail(scrapDetailId);

            scrapDetailToUpdate.Update(rob, price, currency, good, unit, tank,
                 tankDomainService, currencyDomainService, goodDomainService, goodUnitDomainService);

            return scrapDetailToUpdate;
        }
        public void TestInitialize()
        {
            _scope = new UnitOfWorkScope(new EFUnitOfWorkFactory(() => new DataContainer()));

            basicInfoDomainServiceObjects = new BasicInfoDomainServiceObjectsContainer(_scope);
            scrapTestObjects = new ScrapTestObjectsContainer(_scope);

            var orderConfigurator = new OrderConfigurator
                (
                new OrderStateFactory
                    (
                    new InventoryOperationDomainService(new InventoryOperationRepository(_scope),
                        scrapTestObjects.ScrapDomainService)));

            var client = new WebClientHelper(new HttpClient());
            _orderRepository = new OrderRepository(_scope, orderConfigurator, new EFRepository<OrderItem>(_scope));
            _orderRepository.GetAll();
            _tr = new TransactionScope();

            var hostAdapter = new ExternalHostAddressHelper();
            var vesselService = new VesselInCompanyDomainService
                (new VesselInCompanyRepository(_scope, null), new VoyageRepository(_scope));
            //var goodPartyService = new GoodPartyAssignmentDomainService
            //    (new GoodPartyAssignmentAntiCorruptionAdapter(new GoodAssignmentAntiCorruptionServiceWrapper(client, hostAdapter)));
            var goodService = new GoodDomainService
                (
                new GoodAntiCorruptionAdapter(new GoodAntiCorruptionServiceWrapper(client, hostAdapter), new GoodAntiCorruptionMapper()),
                new EFRepository<Good>(_scope), basicInfoDomainServiceObjects.CompanyDomainService, new EFRepository<GoodUnit>(_scope));

            var goodUnitService = new GoodUnitDomainService
                (
                new BaseAntiCorruptionAdapter<GoodUnit, GoodUnitDto>
                    (new BaseAntiCorruptionServiceWrapper<GoodUnitDto>(client), new BaseAntiCorruptionMapper<GoodUnit, GoodUnitDto>()),
                new EFRepository<GoodUnit>(_scope));

            var companyService = new CompanyDomainService
                (
                new CompanyAntiCorruptionAdapter(new CompanyAntiCorruptionServiceWrapper(client, hostAdapter), new CompanyAntiCorruptionMapper()),
                new CompanyRepository(_scope));

            //_target = new OrderApplicationService
            //    (
            //    _orderRepository, _scope, new UserRepository(_scope), vesselService, goodService,
            //    new OrderFactory(new OrderCodeGenerator(_orderRepository), orderConfigurator, new WorkflowRepository(_scope)), companyService,
            //    new OrderItemDomainService(new EFRepository<OrderItem>(_scope)), orderConfigurator);

            //_sapid = FakeDomainService.GetCompanies().Single(c => c.Id == 1);
            //_imsemCo = FakeDomainService.GetCompanies().Single(c => c.Id == 3);
            //_hafiz = FakeDomainService.GetCompanies().Single(c => c.Id == 2);

            this.sapidVesselInCompany = FakeDomainService.GetVesselsInCompanies().First(c => c.CompanyId == 1);
            _sapidVessel2 = FakeDomainService.GetVesselsInCompanies().Last(c => c.CompanyId == 1);
            this.hafizVesselInCompany = FakeDomainService.GetVesselsInCompanies().First(c => c.CompanyId == 2);
            _good = FakeDomainService.GetGoods().Single(c => c.Id == 1);
            _good2 = FakeDomainService.GetGoods().Single(c => c.Id == 2);
            _unit = FakeDomainService.GetCompanyGoodUnits().Single(c => c.Id == 1);
            _unit2 = FakeDomainService.GetCompanyGoodUnits().Single(c => c.Id == 2);
            _unit3 = FakeDomainService.GetCompanyGoodUnits().Single(c => c.Id == 4);

            //_goodPartAssignment = FakeDomainService.GetGoodPartyAssignments().Single(c => c.Id == 1);
            //_goodPartAssignment2 = FakeDomainService.GetGoodPartyAssignments().Single(c => c.Id == 2);
        }
Exemple #13
0
        //================================================================================
        private void validateValues(decimal quantity, decimal feeInVoucherCurrency, decimal feeInMainCurrency, Good good, GoodUnit unit, Tank tank, Offhire offhire,
            IOffhireDomainService offhireDomainService, ITankDomainService tankDomainService, ICurrencyDomainService currencyDomainService,
            IGoodDomainService goodDomainService, IGoodUnitDomainService goodUnitDomainService)
        {
            this.validateTank(tank, offhire, tankDomainService);

            this.validateGood(good, goodDomainService);
            this.validateGoodInTank(tank, good, offhire);
            this.validateGoodToBeUniqueInDetails(good, offhire);

            this.validateQuantity(quantity);

            this.validateFeeInMainCurrency(feeInMainCurrency);

            this.validateUnit(unit, goodUnitDomainService);
            this.validateGoodUnitInCompany(offhire.Introducer, good, unit);

            this.validateFeeInVoucherCurrency(feeInVoucherCurrency, offhire, good, offhireDomainService, currencyDomainService);
        }