コード例 #1
0
        public static ProjectDiaryViewModel ParseToProjectDiary(this LinhasContratos x, string projectNo, string userName, string date, string customerServiceId, string serviceGroupId)
        {
            ProjectDiaryViewModel item = new ProjectDiaryViewModel();

            item.ProjectNo                = projectNo;
            item.Code                     = x.Código;
            item.Description              = x.Descrição;
            item.Quantity                 = x.Quantidade; //A pedido Marco Marcelo 03/07/2019 = 0;
            item.MeasurementUnitCode      = x.CódUnidadeMedida;
            item.RegionCode               = x.CódigoRegião;
            item.FunctionalAreaCode       = x.CódigoÁreaFuncional;
            item.ResponsabilityCenterCode = x.CódigoCentroResponsabilidade;
            item.User                     = userName;
            item.UnitPrice                = x.PreçoUnitário;
            item.Billable                 = x.Faturável;
            item.Registered               = false;
            item.Date                     = string.IsNullOrEmpty(date) ? "" : date;
            item.ServiceClientCode        = (x.CódServiçoCliente != "" && x.CódServiçoCliente != null) ? x.CódServiçoCliente : customerServiceId;
            item.ServiceGroupCode         = serviceGroupId;
            item.PreRegistered            = false;
            item.MovementType             = 1;
            //switch (x.Tipo.Value)
            //{
            //    case 1: item.Type = 2; break;
            //    case 2: item.Type = 1; break;
            //    default: item.Type = x.Tipo; break;
            //}
            item.Type = x.Tipo;
            return(item);
        }
コード例 #2
0
        public static DiárioDeProjeto ParseToDatabase(ProjectDiaryViewModel x)
        {
            return(new DiárioDeProjeto()
            {
                NºLinha = x.LineNo,
                NºProjeto = x.ProjectNo,
                Data = x.Date == "" || x.Date == null ? (DateTime?)null : DateTime.Parse(x.Date),
                TipoMovimento = x.MovementType,
                Tipo = x.Type,
                Código = x.Code,
                Descrição = x.Description,
                Quantidade = x.Quantity,
                CódUnidadeMedida = x.MeasurementUnitCode,
                CódLocalização = x.LocationCode,
                GrupoContabProjeto = x.ProjectContabGroup,
                CódigoRegião = x.RegionCode,
                CódigoÁreaFuncional = x.FunctionalAreaCode,
                CódigoCentroResponsabilidade = x.ResponsabilityCenterCode,
                Utilizador = x.User,
                CustoUnitário = x.UnitCost,
                CustoTotal = x.TotalCost,
                PreçoUnitário = x.UnitPrice,
                PreçoTotal = x.TotalPrice,
                Faturável = x.Billable,
                Registado = x.Registered,
                FaturaANºCliente = x.InvoiceToClientNo,
                Moeda = x.Currency,
                ValorUnitárioAFaturar = x.UnitValueToInvoice,
                TipoRefeição = x.MealType,
                CódGrupoServiço = x.ServiceGroupCode,
                NºGuiaResíduos = x.ResidueGuideNo,
                NºGuiaExterna = x.ExternalGuideNo,
                DataConsumo = x.ConsumptionDate == "" || x.ConsumptionDate == null ? (DateTime?)null : DateTime.Parse(x.ConsumptionDate),
                CódServiçoCliente = x.ServiceClientCode,
                Faturada = x.Billed,
                DataHoraModificação = x.UpdateDate,
                UtilizadorModificação = x.UpdateUser,
                PréRegisto = x.PreRegistered,

                AcertoDePreços = x.AdjustedPrice,
                CódDestinoFinalResíduos = x.ResidueFinalDestinyCode,
                DataAutorizaçãoFaturação = x.AutorizatedInvoiceData == "" || x.AutorizatedInvoiceData == null ? (DateTime?)null : DateTime.Parse(x.AutorizatedInvoiceData),
                DataDocumentoCorrigido = x.AdjustedDocumentData == "" || x.AdjustedDocumentData == null ? (DateTime?)null : DateTime.Parse(x.AdjustedDocumentData),
                DataHoraCriação = x.CreateDate,
                DocumentoCorrigido = x.AdjustedDocument,
                DocumentoOriginal = x.OriginalDocument,
                FaturaçãoAutorizada = x.AutorizatedInvoice,
                Motorista = x.Driver,
                NºDocumento = x.DocumentNo,
                NºFolhaHoras = x.FolhaHoras,
                NºFuncionário = x.EmployeeNo,
                NºLinhaRequisição = x.RequestLineNo,
                NºRequisição = x.RequestNo,
                QuantidadeDevolvida = x.QuantityReturned,
                RequisiçãoInterna = x.InternalRequest,
                TipoRecurso = x.ResourceType,
                UtilizadorCriação = x.CreateUser
            });
        }
コード例 #3
0
        public static async Task <WSCreatePreInvoiceLine.Create_Result> CreatePreInvoiceLine(ProjectDiaryViewModel PreInvoiceLineToCreate, NAVWSConfigurations WSConfigurations, string PKey)
        {
            //Mapping Object
            WSCreatePreInvoiceLine.Type TypeValue;
            switch (PreInvoiceLineToCreate.Type)
            {
            case 1:
                TypeValue = WSCreatePreInvoiceLine.Type.Resource;
                break;

            case 2:
                TypeValue = WSCreatePreInvoiceLine.Type.Item;
                break;

            case 3:
                TypeValue = WSCreatePreInvoiceLine.Type.G_L_Account;
                break;

            case 4:
                TypeValue = WSCreatePreInvoiceLine.Type.Fixed_Asset;
                break;

            case 5:
                TypeValue = WSCreatePreInvoiceLine.Type.Charge_Item;
                break;

            default:
                TypeValue = WSCreatePreInvoiceLine.Type._blank_;
                break;
            }

            WSCreatePreInvoiceLine.Create NAVCreate = new WSCreatePreInvoiceLine.Create()
            {
                WsPreInvoiceLine = new WSCreatePreInvoiceLine.WsPreInvoiceLine()
                {
                    Unit_PriceSpecified    = true,
                    Unit_Cost_LCYSpecified = true,
                    Document_Type          = WSCreatePreInvoiceLine.Document_Type.Invoice,
                    Document_TypeSpecified = true,
                    Document_No            = PKey,
                    Type                                = TypeValue,
                    No                                  = PreInvoiceLineToCreate.Code,
                    Description100                      = PreInvoiceLineToCreate.Description,
                    QuantitySpecified                   = true,
                    Quantity                            = (int)PreInvoiceLineToCreate.Quantity,
                    TypeSpecified                       = true,
                    Unit_of_Measure                     = PreInvoiceLineToCreate.MeasurementUnitCode,
                    Location_Code                       = PreInvoiceLineToCreate.LocationCode,
                    Unit_Price                          = (decimal)PreInvoiceLineToCreate.UnitPrice,
                    Unit_Cost_LCY                       = (decimal)PreInvoiceLineToCreate.UnitCost,
                    Job_Journal_Line_No_Portal          = PreInvoiceLineToCreate.LineNo,
                    Job_Journal_Line_No_PortalSpecified = true,
                }
            };

            //Configure NAV Client
            EndpointAddress WS_URL = new EndpointAddress(WSConfigurations.WS_PreInvoiceLine_URL.Replace("Company", WSConfigurations.WS_User_Company));

            WSCreatePreInvoiceLine.WsPreInvoiceLine_PortClient WS_Client = new WSCreatePreInvoiceLine.WsPreInvoiceLine_PortClient(navWSBinding, WS_URL);
            WS_Client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;
            WS_Client.ClientCredentials.Windows.ClientCredential          = new NetworkCredential(WSConfigurations.WS_User_Login, WSConfigurations.WS_User_Password, WSConfigurations.WS_User_Domain);

            try
            {
                WSCreatePreInvoiceLine.Create_Result result = await WS_Client.CreateAsync(NAVCreate);

                return(result);
            }
            catch (Exception ex)
            {
                throw;
            }
        }