X-Git-Url: https://git.llucax.com/z.facultad/75.06/emufs.git/blobdiff_plain/b004e49297244d2d3ebdd4c9adb91031cf045e10..886256e17add793dcdf26aac88e364e56d9daaa7:/emufs_gui/facturas.c diff --git a/emufs_gui/facturas.c b/emufs_gui/facturas.c index 00b5276..1ad3e5d 100644 --- a/emufs_gui/facturas.c +++ b/emufs_gui/facturas.c @@ -195,7 +195,7 @@ t_LstFacturas *fact_cargar(const char *filename, int tipo, int tam_bloque) /* En el registro no guardo los punteros de nota ni items. Si guardo la cantidad de items * y los items al final del registro. */ - if (tipo == 3) { + if (tipo == T3) { /* Limito a 10 items en el caso de registro constante! */ cant_items = 10; } else { @@ -215,12 +215,18 @@ t_LstFacturas *fact_cargar(const char *filename, int tipo, int tam_bloque) 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); + strncpy(fact.emision, prop = xml_get_prop(node, "FechaEmisión"), 8); xmlFree(prop); + fact.emision[8] = '\0'; + strncpy(fact.vencimiento, prop = xml_get_prop(node, "FechaVto"), 8); xmlFree(prop); + fact.vencimiento[8] = '\0'; + strncpy(fact.estado, prop = xml_get_prop(node, "Estado"), 2); xmlFree(prop); + fact.estado[2] = '\0'; + strncpy(fact.fp, prop = xml_get_prop(node, "FP"), 2); xmlFree(prop); + fact.fp[2] = '\0'; + strncpy(fact.ctacte, prop = xml_get_prop(node, "NroCtaCte"), 5); xmlFree(prop); + fact.ctacte[5] = '\0'; + strncpy(fact.cheque, prop = xml_get_prop(node, "NroCheque"), 18); xmlFree(prop); + fact.cheque[18] = '\0'; fact.nota = leer_nota(node); fact.items = leer_items(node, &fact.cant_items, ((tipo-1)==T3)?10:-1); @@ -472,8 +478,8 @@ void fact_modificar(char *s) void fact_agregar(char *s) { - WINDOW *win, *items; - t_Form *form; + WINDOW *win, *items, *nota, *subnota; + t_Form *form, *form_nota; t_Item *its = NULL; t_Factura fact; EMUFS_REG_SIZE size; @@ -489,6 +495,11 @@ void fact_agregar(char *s) wrefresh(win); items = derwin(win, LINES-20, COLS-4, 15, 1); + nota = derwin(win, 9, COLS-62, 1, 56); + subnota = derwin(nota, 7, COLS-64, 1, 1); + box(nota, 0, 0); + mvwaddstr(nota, 0, 1, "Nota :"); + wrefresh(nota); wrefresh(items); form = form_crear(win); @@ -504,6 +515,10 @@ void fact_agregar(char *s) form_ejecutar(form, 1,1); + form_nota = form_crear(subnota); + form_agregar_widget(form_nota, INPUT, "", 255, ""); + form_ejecutar(form_nota, 0, 0); + fact.numero = form_obtener_valor_int(form, "Numero de Factura"); strcpy(fact.emision, form_obtener_valor_char(form, "Fecha Emision")); strcpy(fact.vencimiento, form_obtener_valor_char(form, "Fecha Vto")); @@ -515,6 +530,7 @@ void fact_agregar(char *s) strcpy(fact.cheque, form_obtener_valor_char(form, "Cheque Nro")); form_destruir(form); + form_destruir(form_nota); form = form_crear(win); form_agregar_widget(form, INPUT, "Nro de Articulo (* == fin)", 8, ""); @@ -533,7 +549,7 @@ void fact_agregar(char *s) entrada = form_obtener_valor_char(form, "Nro de Articulo (* == fin)"); - if (entrada[0] != '\0') { + if ((entrada[0] != '\0') && (entrada[0] != '*')){ y_actual++; if (y_actual > LINES-22) { y_actual = LINES-22; @@ -546,17 +562,22 @@ void fact_agregar(char *s) /* Agrego el Item */ cant++; its = (t_Item *)realloc(its, cant*sizeof(t_Item)); - its[cant-1].numero = form_obtener_valor_int(form, entrada); + its[cant-1].numero = atoi(entrada); strcpy(its[cant-1].cv, form_obtener_valor_char(form, "CV")); strcpy(its[cant-1].pvu, form_obtener_valor_char(form, "PVU")); } - } while (strcmp(entrada, "*") != 0); + } while (entrada[0] != '*'); - if (lst_facturas->fp->tipo == 3) { + if (lst_facturas->fp->tipo == T3) { if (cant != 10) { /* TODO Limitar en la GUI en lugar de truncar! */ its = (t_Item *)realloc(its, 10*sizeof(t_Item)); - cant = 10; + if (its == NULL) { + cant = 0; + } else { + memset(its+sizeof(t_Item)*cant, 0, (10-cant)*sizeof(t_Item)); + cant = 10; + } } } fact.items = its; @@ -578,6 +599,8 @@ void fact_agregar(char *s) werase(win); wrefresh(win); delwin(items); + delwin(subnota); + delwin(nota); delwin(win); }