public static CancelTaxRequest ToAvaTaxCancelRequest(this VirtoCommerce.Domain.Order.Model.CustomerOrder order, string companyCode, CancelCode cancelCode)
        {
            if (order.Addresses != null && order.Addresses.Any() && order.Items != null && order.Items.Any())
            {
                // Document Level Elements
                // Required Request Parameters
                var cancelTaxRequest = new CancelTaxRequest
                {
                    CompanyCode = companyCode,
                    DocCode = order.Number,
                    DocType = DocType.SalesInvoice,
                    CancelCode = cancelCode
                };

                return cancelTaxRequest;
            }

            return null;
        }
Exemplo n.º 2
0
 private static bool GetOrCreateCancelCode(DataToImport record, Dictionary <string, CancelCode> codes, out CancelCode code)
 {
     if (string.IsNullOrEmpty(record.CANCELLATION_CODE))
     {
         code = new CancelCode();
         return(false);
     }
     if (codes.TryGetValue(record.CANCELLATION_CODE, out CancelCode code1))
     {
         code = code1;
     }
     else
     {
         code = new CancelCode
         {
             Code = record.CANCELLATION_CODE
         };
         codes.Add(code.Code, code);
     }
     return(true);
 }
Exemplo n.º 3
0
        private static bool CreateFlight(DataToImport record, Location originLocation, Location destLocation, CancelCode code, Airline airline, out Flight flight)
        {
            flight = new Flight();

            if (DateTime.TryParse(record.FL_DATE, out DateTime flightDate))
            {
                flight.FlightDate = flightDate;
            }
            else
            {
                ++errorsNumber;
                errorString.Add("id:" + record.Id + "\t FL_DATE" + record.FL_DATE);
                return(false);
            }

            if (int.TryParse(record.OP_CARRIER_FL_NUM, out int opCarrierFlightNumber))
            {
                flight.OpCarrierFlightNumber = opCarrierFlightNumber;
            }
            else
            {
                ++errorsNumber;
                errorString.Add("id:" + record.Id + "\t OP_CARRIER_FL_NUM" + record.OP_CARRIER_FL_NUM);
                return(false);
            }

            if (decimal.TryParse(record.CRS_DEP_TIME, style, culture, out decimal plannedDepartureTime))
            {
                flight.PlannedDepartureTime = plannedDepartureTime;
            }
            else
            {
                ++errorsNumber;
                errorString.Add("id:" + record.Id + "\t CRS_DEP_TIME" + record.CRS_DEP_TIME);
                return(false);
            }

            if (decimal.TryParse(record.DEP_TIME, style, culture, out decimal actualDepartureTime))
            {
                flight.ActualDepartureTime = actualDepartureTime;
            }
            else
            {
                if (code != null)
                {
                    ++errorsNumber;
                    errorString.Add("id:" + record.Id + "\t DEP_TIME" + record.DEP_TIME);
                    return(false);
                }
            }

            if (decimal.TryParse(record.DEP_DELAY, style, culture, out decimal departureDelay))
            {
                flight.DepartureDelay = departureDelay;
            }
            else
            {
                if (code != null)
                {
                    ++errorsNumber;
                    errorString.Add("id:" + record.Id + "\t DEP_DELAY" + record.DEP_DELAY);
                    return(false);
                }
            }

            if (decimal.TryParse(record.TAXI_OUT, style, culture, out decimal taxiOut))
            {
                flight.TaxiOut = taxiOut;
            }
            else
            {
                if (code != null)
                {
                    ++errorsNumber;
                    errorString.Add("id:" + record.Id + "\t TAXI_OUT" + record.TAXI_OUT);
                    return(false);
                }
            }

            if (decimal.TryParse(record.TAXI_IN, style, culture, out decimal taxiIn))
            {
                flight.TaxiIn = taxiIn;
            }
            else
            {
                if (code != null)
                {
                    ++errorsNumber;
                    errorString.Add("id:" + record.Id + "\t TAXI_IN" + record.TAXI_IN);
                    return(false);
                }
            }

            if (decimal.TryParse(record.WHEELS_OFF, style, culture, out decimal wheelsOff))
            {
                flight.WheelsOff = wheelsOff;
            }
            else
            {
                if (code != null)
                {
                    ++errorsNumber;
                    errorString.Add("id:" + record.Id + "\t WHEELS_OFF" + record.WHEELS_OFF);
                    return(false);
                }
            }

            if (decimal.TryParse(record.WHEELS_ON, style, culture, out decimal wheelsOn))
            {
                flight.WheelsOn = wheelsOn;
            }
            else
            {
                if (code != null)
                {
                    ++errorsNumber;
                    errorString.Add("id:" + record.Id + "\t WHEELS_ON" + record.WHEELS_ON);
                    return(false);
                }
            }

            if (decimal.TryParse(record.CRS_ARR_TIME, style, culture, out decimal plannedArrivalTime))
            {
                flight.PlannedArrivalTime = plannedArrivalTime;
            }
            else
            {
                ++errorsNumber;
                errorString.Add("id:" + record.Id + "\t CRS_ARR_TIME" + record.CRS_ARR_TIME);
                return(false);
            }

            if (decimal.TryParse(record.ARR_TIME, style, culture, out decimal actualArrivalTime))
            {
                flight.ActualArrivalTime = actualArrivalTime;
            }
            else
            {
                if (code != null)
                {
                    ++errorsNumber;
                    errorString.Add("id:" + record.Id + "\t ARR_TIME" + record.ARR_TIME);
                    return(false);
                }
            }

            if (decimal.TryParse(record.ARR_DELAY, style, culture, out decimal arrivalDelay))
            {
                flight.ArrivalDelay = arrivalDelay;
            }
            else
            {
                if (code != null)
                {
                    ++errorsNumber;
                    errorString.Add("id:" + record.Id + "\t ARR_DELAY" + record.ARR_DELAY);
                    return(false);
                }
            }

            if (decimal.TryParse(record.DIVERTED, style, culture, out decimal diverted))
            {
                flight.Diverted = diverted;
            }
            else
            {
                ++errorsNumber;
                errorString.Add("id:" + record.Id + "\t DIVERTED" + record.DIVERTED);
                return(false);
            }

            if (decimal.TryParse(record.CRS_ELAPSED_TIME, style, culture, out decimal plannedElapsedTime))
            {
                flight.PlannedElapsedTime = plannedElapsedTime;
            }
            else
            {
                ++errorsNumber;
                errorString.Add("id:" + record.Id + "\t CRS_ELAPSED_TIME" + record.CRS_ELAPSED_TIME);
                return(false);
            }

            if (decimal.TryParse(record.ACTUAL_ELAPSED_TIME, style, culture, out decimal actualElapsedTime))
            {
                flight.ActualElapsedTime = actualElapsedTime;
            }
            else
            {
                if (code != null)
                {
                    ++errorsNumber;
                    errorString.Add("id:" + record.Id + "\t ACTUAL_ELAPSED_TIME" + record.ACTUAL_ELAPSED_TIME);
                    return(false);
                }
            }

            if (decimal.TryParse(record.AIR_TIME, style, culture, out decimal airTime))
            {
                flight.AirTime = airTime;
            }
            else
            {
                if (code != null)
                {
                    ++errorsNumber;
                    errorString.Add("id:" + record.Id + "\t AIR_TIME" + record.AIR_TIME);
                    return(false);
                }
            }

            if (decimal.TryParse(record.DISTANCE, style, culture, out decimal distance))
            {
                flight.Distance = distance;
            }
            else
            {
                if (code != null)
                {
                    ++errorsNumber;
                    errorString.Add("id:" + record.Id + "\t DISTANCE" + record.DISTANCE);
                    return(false);
                }
            }

            if (decimal.TryParse(record.CARRIER_DELAY, style, culture, out decimal carrierDelay))
            {
                flight.CarrierDelay = carrierDelay;
            }
            else
            {
                flight.CarrierDelay = null;
            }

            if (decimal.TryParse(record.WEATHER_DELAY, style, culture, out decimal weatherDelay))
            {
                flight.WeatherDelay = weatherDelay;
            }
            else
            {
                flight.WeatherDelay = null;
            }

            if (decimal.TryParse(record.NAS_DELAY, style, culture, out decimal nasDelay))
            {
                flight.NasDelay = nasDelay;
            }
            else
            {
                flight.NasDelay = null;
            }

            if (decimal.TryParse(record.SECURITY_DELAY, style, culture, out decimal securityDelay))
            {
                flight.SecurityDelay = securityDelay;
            }
            else
            {
                flight.SecurityDelay = null;
            }

            if (decimal.TryParse(record.LATE_AIRCRAFT_DELAY, style, culture, out decimal lateAircraftDelay))
            {
                flight.LateAircraftDelay = lateAircraftDelay;
            }
            else
            {
                flight.LateAircraftDelay = null;
            }
            flight.Airline             = airline;
            flight.DestinationLocation = destLocation;
            flight.OriginLocation      = originLocation;
            if (code != null)
            {
                flight.CancelCode = code;
            }

            return(true);
        }
Exemplo n.º 4
0
        public static CancelTaxRequest ToAvaTaxCancelRequest(this VirtoCommerce.Domain.Order.Model.CustomerOrder order, string companyCode, CancelCode cancelCode)
        {
            if (order.Addresses != null && order.Addresses.Any() && order.Items != null && order.Items.Any())
            {
                // Document Level Elements
                // Required Request Parameters
                var cancelTaxRequest = new CancelTaxRequest
                {
                    CompanyCode = companyCode,
                    DocCode     = order.Number,
                    DocType     = DocType.SalesInvoice,
                    CancelCode  = cancelCode
                };

                return(cancelTaxRequest);
            }

            return(null);
        }