예제 #1
0
        private void NumQuickDateIdent(int num)
        {
            if (Peek(2).Kind == TokenKind.AGO)
            {
                num = num * -1;
            }
            switch (Peek(1).Kind)
            {
            case TokenKind.DAY_IDENTIFIER:
                DayDateIdent(Peek(1).Text, TokenKind.NEXT);
                Load();
                break;

            case TokenKind.DAY:
                _dateRange.AddDate(Today.AddDays(num));
                Load();
                break;

            case TokenKind.WEEK:
                _dateRange.AddDate(Today.AddDays(num * 7));
                Load();
                break;

            case TokenKind.MONTH:
                _dateRange.AddDate(Today.AddMonths(num));
                Load();
                break;

            case TokenKind.YEAR:
                _dateRange.AddDate(Today.AddYears(num));
                Load();
                break;
            }
        }
예제 #2
0
        private void obras_ingreso_Load(object sender, EventArgs e)
        {
            sMil = P.Auxiliar.getSeparadorMil;
            DateTime tmp_fecha;

            tmp_fecha = Today.AddMonths(-6);
            ACode.Vperiodo tmp_per = new ACode.Vperiodo(tmp_fecha.Year, tmp_fecha.Month);

            Tfecha_compra.Value        = Today;
            Tfecha_compra.CustomFormat = "dd-MM-yyyy";
            Tfecha_compra.MaxDate      = Today;
            Tfecha_compra.MinDate      = tmp_per.first;

            Tfecha_conta.Value        = Today;
            Tfecha_conta.CustomFormat = "dd-MM-yyyy";
            Tfecha_conta.MaxDate      = Today;
            Tfecha_conta.MinDate      = tmp_per.first;

            //zonas
            cboZona.Items.AddRange(P.Consultas.zonas.SearchList().ToArray());
            cboZona.SelectedIndex = -1;

            //proveedor
            cboProveedor.Items.AddRange(P.Consultas.proveedores.listar().ToArray());
            cboProveedor.SelectedIndex = -1;

            color_btn = btn_guardar.BackColor;
        }
예제 #3
0
        public async Task Contas_Receber_Dados_Principais_Teste()
        {
            var filename   = $"{nameof(Contas_Receber_Dados_Principais_Teste)}.erp";
            var conteudo   = new StringBuilder();
            var vencimento = Today.AddMonths(1);

            conteudo.AppendLine(Arquivo.GetHeader);
            conteudo.AppendLine(ContasReceber.GetHeader);

            conteudo.AppendLine(RetornaContasReceberDadosPrincipais.First());

            conteudo.AppendLine(ContasReceber.GetTrailler);
            conteudo.Append(Arquivo.GetTrailler);

            var actual   = conteudo.ToString();
            var expected = string.Format(@"000000ALTERDATA
002000ARECEBER
002001000001000000123456              RAZÃO SOCIAL LTDA.                                {0}{1}        0000000497340000002300000300000000100000111223344                                          000002        000000000000000Observações aqui                                                                                                                                                                                                  0102      112233              CJ99999999999999    000000                                                          011111N000001                    S
002999{0}
999999{0}", Today.ToString("ddMMyyyy"), new DateTime(vencimento.Year, vencimento.Month, 5).ToString("ddMMyyyy"));

            Assert.Equal(expected, actual);
            Assert.True(Directory.Exists(PASTA_IMPORTACAO));

            var file = Path.Combine(PASTA_IMPORTACAO, filename);

            using (var sw = new StreamWriter(file))
            {
                await sw.WriteAsync(actual);
            }

            Assert.True(File.Exists(file));
        }
예제 #4
0
        public async Task Contas_Receber_Completo_Por_Conta_Teste()
        {
            var filename   = $"{nameof(Contas_Receber_Completo_Por_Conta_Teste)}.erp";
            var conteudo   = new StringBuilder();
            var vencimento = Today.AddMonths(1);

            conteudo.AppendLine(Arquivo.GetHeader);
            //conteudo.AppendLine(ContasReceber.GetHeader);

            conteudo.Append(new ContasReceber
            {
                ContasReceberHeader          = new ContasReceberHeader(),
                ContasReceberDadosPrincipais = RetornaContasReceberDadosPrincipais.First(),
                ContasReceberItensTitulo     = RetornaContasReceberItensTitulo.First(),
                ContasReceberRepasse         = RetornaContasReceberRepasse.First(),
                ContasReceberTrailler        = new ContasReceberTrailler()
            });

            conteudo.Append(new ContasReceber
            {
                ContasReceberHeader          = new ContasReceberHeader(),
                ContasReceberDadosPrincipais = RetornaContasReceberDadosPrincipais.Last(),
                ContasReceberItensTitulo     = RetornaContasReceberItensTitulo.Last(),
                ContasReceberRepasse         = RetornaContasReceberRepasse.Last(),
                ContasReceberTrailler        = new ContasReceberTrailler()
            });

            //conteudo.AppendLine(ContasReceber.GetTrailler);
            conteudo.Append(Arquivo.GetTrailler);

            var actual   = conteudo.ToString();
            var expected = string.Format(@"000000ALTERDATA
002000ARECEBER
002001000001000000123456              RAZÃO SOCIAL LTDA.                                {0}{1}        0000000497340000002300000300000000100000111223344                                          000002        000000000000000Observações aqui                                                                                                                                                                                                  0102      112233              CJ99999999999999    000000                                                          011111N000001                    S
002002000001000000123456              {0}RAZÃO SOCIAL LTDA.                                00000004973400          00000000000000010002590000050000000003000000025700000600000000030000000258000007000000000300000002600000080000000003000000026100000900000000030000000262000010000000000300000000000000000000000000000000000000000000000000000000000008000002000000000300000000000000000000000000000000006400001100000000030000
002003000002999997123456              001409000150000000000100000RRT000000400000000001
002999{0}
002000ARECEBER
002001000001000000654321              OUTRA RAZÃO SOCIAL ME.                            {0}{1}        0000000307940000002300000300000000100000144332211                                          000002        000000000000000                                                                                                                                                                                                                  0204      445566              CJ88888888888888    000000                                                          011111N000001                    S
002002000001000000654321              {0}OUTRA RAZÃO SOCIAL ME.                            00000003079400          00000000000000010002590000050000000002000000025700000600000000020000000258000007000000000200000002600000080000000002000000026100000900000000020000000262000010000000000200000000000000000000000000000000000000000000000000000000000008000002000000000200000000000000000000000000000000006400001100000000020000
002003000001999997654321              001410000200000000000100000RRT000000400000000001
002999{0}
999999{0}", Today.ToString("ddMMyyyy"), new DateTime(vencimento.Year, vencimento.Month, 5).ToString("ddMMyyyy"));

            Assert.Equal(expected, actual);
            Assert.True(Directory.Exists(PASTA_IMPORTACAO));

            var file = Path.Combine(PASTA_IMPORTACAO, filename);

            using (var sw = new StreamWriter(file))
            {
                await sw.WriteAsync(actual);
            }

            Assert.True(File.Exists(file));
        }
예제 #5
0
        public sealed override DateTimeRange CalculateFromInput(string input = "")
        {
            DateTime nextMonthSameDay = Today.AddMonths(months: 1);
            DateTime end = Today.AddMonths(months: 1).AddDays(value: -nextMonthSameDay.Day);

            return(new DateTimeRange
            {
                Start = Today.AddDays(value: -Today.Day + 1),
                End = end
            });
        }
예제 #6
0
        public PricerSheet(Worksheet sheet)
            : base(sheet)
        {
            _status = ControlRoot.AddControl(new StatusControl(sheet.Range["I4"], 10, 1, 6));
            ControlRoot.UnhandledException += ex =>
            {
                _status.Append(ex);
                // TODO: _log.Warn(ex);
            };

            var marketSettings = ControlRoot.AddControl(new PropertyGridControl(sheet.Range["B3"]));

            var market = new DropDownSelector {
                Values = new[] { "Live", "Close" }.ToReadOnly(), SelectedValue = "Live"
            };
            var valuationDate = new DateEditorControl {
                Value = Today
            };

            System.Action onMarketChanged = () => valuationDate.IsDisabled = market.SelectedValue == "Live";
            market.SelectedValueChanged += onMarketChanged;
            onMarketChanged();

            marketSettings.AddProperty("Valuation Date", valuationDate);
            marketSettings.AddProperty("Market", market);

            var trades = new List <TradeRowView>();

            trades.Add(new FXForwardRowView
            {
                Domestic       = { Value = Eur(10000) },
                Foreign        = { Value = Usd(12000) },
                SettlementDate = { Value = Today.AddMonths(3) },
                ForwardRate    = { Value = 1.2m }
            });

            trades.Add(new FXVanillaOptionRowView
            {
                Domestic       = { Value = Rub(10000) },
                Foreign        = { Value = Sgd(-12000) },
                SettlementDate = { Value = Today.AddMonths(6) },
                Strike         = { Value = 1.4m }
            });

            var tradeArea = ControlRoot.AddControl(new DynamicDataGridControl(sheet.Range["B15"], trades));

            tradeArea.AddColumns(new[] { "Settlement Date", "Domestic" });
        }
예제 #7
0
        public bool Validate(ProjectContactProxy savedVersion)
        {
            bool        contactChanged = true;
            bool        roleChanged    = true;
            bool        startChanged   = true;
            bool        amendment      = false;
            ClientTeams predecessor    = Predecessor();

            if (savedVersion == null)
            {
                savedVersion = new ProjectContactProxy();
            }                                                                       // Prevents having to check for null each time
            else
            {
                amendment      = true;
                contactChanged = (savedVersion.ContactID != ContactID);
                roleChanged    = (savedVersion.RoleCode != RoleCode);
                startChanged   = (savedVersion.FromDate != FromDate);
            }
            try
            {
                string errorMessage = "";
                if (Contact == null)
                {
                    errorMessage = "Please choose a contact from the list, or use the 'Search' function.|No Contact Selected";
                }
                else if (TeamRole == null)
                {
                    errorMessage = "Please select a project role for the contact.|No Role Selected";
                }
                else if (FromDate == null)
                {
                    errorMessage = "Please enter a date from which this contact is (or was) part of the team.|No Start Date";
                }
                else if (EffectiveTo < FromDate)
                {
                    errorMessage = "The 'To' date cannot be after the 'From' date.|Invalid Dates";
                }
                else if (amendment && (contactChanged || roleChanged) && savedVersion.IsHistoric)
                {
                    errorMessage = "Past team members cannot be amended, except to change their dates.|Historic Record";
                }
                else if (!Contact.Active && FromDate <= Today && EffectiveTo > Today)
                {
                    errorMessage = Contact.ContactName + " is inactive and cannot be part of the current client team now, but can be added for a future date.|Inactive User";
                }
                else if (IsDuplicate())
                {
                    errorMessage = Contact.ContactName + " already has the same role in the project during this period. Please check the existing record.|Duplicate Record";
                }
                else if (HasKeyRole && predecessor == null && FromDate > Project.StartDate)
                {
                    errorMessage = TeamRole.RoleDescription + " is a key role, and is not covered at the start of the project. Please adjust the 'from' date, then (if appropriate) "
                                   + "add an initial " + TeamRole.RoleDescription + " afterwards; the date of this record will then be adjusted automatically.|Key Role Not Covered";
                }
                else if (HasKeyRole && Successor() == null & ToDate != null)
                {
                    errorMessage = TeamRole.RoleDescription + " is a key role, and must always have a current record. Please leave the 'to' date blank, then (if appropriate) "
                                   + "add a subsequent " + TeamRole.RoleDescription + " afterwards; the date of this record will then be adjusted automatically.|Key Role Not Covered";
                }
                else if (amendment && roleChanged && savedVersion.HasKeyRole)
                {
                    errorMessage = "The existing role (" + savedVersion.TeamRole.RoleDescription + ") is a key role, and must always be filled during the project. Please ensure "
                                   + "continuity in that role (e.g. by selecting an alternative contact for this record) before changing/adding this contact's new project role.|Key Role Not Covered";
                }
                if (errorMessage != "")
                {
                    MessageFunctions.SplitInvalid(errorMessage);
                    return(false);
                }
            }
            catch (Exception generalException)
            {
                MessageFunctions.Error("Error validating client project team details", generalException);
                return(false);
            }

            try
            {
                MessageFunctions.ClearQuery();
                if (AlreadyOnProject())
                {
                    MessageFunctions.AddQuery(Contact.ContactName + " is already a client team member in a different capacity, or at a different time.");
                }
                if (amendment && (contactChanged || roleChanged) && Project.StartDate < Today.AddMonths(-1))
                {
                    MessageFunctions.AddQuery("This change is more than a month after the start of the project, which suggests an addition rather than amendment is required.");
                }
                if (startChanged && FromDate < Project.StartDate)
                {
                    MessageFunctions.AddQuery("This role starts before the project's official start date (which may be correct if involved in initialising the project).");
                }
                if (startChanged && FromDate > Today.AddYears(1))
                {
                    MessageFunctions.AddQuery("This role starts more than a year in the future.");
                }
                if (HasKeyRole)
                {
                    if (predecessor != null &&
                        ((FromDate != null && (predecessor.FromDate == null || predecessor.FromDate < FromDate))) &&
                        ((ToDate != null && (predecessor.ToDate == null || predecessor.ToDate > ToDate)))
                        )
                    {
                        MessageFunctions.AddQuery("Projects can only have one client " + TeamRole.RoleDescription + " at a time, and this project already has another " + TeamRole.RoleDescription
                                                  + " throughout this period. The existing record will automatically be split into 'before' and 'after' sections.");
                    }
                    else if (ProjectFunctions.SubsumesContact(this)) // Opposite scenario of above
                    {
                        MessageFunctions.AddQuery("Projects can only have one client " + TeamRole.RoleDescription + " at a time, and this period entirely covers an existing " + TeamRole.RoleDescription
                                                  + " record. That record will therefore be automatically deleted, and other existing records' dates adjusted to avoid overlaps.");
                    }
                    else if (RoleOverlap()) // Only if not throwing above - i.e. there is at least one overlap, but no complete replacement or split
                    {
                        MessageFunctions.AddQuery("Projects can only have one client " + TeamRole.RoleDescription + " at a time, and this project already has another " + TeamRole.RoleDescription
                                                  + " during part of this period. Existing records' dates will be automatically adjusted to avoid overlaps.");
                    }
                    if (predecessor != null && predecessor.ToDate != null && EffectiveFrom.AddDays(-1) > predecessor.ToDate)
                    {
                        MessageFunctions.AddQuery(TeamRole.RoleDescription + " is a key role, but this leaves a gap after the previous incumbent, so that record will be extended automatically. "
                                                  + "If that is not correct please adjust the 'from' date, or (after saving) add another interim record in between; existing dates will be adjusted to fit.");
                    }
                    if (Successor() != null && Successor().FromDate != null && EffectiveTo.AddDays(1) < Successor().FromDate)
                    {
                        MessageFunctions.AddQuery(TeamRole.RoleDescription + " is a key role, but this leaves a gap to the next incumbent, so that record will be extended automatically. "
                                                  + "If that is not correct please adjust the 'to' date, or (after saving) add another interim record in between; existing dates will be adjusted to fit.");
                    }
                }
                return(MessageFunctions.AskQuery(""));
            }
            catch (Exception generalException)
            {
                MessageFunctions.Error("Error validating client project team details", generalException);
                return(false);
            }
            finally
            {
                MessageFunctions.ClearQuery();
            }
        }