Exemple #1
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute exec_cancelaDespesa ");

            /// USER [ execute ]

            fat_det = new T_FaturamentoDetalhes(this);

            if (!fat_det.selectIdentity(input_fk_faturamentoDetalhe))
            {
                PublishError("Despensa não encontrada");
                return(false);
            }

            if (!fat_det.delete())
            {
                return(false);
            }

            PublishNote("Despesa removida com sucesso");

            /// USER [ execute ] END

            Registry("execute done exec_cancelaDespesa ");

            return(true);
        }
Exemple #2
0
 public void copy(ref T_FaturamentoDetalhes cpy)
 {
     fk_fatura     = cpy.fk_fatura;
     tg_tipoFat    = cpy.tg_tipoFat;
     nu_quantidade = cpy.nu_quantidade;
     vr_cobranca   = cpy.vr_cobranca;
     tg_desconto   = cpy.tg_desconto;
     st_extras     = cpy.st_extras;
     fk_empresa    = cpy.fk_empresa;
     fk_loja       = cpy.fk_loja;
 }
Exemple #3
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute schedule_faturamento ");

            /// USER [ execute ]

            T_Empresa emp   = new T_Empresa(this);
            DateTime  dtFat = DateTime.Now.AddDays(-1);

            #region - ## Busca todas as empresas -

            if (emp.selectAll())
            {
                // ## Busco todos os registros

                while (emp.fetch())
                {
                    // ## Se dia é hoje

                    if (emp.get_int_nu_periodoFat() == dtFat.Day &&
                        emp.get_tg_isentoFat() == Context.FALSE)
                    {
                        T_Faturamento fat     = new T_Faturamento(this);
                        T_Faturamento fat_upd = new T_Faturamento(this);

                        DateTime aux = dtFat;

                        // ## Para casos onde o mês deve ser o próximo

                        if (emp.get_int_nu_diaVenc() < dtFat.Day)
                        {
                            aux = dtFat.AddMonths(1);
                        }

                        DateTime dtVenc = new DateTime(aux.Year,
                                                       aux.Month,
                                                       (int)emp.get_int_nu_diaVenc());

                        fat.set_dt_vencimento(GetDataBaseTime(dtVenc));
                        fat.set_fk_empresa(emp.get_identity());
                        fat.set_tg_situacao(TipoSitFat.Pendente);

                        // ## Crio registro

                        fat.create_T_Faturamento();

                        long vr_total_fat = 0;

                        // ## Crio registro detalhe

                        #region - 1 - mensalidade -

                        {
                            T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this);

                            fat_det.set_fk_fatura(fat.get_identity());
                            fat_det.set_vr_cobranca(emp.get_vr_mensalidade());
                            fat_det.set_tg_tipoFat(TipoFat.TBM);
                            fat_det.set_tg_desconto(Context.FALSE);
                            fat_det.set_fk_empresa(emp.get_identity());
                            fat_det.set_fk_loja(Context.FALSE);

                            vr_total_fat += fat_det.get_int_vr_cobranca();

                            fat_det.create_T_FaturamentoDetalhes();
                        }

                        #endregion

                        #region - 2 - valor por transações -

                        if (emp.get_int_vr_transacao() > 0)
                        {
                            LOG_Transacoes l_tr = new LOG_Transacoes(this);

                            l_tr.SetCountMode();

                            l_tr.select_rows_dt_emp(GetDataBaseTime(dtFat.AddMonths(-1)),
                                                    GetDataBaseTime(dtFat),
                                                    emp.get_identity());

                            long trans = l_tr.GetCount() - emp.get_int_nu_franquia();

                            if (trans > 0)
                            {
                                T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this);

                                fat_det.set_fk_fatura(fat.get_identity());
                                fat_det.set_vr_cobranca((trans * emp.get_int_vr_transacao()).ToString());
                                fat_det.set_tg_tipoFat(TipoFat.FixoTrans);
                                fat_det.set_nu_quantidade(l_tr.GetCount().ToString());
                                fat_det.set_tg_desconto(Context.FALSE);
                                fat_det.set_fk_empresa(emp.get_identity());
                                fat_det.set_fk_loja(Context.FALSE);

                                vr_total_fat += fat_det.get_int_vr_cobranca();

                                fat_det.create_T_FaturamentoDetalhes();
                            }
                        }

                        #endregion

                        #region - 3 - valor percentual por transações -

                        if (emp.get_int_nu_pctValor() > 0)
                        {
                            LOG_Transacoes l_tr = new LOG_Transacoes(this);

                            // ## Busca por período e empresa

                            if (l_tr.select_rows_dt_emp(GetDataBaseTime(dtFat.AddMonths(-1)),
                                                        GetDataBaseTime(dtFat),
                                                        emp.get_identity()))
                            {
                                long vr_trans = 0;

                                while (l_tr.fetch())
                                {
                                    if (l_tr.get_tg_confirmada() == TipoConfirmacao.Confirmada)
                                    {
                                        vr_trans += l_tr.get_int_vr_total();
                                    }
                                }

                                if (vr_trans > 0)
                                {
                                    vr_trans = vr_trans * emp.get_int_nu_pctValor() / 10000;

                                    T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this);

                                    fat_det.set_fk_fatura(fat.get_identity());
                                    fat_det.set_vr_cobranca(vr_trans.ToString());
                                    fat_det.set_tg_tipoFat(TipoFat.Percent);
                                    fat_det.set_tg_desconto(Context.FALSE);
                                    fat_det.set_fk_empresa(emp.get_identity());
                                    fat_det.set_fk_loja(Context.FALSE);

                                    vr_total_fat += fat_det.get_int_vr_cobranca();

                                    fat_det.create_T_FaturamentoDetalhes();
                                }
                            }
                        }

                        #endregion

                        #region - 4 - valor cartão ativo -

                        if (emp.get_int_vr_cartaoAtivo() > 0)
                        {
                            T_Cartao cart = new T_Cartao(this);

                            // ## Busca por período e empresa

                            if (cart.select_rows_empresa(emp.get_st_empresa()))
                            {
                                T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this);

                                fat_det.set_fk_fatura(fat.get_identity());
                                fat_det.set_vr_cobranca((cart.RowCount() * emp.get_int_vr_cartaoAtivo()).ToString());
                                fat_det.set_tg_tipoFat(TipoFat.CartaoAtiv);
                                fat_det.set_tg_desconto(Context.FALSE);
                                fat_det.set_fk_empresa(emp.get_identity());
                                fat_det.set_fk_loja(Context.FALSE);

                                vr_total_fat += fat_det.get_int_vr_cobranca();

                                fat_det.create_T_FaturamentoDetalhes();
                            }
                        }

                        #endregion

                        #region - 5 - valores extras -

                        T_FaturamentoDetalhes fat_extras = new T_FaturamentoDetalhes(this);

                        if (fat_extras.select_rows_emp(emp.get_identity(), TipoFat.Extras))
                        {
                            while (fat_extras.fetch())
                            {
                                vr_total_fat += fat_extras.get_int_vr_cobranca();

                                T_FaturamentoDetalhes fat_extras_upd = new T_FaturamentoDetalhes(this);

                                fat_extras_upd.ExclusiveAccess();

                                fat_extras_upd.selectIdentity(fat_extras.get_identity());
                                fat_extras_upd.set_fk_fatura(fat.get_identity());

                                fat_extras_upd.synchronize_T_FaturamentoDetalhes();
                                fat_extras_upd.ReleaseExclusive();
                            }
                        }

                        #endregion

                        if (emp.get_int_vr_minimo() > vr_total_fat)
                        {
                            vr_total_fat = emp.get_int_vr_minimo();
                        }

                        fat_upd.ExclusiveAccess();
                        fat_upd.selectIdentity(fat.get_identity());

                        fat_upd.set_vr_cobranca(vr_total_fat.ToString());

                        fat_upd.synchronize_T_Faturamento();
                        fat_upd.ReleaseExclusive();
                    }
                }
            }

            #endregion

            T_Loja loj = new T_Loja(this);

            // ## Busca todas as lojas

            if (loj.selectAll())
            {
                // ## Busco todos os registros

                while (loj.fetch())
                {
                    // ## Se dia é hoje

                    Trace("Loja: " + loj.get_st_nome());

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

                    Trace("Loja ok ");

                    if (loj.get_int_nu_periodoFat() == dtFat.Day &&
                        loj.get_tg_isentoFat() == Context.FALSE)
                    {
                        Trace("[A]");

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

                        DateTime aux = dtFat;

                        // ## Para casos onde o mês deve ser o próximo

                        if (loj.get_int_nu_diavenc() < dtFat.Day)
                        {
                            Trace("[B]");
                            aux = dtFat.AddMonths(1);
                        }

                        Trace("[C]");

                        int zday = Convert.ToInt32(loj.get_int_nu_diavenc());

                        Trace("[C] 1 " + aux.Year.ToString());
                        Trace("[C] 2 " + aux.Month.ToString());
                        Trace("[C] 3 " + zday.ToString());

                        DateTime dtVenc = new DateTime(aux.Year, aux.Month, zday);

                        Trace("[D]");

                        fat.set_dt_vencimento(GetDataBaseTime(dtVenc));
                        fat.set_fk_loja(loj.get_identity());
                        fat.set_tg_situacao(TipoSitFat.Pendente);

                        // ## Crio registro

                        fat.create_T_Faturamento();

                        long vr_total_fat = 0;

                        // ## Crio registro detalhe

                        #region - 1 - mensalidade -

                        {
                            Trace("[E]");

                            T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this);

                            fat_det.set_fk_fatura(fat.get_identity());
                            fat_det.set_vr_cobranca(loj.get_vr_mensalidade());
                            fat_det.set_tg_tipoFat(TipoFat.TBM);
                            fat_det.set_tg_desconto(Context.FALSE);
                            fat_det.set_fk_empresa(Context.FALSE);
                            fat_det.set_fk_loja(loj.get_identity());

                            vr_total_fat += fat_det.get_int_vr_cobranca();

                            fat_det.create_T_FaturamentoDetalhes();
                        }

                        #endregion

                        #region - 2 - valor por transações -

                        if (loj.get_int_vr_transacao() > 0)
                        {
                            Trace("[F]");

                            LOG_Transacoes l_tr = new LOG_Transacoes(this);

                            l_tr.SetCountMode();

                            l_tr.select_rows_dt_loj(GetDataBaseTime(dtFat.AddMonths(-1)),
                                                    GetDataBaseTime(dtFat),
                                                    loj.get_identity());

                            long trans = l_tr.GetCount() - loj.get_int_nu_franquia();

                            if (trans > 0)
                            {
                                Trace("[G]");

                                T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this);

                                fat_det.set_fk_fatura(fat.get_identity());
                                fat_det.set_vr_cobranca((trans * loj.get_int_vr_transacao()).ToString());
                                fat_det.set_tg_tipoFat(TipoFat.FixoTrans);
                                fat_det.set_nu_quantidade(l_tr.GetCount().ToString());
                                fat_det.set_tg_desconto(Context.FALSE);
                                fat_det.set_fk_empresa(Context.FALSE);
                                fat_det.set_fk_loja(loj.get_identity());

                                vr_total_fat += fat_det.get_int_vr_cobranca();

                                fat_det.create_T_FaturamentoDetalhes();
                            }
                        }

                        #endregion

                        #region - 3 - valor percentual por transações -

                        if (loj.get_int_nu_pctValor() > 0)
                        {
                            Trace("[H]");

                            LOG_Transacoes l_tr = new LOG_Transacoes(this);

                            // ## Busca por período e empresa

                            if (l_tr.select_rows_dt_loj(GetDataBaseTime(dtFat.AddMonths(-1)),
                                                        GetDataBaseTime(dtFat),
                                                        loj.get_identity()))
                            {
                                Trace("[I]");

                                long vr_trans = 0;

                                while (l_tr.fetch())
                                {
                                    if (l_tr.get_tg_confirmada() == TipoConfirmacao.Confirmada)
                                    {
                                        vr_trans += l_tr.get_int_vr_total();
                                    }
                                }

                                if (vr_trans > 0)
                                {
                                    Trace("[J]");

                                    vr_trans = vr_trans * loj.get_int_nu_pctValor() / 10000;

                                    T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this);

                                    fat_det.set_fk_fatura(fat.get_identity());
                                    fat_det.set_vr_cobranca(vr_trans.ToString());
                                    fat_det.set_tg_tipoFat(TipoFat.Percent);
                                    fat_det.set_tg_desconto(Context.FALSE);
                                    fat_det.set_fk_empresa(Context.FALSE);
                                    fat_det.set_fk_loja(loj.get_identity());

                                    vr_total_fat += fat_det.get_int_vr_cobranca();

                                    fat_det.create_T_FaturamentoDetalhes();
                                }
                            }
                        }

                        #endregion

                        #region - 4 - valores extras -

                        T_FaturamentoDetalhes fat_extras = new T_FaturamentoDetalhes(this);

                        if (fat_extras.select_rows_emp(loj.get_identity(), TipoFat.Extras))
                        {
                            Trace("[K]");

                            while (fat_extras.fetch())
                            {
                                Trace("[L]");

                                vr_total_fat += fat_extras.get_int_vr_cobranca();

                                T_FaturamentoDetalhes fat_extras_upd = new T_FaturamentoDetalhes(this);

                                fat_extras_upd.ExclusiveAccess();

                                fat_extras_upd.selectIdentity(fat_extras.get_identity());
                                fat_extras_upd.set_fk_fatura(fat.get_identity());

                                fat_extras_upd.synchronize_T_FaturamentoDetalhes();
                                fat_extras_upd.ReleaseExclusive();
                            }
                        }

                        #endregion

                        if (vr_total_fat < loj.get_int_vr_minimo())
                        {
                            vr_total_fat = loj.get_int_vr_minimo();
                        }

                        fat_upd.ExclusiveAccess();
                        fat_upd.selectIdentity(fat.get_identity());

                        fat_upd.set_vr_cobranca(vr_total_fat.ToString());

                        fat_upd.synchronize_T_Faturamento();
                        fat_upd.ReleaseExclusive();

                        Trace("[M]");
                    }
                }
            }

            /// USER [ execute ] END

            Registry("execute done schedule_faturamento ");

            return(true);
        }
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute fetch_dadosDespesas ");

            /// USER [ execute ]

            string fk = "";

            if (input_tg_empresa == Context.TRUE)
            {
                T_Empresa emp = new T_Empresa(this);

                if (!emp.select_rows_empresa(input_st_codigo.PadLeft(6, '0')))
                {
                    PublishError("Código de empresa inválido");
                    return(false);
                }

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

                fk             = emp.get_identity();
                output_st_nome = emp.get_st_fantasia();
            }
            else
            {
                T_Loja loj = new T_Loja(this);

                if (!loj.select_rows_loja(input_st_codigo))
                {
                    PublishError("Código de loja inválido");
                    return(false);
                }

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

                fk             = loj.get_identity();
                output_st_nome = loj.get_st_nome();
            }

            T_FaturamentoDetalhes fat_det = new T_FaturamentoDetalhes(this);

            if (input_tg_empresa == Context.TRUE)
            {
                if (!fat_det.select_rows_emp(fk, TipoFat.Extras))
                {
                    PublishError("Nenhuma despesa encontrada");
                    return(false);
                }
            }
            else
            {
                if (!fat_det.select_rows_loja(fk, TipoFat.Extras))
                {
                    PublishError("Nenhuma despesa encontrada");
                    return(false);
                }
            }

            T_Faturamento fat = new T_Faturamento(this);

            while (fat_det.fetch())
            {
                if (fat.selectIdentity(fat_det.get_fk_fatura()))
                {
                    if (fat.get_tg_situacao() != TipoSitFat.Pendente)
                    {
                        continue;
                    }
                }

                DadosDespesas dd = new DadosDespesas();

                dd.set_fk_faturadet(fat_det.get_identity());
                dd.set_st_info(fat_det.get_st_extras());

                if (fat_det.get_tg_desconto() == Context.TRUE)
                {
                    dd.set_vr_cobrança("-" + fat_det.get_vr_cobranca());
                }
                else
                {
                    dd.set_vr_cobrança(fat_det.get_vr_cobranca());
                }

                output_array_generic_list.Add(dd);
            }

            /// USER [ execute ] END

            Registry("execute done fetch_dadosDespesas ");

            return(true);
        }
        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);
        }
Exemple #6
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);
        }
Exemple #7
0
        public override bool execute( )
        {
            if (base.execute() == false)
            {
                return(false);
            }

            Registry("execute ins_despesa ");

            /// USER [ execute ]

            T_FaturamentoDetalhes det = new T_FaturamentoDetalhes(this);

            det.set_vr_cobranca(input_vr_cobranca);
            det.set_tg_tipoFat(TipoFat.Extras);
            det.set_st_extras(input_st_extra);

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

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

                det.set_fk_empresa(emp.get_identity());
            }
            else
            {
                if (!loj.select_rows_loja(input_st_codigo))
                {
                    PublishError("Loja inexistente");
                    return(false);
                }

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

                det.set_fk_loja(loj.get_identity());
            }

            if (Convert.ToInt64(input_vr_cobranca) == 0)
            {
                PublishNote("Despesa de " + new money().formatToMoney(input_vr_cobranca) + " não registrada");
                return(true);
            }

            det.set_tg_desconto(input_tg_desconto);

            if (!det.create_T_FaturamentoDetalhes())
            {
                return(false);
            }

            if (!quiet)
            {
                PublishNote("Despesa de " + new money().formatToMoney(input_vr_cobranca) + " criada");
            }

            /// USER [ execute ] END

            Registry("execute done ins_despesa ");

            return(true);
        }