/src/ventas.c
C | 7178 lines | 4781 code | 1293 blank | 1104 comment | 632 complexity | 0fe42238b99186b58a80fbcbc7c58742 MD5 | raw file
Possible License(s): GPL-2.0
Large files files are truncated, but you can click here to view the full file
- /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4;
- c-indentation-style: gnu -*- */
- /*ventas.c
- *
- * Copyright (C) 2004,2008 Rizoma Tecnologia Limitada <info@rizoma.cl>
- *
- * This file is part of rizoma.
- *
- * Rizoma is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
- #define _XOPEN_SOURCE 600
- #include<features.h>
- #include<gtk/gtk.h>
- #include<gdk/gdkkeysyms.h>
- #include<math.h>
- #include<stdlib.h>
- #include<string.h>
- #include<time.h>
- #include"tipos.h"
- #include"ventas.h"
- #include"credito.h"
- #include"postgres-functions.h"
- #include"errors.h"
- #include"manejo_productos.h"
- #include"manejo_pagos.h"
- #include"boleta.h"
- #include"config_file.h"
- #include"utils.h"
- #include"encriptar.h"
- #include"factura_more.h"
- #include"rizoma_errors.h"
- #include"proveedores.h"
- #include"caja.h"
- #include"vale.h"
- GtkBuilder *builder;
- GtkWidget *vuelto_button;
- GtkWidget *calendar_window;
- GtkWidget *button_cheque;
- GtkWidget *buscador_window;
- GtkWidget *label_found;
- GtkWidget *tipos_window;
- GtkWidget *canje_cantidad;
- GtkWidget *window_seller;
- gchar *tipo_venta;
- gint monto_cheque = 0;
- gboolean cheques = FALSE;
- GtkWidget *canje_entry;
- gboolean ventas = TRUE;
- gint tipo_documento = -1;
- gboolean mayorista = FALSE;
- gboolean closing_tipos = FALSE;
- gboolean block_discount = FALSE;
- // Venta de mercadería que se encuentre en la tabla de reserva
- gboolean venta_reserva = FALSE;
- // Inhabilita los procedimientos que requieran un stock en el producto
- //gboolean no_venta = FALSE;
- /**
- * Display the information of a product on the main sales window
- *
- * @param barcode the barcode of the product
- * @param mayorista TRUE if the product has a especial value for mayorist sales
- * @param marca the brand of the product
- * @param descripcion the description of the product
- * @param contenido the contents (amount) of the product
- * @param unidad the unit of the product (i.e. kg)
- * @param stock the current stock of the product
- * @param stock_day for how many days the current stock will be enough
- * @param precio the price of the product
- * @param precio_mayor the price of the producto for mayorist values
- * @param cantidad_mayor how many products must be saled to be considered as mayorist
- * @param codigo_corto the short code associated to the product
- */
- void
- FillProductSell (gchar *barcode,
- gboolean mayorista,
- gchar *marca,
- gchar *descripcion,
- gchar *contenido,
- gchar *unidad,
- gchar *stock,
- gchar *stock_day,
- gchar *precio,
- gchar *precio_mayor,
- gchar *cantidad_mayor,
- gchar *codigo_corto)
- {
- GtkWidget *widget;
- gchar *str_aux;
- //caja de producto
- widget = GTK_WIDGET(gtk_builder_get_object(builder, "barcode_entry"));
- gtk_entry_set_text(GTK_ENTRY(widget), barcode);
- gtk_label_set_markup (GTK_LABEL (gtk_builder_get_object (builder, "product_label")),
- g_strdup_printf ("<span weight=\"ultrabold\" size=\"12000\">%s\n%s %s %s</span>",
- g_strndup (descripcion, 30), marca, contenido, unidad));
- if (strtod (PUT (stock), (char **)NULL) <= GetMinStock (barcode))
- gtk_label_set_markup (GTK_LABEL (gtk_builder_get_object (builder, "label_stockday")),
- g_strdup_printf("<span foreground=\"red\"><b>%.2f dia(s)</b></span>",
- strtod (PUT (stock_day), (char **)NULL)));
- else
- gtk_label_set_markup (GTK_LABEL (gtk_builder_get_object (builder, "label_stockday")),
- g_strdup_printf ("<b>%.2f dia(s)</b>", strtod (PUT (stock_day), (char **)NULL)));
- //precio
- /*gtk_label_set_markup (GTK_LABEL (gtk_builder_get_object (builder, "label_precio")),
- g_strdup_printf ("<span weight=\"ultrabold\" size=\"12000\">%s</span>",
- PutPoints (precio)));*/
- if (rut_cliente_pre_factura > 0)
- {
- gchar *q;
- gdouble client_price = 0;
- q = g_strdup_printf ("SELECT precio FROM cliente_precio WHERE rut_cliente = %d AND barcode = '%s'",
- rut_cliente_pre_factura, barcode);
- PGresult *res = EjecutarSQL (q);
- if (res != NULL && PQntuples (res) != 0)
- {
- client_price = strtod (PUT (PQgetvalue (res, 0, 0)), (char **)NULL);
- if (client_price > 0)
- precio = PUT (g_strdup_printf ("%.3f",client_price));
- }
- g_free (q);
- }
- gtk_entry_set_text (GTK_ENTRY (builder_get (builder, "entry_precio")), precio);
- //precio de mayorista
- gtk_label_set_markup (GTK_LABEL (gtk_builder_get_object (builder, "label_mayor")),
- g_strdup_printf ("<span weight=\"ultrabold\" size=\"12000\">%s</span>",
- PutPoints (precio_mayor)));
- gtk_label_set_markup (GTK_LABEL (gtk_builder_get_object (builder, "label_mayor_cantidad")),
- g_strdup_printf ("<span weight=\"ultrabold\" size=\"12000\">%s</span>",
- PutPoints (cantidad_mayor)));
- gtk_label_set_markup (GTK_LABEL (gtk_builder_get_object (builder, "label_stock")),
- g_strdup_printf ("<span weight=\"ultrabold\" size=\"12000\">%.2f</span>",
- strtod (PUT (stock), (char **)NULL)));
- str_aux = g_strdup(gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (builder, "cantidad_entry"))));
- str_aux = g_strdup_printf ("%.0f", strtod (PUT (str_aux), (char **)NULL) * atoi (precio));
- gtk_label_set_markup (GTK_LABEL (gtk_builder_get_object (builder, "label_subtotal")),
- g_strdup_printf ("<span weight=\"ultrabold\" size=\"12000\">%s</span>", PutPoints(str_aux)));
- gtk_label_set_markup (GTK_LABEL (gtk_builder_get_object (builder, "codigo_corto")),
- g_strdup_printf ("<span weight=\"ultrabold\" size=\"12000\">%s</span>", codigo_corto));
- }
- void
- CanjearProducto (GtkWidget *widget, gpointer data)
- {
- GtkWidget *entry = (GtkWidget *) data;
- if (entry == NULL)
- {
- gtk_widget_destroy (gtk_widget_get_toplevel (widget));
- gtk_widget_grab_focus (GTK_WIDGET (gtk_builder_get_object (builder, "barcode_entry")));
- }
- else
- {
- gchar *barcode = g_strdup (gtk_entry_get_text (GTK_ENTRY (canje_entry)));
- if ((GetDataByOne (g_strdup_printf ("SELECT barcode FROM producto WHERE barcode='%s'",
- barcode))) == NULL)
- {
- ErrorMSG (entry, "No existe el producto");
- return;
- }
- else
- {
- gdouble cantidad = strtod (PUT (g_strdup (gtk_entry_get_text (GTK_ENTRY (canje_cantidad)))),
- (char **)NULL);
- CanjearProduct (barcode, cantidad);
- CanjearProducto (widget, NULL);
- }
- }
- }
- void
- CanjearProductoWin (GtkWidget *widget, gpointer data)
- {
- GtkWidget *window;
- GtkWidget *vbox;
- GtkWidget *hbox;
- GtkWidget *label;
- GtkWidget *button;
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title (GTK_WINDOW (window), "Canjear Producto");
- gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ALWAYS);
- gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
- gtk_window_present (GTK_WINDOW (window));
- gtk_widget_show (window);
- g_signal_connect (G_OBJECT (window), "destroy",
- G_CALLBACK (CanjearProducto), NULL);
- vbox = gtk_vbox_new (FALSE, 3);
- gtk_container_add (GTK_CONTAINER (window), vbox);
- gtk_widget_show (vbox);
- hbox = gtk_hbox_new (FALSE, 3);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
- gtk_widget_show (hbox);
- label = gtk_label_new ("Código de Barras: ");
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 3);
- gtk_widget_show (label);
- canje_entry = gtk_entry_new ();
- gtk_box_pack_start (GTK_BOX (hbox), canje_entry, FALSE, FALSE, 3);
- gtk_widget_show (canje_entry);
- g_signal_connect (G_OBJECT (canje_entry), "activate",
- G_CALLBACK (SearchSellProduct), (gpointer)FALSE);
- gtk_window_set_focus (GTK_WINDOW (window), canje_entry);
- hbox = gtk_hbox_new (FALSE, 3);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
- gtk_widget_show (hbox);
- label = gtk_label_new ("Cantidad: ");
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 3);
- gtk_widget_show (label);
- canje_cantidad = gtk_entry_new ();
- gtk_box_pack_start (GTK_BOX (hbox), canje_cantidad, FALSE, FALSE, 3);
- gtk_widget_show (canje_cantidad);
- g_signal_connect (G_OBJECT (canje_entry), "activate",
- G_CALLBACK (SendCursorTo), (gpointer)canje_cantidad);
- hbox = gtk_hbox_new (FALSE, 3);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
- gtk_widget_show (hbox);
- button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 3);
- gtk_widget_show (button);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (CanjearProducto), NULL);
- button = gtk_button_new_from_stock (GTK_STOCK_OK);
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 3);
- gtk_widget_show (button);
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (CanjearProducto), (gpointer)canje_entry);
- g_signal_connect (G_OBJECT (canje_cantidad), "activate",
- G_CALLBACK (SendCursorTo), (gpointer)button);
- }
- void
- SetChequeDate (GtkCalendar *calendar, gpointer data)
- {
- GtkButton *button = (GtkButton *) data;
- guint day, month, year;
- time_t t;
- struct tm *current;
- if (calendar == NULL)
- {
- calendar = GTK_CALENDAR (gtk_calendar_new ());
- gtk_calendar_get_date (calendar, &year, &month, &day);
- gtk_button_set_label (button, g_strdup_printf ("%.2u/%.2u/%.4u", day, month+1, year));
- }
- else
- {
- time (&t);
- current = localtime (&t);
- gtk_calendar_get_date (calendar, &year, &month, &day);
- if (year >= (current->tm_year + 1900) && month >= current->tm_mon && day >= current->tm_mday)
- {
- gtk_button_set_label (button, g_strdup_printf ("%.2u/%.2u/%.4u", day, month+1, year));
- SetToggleMode (GTK_TOGGLE_BUTTON (data), NULL);
- }
- }
- }
- void
- SelectChequeDate (GtkToggleButton *widget, gpointer data)
- {
- GtkWidget *vbox;
- GtkCalendar *calendar;
- GtkRequisition req;
- gint h; //w;
- gint x, y;
- gint button_y, button_x;
- gboolean toggle = gtk_toggle_button_get_active (widget);
- if (toggle == TRUE)
- {
- gdk_window_get_origin (GTK_WIDGET (widget)->window, &x, &y);
- gtk_widget_size_request (GTK_WIDGET (widget), &req);
- h = req.height;
- //w = req.width;
- button_y = GTK_WIDGET (widget)->allocation.y;
- button_x = GTK_WIDGET (widget)->allocation.x;
- calendar_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_screen (GTK_WINDOW (calendar_window),
- gtk_widget_get_screen (GTK_WIDGET (widget)));
- gtk_container_set_border_width (GTK_CONTAINER (calendar_window), 5);
- gtk_window_set_type_hint (GTK_WINDOW (calendar_window), GDK_WINDOW_TYPE_HINT_DOCK);
- gtk_window_set_decorated (GTK_WINDOW (calendar_window), FALSE);
- gtk_window_set_resizable (GTK_WINDOW (calendar_window), FALSE);
- gtk_window_stick (GTK_WINDOW (calendar_window));
- gtk_window_set_title (GTK_WINDOW (calendar_window), "Calendario");
- vbox = gtk_vbox_new (FALSE, 3);
- gtk_container_add (GTK_CONTAINER (calendar_window), vbox);
- gtk_widget_show (vbox);
- calendar = GTK_CALENDAR (gtk_calendar_new ());
- gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (calendar), FALSE, FALSE, 0);
- gtk_widget_show (GTK_WIDGET (calendar));
- g_signal_connect (G_OBJECT (calendar), "day-selected-double-click",
- G_CALLBACK (SetChequeDate), (gpointer) widget);
- gtk_widget_show (calendar_window);
- x = (x + button_x);
- y = (y + button_y) + h;
- gtk_window_move (GTK_WINDOW (calendar_window), x, y);
- gtk_window_present (GTK_WINDOW (calendar_window));
- }
- else if (toggle == FALSE)
- {
- gtk_widget_destroy (calendar_window);
- }
- }
- void
- DatosCheque (void)
- {
- GtkWidget *window;
- GtkWidget *label;
- GtkWidget *frame;
- GtkWidget *button;
- GtkWidget *hbox;
- GtkWidget *vbox;
- GtkWidget *vbox2;
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title (GTK_WINDOW (window), "Ingreso de Cheque");
- gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ALWAYS);
- gtk_widget_show (window);
- gtk_window_present (GTK_WINDOW (window));
- gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
- gtk_widget_show (window);
- vbox = gtk_vbox_new (FALSE, 3);
- gtk_container_add (GTK_CONTAINER (window), vbox);
- gtk_widget_show (vbox);
- hbox = gtk_hbox_new (FALSE, 3);
- gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 3);
- gtk_widget_show (hbox);
- button = gtk_button_new_with_mnemonic ("_Vender");
- gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 3);
- gtk_widget_show (button);
- frame = gtk_frame_new ("Datos Cheque");
- gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 3);
- gtk_widget_show (frame);
- vbox2 = gtk_vbox_new (FALSE, 3);
- gtk_container_add (GTK_CONTAINER (frame), vbox2);
- gtk_widget_show (vbox2);
- hbox = gtk_hbox_new (FALSE, 3);
- gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 3);
- gtk_widget_show (hbox);
- label = gtk_label_new ("Serie: ");
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 3);
- gtk_widget_show (label);
- venta->cheque_serie = gtk_entry_new_with_max_length (10);
- gtk_box_pack_end (GTK_BOX (hbox), venta->cheque_serie, FALSE, FALSE, 3);
- gtk_widget_show (venta->cheque_serie);
- g_signal_connect (G_OBJECT (venta->venta_rut), "changed",
- G_CALLBACK (SendCursorTo), (gpointer)venta->cheque_serie);
- hbox = gtk_hbox_new (FALSE, 3);
- gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 3);
- gtk_widget_show (hbox);
- label = gtk_label_new ("Número: ");
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 3);
- gtk_widget_show (label);
- venta->cheque_numero = gtk_entry_new ();
- gtk_box_pack_end (GTK_BOX (hbox), venta->cheque_numero, FALSE, FALSE, 3);
- gtk_widget_show (venta->cheque_numero);
- g_signal_connect (G_OBJECT (venta->cheque_serie), "activate",
- G_CALLBACK (SendCursorTo), (gpointer)venta->cheque_numero);
- hbox = gtk_hbox_new (FALSE, 3);
- gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 3);
- gtk_widget_show (hbox);
- label = gtk_label_new ("Banco: ");
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 3);
- gtk_widget_show (label);
- venta->cheque_banco = gtk_entry_new_with_max_length (50);
- gtk_box_pack_end (GTK_BOX (hbox), venta->cheque_banco, FALSE, FALSE, 3);
- gtk_widget_show (venta->cheque_banco);
- g_signal_connect (G_OBJECT (venta->cheque_numero), "activate",
- G_CALLBACK (SendCursorTo), (gpointer)venta->cheque_banco);
- hbox = gtk_hbox_new (FALSE, 3);
- gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 3);
- gtk_widget_show (hbox);
- label = gtk_label_new ("Plaza: ");
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 3);
- gtk_widget_show (label);
- venta->cheque_plaza = gtk_entry_new_with_max_length (50);
- gtk_box_pack_end (GTK_BOX (hbox), venta->cheque_plaza, FALSE, FALSE, 3);
- gtk_widget_show (venta->cheque_plaza);
- g_signal_connect (G_OBJECT (venta->cheque_banco), "activate",
- G_CALLBACK (SendCursorTo), (gpointer)venta->cheque_plaza);
- hbox = gtk_hbox_new (FALSE, 3);
- gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 3);
- gtk_widget_show (hbox);
- label = gtk_label_new ("Fecha: ");
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 3);
- gtk_widget_show (label);
- button_cheque = gtk_toggle_button_new ();
- gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button_cheque), FALSE);
- gtk_box_pack_end (GTK_BOX (hbox), button_cheque, FALSE, FALSE, 3);
- gtk_widget_show (button_cheque);
- g_signal_connect (G_OBJECT (venta->cheque_plaza), "activate",
- G_CALLBACK (SendCursorTo), (gpointer)button_cheque);
- SetChequeDate (NULL, (gpointer)button_cheque);
- g_signal_connect (G_OBJECT (button_cheque), "toggled",
- G_CALLBACK (SelectChequeDate), NULL);
- hbox = gtk_hbox_new (FALSE, 3);
- gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 3);
- gtk_widget_show (hbox);
- label = gtk_label_new ("Monto: ");
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 3);
- gtk_widget_show (label);
- venta->cheque_monto = gtk_entry_new_with_max_length (50);
- gtk_box_pack_end (GTK_BOX (hbox), venta->cheque_monto, FALSE, FALSE, 3);
- gtk_widget_show (venta->cheque_monto);
- g_signal_connect (G_OBJECT (button_cheque), "toggled",
- G_CALLBACK (SendCursorTo), (gpointer)venta->cheque_monto);
- g_signal_connect (G_OBJECT (venta->cheque_monto), "activate",
- G_CALLBACK (SendCursorTo), (gpointer)button);
- venta->tipo_venta = CHEQUE;
- }
- void
- CancelarTipo (GtkWidget *widget, gpointer data)
- {
- if (closing_tipos == TRUE)
- return;
- closing_tipos = TRUE;
- gtk_widget_destroy (gtk_widget_get_toplevel (widget));
- if ((gboolean)data == TRUE)
- {
- //TiposVenta (NULL, NULL);
- }
- else
- {
- gtk_widget_grab_focus (GTK_WIDGET (gtk_builder_get_object (builder, "sencillo_entry")));
- venta->tipo_venta = SIMPLE;
- }
- closing_tipos = FALSE;
- }
- /**
- *
- *
- */
- void
- on_precio_neto_sell_edited (GtkCellRendererText *cell, gchar *path_string, gchar *precio_neto_t, gpointer data)
- {
- GtkTreeModel *model = GTK_TREE_MODEL (data);
- GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
- GtkTreeIter iter;
- gchar *codigo, *barcode;
- gdouble iva, otros;
- gdouble precio_final, precio_neto, costo_neto, cantidad;
- gint sub_neto, sub_total;
- gdouble ganancia_minima = strtod (PUT (rizoma_get_value ("GANANCIA_MINIMA")), (char **)NULL);
- //Verifica que sea un valor numérico
- if (!is_numeric (precio_neto_t))
- {
- AlertMSG (GTK_WIDGET (builder_get (builder, "sell_products_list")),
- "El precio neto debe ser un valor numérico");
- return;
- }
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_path_free (path);
- gtk_tree_model_get (model, &iter,
- 0, &codigo, // Se obtiene el codigo del producto
- 2, &cantidad,
- -1);
- barcode = PQvaluebycol (EjecutarSQL (g_strdup_printf ("SELECT barcode FROM codigo_corto_to_barcode('%s')", codigo)),
- 0, "barcode");
- precio_neto = strtod (PUT (precio_neto_t), (char **)NULL);
- costo_neto = obtener_costo_promedio (barcode);
- ganancia_minima = (ganancia_minima > 0) ? (ganancia_minima/100)+1 : 1;
- costo_neto = costo_neto * ganancia_minima;
- //Se obtienen los impuestos
- iva = GetIVA (barcode);
- iva = (iva > 0) ? iva / 100 : 0;
- otros = GetOtros (barcode);
- otros = (otros > 0) ? otros / 100 : 0;
- if (precio_neto < costo_neto)
- {
- AlertMSG (GTK_WIDGET (builder_get (builder, "sell_products_list")),
- g_strdup_printf ("El precio es inferior al mínimo permitido ($ %s)",
- PutPoints (g_strdup_printf ("%ld", lround (costo_neto)))));
- return;
- }
- precio_final = (precio_neto * (1 + otros + iva));
- sub_neto = lround (precio_neto*cantidad);
- sub_total = lround (precio_final*cantidad);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- 3, precio_neto,
- 4, sub_neto,
- 5, precio_final,
- 6, sub_total,
- -1);
- /*Se modifican los datos de la estructura*/
- venta->product_check = BuscarPorCodigo (venta->header, codigo);
- venta->product_check->product->precio_mayor = precio_final;
- venta->product_check->product->precio = precio_final;
- venta->product_check->product->precio_neto = precio_neto;
- gtk_label_set_markup (GTK_LABEL (gtk_builder_get_object (builder, "label_total")),
- g_strdup_printf ("<span size=\"40000\">%s</span>",
- PutPoints (g_strdup_printf ("%ld", lround (CalcularTotal (venta->header))))));
- }
- /**
- *
- *
- */
- void
- on_precio_final_sell_edited (GtkCellRendererText *cell, gchar *path_string, gchar *precio_final_t, gpointer data)
- {
- GtkTreeModel *model = GTK_TREE_MODEL (data);
- GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
- GtkTreeIter iter;
- gchar *codigo, *barcode;
- gdouble iva, otros;
- gdouble precio_final, precio_neto, costo_neto, cantidad;
- gint sub_neto, sub_total;
- gdouble ganancia_minima = strtod (PUT (rizoma_get_value ("GANANCIA_MINIMA")), (char **)NULL);
- //Verifica que sea un valor numérico
- if (!is_numeric (precio_final_t))
- {
- AlertMSG (GTK_WIDGET (builder_get (builder, "sell_products_list")),
- "El precio neto debe ser un valor numérico");
- return;
- }
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_path_free (path);
- gtk_tree_model_get (model, &iter,
- 0, &codigo, // Se obtiene el codigo del producto
- 2, &cantidad,
- -1);
- barcode = PQvaluebycol (EjecutarSQL
- (g_strdup_printf ("SELECT barcode FROM codigo_corto_to_barcode('%s')", codigo)),
- 0, "barcode");
- precio_final = strtod (PUT (precio_final_t), (char **)NULL);
- costo_neto = obtener_costo_promedio (barcode);
- ganancia_minima = (ganancia_minima > 0) ? (ganancia_minima/100)+1 : 1;
- costo_neto = costo_neto * ganancia_minima;
- //Se obtienen los impuestos
- iva = GetIVA (barcode);
- iva = (iva > 0) ? iva / 100 : 0;
- otros = GetOtros (barcode);
- otros = (otros > 0) ? otros / 100 : 0;
- //Costo neto + impuestos
- costo_neto *= (1 + otros + iva);
- if ((precio_final / (1 + otros + iva)) < costo_neto)
- {
- AlertMSG (GTK_WIDGET (builder_get (builder, "sell_products_list")),
- g_strdup_printf ("El precio es inferior al mínimo permitido ($ %s)",
- PutPoints (g_strdup_printf ("%ld", lround (costo_neto)))));
- return;
- }
- precio_neto = (precio_final / (1 + otros + iva));
- sub_neto = lround ( (precio_neto*cantidad) );
- sub_total = lround ( (precio_final*cantidad) );
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- 3, precio_neto,
- 4, sub_neto,
- 5, precio_final,
- 6, sub_total,
- -1);
- /*Se modifican los datos de la estructura*/
- venta->product_check = BuscarPorCodigo (venta->header, codigo);
- venta->product_check->product->precio_mayor = precio_final;
- venta->product_check->product->precio = precio_final;
- venta->product_check->product->precio_neto = precio_neto;
- gtk_label_set_markup (GTK_LABEL (gtk_builder_get_object (builder, "label_total")),
- g_strdup_printf ("<span size=\"40000\">%s</span>",
- PutPoints (g_strdup_printf ("%ld", lround (CalcularTotal (venta->header))))));
- }
- /**
- *
- *
- */
- void
- on_cantidad_sell_edited (GtkCellRendererText *cell, gchar *path_string, gchar *cantidad_t, gpointer data)
- {
- GtkTreeModel *model = GTK_TREE_MODEL (data);
- GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
- GtkTreeIter iter;
- gchar *codigo, *color;
- gdouble cantidad, precio_neto, precio_final, iva, otros;
- //Verifica que sea un valor numérico
- if (!is_numeric (cantidad_t) || (cantidad = strtod (PUT (cantidad_t), (char **)NULL)) < 1 )
- {
- AlertMSG (GTK_WIDGET (builder_get (builder, "sell_products_list")),
- "La cantidad debe ser un valor numérico mayor a cero");
- return;
- }
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_path_free (path);
- gtk_tree_model_get (model, &iter,
- 0, &codigo, // Se obtiene el codigo del producto
- 3, &precio_neto,
- 5, &precio_final,
- -1);
- /*Se modifican los datos de la estructura*/
- venta->product_check = BuscarPorCodigo (venta->header, codigo);
- venta->product_check->product->cantidad = cantidad;
- /*Se ve si es mayorista, de acuerdo a eso se le cambia el precio*/
- if (venta->product_check->product->mayorista == TRUE && venta->product_check->product->cantidad_mayorista > 0 &&
- venta->product_check->product->precio_mayor > 0 && cantidad >= venta->product_check->product->cantidad_mayorista)
- {
- //Se toma en cuenta el precio mayorista SOLO si no se ha modificado el precio del producto
- if (venta->product_check->product->precio == venta->product_check->product->precio_original)
- {
- precio_final = venta->product_check->product->precio_mayor;
- //Se obtienen los impuestos
- iva = venta->product_check->product->iva;
- iva = (iva > 0) ? iva / 100 : 0;
- otros = venta->product_check->product->otros;
- otros = (otros > 0) ? otros / 100 : 0;
- precio_neto = venta->product_check->product->precio_mayor / (1 + otros + iva);
- venta->product_check->product->precio_neto = precio_neto;
- }
- }
- /*Se elige el color de la fila*/
- if (venta->product_check->product->cantidad <= venta->product_check->product->stock)
- color = (venta->product_check->product->cantidad != venta->product_check->product->cantidad_impresa) ? g_strdup ("Blue") : g_strdup ("Black");
- else /*Si la cantidad solicitada supera al stock*/
- color = g_strdup ("Red");
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- 2, cantidad,
- 3, precio_neto,
- 4, lround (precio_neto*cantidad),
- 5, precio_final,
- 6, lround (precio_final*cantidad),
- 9, color,
- 10, TRUE,
- -1);
- //Se actualiza la cantidad en la tabla mesa
- if (rizoma_get_value_boolean ("MODO_MESERO") ||
- rizoma_get_value_boolean ("MODO_VENTA_RESTAURANT"))
- modificar_producto_mesa (venta->num_mesa, venta->product_check->product->barcode, venta->product_check->product->cantidad, venta->product_check->product->cantidad_impresa);
- /* AHORA SE PERMITE VENTA NEGATIVA
- if (venta->product_check->product->stock < cantidad)
- {
- no_venta = TRUE;
- gtk_widget_set_sensitive (GTK_WIDGET (builder_get (builder, "btn_invoice")), FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (builder_get (builder, "btn_sale")), FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (builder_get (builder, "btn_devolver")), FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (builder_get (builder, "btn_traspaso_enviar")), FALSE);
- }*/
- //habilitar_venta ();
- gtk_label_set_markup (GTK_LABEL (gtk_builder_get_object (builder, "label_total")),
- g_strdup_printf ("<span size=\"40000\">%s</span>",
- PutPoints (g_strdup_printf ("%ld", lround (CalcularTotal (venta->header))))));
- }
- /**
- *
- */
- void
- on_btn_seleccionar_mesa_clicked (GtkButton *button, gpointer data)
- {
- clean_container (GTK_CONTAINER (builder_get (builder, "wnd_cambio_mesa")));
- gtk_widget_show (GTK_WIDGET (builder_get (builder, "wnd_cambio_mesa")));
- gtk_widget_grab_focus (GTK_WIDGET (builder_get (builder, "entry_numero_mesa")));
- }
- /**
- * Obtiene pre-ventas y reservas
- */
- void
- on_btn_get_preventa_ok_clicked (GtkButton *button, gpointer data)
- {
- gint id;
- gchar *preventa_txt1;
- gchar *preventa_txt2;
- gchar *entry_text;
- guint32 total;
- gdouble iva, otros;
- GtkTreeIter iter;
- PGresult *res;
- gchar *q;
- gint tuples, i;
- GtkListStore *sell = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (builder_get (builder, "sell_products_list"))));
- entry_text = pango_trim_string (gtk_entry_get_text (GTK_ENTRY (builder_get (builder, "entry_id_preventa"))));
- if (g_str_equal (entry_text, "") || strlen (entry_text) < 3)
- {
- ErrorMSG (GTK_WIDGET (builder_get (builder, "entry_id_preventa")), "El ID ingresado es inválido");
- return;
- }
- preventa_txt1 = g_strndup (entry_text, 2);
- preventa_txt2 = invested_strndup (entry_text, 2);
- //Si el código no es un PV (PreVenta) o un RV (ReserVa) es inválido
- if ( (!g_str_equal (preventa_txt1, "PV") && !g_str_equal (preventa_txt1, "RV"))
- || HaveCharacters (preventa_txt2) || g_str_equal (preventa_txt2, ""))
- {
- ErrorMSG (GTK_WIDGET (builder_get (builder, "entry_id_preventa")), "El ID ingresado es inválido");
- return;
- }
- //printf ("COD: %s %s", preventa_txt1, preventa_txt2);
- id = atoi (preventa_txt2);
- //Si es un id valido
- if (id > 0)
- {
- /*TODO: Se debería dejar que la preventa de agregue a la lista
- junto a productos anteriormente agregados. Se debe cuidar que una
- misma pre-venta no se cargue 2 veces en la misma lista.
- Para ello debe haber una especie de 'manejo' de pre-venta.*/
- gtk_list_store_clear (sell);
- CleanEntryAndLabelData ();
- ListClean ();
- //Se obtiene la preventa, si el id es del tipo PV
- if (g_str_equal (preventa_txt1, "PV"))
- q = g_strdup_printf ("SELECT barcode, cantidad, precio "
- "FROM preventa_detalle pvd "
- "INNER JOIN preventa pv "
- "ON pvd.id_preventa = pv.id "
- "WHERE pv.id = %d "
- "AND pv.vendido = false", id);
- //Se obtiene la reserva, si el id es del tipo RV
- else if (g_str_equal (preventa_txt1, "RV"))
- q = g_strdup_printf ("SELECT barcode, cantidad, precio FROM reserva_detalle WHERE id_reserva = %d", id);
- res = EjecutarSQL (q);
- g_free (q);
- if (res != NULL && PQntuples (res) != 0)
- {
- tuples = PQntuples (res);
- /*Se agregan las mercaderías independientemente de si tienen o no stock (al realizar el pago total de venta
- ésta se finalizará y en ese proceso se debe exigir el stock suficiente de cada mercadería)*/
- for (i = 0; i < tuples; i++)
- {
- AgregarALista (NULL, PQvaluebycol (res, i, "barcode"), strtod (PUT (PQvaluebycol (res, i, "cantidad")), (char **)NULL));
- //Se reemplazan los 2 precios, para asegurarse que se venda con el precio puesto en el pedido, sin importar si la mercadería esta por mayor o no
- venta->products->product->precio = strtod (PUT (PQvaluebycol (res, i, "precio")), (char **)NULL);
- venta->products->product->precio_mayor = strtod (PUT (PQvaluebycol (res, i, "precio")), (char **)NULL);
- iva = (gdouble)venta->products->product->iva / 100;
- otros = (gdouble)venta->products->product->otros / 100;
- venta->products->product->precio_neto = (venta->products->product->precio / (1 + otros + iva));
- gtk_list_store_insert_after (sell, &iter, NULL);
- gtk_list_store_set (sell, &iter,
- 0, venta->products->product->codigo,
- 1, g_strdup_printf ("%s %s %d %s",
- venta->products->product->producto,
- venta->products->product->marca,
- venta->products->product->contenido,
- venta->products->product->unidad),
- 2, venta->products->product->cantidad,
- 3, venta->products->product->precio_neto,
- 4, lround (venta->products->product->cantidad * venta->products->product->precio_neto),
- 5, venta->products->product->precio,
- 6, lround (venta->products->product->cantidad * venta->products->product->precio),
- 7, venta->products->product->stock,
- 8, venta->products->product->cantidad_impresa,
- 9, (venta->products->product->cantidad > venta->products->product->stock) ? "Red":"Black",
- 10, TRUE,
- -1);
- venta->products->product->iter = iter;
- }
- total = llround (CalcularTotal (venta->header));
- gtk_label_set_markup (GTK_LABEL (gtk_builder_get_object (builder, "label_total")),
- g_strdup_printf ("<span size=\"40000\">%s</span>",
- PutPoints (g_strdup_printf ("%u", total))));
- }
- else
- {
- //No existen datos con ese id
- gtk_entry_set_text (GTK_ENTRY (builder_get (builder, "entry_id_preventa")), "");
- ErrorMSG (GTK_WIDGET (builder_get (builder, "entry_id_preventa")),
- g_strdup_printf ("No existen datos con el id %s%s", preventa_txt1, preventa_txt2));
- return;
- }
- if (g_str_equal (preventa_txt1, "PV"))
- venta->id_preventa = id;
- else if (g_str_equal (preventa_txt2, "RV"))
- {
- res = get_data_from_reserva_id (id);
- if (res == NULL || PQntuples (res) == 0)
- {
- //No existen datos con ese id
- gtk_entry_set_text (GTK_ENTRY (builder_get (builder, "entry_id_preventa")), "");
- ErrorMSG (GTK_WIDGET (builder_get (builder, "entry_id_preventa")),
- g_strdup_printf ("No existen datos con el id %s%s", preventa_txt1, preventa_txt2));
- return;
- }
- venta_reserva = TRUE;
- venta->deuda_total = atoi (PQvaluebycol (res, 0, "monto"));
- venta->total_pagado = atoi (PQvaluebycol (res, 0, "monto_pagado"));
- venta->rut_cliente = atoi (g_strdup (PQvaluebycol(res, 0, "rut_cliente")));
- venta->id_reserva = id;
- }
- }
- gtk_widget_hide (GTK_WIDGET (builder_get (builder, "wnd_get_preventa")));
- if (g_str_equal (preventa_txt1, "RV"))
- TipoVenta (NULL, NULL);
- }
- /**
- * Es llamada cuando se presiona el boton "btn_print_preventa" (signal clicked)
- *
- * Esta funcion muestra la ventana "wnd_preventa"
- *
- * @param button the button
- * @param user_data the user data
- */
- void
- on_btn_get_preventa_clicked (GtkButton *button, gpointer data)
- {
- GtkWidget *widget;
- widget = GTK_WIDGET (gtk_builder_get_object(builder, "wnd_get_preventa"));
- clean_container (GTK_CONTAINER (widget));
- gtk_widget_show(widget);
- gtk_widget_grab_focus (GTK_WIDGET (builder_get (builder,"entry_id_preventa")));
- }
- /**
- * Main window
- */
- void
- ventas_win ()
- {
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
- GtkTreeIter iter;
- GtkWidget *ventas_gui;
- GError *error = NULL;
- //Inicializacion de la estructura venta
- venta = (Venta *) g_malloc (sizeof (Venta));
- venta->header = NULL;
- venta->products = NULL;
- venta->window = NULL;
- venta->id_preventa = 0;
- Productos *fill = venta->header;
- //TODO: Usar esta estructura para almacenar los datos del cliente seleccionado
- cliente = (DatosCliente *) g_malloc (sizeof (DatosCliente));
- //Inicialización de la estructura de cheques de restaurant
- pago_chk_rest = (PagoChequesRest *) g_malloc (sizeof (PagoChequesRest));
- pago_chk_rest->header = NULL;
- pago_chk_rest->cheques = NULL;
- //ChequesRestaurant *fill = pago_chk_rest->header;
- //Inicialización de pago mixto
- pago_mixto = (PagoMixto *) g_malloc (sizeof (PagoMixto));
- pago_mixto->check_rest1 = NULL;
- pago_mixto->check_rest2 = NULL;
- //Se inicializa bandera global (venta suscritos)
- rut_cliente_pre_factura = 0;
- venta->total_pagado = 0;
- venta->num_mesa = 0;
- builder = gtk_builder_new ();
- gtk_builder_add_from_file (builder, DATADIR"/ui/rizoma-ventas.ui", &error);
- if (error != NULL)
- g_printerr ("%s: %s\n", G_STRFUNC, error->message);
- gtk_builder_add_from_file (builder, DATADIR"/ui/rizoma-common.ui", &error);
- if (error != NULL)
- g_printerr ("%s: %s\n", G_STRFUNC, error->message);
- gtk_builder_connect_signals (builder, NULL);
- // check if is enabled the print of invoices to show or not show the
- // make invoice button
- if (!(rizoma_get_value_boolean ("PRINT_FACTURA")))
- {
- GtkWidget *aux_widget;
- aux_widget = GTK_WIDGET(gtk_builder_get_object (builder, "btn_invoice"));
- gtk_widget_hide (aux_widget);
- }
- if (rizoma_get_value_boolean ("CAJA"))
- {
- gtk_widget_show (GTK_WIDGET (builder_get (builder, "btn_cash_box_close")));
- }
- if (rizoma_get_value_boolean ("TRASPASO"))
- {
- gtk_widget_show (GTK_WIDGET (builder_get (builder, "btn_traspaso_enviar")));
- }
- ventas_gui = GTK_WIDGET (gtk_builder_get_object (builder, "wnd_sell"));
- //Titulo
- gtk_window_set_title (GTK_WINDOW (ventas_gui),
- g_strdup_printf ("POS Rizoma Comercio: Ventas - Conectado a [%s@%s]",
- config_profile,
- rizoma_get_value ("SERVER_HOST")));
- // check if the window must be set to fullscreen
- if (rizoma_get_value_boolean("FULLSCREEN"))
- gtk_window_maximize(GTK_WINDOW(ventas_gui));
- gtk_widget_show_all (ventas_gui);
- // Se setea el label con el nombre de usuario
- gtk_label_set_markup (GTK_LABEL (gtk_builder_get_object (builder, "label_seller_name")),
- g_strdup_printf ("<span size=\"15000\">%s</span>", user_data->user));
- // Se setea el label con el número de mesa
- gtk_label_set_markup (GTK_LABEL (gtk_builder_get_object (builder, "lbl_num_mesa")),
- g_strdup_printf ("<span size=\"15000\">%d</span>", venta->num_mesa));
- // Se setea el label con el número de boleta
- gtk_label_set_markup (GTK_LABEL (gtk_builder_get_object (builder, "label_ticket_number")),
- g_strdup_printf ("<span size=\"15000\">%.6d</span>", get_ticket_number (SIMPLE)-1)); //antes get_last_sell_id ()
- // El numerno de venta no se debe basar en el numero de ticket, puesto que aquel corresponde a los documentos que se han emitido
- /* gtk_label_set_markup (GTK_LABEL (gtk_builder_get_object (builder, "label_ticket_number")), */
- /* g_strdup_printf ("<b><big>%.6d</big></b>", get_ticket_number (SIMPLE))); */
- venta->store = gtk_list_store_new (11,
- G_TYPE_STRING, //CODIGO
- G_TYPE_STRING, //DESCRIPCION
- G_TYPE_DOUBLE, //CANTIDAD
- G_TYPE_DOUBLE, //PRECIO NETO
- G_TYPE_INT, //SUB TOTAL NETO
- G_TYPE_DOUBLE, //PRECIO FINAL
- G_TYPE_INT, //SUB TOTAL FINAL
- G_TYPE_DOUBLE, //STOCK
- G_TYPE_DOUBLE, //CANTIDAD IMPRESA
- G_TYPE_STRING, //COLOR
- G_TYPE_BOOLEAN); //COLOREAR
- if (venta->header != NULL)
- {
- gdouble precio, precio_neto;
- do
- {
- if (fill->product->cantidad_mayorista > 0 && fill->product->precio_mayor > 0 && fill->product->cantidad >= fill->product->cantidad_mayorista &&
- fill->product->mayorista == TRUE)
- precio = fill->product->precio_mayor;
- else
- precio = fill->product->precio;
- precio_neto = precio / (fill->product->otros/100 + fill->product->iva/100 + 1);
- fill->product->precio_neto = precio_neto;
- gtk_list_store_insert_after (venta->store, &iter, NULL);
- gtk_list_store_set (venta->store, &iter,
- 0, fill->product->codigo,
- 1, g_strdup_printf ("%s %s %d %s",
- fill->product->producto,
- fill->product->marca,
- fill->product->contenido,
- fill->product->unidad),
- 2, fill->product->cantidad,
- 3, precio_neto,
- 4, lround (fill->product->cantidad * precio_neto),
- 5, precio,
- 6, lround (fill->product->cantidad * precio),
- 7, fill->product->stock,
- 8, fill->product->cantidad_impresa,
- 9, (fill->product->cantidad > fill->product->stock) ? "Red":"Black",
- 10, TRUE,
- -1);
- fill = fill->next;
- }
- while (fill != venta->header);
- }
- venta->treeview_products = GTK_WIDGET (gtk_builder_get_object (builder, "sell_products_list"));
- gtk_tree_view_set_model (GTK_TREE_VIEW (venta->treeview_products), GTK_TREE_MODEL (venta->store));
- renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes ("Código", renderer,
- "text", 0,
- "foreground", 9,
- "foreground-set", 10,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (venta->treeview_products), column);
- gtk_tree_view_column_set_alignment (column, 0.5);
- g_object_set (G_OBJECT (renderer), "xalign", 0.0, "font", "15", NULL);
- gtk_tree_view_column_set_resizable (column, FALSE);
- renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes ("Descripción", renderer,
- "text", 1,
- "foreground", 9,
- "foreground-set", 10,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (venta->treeview_products), column);
- gtk_tree_view_column_set_alignment (column, 0.5);
- g_object_set (G_OBJECT (renderer), "xalign", 0.0, "font", "15", NULL);
- gtk_tree_view_column_set_resizable (column, FALSE);
- gtk_tree_view_column_set_min_width (column, 400);
- gtk_tree_view_column_set_expand (column, TRUE);
- /* renderer = gtk_cell_renderer_text_new (); */
- /* column = gtk_tree_view_column_new_with_attributes ("Marca", renderer, */
- /* "text", 2, */
- /* NULL); */
- /* gtk_tree_view_append_column (GTK_TREE_VIEW (venta->treeview_products), column); */
- /* gtk_tree_view_column_set_alignment (column, 0.5); */
- /* gtk_tree_view_column_set_resizable (column, FALSE); */
- /* renderer = gtk_cell_renderer_text_new (); */
- /* column = gtk_tree_view_column_new_with_attributes ("Cont.", renderer, */
- /* "text", 3, */
- /* NULL); */
- /* gtk_tree_view_append_column (GTK_TREE_VIEW (venta->treeview_products), column); */
- /* gtk_tree_view_column_set_alignment (column, 0.5); */
- /* gtk_tree_view_column_set_resizable (column, FALSE); */
- /* renderer = gtk_cell_renderer_text_new (); */
- /* column = gtk_tree_view_column_new_with_attributes ("Uni.", renderer, */
- /* "text", 4, */
- /* NULL); */
- /* gtk_tree_view_append_column (GTK_TREE_VIEW (venta->treeview_products), column); */
- /* g_object_set (G_OBJECT (renderer), "xalign", 1.0, NULL); */
- /* gtk_tree_view_column_set_resizable (column, FALSE); */
- renderer = gtk_cell_renderer_text_new ();
- g_object_set (renderer, "editable", TRUE, NULL);
- g_signal_connect (G_OBJECT (renderer), "edited", G_CALLBACK (on_cantidad_sell_edited), (gpointer)venta->store);
- column = gtk_tree_view_column_new_with_attributes ("Cant.", renderer,
- "text", 2,
- "foreground", 9,
- "foreground-set", 10,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (venta->treeview_products), column);
- gtk_tree_view_column_set_alignment (column, 0.5);
- g_object_set (G_OBJECT (renderer), "xalign", 1.0, "font", "15", NULL);
- gtk_tree_view_column_set_resizable (column, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, renderer, control_decimal, (gpointer)2, NULL);
- if (rizoma_get_value_boolean ("MODO_GUIA_FACTURA"))
- {
- renderer = gtk_cell_renderer_text_new ();
- //El precio es editable si PRECIO_DISCRECIONAL esta habilitado
- if (rizoma_get_value_boolean ("PRECIO_DISCRECIONAL"))
- {
- g_object_set (renderer, "editable", TRUE, NULL);
- g_signal_connect (G_OBJECT (renderer), "edited", G_CALLBACK (on_precio_neto_sell_edited), (gpointer)venta->store);
- }
- column = gtk_tree_view_column_new_with_attributes ("Prec. Neto Un.", renderer,
- "text", 3,
- "foreground", 9,
- "foreground-set", 10,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (venta->treeview_products), column);
- gtk_tree_view_column_set_alignment (column, 0.5);
- g_object_set (G_OBJECT (renderer), "xalign", 1.0, "font", "15", NULL);
- gtk_tree_view_column_set_resizable (column, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, renderer, control_decimal, (gpointer)3, NULL);
- renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes ("Sub Total Neto", renderer,
- "text", 4,
- "foreground", 9,
- "foreground-set", 10,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (venta->treeview_products), column);
- gtk_tree_view_column_set_alignment (column, 0.5);
- g_object_set (G_OBJECT (renderer), "xalign", 1.0, "font", "15", NULL);
- gtk_tree_view_column_set_resizable (column, FALSE);
- gtk_tree_view_column_set_max_width (column, 100);
- gtk_tree_view_column_set_cell_data_func (column, renderer, control_decimal, (gpointer)4, NULL);
- }
- renderer = gtk_cell_renderer_text_new ();
- //El precio es editable si PRECIO_DISCRECIONAL esta habilitado
- if (rizoma_get_value_boolean ("PRECIO_DISCRECIONAL"))
- {
- g_object_set (renderer, "editable", TRUE, NULL);
- g_signal_connect (G_OBJECT (renderer), "edited", G_CALLBACK (on_precio_final_sell_edited), (gpointer)venta->store);
- }
- column = gtk_tree_view_column_new_with_attributes ("Precio Uni.", renderer,
- "text", 5,
- "foreground", 9,
- "foreground-set", 10,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (venta->treeview_products), column);
- gtk_tree_view_column_set_alignment (column, 0.5);
- g_object_set (G_OBJECT (renderer), "xalign", 1.0, "font", "15", NULL);
- gtk_tree_view_column_set_resizable (column, FALSE);
- gtk_tree_view_column_set_cell_data_func (column, renderer, control_decimal, (gpointer)5, NULL);
- renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes ("Sub Total", renderer,
- "text", 6,
- "foreground", 9,
- "foreground-set", 10,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (venta->treeview_products), column);
- gtk_tree_view_column_set_alignment (column, 0.5);
- g_object_set (G_OBJECT (renderer), "xalign", 1.0, "font", "15", NULL);
- gtk_tree_view_column_set_resizable (column, FALSE);
- gtk_tree_view_column_set_max_width (column, 100);
- gtk_tree_view_column_set_cell_data_func (column, renderer, control_decimal, (gpointer)6, NULL);
- if (venta->header != NULL)
- CalcularVentas (venta->header);
- gtk_widget_grab_focus (GTK_WIDGET (gtk_builder_get_object (builder, "barcode_entry")));
- if (rizoma_get_value_boolean ("CAJA"))
- {
- if (check_caja())
- {
- open_caja (FALSE);
- }
- else
- {
- gtk…
Large files files are truncated, but you can click here to view the full file