コード例 #1
0
        public void TestTempIn()
        {
            CAB        cab  = new CAB();
            List <int> list = new List <int> {
                5, 4, 4, 2
            };

            Assert.AreEqual(list, cab.TempIn("5442"));
        }
コード例 #2
0
        public void TestBaseNum()
        {
            CAB        cab  = new CAB();
            List <int> list = new List <int> {
                6, 7, 7, 4
            };

            Assert.AreEqual(list, cab.BaseNum(6774));
        }
コード例 #3
0
        public void TestWin()
        {
            CAB cab = new CAB();

            Assert.AreEqual(40, cab.Guessing(new List <int> {
                1, 2, 3, 4
            }, new List <int> {
                1, 2, 3, 4
            }));
        }
コード例 #4
0
        public void TestBullCoW()
        {
            CAB cab = new CAB();

            Assert.AreEqual(22, cab.Guessing(new List <int> {
                1, 2, 3, 4
            }, new List <int> {
                1, 2, 4, 3
            }));
        }
コード例 #5
0
        public void TestCowNoBull()
        {
            CAB cab = new CAB();

            Assert.AreEqual(10, cab.Guessing(new List <int> {
                1, 0, 0, 0
            }, new List <int> {
                1, 2, 3, 4
            }));
        }
コード例 #6
0
        public void TestBullNoCoW()
        {
            CAB cab = new CAB();

            Assert.AreEqual(4, cab.Guessing(new List <int> {
                2, 2, 3, 4
            }, new List <int> {
                5, 5, 2, 2
            }));
        }
コード例 #7
0
        public void TestNoBullNoCoW()
        {
            CAB cab = new CAB();

            Assert.AreEqual(0, cab.Guessing(new List <int> {
                1, 2, 3, 4
            }, new List <int> {
                5, 6, 7, 8
            }));
        }
コード例 #8
0
        public static void GetDocumentoFromMove(int moveId)
        {
            MySqlConnection connection = null;

            connection = new MySqlConnection(ConnectionConfig.connectionString);
            Console.WriteLine(ConnectionConfig.connectionString);
            MySqlCommand command = connection.CreateCommand();

            command.CommandText = "SELECT " +
                                  "it_tmove.Docu_type_ID AS 'TipoDocumento', " +
                                  //Receptor
                                  "fl_tcustomer.TaxExemptNo, " +
                                  "fl_tcustomer.SS_NO, " +
                                  "idtypes.Codigo AS 'Tipo_Doc_Receptor', " +
                                  "Company_Name, " +
                                  "Cust_name, " +
                                  "it_tmove.Move_wic_Value, " +
                                  "it_tmove.Money_Conv, " +
                                  "it_tmove.Ticket_count AS 'IdDocumento', " +
                                  "it_tmove.Move_Date AS 'FechaEmision', " +
                                  "SUM(it_tdetamove.Move_Deta_Tax_Value) AS 'TotalIgv', " +
                                  "SUM(it_tdetamove.Move_Deta_Tax2_Value) AS 'TotalIsc', " +
                                  "SUM((it_tdetamove.Move_Deta_Q * it_tdetamove.Move_Deta_price)) AS 'TotalVenta' " +
                                  "FROM it_tmove " +
                                  "LEFT JOIN fl_tcustomer ON it_tmove.Cust_Id = fl_tcustomer.Cust_ID " +
                                  "INNER JOIN it_tdetamove ON it_tdetamove.Move_Deta_Move_ID = it_tmove.Move_ID " +
                                  "LEFT JOIN idtypes ON idtypes.TYPE_ID =  fl_tcustomer.IDType " +
                                  "WHERE it_tmove.Move_ID = " + moveId + " " +
                                  "GROUP BY NULL;";
            MySqlDataReader Reader;

            Console.WriteLine(command.CommandText);
            connection.Open();
            Reader = command.ExecuteReader();
            int i = 0;

            while (Reader.Read())
            {
                string TipoDocumento     = HelpersDatabase.GetString(Reader, "TipoDocumento");
                string TaxExemptNo       = HelpersDatabase.GetString(Reader, "TaxExemptNo");
                string SS_NO             = HelpersDatabase.GetString(Reader, "SS_NO");
                string Tipo_Doc_Receptor = HelpersDatabase.GetString(Reader, "Tipo_Doc_Receptor");
                string Company_Name      = HelpersDatabase.GetString(Reader, "Company_Name");
                string Cust_name         = HelpersDatabase.GetString(Reader, "Cust_name");

                decimal PrecioUnitario = HelpersDatabase.GetInt(Reader, "Move_wic_Value");
                decimal Money_Conv     = HelpersDatabase.GetInt(Reader, "Money_Conv");
                string  IdDocumento    = HelpersDatabase.GetString(Reader, "IdDocumento");
                string  FechaEmision   = HelpersDatabase.GetDate(Reader, "FechaEmision");
                string  HoraEmision    = HelpersDatabase.GetTime(Reader, "FechaEmision");

                decimal TotalIgv   = Reader.GetInt32("TotalIgv");
                decimal TotalIsc   = Reader.GetInt32("TotalIsc");
                decimal TotalVenta = Reader.GetInt32("TotalVenta");

                string NombreLegal;
                string NroDocumento;

                DetasPlusTaxes detasPlusTaxes = GetDETFromMove(moveId);

                if (string.IsNullOrEmpty(Company_Name) && string.IsNullOrEmpty(TaxExemptNo))
                {
                    NombreLegal  = Cust_name;
                    NroDocumento = SS_NO;
                }
                else
                {
                    NombreLegal  = Company_Name;
                    NroDocumento = TaxExemptNo;
                }

                string Moneda;
                if (PrecioUnitario == 0 && Money_Conv == 0)
                {
                    Moneda = "PEN";
                }
                else
                {
                    Moneda = "USD";
                }

                IDE iDE = new IDE()
                {
                    numeracion       = IdDocumento,
                    fechaEmision     = FechaEmision,
                    horaEmision      = HoraEmision,
                    codTipoDocumento = TipoDocumento,
                    tipoMoneda       = Moneda,
                    //numeroOrdenCompra = "",
                    //fechaVencimiento = "",
                };
                EMI eMI = new EMI()
                {
                    //codigoPais = "",
                    //correoElectronico = "",
                    tipoDocId       = "6",//falta
                    departamento    = Settings.Default.emDepartamento,
                    direccion       = Settings.Default.emDireccion,
                    distrito        = Settings.Default.emDistrito,
                    nombreComercial = Settings.Default.emNombreComercial,
                    numeroDocId     = Settings.Default.emRUC,
                    provincia       = Settings.Default.emProvincia,
                    razonSocial     = Settings.Default.emNombreLegal,
                    //telefono = "",

                    ubigeo       = Settings.Default.emUbigeo,
                    urbanizacion = Settings.Default.emUrbanizacion,
                };
                DRF dRF = new DRF()
                {
                    numeroDocRelacionado = "",
                    tipoDocRelacionado   = "",
                };
                CAB cAB = new CAB()
                {
                    gravadas = new Gravadas()
                    {
                        codigo      = "1002",
                        totalVentas = ""
                    },

                    inafectas = new Inafectas()
                    {
                        codigo      = "1004",
                        totalVentas = ""
                    },
                    importeTotal = TotalVenta.ToString(),
                    leyenda      = new List <Leyenda>()
                    {
                        new Leyenda()
                        {
                            codigo      = "1000",
                            descripcion = Conversores.NumeroALetras(TotalVenta)
                        }
                    },
                    tipoOperacion  = "01",
                    totalImpuestos = new List <TotalImpuesto>()
                    {
                        new TotalImpuesto()
                        {
                            idImpuesto = "1000", montoImpuesto = TotalIgv.ToString()
                        },                                                                             //IGV
                        new TotalImpuesto()
                        {
                            idImpuesto = "2000", montoImpuesto = TotalIsc.ToString()
                        }                                                                             //ISC
                    }
                };

                REC rEC = new REC()
                {
                    //codigoPais = "",
                    //correoElectronico = "",
                    //departamento = "",
                    //direccion = "",
                    //distrito = "",

                    numeroDocId = NroDocumento,
                    //provincia = "",
                    razonSocial = NombreLegal,
                    //telefono = "",
                    tipoDocId = Tipo_Doc_Receptor,
                };
                //GetDETFromMove(moveId),
                string output;
                if (TipoDocumento == "1")
                {
                    Factura fac = new Factura()
                    {
                        IDE = iDE,
                        EMI = eMI,
                        REC = rEC,
                        //DRF = ,
                        CAB = cAB,
                        DET = GetDETFromMove(moveId).DET,
                        //ADI
                    };
                    output = JsonConvert.SerializeObject(fac,
                                                         new JsonSerializerSettings
                    {
                        NullValueHandling = NullValueHandling.Ignore
                    });
                }
                else
                {
                    Boleta bol = new Boleta()
                    {
                        IDE = iDE,
                        EMI = eMI,
                        REC = rEC,
                        //DRF = ,
                        CAB = cAB,
                        DET = GetDETFromMove(moveId).DET,
                        //ADI
                    };
                    output = JsonConvert.SerializeObject(bol,
                                                         new JsonSerializerSettings
                    {
                        NullValueHandling = NullValueHandling.Ignore,
                    });
                }
                Console.WriteLine(output);
            }

            Reader.Close();
        }