PrevisionPagoTest.cs
1 using Microsoft.VisualStudio.TestTools.UnitTesting;
2 using System;
3 using System.Data;
4 using sage.ew.docscompra;
5 using sage.ew.global;
6 using sage.ew.db;
7 using sage.ew.contabilidad;
8 using Sage.ES.S50.UnitTest.Tools;
9 
10 namespace Sage.ES.S50.UnitTest.Docscompra
11 {
12 
13 
18  [TestClass()]
19  public class PrevisionPagoTest
20  {
21 
22  private TestContext testContextInstance;
23 
28  public TestContext TestContext
29  {
30  get
31  {
32  return testContextInstance;
33  }
34  set
35  {
36  testContextInstance = value;
37  }
38  }
39 
40  #region Atributos de prueba adicionales
41  //
42  //Puede utilizar los siguientes atributos adicionales mientras escribe sus pruebas:
43  //
44  //Use ClassInitialize para ejecutar código antes de ejecutar la primera prueba en la clase
45 
46  [ClassInitialize()]
47  public static void MyClassInitialize(TestContext testContext)
48  {
49  //Conexion a Base de Datos
50  testContext.__Test_LoadRandomConfig();
51 
52  if (EW_GLOBAL._Empresa == null) EW_GLOBAL._Empresa = new sage.ew.empresa.Empresa(Convert.ToString(EW_GLOBAL._GetVariable("wc_empresa")));
53 
54  _NewCodigo = EW_GLOBAL._Empresa._Codigo + "|" + Convert.ToInt32(DB.Ejercicio_EW) + "|41000001|FACPRUEBA|1|1";
55  }
56 
57 
58  #endregion
59 
60  public PrevisionPago _Mantenimiento = new PrevisionPago();
61 
65  public static string _NewCodigo = "";
66 
70  public static string _RandomCodigo = "";
71 
75  [TestMethod()]
76  [Priority(1)]
77  public void NewTest()
78  {
79  string tcProveedor = "41000001";
80  string tcEmpresa = EW_GLOBAL._Empresa._Codigo;
81  string tcFactura = "FACPRUEBA";
82  int tnOrden = 1;
83  int tnPendiente = 0;
84  Decimal tnImporte = 10;
85  DateTime tdEmision = DateTime.Now;
86  DateTime tdVencim = DateTime.Now.AddDays(1);
87  string tcMoneda = EW_GLOBAL._Empresa._Moneda;
88  int tnNum_Banco = 0;
89  string tcBanco = string.Empty;
90  string tcVendedor = string.Empty;
91  string tcFpago = string.Empty;
92  string tcMandato = string.Empty;
93  string tcCobrador = string.Empty;
94  Int32 tnPeriodo = Convert.ToInt32(DB.Ejercicio_EW);
95 
96  _Mantenimiento._New(tcProveedor, tcEmpresa, tcFactura, tnOrden, tnPendiente, tnImporte, tdEmision, tdVencim, tcMoneda, tnNum_Banco, tcBanco, tdEmision, tcFpago, false, tnPeriodo);
97 
98  if (!_Mantenimiento._Existe_Registro())
99  {
100  Assert.Fail("No se puede crear una prevision de cobro");
101  }
102  else
103  {
104  _Mantenimiento._Delete();
105  }
106  }
107  [Owner(Owners.JoseA_Sevillano), TestMethod()]
108  [Priority(1)]
109  public void DeleteTest()
110  {
111  //Test genéric
112  _Mantenimiento.__Test_EwMante_Delete(_NewCodigo);
113  }
114 
118  [Owner(Owners.JoseA_Sevillano), TestMethod()]
119  [Priority(1)]
120  public void SaveTest()
121  {
122  DataTable ldtCodCom = new DataTable();
123  PrevisionPago target = new PrevisionPago();
124  target._Estado = sage.ew.ewbase.ewMante._EstadosMantenimiento.EntrandoNuevo;
125 
126 
127  string tcProveedor = "41000001";
128  string tcEmpresa = EW_GLOBAL._Empresa._Codigo;
129  string tcFactura = "FACPRUEBA";
130  int tnOrden = 0;
131  int tnPendiente = 0;
132  Decimal tnImporte = 10;
133  DateTime tdEmision = DateTime.Now;
134  DateTime tdVencim = DateTime.Now.AddDays(1);
135  string tcMoneda = EW_GLOBAL._Empresa._Moneda;
136  int tnNum_Banco = 0;
137  string tcBanco = string.Empty;
138  string tcVendedor = string.Empty;
139  string tcFpago = string.Empty;
140  string tcMandato = string.Empty;
141  string tcCobrador = string.Empty;
142  Boolean llOk = false;
143 
144  target._Codigo = tcEmpresa + "|" + Convert.ToInt32(DB.Ejercicio_EW) + "|" + tcProveedor + "|" + tcFactura + "|" + tnOrden + "|1";
145  target._Proveedor = tcProveedor;
146  target._Empresa = tcEmpresa;
147  target._Factura = tcFactura;
148  target._Numereb = tnOrden;
149  target._Pendiente = tnPendiente;
150  target._Divisa = tcMoneda;
151  target._Importe = tnImporte;
152  target._ImporteDiv = tnImporte;
153  target._Num_Banco = tnNum_Banco;
154  target._Fecha_Emision = tdEmision;
155  target._Fecha_Vencim = tdVencim;
156  target._Ejercicio = Convert.ToInt32(DB.Ejercicio_EW);
157 
158  if (!target._Existe_Registro()) target._Save();
159  llOk = target._Delete();
160 
161  Assert.AreEqual(llOk, true, "No se ha podido eliminar la prevision de pago");
162 
163  }
164 
168  [Owner(Owners.JoseA_Sevillano), TestMethod()]
169  [Priority(1)]
170  public void DeleteTest2()
171  {
172  DataTable ldtCodCom = new DataTable();
173  PrevisionPago target = new PrevisionPago();
174  target._Estado = sage.ew.ewbase.ewMante._EstadosMantenimiento.EntrandoNuevo;
175 
176 
177  if (EW_GLOBAL._Empresa == null) EW_GLOBAL._Empresa = new sage.ew.empresa.Empresa(Convert.ToString(EW_GLOBAL._GetVariable("wc_empresa")));
178 
179  string tcProveedor = "41000001";
180  string tcEmpresa = EW_GLOBAL._Empresa._Codigo;
181  string tcFactura = "FACPRUEBA";
182  int tnOrden = 1;
183  int tnPendiente = 0;
184  Decimal tnImporte = 10;
185  DateTime tdEmision = DateTime.Now;
186  DateTime tdVencim = DateTime.Now.AddDays(1);
187  string tcMoneda = EW_GLOBAL._Empresa._Moneda;
188  int tnNum_Banco = 0;
189  string tcBanco = string.Empty;
190  string tcVendedor = string.Empty;
191  string tcFpago = string.Empty;
192  string tcMandato = string.Empty;
193  string tcCobrador = string.Empty;
194  Boolean llOk = false;
195 
196  target._Codigo = tcEmpresa + "|" + Convert.ToInt32(DB.Ejercicio_EW) + "|" + tcProveedor + "|" + tcFactura + "|" + tnOrden + "|1";
197  target._Proveedor = tcProveedor;
198  target._Empresa = tcEmpresa;
199  target._Factura = tcFactura;
200  target._Numereb = tnOrden;
201  target._Pendiente = tnPendiente;
202  target._Divisa = tcMoneda;
203  target._Importe = tnImporte;
204  target._ImporteDiv = tnImporte;
205  target._Num_Banco = tnNum_Banco;
206  target._Fecha_Emision = tdEmision;
207  target._Fecha_Vencim = tdVencim;
208  target._Ejercicio = Convert.ToInt32(DB.Ejercicio_EW);
209 
210  if (!target._Existe_Registro()) target._Save();
211  llOk = target._Delete();
212 
213  Assert.AreEqual(llOk, true, "No se ha podido eliminar la prevision de pago");
214 
215  }
216 
220  [Owner(Owners.JoseA_Sevillano), TestMethod()]
221  [Priority(1)]
223  {
224  Boolean llRemoveCuenta = false;
225  DataTable ldtCodCom = new DataTable();
226  PrevisionPago target = new PrevisionPago();
227  target._Estado = sage.ew.ewbase.ewMante._EstadosMantenimiento.EntrandoNuevo;
228 
229  Cuenta loCuenta = new Cuenta();
230  loCuenta._Codigo = "57200001";
231  if (!loCuenta._Existe_Registro())
232  {
233  loCuenta._New("57200001", "BANCO");
234  llRemoveCuenta = true;
235  }
236 
237  if (EW_GLOBAL._Empresa == null) EW_GLOBAL._Empresa = new sage.ew.empresa.Empresa(Convert.ToString(EW_GLOBAL._GetVariable("wc_empresa")));
238 
239  string tcProveedor = "41000001";
240  string tcEmpresa = EW_GLOBAL._Empresa._Codigo;
241  string tcFactura = "FACPRUEBA";
242  int tnOrden = 1;
243  int tnPendiente = 0;
244  Decimal tnImporte = 10;
245  DateTime tdEmision = DateTime.Now;
246  DateTime tdVencim = DateTime.Now.AddDays(1);
247  string tcMoneda = EW_GLOBAL._Empresa._Moneda;
248  int tnNum_Banco = 0;
249  string tcBanco = string.Empty;
250  string tcVendedor = string.Empty;
251  string tcFpago = string.Empty;
252  string tcMandato = string.Empty;
253  string tcCobrador = string.Empty;
254  Boolean llOkC = false;
255 
256  target._Codigo = tcEmpresa + "|" + Convert.ToInt32(DB.Ejercicio_EW) + "|" + tcProveedor + "|" + tcFactura + "|" + tnOrden + "|1";
257  target._Proveedor = tcProveedor;
258  target._Empresa = tcEmpresa;
259  target._Factura = tcFactura;
260  target._Numereb = tnOrden;
261  target._Pendiente = tnPendiente;
262  target._Divisa = tcMoneda;
263  target._Importe = tnImporte;
264  target._ImporteDiv = tnImporte;
265  target._Num_Banco = tnNum_Banco;
266  target._Fecha_Emision =tdEmision;
267  target._Fecha_Vencim = tdVencim;
268  target._Ejercicio = Convert.ToInt32(DB.Ejercicio_EW);
269 
270  llOkC = target._Contabilizar("57200001", DateTime.Now, tnImporte);
271  llOkC = !String.IsNullOrEmpty(target._Asi);
272 
273  if (llOkC)
274  {
275  Asientos loAsiento = new Asientos(target._Asi);
276  loAsiento._Delete();
277  }
278  target._Delete();
279 
280  if (llRemoveCuenta) loCuenta._Delete();
281 
282  Assert.AreEqual(llOkC, true, "No se ha podido contabilizar la prevision de pago");
283  }
284  }
285 }
Clase de negocio base para mantenimientos
Definition: clsEwBase.cs:1643
Classe empresa basada en sage.ew.ewmante
Definition: clsEmpresa.cs:48
void _New(string tcProveedor, string tcEmpresa, string tcFactura, int tnOrden, int tnPendiente, decimal tnImporte, DateTime tdEmision, DateTime tdVencim, string tcMoneda, int tnNum_Banco, string tcBanco, DateTime? tdFecha_Oper, string tcFpago="", bool tlRecc=false, int tnPeriodo=0, decimal tnCambio=1, decimal tnImporteDiv=0, string lcConcepto="")
Crea una nueva previsión de pago a partir de los parámetros indicados y la carga en el objeto...
string _Empresa
Código de empresa.
string _Proveedor
Código de proveedor Contable
bool _Contabilizar(string tcBanco, DateTime tdFecha, decimal tnImporteEntrega, Asientos toAsiento=null)
Contabiliza la previsión cargada en el objeto, si el importe cobrado es inferior al de la prevision d...
Clase utilizada para realizar asientos contables.
Definition: Asientos.cs:36
_EstadosMantenimiento _Estado
Estado en que se encuentra el registro
Definition: clsEwBase.cs:2968
override void _New(string tcCodigo="")
_New
override bool _Save()
Método publico para guardar los datos de la previsión.
virtual bool _Existe_Registro()
Nos indica si existe el registro en la Base de Datos
Definition: clsEwBase.cs:3649
override string _Codigo
Sobreescribe el metodo _Codigo para cargar la configuración del TPV cuando se estableza el valor del ...
Definition: clsEmpresa.cs:2518
DateTime _Fecha_Vencim
Fecha vencimiento de previsión
Clase para las previsiones de pago de proveedores
override bool _Delete()
Borra la previsión de pago cargada, se realizan controles previos para asegurar que es posible el bor...
void PrevisionPagoContabilizar()
Una prueba de CContabilización /summary>
override string _Codigo
Campo clave del mantenimiento
Clase de negocio del mantenimiento de cuentas contables
virtual string _Codigo
Valor del campo clave que
Definition: clsEwBase.cs:2513
_EstadosMantenimiento
Declaro un enum para los estados del mantenimiento.
Definition: clsEwBase.cs:1671
static void MyClassInitialize(TestContext testContext)
string _Factura
Número de factura
void DeleteTest2()
Una prueba de _Delete /summary>
Se trata de una clase de prueba para PrevisionCobroTest y se pretende que contenga todas las pruebas ...
DateTime _Fecha_Emision
Fecha emisión de previsión
void NewTest()
Una prueba de _New /summary>
bool _Delete(bool tlActivarValidaciones)
si se pasa un true al borrar realiza todas la validaciones del borrado como si estuvieras al formular...
Definition: Asientos.cs:2438
string _Divisa
Moneda de la previsión
override bool _Delete()
Elimina el registro actual
void SaveTest()
Una prueba de _Delete /summary>