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);
count++;
}
}
+ if (count == 10) break; /* No me entran mas items! */
node = node->next;
}
}
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);
}
free(indices);
}
+
+ PERR("Facturas todo Ok");
return lst_facturas;
}
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;
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");
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);