X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/blobdiff_plain/c11646cc62f361d1bb7e9dd583f1ee9e11116082..ba5a290c38249add0bbd77330368fc29ada65155:/emufs_gui/facturas.c diff --git a/emufs_gui/facturas.c b/emufs_gui/facturas.c index f940890..08eee4a 100644 --- a/emufs_gui/facturas.c +++ b/emufs_gui/facturas.c @@ -20,7 +20,12 @@ t_LstFacturas *fact_get_lst() /* Hack! ... Si no existe propiedad retorna "" */ char *xml_get_prop(xmlNode *node, char *nombre) { - if (xmlGetProp(node, nombre) == NULL) return ""; + char *s; + if (xmlGetProp(node, nombre) == NULL) { + s = malloc(1); + s[0] = '\0'; + return s; + } return xmlGetProp(node, nombre); } @@ -75,6 +80,7 @@ t_Item *leer_items(xmlNode *node, int *cant, int size) { t_Item *tmp; int count; + char *prop; if (size == -1) { *cant = 0; return NULL; @@ -88,9 +94,11 @@ t_Item *leer_items(xmlNode *node, int *cant, int size) while (node) { if (node->type == XML_ELEMENT_NODE) { if (strcmp(node->name, "ITEMVENTA") == 0) { - tmp[count].numero = atoi(xml_get_prop(node, "NroArtículo")); - strcpy(tmp[count].cv, xml_get_prop(node, "CV")); - strcpy(tmp[count].pvu, xml_get_prop(node, "PVU")); + prop = xml_get_prop(node, "NroArtículo"); + tmp[count].numero = atoi(prop); + xmlFree(prop); + strcpy(tmp[count].cv, prop = xml_get_prop(node, "CV")); xmlFree(prop); + strcpy(tmp[count].pvu, prop = xml_get_prop(node, "PVU")); xmlFree(prop); count++; } } @@ -130,6 +138,7 @@ t_LstFacturas *fact_cargar(const char *filename, int tipo, int tam_bloque) xmlDocPtr document; xmlNode *node, *inicio; int error = 0, cant_items; + char *prop; EMUFS_REG_SIZE size; t_LstFacturas *tmp; EMUFS_REG_ID id; /*, *indices, indices_cant;*/ @@ -179,15 +188,18 @@ t_LstFacturas *fact_cargar(const char *filename, int tipo, int tam_bloque) t_Factura fact; void *save; memset(&fact, '*', sizeof(t_Factura)); - fact.numero = atoi(xml_get_prop(node, "NroFac")); - fact.procdoi = atof(xml_get_prop(node, "PorcDoI")); - fact.numero_remito = atoi(xml_get_prop(node, "NroRemito")); - strcpy(fact.emision, xml_get_prop(node, "FechaEmisión")); - strcpy(fact.vencimiento, xml_get_prop(node, "FechaVto")); - strcpy(fact.estado, xml_get_prop(node, "Estado")); - strcpy(fact.fp, xml_get_prop(node, "FP")); - strcpy(fact.ctacte, xml_get_prop(node, "NroCtaCte")); - strcpy(fact.cheque, xml_get_prop(node, "NroCheque")); + prop = xml_get_prop(node, "NroFac"); + fact.numero = atoi(prop); xmlFree(prop); + prop = xml_get_prop(node, "PorcDoI"); + fact.procdoi = atof(prop); xmlFree(prop); + prop = xml_get_prop(node, "NroRemito"); + fact.numero_remito = atoi(prop); xmlFree(prop); + strcpy(fact.emision, prop = xml_get_prop(node, "FechaEmisión")); xmlFree(prop); + strcpy(fact.vencimiento, prop = xml_get_prop(node, "FechaVto")); xmlFree(prop); + strcpy(fact.estado, prop = xml_get_prop(node, "Estado")); xmlFree(prop); + strcpy(fact.fp, prop = xml_get_prop(node, "FP")); xmlFree(prop); + strcpy(fact.ctacte, prop = xml_get_prop(node, "NroCtaCte")); xmlFree(prop); + strcpy(fact.cheque, prop = xml_get_prop(node, "NroCheque")); xmlFree(prop); fact.nota = leer_nota(node); fact.items = leer_items(node, &fact.cant_items, (tipo==3)?10:-1);