Ejemplo n.º 1
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute fetch_rel_6_fat ");

            /// USER [ execute ]

            T_Faturamento fat = new T_Faturamento(this);

            if (!fat.select_rows_dt_venc(input_st_dt_ini,
                                         input_st_dt_fim,
                                         TipoSitFat.Pendente))
            {
                PublishError("Nenhum registro encontrado");
                return(false);
            }

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

            StringBuilder sb_content = new StringBuilder();
            StringBuilder sb_entity  = new StringBuilder();

            long total          = 0,
                 total_desconto = 0,
                 CartaoAtiv     = 0,
                 Extras         = 0,
                 FixoTrans      = 0,
                 Percent        = 0,
                 TBM            = 0;

            while (fat.fetch())
            {
                Entidade ent = new Entidade();

                ent.set_fk_fatura(fat.get_identity());

                long desconto = 0;

                if (fat.get_fk_empresa() != Context.NONE)
                {
                    if (!emp.selectIdentity(fat.get_fk_empresa()))
                    {
                        return(false);
                    }

                    if (emp.get_tg_isentoFat() == Context.TRUE)
                    {
                        continue;
                    }

                    ent.set_st_nome("Associação (" + emp.get_st_empresa() + ") " + emp.get_st_fantasia() + " - CNPJ: " + emp.get_nu_CNPJ());
                }
                else
                {
                    if (!loj.selectIdentity(fat.get_fk_loja()))
                    {
                        return(false);
                    }

                    if (loj.get_tg_isentoFat() == Context.TRUE)
                    {
                        continue;
                    }

                    ent.set_st_nome("Loja (" + loj.get_st_loja() + ") " + loj.get_st_nome() + " - CNPJ: " + loj.get_nu_CNPJ());
                }

                DataPortable tmp = ent as DataPortable;

                sb_entity.Append(MemorySave(ref tmp));
                sb_entity.Append(",");

                fat_det.Reset();

                if (fat_det.select_fk_fat(fat.get_identity()))
                {
                    while (fat_det.fetch())
                    {
                        Rel_FAT r_f = new Rel_FAT();

                        if (fat_det.get_tg_desconto() == Context.TRUE)
                        {
                            desconto += fat_det.get_int_vr_cobranca();
                        }

                        r_f.set_st_extra(fat_det.get_st_extras());
                        r_f.set_vr_cob(fat_det.get_vr_cobranca());
                        r_f.set_tg_tipoFat(fat_det.get_tg_tipoFat());
                        r_f.set_tg_desconto(fat_det.get_tg_desconto());

                        switch (fat_det.get_tg_tipoFat())
                        {
                        case TipoFat.CartaoAtiv:        CartaoAtiv += fat_det.get_int_vr_cobranca();    break;

                        case TipoFat.Extras:            Extras += fat_det.get_int_vr_cobranca();    break;

                        case TipoFat.FixoTrans:         FixoTrans += fat_det.get_int_vr_cobranca();    break;

                        case TipoFat.Percent:           Percent += fat_det.get_int_vr_cobranca();    break;

                        case TipoFat.TBM:                       TBM += fat_det.get_int_vr_cobranca();    break;
                        }

                        r_f.set_fk_fatura(fat_det.get_fk_fatura());

                        DataPortable tmp2 = r_f as DataPortable;

                        sb_content.Append(MemorySave(ref tmp2));
                        sb_content.Append(",");
                    }
                }

                total          += fat.get_int_vr_cobranca();
                total_desconto += desconto;

                output_st_csv_subtotal          += fat.get_vr_cobranca() + ",";
                output_st_csv_subtotal_desconto += desconto.ToString() + ",";
            }

            // content
            {
                string list_ids = sb_content.ToString().TrimEnd(',');

                DataPortable dp = new DataPortable();

                dp.setValue("ids", list_ids);

                output_st_content_block = MemorySave(ref dp);
            }

            // entidades
            {
                string list_ids = sb_entity.ToString().TrimEnd(',');

                DataPortable dp = new DataPortable();

                dp.setValue("ids", list_ids);

                output_st_emp_loj_block = MemorySave(ref dp);
            }

            output_st_csv_subtotal          = output_st_csv_subtotal.TrimEnd(',');
            output_st_csv_subtotal_desconto = output_st_csv_subtotal_desconto.TrimEnd(',');

            output_st_total          = total.ToString();
            output_st_total_desconto = total_desconto.ToString();
            output_CartaoAtiv        = CartaoAtiv.ToString();
            output_Extras            = Extras.ToString();
            output_FixoTrans         = FixoTrans.ToString();
            output_Percent           = Percent.ToString();
            output_TBM = TBM.ToString();

            /// USER [ execute ] END

            Registry("execute done fetch_rel_6_fat ");

            return(true);
        }
Ejemplo n.º 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);
        }