private XElement ContractAward()
        {
            var lot = _notice.ObjectDescriptions.FirstOrDefault();

            if (lot == null)
            {
                return(null);
            }

            return(TedHelpers.Element("AWARD_CONTRACT",
                                      TedHelpers.Element("CONTRACT_NO", lot.AwardContract?.AwardedContract?.ContractNumber),
                                      _notice.LotsInfo.DivisionLots ? TedHelpers.Element("LOT_NO", lot.LotNumber.ToString()) : null,
                                      TedHelpers.PElement("TITLE", lot.AwardContract?.AwardedContract?.ContractTitle),
                                      TedHelpers.Element("AWARDED_CONTRACT",
                                                         TedHelpers.DateElement("DATE_CONCLUSION_CONTRACT", lot.AwardContract?.AwardedContract?.ConclusionDate <= DateTime.Now ? lot.AwardContract?.AwardedContract?.ConclusionDate : DateTime.Now),
                                                         TedHelpers.Element("CONTRACTORS",
                                                                            lot.AwardContract?.AwardedContract?.Contractors?.Count > 1 ? TedHelpers.Element("AWARDED_TO_GROUP") : TedHelpers.Element("NO_AWARDED_TO_GROUP"),
                                                                            lot.AwardContract?.AwardedContract?.Contractors?.Select((contractor, a) =>
                                                                                                                                    TedHelpers.Element("CONTRACTOR",
                                                                                                                                                       TedHelpers.ADDRS5(contractor),
                                                                                                                                                       contractor.IsSmallMediumEnterprise ? TedHelpers.Element("SME") : TedHelpers.Element("NO_SME")))
                                                                            ),
                                                         TedHelpers.Element("VALUES",
                                                                            lot.AwardContract?.AwardedContract?.FinalTotalValue.Value > 0 ?
                                                                            TedHelpers.ElementWithAttribute("VAL_TOTAL", "CURRENCY", lot.AwardContract.AwardedContract.FinalTotalValue.Currency, lot.AwardContract.AwardedContract.FinalTotalValue.Value)
                                : null))));
        }
        /// <summary>
        /// Section II: Object
        /// </summary>
        /// <returns>OBJECT_CONTRACT XElement</returns>
        private XElement ObjectContract()
        {
            var shortDescr = _notice.ProcurementObject.ShortDescription;

            // Using object description in design contest, because it cannot be lotted and doesn't have ShortDescription
            if (_notice.Type == NoticeType.DesignContest || _notice.Type == NoticeType.DesignContestResults)
            {
                shortDescr = _notice.ObjectDescriptions.FirstOrDefault().DescrProcurement;
            }

            if (_notice.Type == NoticeType.DefencePriorInformation)
            {
                shortDescr = _notice.ProcurementObject.Defence.TotalQuantity;
            }

            var contract = TedHelpers.Element("OBJECT_CONTRACT",
                                              TedHelpers.PElement("TITLE", _notice.Project.Title),
                                              TedHelpers.Element("REFERENCE_NUMBER", _notice.Project.ReferenceNumber),
                                              TedHelpers.CpvCodeElement("CPV_MAIN", new CpvCode[] { _notice.ProcurementObject.MainCpvCode }),
                                              TedHelpers.ElementWithAttribute("TYPE_CONTRACT", "CTYPE", _notice.Project.ContractType.ToTEDFormat()),
                                              TedHelpers.PElement("SHORT_DESCR", shortDescr)
                                              );

            return(contract);
        }
 /// <summary>
 /// Section VI: Complementary information
 /// </summary>
 /// <returns>The COMPLEMENTARY_INFO XElement</returns>
 private XElement ComplementaryInformation()
 {
     return(TedHelpers.Element("COMPLEMENTARY_INFO",
                               TedHelpers.PElement("INFO_ADD", _notice.ComplementaryInformation?.AdditionalInformation),
                               TedHelpers.ADDRS6("ADDRESS_REVIEW_BODY", _notice.ProceduresForReview?.ReviewBody),
                               TedHelpers.PElement("REVIEW_PROCEDURE", _notice.ProceduresForReview?.ReviewProcedure),
                               TedHelpers.DateElement("DATE_DISPATCH_NOTICE", DateTime.Now)));
 }
        private XElement Modifications()
        {
            var modifications = _notice.Modifications;

            if (modifications == null)
            {
                return(null);
            }

            try
            {
                return(TedHelpers.Element("MODIFICATIONS_CONTRACT",
                                          TedHelpers.Element("DESCRIPTION_PROCUREMENT",
                                                             TedHelpers.CpvCodeElement("CPV_MAIN", new CpvCode[] { modifications.MainCpvCode }),
                                                             TedHelpers.CpvCodeElement("CPV_ADDITIONAL", modifications.AdditionalCpvCodes),
                                                             modifications.NutsCodes.Select(n =>
                                                                                            new XElement(TedHelpers.n2016 + "NUTS", new XAttribute("CODE", n))),
                                                             TedHelpers.PElement("MAIN_SITE", modifications.MainsiteplaceWorksDelivery),
                                                             TedHelpers.PElement("SHORT_DESCR", modifications.DescrProcurement),
                                                             Duration(modifications.TimeFrame, modifications.JustificationForDurationOverFourYears,
                                                                      modifications.JustificationForDurationOverEightYears),
                                                             TedHelpers.Element("VALUES", TedHelpers.ElementWithAttribute("VAL_TOTAL", "CURRENCY",
                                                                                                                          modifications.TotalValue?.Currency, modifications.TotalValue?.Value)),
                                                             TedHelpers.Element("CONTRACTORS",
                                                                                modifications.Contractors?.Count > 1
                                ? TedHelpers.Element("AWARDED_TO_GROUP")
                                : TedHelpers.Element("NO_AWARDED_TO_GROUP"),
                                                                                modifications.Contractors?.Select((contractor, a) =>
                                                                                                                  TedHelpers.Element("CONTRACTOR",
                                                                                                                                     TedHelpers.ADDRS5(contractor),
                                                                                                                                     contractor.IsSmallMediumEnterprise
                                        ? TedHelpers.Element("SME")
                                        : TedHelpers.Element("NO_SME"))))
                                                             ),
                                          TedHelpers.Element("INFO_MODIFICATIONS",
                                                             TedHelpers.PElement("SHORT_DESCR", modifications.Description),
                                                             modifications.Reason == ModificationReason.ModNeedForAdditional
                            ? TedHelpers.PElement("ADDITIONAL_NEED", modifications.ReasonDescriptionEconomic)
                            : TedHelpers.PElement("UNFORESEEN_CIRCUMSTANCE",
                                                  modifications.ReasonDescriptionCircumstances),
                                                             TedHelpers.Element("VALUES",
                                                                                TedHelpers.ElementWithAttribute("VAL_TOTAL_BEFORE", "CURRENCY",
                                                                                                                modifications.IncreaseBeforeModifications?.Currency,
                                                                                                                modifications.IncreaseBeforeModifications?.Value),
                                                                                TedHelpers.ElementWithAttribute("VAL_TOTAL_AFTER", "CURRENCY",
                                                                                                                modifications.IncreaseAfterModifications?.Currency,
                                                                                                                modifications.IncreaseAfterModifications?.Value)))
                                          ));
            }
            catch (HilmaMalformedRequestException e)
            {
                throw new HilmaMalformedRequestException($"Invalid content in notice.Modifications: {e.Message}");
            }
        }
 /// <summary>
 /// #  XSD name : F14_2014
 /// #  RELEASE : "R2.0.9.S03"
 /// #  Intermediate release number 007-20181030
 /// #  Last update : 08/06/2018
 /// #  Form : Corrigendum
 /// </summary>
 private XElement NoticeBody()
 {
     return(TedHelpers.Element("FORM_SECTION",
                               TedHelpers.Element("F14_2014", new XAttribute("LG", _notice.Language), new XAttribute("CATEGORY", "ORIGINAL"), new XAttribute("FORM", "F14"),
                                                  TedHelpers.LegalBasis(_notice, _parent),
                                                  ContractingBody(_notice.Project, _notice.ContactPerson, _notice.CommunicationInformation),
                                                  ObjectContract(),
                                                  ComplementaryInformation(),
                                                  TedHelpers.Element("CHANGES",
                                                                     ChangesToXml(new NoticeChangesFactory(_notice, _parent, _translationProvider).Changes()),
                                                                     TedHelpers.PElement("INFO_ADD", _notice.CorrigendumAdditionalInformation)))));
 }
        /// <summary>
        /// Section II: Object
        /// </summary>
        /// <returns>OBJECT_CONTRACT XElement</returns>
        private XElement ObjectContract()
        {
            var contract = TedHelpers.Element("OBJECT_CONTRACT",
                                              TedHelpers.PElement("TITLE", _notice.Project?.Title),
                                              TedHelpers.Element("REFERENCE_NUMBER", _notice.Project?.ReferenceNumber),
                                              TedHelpers.CpvCodeElement("CPV_MAIN", new CpvCode[] { _notice.ProcurementObject?.MainCpvCode }),
                                              TedHelpers.ElementWithAttribute("TYPE_CONTRACT", "CTYPE", _notice.Project?.ContractType.ToTEDFormat())
                                              );

            contract.Add(ObjectDescriptions());

            return(contract);
        }
        private static List <XElement> NewValue(Change change)
        {
            List <XElement> newValue;

            if (change.NewText != null && change.NewText.Length > 0 && !string.IsNullOrEmpty(change.NewText[0]))
            {
                newValue = new List <XElement> {
                    TedHelpers.PElement("TEXT", change.NewText)
                };
            }
            else if (change.NewDate != null && change.NewDate != DateTime.MinValue)
            {
                newValue = new List <XElement> {
                    TedHelpers.DateElement("DATE", change.NewDate)
                };
            }
            else if (change.NewMainCpvCode != null && !string.IsNullOrEmpty(change.NewMainCpvCode.Code))
            {
                newValue = new List <XElement> {
                    TedHelpers.Element("CPV_MAIN",
                                       TedHelpers.ElementWithAttribute("CPV_CODE", "CODE", change.NewMainCpvCode.Code),
                                       change.NewMainCpvCode.VocCodes?.Select(x => TedHelpers.ElementWithAttribute("CPV_SUPPLEMENTARY_CODE", "CODE", x.Code)))
                };
            }
            else if (change.NewAdditionalCpvCodes != null &&
                     change.NewAdditionalCpvCodes.Count > 0 &&
                     change.NewAdditionalCpvCodes.Any(x => !string.IsNullOrEmpty(x.Code)))
            {
                newValue = change.NewAdditionalCpvCodes.Select(x =>
                                                               TedHelpers.Element("CPV_ADDITIONAL",
                                                                                  TedHelpers.ElementWithAttribute("CPV_CODE", "CODE", x.Code),
                                                                                  x.VocCodes?.Select(y => TedHelpers.ElementWithAttribute("CPV_SUPPLEMENTARY_CODE", "CODE", y.Code)))
                                                               ).ToList();
            }
            else
            {
                newValue = new List <XElement> {
                    TedHelpers.Element("NOTHING")
                };
            }

            return(newValue);
        }
Exemple #8
0
        private XElement ObjectContract()
        {
            var configuration    = _configuration.ProcurementObject;
            var projectConfig    = _configuration.Project;
            var procuremenObject = _notice.ProcurementObject;

            var contract = TedHelpers.Element("OBJECT_CONTRACT",
                                              projectConfig.Title
                    ? TedHelpers.PElement("TITLE", _notice.Project.Title)
                    : null,
                                              projectConfig.ReferenceNumber
                    ? TedHelpers.Element("REFERENCE_NUMBER", _notice.Project.ReferenceNumber)
                    : null,
                                              configuration.MainCpvCode.Code
                    ? TedHelpers.CpvCodeElement("CPV_MAIN", new [] { procuremenObject.MainCpvCode })
                    : null,
                                              projectConfig.ContractType
                    ? TedHelpers.ElementWithAttribute("TYPE_CONTRACT", "CTYPE", _notice.Project.ContractType.ToTEDFormat(_notice.Project.ProcurementCategory))
                    : null,
                                              configuration.ShortDescription
                    ? TedHelpers.PElement("SHORT_DESCR", procuremenObject.ShortDescription)
                    : null,
                                              procuremenObject.TotalValue != null ? procuremenObject.TotalValue.Type == ContractValueType.Exact
                    ? TedHelpers.Element("VAL_TOTAL",
                                         _notice.Project.ProcurementCategory == ProcurementCategory.Utility
                            ? new XAttribute("PUBLICATION", (!procuremenObject.TotalValue?.DisagreeToBePublished ?? false).ToYesNo("EN").ToUpperInvariant())
                            : null,
                                         new XAttribute("CURRENCY", procuremenObject.TotalValue.Currency),
                                         procuremenObject.TotalValue.Value)
                    : TedHelpers.Element("VAL_RANGE_TOTAL",
                                         _notice.Project.ProcurementCategory == ProcurementCategory.Utility
                            ? new XAttribute("PUBLICATION", (!procuremenObject.TotalValue.DisagreeToBePublished ?? false).ToYesNo("EN").ToUpperInvariant())
                            : null,
                                         new XAttribute("CURRENCY", procuremenObject.TotalValue.Currency),
                                         TedHelpers.Element("LOW", procuremenObject.TotalValue.MinValue),
                                         TedHelpers.Element("HIGH", procuremenObject.TotalValue.MaxValue)) : null,
                                              _helper.LotDivision(_notice.LotsInfo),
                                              _helper.ObjectDescriptions(_notice.ObjectDescriptions)
                                              );

            return(contract);
        }
        /// <summary>
        /// Section II.2: Description
        /// </summary>
        /// <returns></returns>
        private XElement ObjectDescriptions()
        {
            var lot = _notice.ObjectDescriptions?.FirstOrDefault();

            if (lot == null)
            {
                return(null);
            }

            return(TedHelpers.Element("OBJECT_DESCR",
                                      TedHelpers.PElement("TITLE", lot.Title),
                                      TedHelpers.Element("LOT_NO", lot.LotNumber),
                                      TedHelpers.CpvCodeElement("CPV_ADDITIONAL", lot.AdditionalCpvCodes),
                                      lot.NutsCodes.Select(n => new XElement(TedHelpers.n2016 + "NUTS", new XAttribute("CODE", n))),
                                      TedHelpers.PElement("MAIN_SITE", lot.MainsiteplaceWorksDelivery),
                                      TedHelpers.PElement("SHORT_DESCR", lot.DescrProcurement),
                                      Duration(lot.TimeFrame, _notice.ProcedureInformation?.FrameworkAgreement?.JustificationForDurationOverFourYears, _notice.ProcedureInformation?.FrameworkAgreement?.JustificationForDurationOverEightYears),
                                      lot.EuFunds?.ProcurementRelatedToEuProgram ?? false ? TedHelpers.PElement("EU_PROGR_RELATED", lot.EuFunds?.ProjectIdentification) : TedHelpers.Element("NO_EU_PROGR_RELATED")
                                      ));
        }
        private IEnumerable <XElement> Duration(TimeFrame timeFrame, string[] justificationIsOverFourYears, string[] justificationIsOverEightYears)
        {
            if (timeFrame == null)
            {
                yield break;
            }

            switch (timeFrame.Type)
            {
            case TimeFrameType.Days:
                yield return(TedHelpers.ElementWithAttribute("DURATION", "TYPE", "DAY", timeFrame.Days));

                break;

            case TimeFrameType.Months:
                yield return(TedHelpers.ElementWithAttribute("DURATION", "TYPE", "MONTH", timeFrame.Months));

                break;

            case TimeFrameType.BeginAndEndDate:
                yield return(TedHelpers.DateElement("DATE_START", timeFrame.BeginDate));

                yield return(TedHelpers.DateElement("DATE_END", timeFrame.EndDate));

                break;

            default:
                throw new HilmaMalformedRequestException("Undefined is not allowed value for time frame type");
            }

            if (justificationIsOverFourYears != null && justificationIsOverFourYears.HasAnyContent() && timeFrame.IsOverFourYears)
            {
                yield return(TedHelpers.PElement("JUSTIFICATION", justificationIsOverFourYears));
            }
            if (justificationIsOverEightYears != null && justificationIsOverEightYears.HasAnyContent() && timeFrame.IsOverEightYears)
            {
                yield return(TedHelpers.PElement("JUSTIFICATION", justificationIsOverEightYears));
            }
        }
Exemple #11
0
        private XElement WrapAnnex(IEnumerable <XElement> annex,
                                   ProcedureType annexType      = ProcedureType.AwardWoPriorPubD1,
                                   string annexElement          = "PT_NEGOTIATED_WITHOUT_PUBLICATION",
                                   ProcedureType outOfScopeType = ProcedureType.ProctypeNegotiatedWoNotice,
                                   string outOfScopeElement     = "PT_AWARD_CONTRACT_WITHOUT_CALL"
                                   )
        {
            if (_notice.ProcedureInformation.ProcedureType == annexType)
            {
                return(TedHelpers.Element(annexElement,
                                          TedHelpers.Element("D_ACCORDANCE_ARTICLE", annex),
                                          TedHelpers.PElement("D_JUSTIFICATION", SelectJustification().Justification)));
            }
            else if (_notice.ProcedureInformation.ProcedureType == outOfScopeType)
            {
                return(TedHelpers.Element(outOfScopeElement,
                                          TedHelpers.Element("D_OUTSIDE_SCOPE"),
                                          TedHelpers.PElement("D_JUSTIFICATION", SelectJustification().Justification)));
            }

            return(null);
        }