Skip to content

Commit

Permalink
docs: crea ejemplo json de movimientos
Browse files Browse the repository at this point in the history
  • Loading branch information
AndresRamos committed Aug 7, 2023
1 parent 00679b1 commit 45a9731
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 2 deletions.
87 changes: 87 additions & 0 deletions docs/Requests/Movimientos/Movimiento.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"id": 0,
"producto": {
"id": 0,
"codigo": "PROD001",
"nombre": "",
"tipo": "Producto",
"claveSat": "",
"datosExtra": {}
},
"almacen": {
"id": 0,
"codigo": "ALMACENPRUEBA",
"nombre": "",
"datosExtra": {}
},
"unidades": 1,
"precio": 100,
"subtotal": 0,
"descuentos": {
"descuento1": {
"tasa": 10,
"importe": 0
},
"descuento2": {
"tasa": 0,
"importe": 0
},
"descuento3": {
"tasa": 0,
"importe": 0
},
"descuento4": {
"tasa": 0,
"importe": 0
},
"descuento5": {
"tasa": 0,
"importe": 0
}
},
"impuestos": {
"impuesto1": {
"tasa": 16,
"importe": 0
},
"impuesto2": {
"tasa": 0,
"importe": 0
},
"impuesto3": {
"tasa": 0,
"importe": 0
}
},
"retenciones": {
"retencion1": {
"tasa": 0,
"importe": 0
},
"retencion2": {
"tasa": 0,
"importe": 0
}
},
"total": 0,
"referencia": "Referencia mov",
"observaciones": "Observaciones del movimiento",
"seriesCapas": [
{
"unidades": 0,
"tipoCambio": 0,
"series": "",
"pedimento": "",
"agencia": "",
"fechaPedimento": null,
"numeroLote": "",
"fechaFabricacion": null,
"fechaCaducidad": null
}
],
"datosExtra": {
"CTEXTOEXTRA1": "Texto extra 1",
"CTEXTOEXTRA2": "Texto extra 2",
"CTEXTOEXTRA3": "Texto extra 3"
}
}
46 changes: 46 additions & 0 deletions samples/Api.Sdk.ConsoleApp/JsonFactories/MovimientoFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Text.Json;
using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.Models;
using ARSoftware.Contpaqi.Comercial.Sdk.Abstractions.ValueObjects;
using ARSoftware.Contpaqi.Comercial.Sql.Models.Empresa;

namespace Api.Sdk.ConsoleApp.JsonFactories;

public class MovimientoFactory
{
public static Movimiento GetModeloPrueba()
{
return new Movimiento
{
Producto = new Producto { Codigo = ProductoFactory.CodigoPrueba },
Almacen = new Almacen { Codigo = AlmacenFactory.CodigoPrueba },
Unidades = 1,
Precio = 100,
Impuestos = new ImpuestosMovimiento { Impuesto1 = new Impuesto { Tasa = 16 } },
Descuentos = new DescuentosMovimiento { Descuento1 = new Descuento { Tasa = 10 } },
Retenciones = new RetencionesMovimiento { Retencion1 = new Retencion(), Retencion2 = new Retencion() },
Referencia = "Referencia mov",
Observaciones = "Observaciones del movimiento",
SeriesCapas = new List<SeriesCapas> { new() },
DatosExtra = GetDatosExtraPrueba()
};
}

public static Dictionary<string, string> GetDatosExtraPrueba()
{
return new Dictionary<string, string>
{
{ nameof(admMovimientos.CTEXTOEXTRA1), "Texto extra 1" },
{ nameof(admMovimientos.CTEXTOEXTRA2), "Texto extra 2" },
{ nameof(admMovimientos.CTEXTOEXTRA3), "Texto extra 3" }
};
}

public static void CearJson(string directory)
{
Directory.CreateDirectory(directory);

JsonSerializerOptions options = FactoryExtensions.GetJsonSerializerOptions();

File.WriteAllText(Path.Combine(directory, $"{nameof(Movimiento)}.json"), JsonSerializer.Serialize(GetModeloPrueba(), options));
}
}
3 changes: 2 additions & 1 deletion samples/Api.Sdk.ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
EmpresaFactory.CearJson(Path.Combine(baseDirectory, "Empresas"));
ProductoFactory.CearJson(Path.Combine(baseDirectory, "Productos"));
DocumentoFactory.CearJson(Path.Combine(baseDirectory, "Documentos"));
//CartaPorteFactory.CearJson(Path.Combine(baseDirectory, "CartaPorte"));
CartaPorteFactory.CearJson(Path.Combine(baseDirectory, "CartaPorte"));
MovimientoFactory.CearJson(Path.Combine(baseDirectory, "Movimientos"));

Console.WriteLine("Programa Fin");
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public async Task<CrearFacturaResponse> Handle(CrearFacturaRequest request, Canc
new GenerarDocumentoDigitalRequestModel { LlaveDocumento = _llaveDocumento },
new GenerarDocumentoDigitalRequestOptions
{
Tipo = TipoArchivoDigital.Xml, NombrePlantilla = request.Options.NombrePlantilla
Tipo = TipoArchivoDigital.Pdf, NombrePlantilla = request.Options.NombrePlantilla
});
GenerarDocumentoDigitalResponse generarPdfResponse = await _mediator.Send(generarPdfRequest, cancellationToken);
pdf = generarPdfResponse.Model.DocumentoDigital;
Expand Down

0 comments on commit 45a9731

Please sign in to comment.