public void CalculateWage_ForDriverWithMercenariesCarWithForwarder()
        {
            //arrange
            var wageParameter = new OldRatesWageParameterItem();

            var source = Substitute.For <IRouteListWageCalculationSource>();

            source.IsTruck.Returns(false);
            source.HasAnyCompletedAddress.Returns(true);
            source.EmployeeCategory.Returns(EmployeeCategory.driver);
            source.DriverOfOurCar.Returns(false);
            source.RouteListDate.Returns(new DateTime(2019, 09, 25));

            var sourceItem = Substitute.For <IRouteListItemWageCalculationSource>();

            sourceItem.Bottle600mlCount.Returns(5);
            sourceItem.Bottle6LCount.Returns(5);
            sourceItem.FullBottle19LCount.Returns(5);
            sourceItem.EmptyBottle19LCount.Returns(5);
            sourceItem.ContractCancelation.Returns(false);
            sourceItem.DriverWageSurcharge.Returns(0);
            sourceItem.HasFirstOrderForDeliveryPoint.Returns(true);
            sourceItem.IsDelivered.Returns(true);
            sourceItem.NeedTakeOrDeliverEquipment.Returns(false);
            sourceItem.WasVisitedByForwarder.Returns(true);
            sourceItem.IsDelivered.Returns(true);

            source.ItemSources.Returns(new List <IRouteListItemWageCalculationSource> {
                { sourceItem }
            });

            var service = new RouteListOldRatesWageCalculationService(wageParameter, source);

            decimal expectedValue = wageParameter.GetRateForMercenaries(source.RouteListDate, WageRateTypes.Bottle19L).ForDriverWithForwarder *sourceItem.FullBottle19LCount;

            expectedValue += wageParameter.GetRateForMercenaries(source.RouteListDate, WageRateTypes.EmptyBottle19L).ForDriverWithForwarder *sourceItem.EmptyBottle19LCount;
            expectedValue += wageParameter.GetRateForMercenaries(source.RouteListDate, WageRateTypes.Bottle6L).ForDriverWithForwarder *sourceItem.Bottle6LCount;
            expectedValue += Math.Truncate(wageParameter.GetRateForMercenaries(source.RouteListDate, WageRateTypes.PackOfBottles600ml).ForDriverWithForwarder / 36 * sourceItem.Bottle600mlCount);
            expectedValue += wageParameter.GetRateForMercenaries(source.RouteListDate, WageRateTypes.Address).ForDriverWithForwarder;

            //act
            var result = service.CalculateWage();

            //assert
            AssertsAccumulator.Create
            .Accumulate(() => Assert.That(result.Wage, Is.EqualTo(expectedValue)))
            .Accumulate(() => Assert.That(result.FixedWage, Is.EqualTo(0)))
            .Accumulate(() => Assert.That(result.WageDistrictLevelRate, Is.EqualTo(null)))
            .Release();
        }
Пример #2
0
 private WageRate GetActualRate(WageRateTypes wageRateType)
 {
     if (source.DriverOfOurCar)
     {
         return(wageParameterItem.GetRateForOurs(source.RouteListDate, wageRateType));
     }
     else
     {
         return(wageParameterItem.GetRateForMercenaries(source.RouteListDate, wageRateType));
     }
 }