X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/blobdiff_plain/1a91316f990d419553dcad3b40074f6484d28b28..e12f7e6ef14af28c89e08f570e24c61493558731:/emufs_gui/facturas.c diff --git a/emufs_gui/facturas.c b/emufs_gui/facturas.c index f1b60aa..00b5276 100644 --- a/emufs_gui/facturas.c +++ b/emufs_gui/facturas.c @@ -83,8 +83,25 @@ t_Item *leer_items(xmlNode *node, int *cant, int size) int count; char *prop; if (size == -1) { - *cant = 0; - return NULL; + tmp = NULL; + count = 0; + node = node->children; + while (node) { + if (node->type == XML_ELEMENT_NODE) { + if (strcmp(node->name, "ITEMVENTA") == 0) { + count++; + tmp = realloc(tmp, sizeof(t_Item)*count); + memset(&tmp[count-1], '*', sizeof(t_Item)); + prop = xml_get_prop(node, "NroArtículo"); + tmp[count-1].numero = atoi(prop); + xmlFree(prop); + strcpy(tmp[count-1].cv, prop = xml_get_prop(node, "CV")); xmlFree(prop); + strcpy(tmp[count-1].pvu, prop = xml_get_prop(node, "PVU")); xmlFree(prop); + } + } + node = node->next; + } + *cant = count; } else { (*cant) = size; tmp = (t_Item *)malloc(sizeof(t_Item)*size); @@ -206,7 +223,7 @@ t_LstFacturas *fact_cargar(const char *filename, int tipo, int tam_bloque) 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); + fact.items = leer_items(node, &fact.cant_items, ((tipo-1)==T3)?10:-1); error = 0; id = tmp->fp_texto->grabar_registro(tmp->fp_texto, fact.nota, strlen(fact.nota)+1, &error); @@ -264,10 +281,16 @@ t_LstFacturas *fact_cargar(const char *filename, int tipo, int tam_bloque) int fact_liberar(t_LstFacturas *l) { + t_Reg_Factura *del; if (l == NULL) l = lst_facturas; if (l == NULL) return 1; emufs_destruir(l->fp); + while (l->primero) { + del = l->primero; + l->primero = l->primero->sig; + free(del); + } free(l); lst_facturas = NULL; @@ -482,7 +505,6 @@ void fact_agregar(char *s) form_ejecutar(form, 1,1); fact.numero = form_obtener_valor_int(form, "Numero de Factura"); - fprintf(stderr, "Agregando numero %d\n", fact.numero); strcpy(fact.emision, form_obtener_valor_char(form, "Fecha Emision")); strcpy(fact.vencimiento, form_obtener_valor_char(form, "Fecha Vto")); fact.numero_remito = form_obtener_valor_int(form, "Nro Remito"); @@ -586,17 +608,18 @@ void *procesar_guardar_factura(t_Factura *f, t_LstFacturas *lst, EMUFS_REG_SIZE memset(tmp, 0, *size); /* Ahora copio la info */ memcpy(tmp, &f->numero, i[0]); - memcpy(tmp, &f->procdoi, i[1]); - memcpy(tmp, &f->numero_remito, i[2]); - memcpy(tmp, &f->cant_items, i[3]); - memcpy(tmp, &f->reg_nota, i[4]); + memcpy(tmp+i[0], &f->procdoi, i[1]); + memcpy(tmp+i[0]+i[1], &f->numero_remito, i[2]); + memcpy(tmp+i[0]+i[1]+i[2], &f->cant_items, i[3]); + memcpy(tmp+i[0]+i[1]+i[2]+i[3], &f->reg_nota, i[4]); memcpy(tmp+i[0]+i[1]+i[2]+i[3]+i[4], f->emision, i[5]); memcpy(tmp+i[0]+i[1]+i[2]+i[3]+i[4]+i[5], f->vencimiento, i[6]); memcpy(tmp+i[0]+i[1]+i[2]+i[3]+i[4]+i[5]+i[6], f->estado, i[7]); memcpy(tmp+i[0]+i[1]+i[2]+i[3]+i[4]+i[5]+i[6]+i[7], f->fp, i[8]); memcpy(tmp+i[0]+i[1]+i[2]+i[3]+i[4]+i[5]+i[6]+i[7]+i[8], f->ctacte, i[9]); memcpy(tmp+i[0]+i[1]+i[2]+i[3]+i[4]+i[5]+i[6]+i[7]+i[8]+i[9], f->cheque, i[10]); - memcpy(tmp+i[0]+i[1]+i[2]+i[3]+i[4]+i[5]+i[6]+i[7]+i[8]+i[9]+i[10], f->items, i[11]); + if (i[11] != 0) + memcpy(tmp+i[0]+i[1]+i[2]+i[3]+i[4]+i[5]+i[6]+i[7]+i[8]+i[9]+i[10], f->items, i[11]); break; case T3: (*size) = sizeof(t_Factura)-sizeof(char *)-sizeof(t_Item *) + f->cant_items*sizeof(t_Item);