Пример #1
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute exec_fat_recManual ");

            /// USER [ execute ]

            T_Empresa emp = new T_Empresa(this);
            T_Loja    loj = new T_Loja(this);

            if (input_tg_empresa == Context.TRUE)
            {
                if (!emp.select_rows_empresa(input_st_codigo.PadLeft(6, '0')))
                {
                    PublishError("Empresa não disponível");
                    return(false);
                }

                if (!emp.fetch())
                {
                    return(false);
                }
            }
            else
            {
                if (!loj.select_rows_loja(input_st_codigo))
                {
                    PublishError("Loja não disponível");
                    return(false);
                }

                if (!loj.fetch())
                {
                    return(false);
                }
            }

            T_Faturamento fat     = new T_Faturamento(this);
            T_Faturamento fat_upd = new T_Faturamento(this);

            if (input_tg_empresa == Context.TRUE)
            {
                fat.select_rows_emp(emp.get_identity());
            }
            else
            {
                fat.select_rows_loj(loj.get_identity());
            }

            while (fat.fetch())
            {
                if (fat.get_tg_situacao() == TipoSitFat.EmCobrança)
                {
                    fat_upd.ExclusiveAccess();

                    if (!fat_upd.selectIdentity(fat.get_identity()))
                    {
                        return(false);
                    }

                    fat_upd.set_tg_situacao(TipoSitFat.PagoOutros);
                    fat_upd.set_vr_cobranca(input_vr_valor);

                    if (!fat_upd.synchronize_T_Faturamento())
                    {
                        return(false);
                    }

                    fat_upd.ReleaseExclusive();

                    PublishNote("Faturamento atualizado com sucesso");
                    break;
                }
            }

            /// USER [ execute ] END

            Registry("execute done exec_fat_recManual ");

            return(true);
        }
Пример #2
0
        public override bool authenticate( )
        {
            if (base.authenticate() == false)
            {
                return(false);
            }

            Registry("authenticate fetch_dadosFaturamento ");

            /// USER [ authenticate ]

            T_Faturamento         fat     = new T_Faturamento(this);
            T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this);

            T_Empresa emp = new T_Empresa(this);
            T_Loja    loj = new T_Loja(this);

            money mon = new money();

            string ident = "";

            if (input_tg_empresa == Context.TRUE)
            {
                if (!emp.select_rows_empresa(input_st_codigo.PadLeft(6, '0')))
                {
                    PublishError("Empresa não existente");
                    return(false);
                }

                if (!emp.fetch())
                {
                    return(false);
                }

                output_st_msg += emp.get_st_social() + "@";
                output_st_msg += emp.get_st_fantasia() + "@";
                output_st_msg += emp.get_nu_CNPJ() + "@";
                output_st_msg += emp.get_nu_telefone() + "@";

                output_st_msg += "@Faturamento pendente: @@";

                fat.SetReversedFetch();

                if (!fat.select_rows_emp(emp.get_identity()))
                {
                    PublishError("Nenhum faturamento encontrado");
                    return(false);
                }

                ident = emp.get_st_fantasia();
            }
            else
            {
                if (!loj.select_rows_loja(input_st_codigo))
                {
                    PublishError("Loja não existente");
                    return(false);
                }

                if (!loj.fetch())
                {
                    return(false);
                }

                output_st_msg += loj.get_st_nome() + "@";
                output_st_msg += loj.get_st_social() + "@";
                output_st_msg += loj.get_nu_CNPJ() + "@";
                output_st_msg += loj.get_nu_telefone();

                //fat.SetReversedFetch();

                if (!fat.select_rows_loj(loj.get_identity()))
                {
                    PublishError("Nenhum faturamento encontrado");
                    return(false);
                }
            }

            bool Found = false;

            long tot_cob = 0;

            while (fat.fetch())
            {
                if (fat.get_tg_situacao() == TipoSitFat.Pendente)
                {
                    output_st_msg += "@@Faturamento pendente: ";
                    Found          = true;
                }
                else if (fat.get_tg_situacao() == TipoSitFat.EmCobrança)
                {
                    output_st_msg += "@@Faturamento em cobrança: ";
                    Found          = true;
                }
                else
                {
                    continue;
                }

                output_st_msg += var_util.getDDMMYYYY_format(fat.get_dt_vencimento()).Substring(0, 10) + "@";
                output_st_msg += "@Total: R$ " + mon.formatToMoney(fat.get_vr_cobranca()) + "@";

                tot_cob += fat.get_int_vr_cobranca();

                if (!fat_det.select_fk_fat(fat.get_identity()))
                {
                    PublishNote("Nenhum faturamento encontrado");
                }

                output_st_msg += "@------ Detalhes ------- @";

                while (fat_det.fetch())
                {
                    switch (fat_det.get_tg_tipoFat())
                    {
                    case TipoFat.TBM:
                    {
                        output_st_msg += "@Tarifa básica mensal: ".PadRight(33, ' ') + "R$ " + mon.formatToMoney(fat_det.get_vr_cobranca()).PadLeft(7, ' ');
                        break;
                    }

                    case TipoFat.CartaoAtiv:
                    {
                        output_st_msg += "@Tarifa por cartões ativos: ".PadRight(33, ' ') + "R$ " + mon.formatToMoney(fat_det.get_vr_cobranca()).PadLeft(7, ' ');
                        break;
                    }

                    case TipoFat.FixoTrans:
                    {
                        output_st_msg += "@Valor sobre Transações: ".PadRight(33, ' ') + "R$ " + mon.formatToMoney(fat_det.get_vr_cobranca()).PadLeft(7, ' ');
                        break;
                    }

                    case TipoFat.Percent:
                    {
                        output_st_msg += "@Percentual sobre Transações: ".PadRight(33, ' ') + "R$ " + mon.formatToMoney(fat_det.get_vr_cobranca()).PadLeft(7, ' ');
                        break;
                    }
                    }
                }

                if (!fat_det.select_fk_fat(fat.get_identity()))
                {
                    PublishError("Nenhum faturamento encontrado");
                    return(false);
                }

                while (fat_det.fetch())
                {
                    switch (fat_det.get_tg_tipoFat())
                    {
                    case TipoFat.Extras:
                    {
                        output_st_msg += "@@------ Extras ------- @";

                        output_st_msg += "@" + fat_det.get_st_extras().PadRight(32, ' ') + "R$ " + mon.formatToMoney(fat_det.get_vr_cobranca()).PadLeft(7, ' ');

                        break;
                    }
                    }
                }
            }

            if (!Found)
            {
                output_st_msg += "@ - Nenhum débito pendente ou em cobrança - @";
            }
            else
            {
                output_st_msg += "@@@# Valor completo devido: R$ " + new money().setMoneyFormat(tot_cob) + "@";
            }

            output_vr_valor = tot_cob.ToString();

            if (input_tg_empresa == Context.TRUE)
            {
                fat_det.select_rows_emp(emp.get_identity(), TipoFat.Extras);
            }
            else
            {
                fat_det.select_rows_loja(loj.get_identity(), TipoFat.Extras);
            }

            if (fat_det.RowCount() > 0)
            {
                output_st_msg += "@@------ Lançamentos futuros ------- @";

                while (fat_det.fetch())
                {
                    output_st_msg += "@" + fat_det.get_st_extras().PadRight(32, ' ') + "R$ " + mon.formatToMoney(fat_det.get_vr_cobranca()).PadLeft(7, ' ');
                }

                if (Found)
                {
                    output_st_msg += "@@";
                }
            }

            /// USER [ authenticate ] END

            Registry("authenticate done fetch_dadosFaturamento ");

            return(true);
        }