mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
- Add a "date-close" dialog that basically asks for confimation
of closing and sets the close-date (for when you close out an order to post an invoice). - Refactor the Entry Value computation so that it is possible to compute the values in real-time (although it's not used at the moment) - Change the Order Entry UI to make it a but clearer. - change the EntryLedger to allow RO and RW entries for Invoices and Orders. - Implement closing an Order; Opening (editing/viewing) a closed should be a read-only operation. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6621 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* gncEntry.c -- the Core Business Entry Interface
|
||||
* Copyright (C) 2001 Derek Atkins
|
||||
* Copyright (C) 2001,2002 Derek Atkins
|
||||
* Author: Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
||||
@@ -341,43 +341,32 @@ GncEntry * gncEntryLookup (GNCBook *book, const GUID *guid)
|
||||
guid, _GNC_MOD_NAME);
|
||||
}
|
||||
|
||||
void gncEntryGetValue (GncEntry *entry, gnc_numeric *value,
|
||||
gnc_numeric *tax_value)
|
||||
void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
|
||||
gnc_numeric tax, gint tax_type,
|
||||
gnc_numeric discount, gint discount_type,
|
||||
gnc_numeric *value, gnc_numeric *tax_value)
|
||||
{
|
||||
gnc_numeric subtotal;
|
||||
gnc_numeric disc;
|
||||
gnc_numeric this_value;
|
||||
gint type;
|
||||
|
||||
if (!entry) return;
|
||||
|
||||
/* Compute the value */
|
||||
|
||||
type = gncEntryGetDiscountType (entry);
|
||||
disc = gncEntryGetDiscount (entry);
|
||||
subtotal = gnc_numeric_mul (gncEntryGetQuantity (entry),
|
||||
gncEntryGetPrice (entry),
|
||||
100, /* XXX */
|
||||
GNC_RND_ROUND);
|
||||
subtotal = gnc_numeric_mul (qty, price, 100, /* XXX */ GNC_RND_ROUND);
|
||||
|
||||
if (GNC_ENTRY_INTERP_IS_PERCENT (type))
|
||||
disc = gnc_numeric_mul (subtotal, disc, 100 /* XXX */, GNC_RND_ROUND);
|
||||
if (GNC_ENTRY_INTERP_IS_PERCENT (discount_type))
|
||||
discount = gnc_numeric_mul (subtotal, discount, 100 /* XXX */, GNC_RND_ROUND);
|
||||
|
||||
this_value = gnc_numeric_sub_fixed (subtotal, disc);
|
||||
if (type & GNC_ENTRY_PRETAX_FLAG)
|
||||
this_value = gnc_numeric_sub_fixed (subtotal, discount);
|
||||
if (discount_type & GNC_ENTRY_PRETAX_FLAG)
|
||||
subtotal = this_value;
|
||||
|
||||
if (value != NULL)
|
||||
*value = this_value;
|
||||
|
||||
|
||||
/* Compute the tax value */
|
||||
/* Now... Compute the tax value (if the caller wants it) */
|
||||
|
||||
if (tax_value != NULL) {
|
||||
gnc_numeric tax = gncEntryGetTax (entry);
|
||||
type = gncEntryGetTaxType (entry);
|
||||
|
||||
if (GNC_ENTRY_INTERP_IS_PERCENT (type))
|
||||
if (GNC_ENTRY_INTERP_IS_PERCENT (tax_type))
|
||||
tax = gnc_numeric_mul (subtotal, tax, 100 /* XXX */, GNC_RND_ROUND);
|
||||
|
||||
*tax_value = tax;
|
||||
@@ -386,6 +375,20 @@ void gncEntryGetValue (GncEntry *entry, gnc_numeric *value,
|
||||
return;
|
||||
}
|
||||
|
||||
void gncEntryGetValue (GncEntry *entry, gnc_numeric *value,
|
||||
gnc_numeric *tax_value)
|
||||
{
|
||||
if (!entry) return;
|
||||
|
||||
return gncEntryComputeValue (gncEntryGetQuantity (entry),
|
||||
gncEntryGetPrice (entry),
|
||||
gncEntryGetTax (entry),
|
||||
gncEntryGetTaxType (entry),
|
||||
gncEntryGetDiscount (entry),
|
||||
gncEntryGetDiscountType (entry),
|
||||
value, tax_value);
|
||||
}
|
||||
|
||||
void gncEntryCommitEdit (GncEntry *entry)
|
||||
{
|
||||
if (!entry) return;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* gncEntry.h -- the Core Business Entry Interface
|
||||
* Copyright (C) 2001 Derek Atkins
|
||||
* Copyright (C) 2001,2002 Derek Atkins
|
||||
* Author: Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
||||
@@ -68,6 +68,10 @@ const char * gncEntryGetDiscountTypeStr (gint type);
|
||||
*/
|
||||
void gncEntryGetValue (GncEntry *entry, gnc_numeric *value,
|
||||
gnc_numeric *tax_value);
|
||||
void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
|
||||
gnc_numeric tax, gint tax_type,
|
||||
gnc_numeric discount, gint discount_type,
|
||||
gnc_numeric *value, gnc_numeric *tax_value);
|
||||
|
||||
gint gncEntryGetTypeFromStr (const char *type);
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
"#include <gncInvoice.h>\n"
|
||||
"#include <gncJob.h>\n"
|
||||
"#include <gncOrder.h>\n"
|
||||
"#include <gncOwner.h>\n"
|
||||
"#include <gncVendor.h>\n")))
|
||||
|
||||
(gw:wrapset-add-cs-initializers!
|
||||
@@ -53,6 +54,7 @@
|
||||
(gw:wrap-as-wct ws '<gnc:GncInvoice*> "GncInvoice*" "const GncInvoice*")
|
||||
(gw:wrap-as-wct ws '<gnc:GncJob*> "GncJob*" "const GncJob*")
|
||||
(gw:wrap-as-wct ws '<gnc:GncOrder*> "GncOrder*" "const GncOrder*")
|
||||
(gw:wrap-as-wct ws '<gnc:GncOwner*> "GncOwner*" "const GncOwner*")
|
||||
(gw:wrap-as-wct ws '<gnc:GncVendor*> "GncVendor*" "const GncVendor*")
|
||||
|
||||
;;
|
||||
@@ -81,6 +83,8 @@
|
||||
|
||||
;; gncOrder.h
|
||||
|
||||
;; gncOwner.h
|
||||
|
||||
;; gncVendor.h
|
||||
|
||||
)
|
||||
|
||||
@@ -26,6 +26,7 @@ libgncmod_business_gnome_la_SOURCES = \
|
||||
business-chooser.c \
|
||||
business-utils.c \
|
||||
dialog-customer.c \
|
||||
dialog-date-close.c \
|
||||
dialog-employee.c \
|
||||
dialog-job.c \
|
||||
dialog-job-select.c \
|
||||
@@ -36,6 +37,7 @@ noinst_HEADERS = \
|
||||
business-chooser.h \
|
||||
business-utils.h \
|
||||
dialog-customer.h \
|
||||
dialog-date-close.h \
|
||||
dialog-employee.h \
|
||||
dialog-job.h \
|
||||
dialog-job-select.h \
|
||||
@@ -68,6 +70,7 @@ gladedir = $(GNC_GLADE_DIR)
|
||||
glade_DATA = \
|
||||
business-chooser.glade \
|
||||
customer.glade \
|
||||
date-close.glade \
|
||||
employee.glade \
|
||||
job.glade \
|
||||
order.glade \
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
(gnc:business-create-book gnc:extensions-temp-book)
|
||||
gnc:extensions-temp-book)))
|
||||
|
||||
(define gnc:extensions-last-order #f)
|
||||
(define gnc:extensions-owner #f)
|
||||
|
||||
(define new-job-item
|
||||
(gnc:make-menu-item (N_ "Test New Job Dialog")
|
||||
(N_ "Test New Job Dialog")
|
||||
@@ -70,8 +73,19 @@
|
||||
(N_ "Test New Order Dialog")
|
||||
(list "Extensions" "")
|
||||
(lambda ()
|
||||
(gnc:order-new #f (gnc:extensions-get-book)))))
|
||||
(set! gnc:extensions-last-order
|
||||
(gnc:order-new #f gnc:extensions-owner
|
||||
(gnc:extensions-get-book))))))
|
||||
|
||||
(define edit-order-item
|
||||
(gnc:make-menu-item (N_ "Test Edit/View Order Dialog")
|
||||
(N_ "Test Edit/View Order Dialog")
|
||||
(list "Extensions" "")
|
||||
(lambda ()
|
||||
(gnc:order-edit #f gnc:extensions-last-order))))
|
||||
|
||||
|
||||
(gnc:add-extension edit-order-item)
|
||||
(gnc:add-extension new-order-item)
|
||||
(gnc:add-extension select-employee-item)
|
||||
(gnc:add-extension new-employee-item)
|
||||
|
||||
188
src/business/business-gnome/date-close.glade
Normal file
188
src/business/business-gnome/date-close.glade
Normal file
@@ -0,0 +1,188 @@
|
||||
<?xml version="1.0"?>
|
||||
<GTK-Interface>
|
||||
|
||||
<project>
|
||||
<name>Date-close</name>
|
||||
<program_name>date-close</program_name>
|
||||
<directory></directory>
|
||||
<source_directory>src</source_directory>
|
||||
<pixmaps_directory>pixmaps</pixmaps_directory>
|
||||
<language>C</language>
|
||||
<gnome_support>True</gnome_support>
|
||||
<gettext_support>True</gettext_support>
|
||||
<output_main_file>False</output_main_file>
|
||||
<output_support_files>False</output_support_files>
|
||||
<output_build_files>False</output_build_files>
|
||||
<backup_source_files>False</backup_source_files>
|
||||
</project>
|
||||
|
||||
<widget>
|
||||
<class>GnomeDialog</class>
|
||||
<name>Date Close Dialog</name>
|
||||
<title>Question</title>
|
||||
<type>GTK_WINDOW_TOPLEVEL</type>
|
||||
<position>GTK_WIN_POS_NONE</position>
|
||||
<modal>False</modal>
|
||||
<allow_shrink>False</allow_shrink>
|
||||
<allow_grow>False</allow_grow>
|
||||
<auto_shrink>False</auto_shrink>
|
||||
<auto_close>False</auto_close>
|
||||
<hide_on_close>False</hide_on_close>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<child_name>GnomeDialog:vbox</child_name>
|
||||
<name>dialog-vbox1</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>8</spacing>
|
||||
<child>
|
||||
<padding>4</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkHButtonBox</class>
|
||||
<child_name>GnomeDialog:action_area</child_name>
|
||||
<name>dialog-action_area1</name>
|
||||
<layout_style>GTK_BUTTONBOX_END</layout_style>
|
||||
<spacing>8</spacing>
|
||||
<child_min_width>85</child_min_width>
|
||||
<child_min_height>27</child_min_height>
|
||||
<child_ipad_x>7</child_ipad_x>
|
||||
<child_ipad_y>0</child_ipad_y>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>True</fill>
|
||||
<pack>GTK_PACK_END</pack>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button1</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button3</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<name>vbox1</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>the_hbox</name>
|
||||
<border_width>3</border_width>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>Placeholder</class>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>hbox2</name>
|
||||
<border_width>3</border_width>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label1</name>
|
||||
<label></label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>0.5</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label</name>
|
||||
<label>label1</label>
|
||||
<justify>GTK_JUSTIFY_LEFT</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>1</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>3</padding>
|
||||
<expand>False</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GnomeDateEdit</class>
|
||||
<name>date</name>
|
||||
<show_time>False</show_time>
|
||||
<use_24_format>True</use_24_format>
|
||||
<week_start_monday>False</week_start_monday>
|
||||
<lower_hour>7</lower_hour>
|
||||
<upper_hour>19</upper_hour>
|
||||
<child>
|
||||
<padding>3</padding>
|
||||
<expand>False</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label2</name>
|
||||
<label></label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>0.5</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
</GTK-Interface>
|
||||
136
src/business/business-gnome/dialog-date-close.c
Normal file
136
src/business/business-gnome/dialog-date-close.c
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* dialog-date-close.c -- Dialog to ask a question and request a date
|
||||
* Copyright (C) 2002 Derek Atkins
|
||||
* Author: Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gnome.h>
|
||||
|
||||
#include "dialog-utils.h"
|
||||
|
||||
#include "dialog-date-close.h"
|
||||
|
||||
typedef struct _dialog_date_close_window {
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *date;
|
||||
Timespec *ts;
|
||||
gboolean retval;
|
||||
} DialogDateClose;
|
||||
|
||||
static void
|
||||
gnc_dialog_date_close_ok_cb (GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
DialogDateClose *ddc = user_data;
|
||||
time_t tt;
|
||||
|
||||
tt = gnome_date_edit_get_date (GNOME_DATE_EDIT (ddc->date));
|
||||
timespecFromTime_t (ddc->ts, tt);
|
||||
ddc->retval = TRUE;
|
||||
gnome_dialog_close (GNOME_DIALOG (ddc->dialog));
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_dialog_date_close_cancel_cb (GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
DialogDateClose *ddc = user_data;
|
||||
ddc->retval = FALSE;
|
||||
gnome_dialog_close (GNOME_DIALOG (ddc->dialog));
|
||||
}
|
||||
|
||||
static gint
|
||||
gnc_dialog_date_close_cb (GnomeDialog *dialog, gpointer data)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
build_date_close_window (GtkWidget *hbox, const char *message)
|
||||
{
|
||||
GtkWidget *pixmap = NULL;
|
||||
GtkWidget *label;
|
||||
GtkWidget *alignment;
|
||||
char *s;
|
||||
|
||||
/* Make noises, basically */
|
||||
gnome_triggers_vdo(message, GNOME_MESSAGE_BOX_QUESTION, NULL);
|
||||
|
||||
s = gnome_unconditional_pixmap_file("gnome-question.png");
|
||||
if (s) {
|
||||
pixmap = gnome_pixmap_new_from_file(s);
|
||||
g_free(s);
|
||||
}
|
||||
|
||||
if (pixmap) {
|
||||
gtk_box_pack_start (GTK_BOX(hbox), pixmap, FALSE, TRUE, 0);
|
||||
gtk_widget_show (pixmap);
|
||||
}
|
||||
|
||||
label = gtk_label_new (message);
|
||||
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
||||
gtk_misc_set_padding (GTK_MISC (label), GNOME_PAD, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
/* Add some extra space on the right to balance the pixmap */
|
||||
if (pixmap) {
|
||||
alignment = gtk_alignment_new (0., 0., 0., 0.);
|
||||
gtk_widget_set_usize (alignment, GNOME_PAD, -1);
|
||||
gtk_widget_show (alignment);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), alignment, FALSE, FALSE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_dialog_date_close_parented (GtkWidget *parent, const char *message,
|
||||
const char *label_message,
|
||||
gboolean ok_is_default, Timespec *ts)
|
||||
{
|
||||
DialogDateClose *ddc;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
GladeXML *xml;
|
||||
gboolean retval;
|
||||
|
||||
if (!message || !label_message || !ts)
|
||||
return FALSE;
|
||||
|
||||
ddc = g_new0 (DialogDateClose, 1);
|
||||
ddc->ts = ts;
|
||||
|
||||
xml = gnc_glade_xml_new ("date-close.glade", "Date Close Dialog");
|
||||
ddc->dialog = glade_xml_get_widget (xml, "Date Close Dialog");
|
||||
ddc->date = glade_xml_get_widget (xml, "date");
|
||||
hbox = glade_xml_get_widget (xml, "the_hbox");
|
||||
label = glade_xml_get_widget (xml, "label");
|
||||
|
||||
if (parent)
|
||||
gnome_dialog_set_parent (GNOME_DIALOG(ddc->dialog), GTK_WINDOW(parent));
|
||||
|
||||
build_date_close_window (hbox, message);
|
||||
|
||||
gnome_date_edit_set_time (GNOME_DATE_EDIT (ddc->date), ts->tv_sec);
|
||||
gtk_label_set_text (GTK_LABEL (label), label_message);
|
||||
|
||||
gnome_dialog_button_connect
|
||||
(GNOME_DIALOG(ddc->dialog), 0,
|
||||
GTK_SIGNAL_FUNC(gnc_dialog_date_close_ok_cb), ddc);
|
||||
gnome_dialog_button_connect
|
||||
(GNOME_DIALOG(ddc->dialog), 1,
|
||||
GTK_SIGNAL_FUNC(gnc_dialog_date_close_cancel_cb), ddc);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT(ddc->dialog), "close",
|
||||
GTK_SIGNAL_FUNC(gnc_dialog_date_close_cb), ddc);
|
||||
|
||||
gtk_window_set_modal (GTK_WINDOW (ddc->dialog), TRUE);
|
||||
gtk_widget_show (ddc->dialog);
|
||||
gtk_main ();
|
||||
|
||||
retval = ddc->retval;
|
||||
g_free (ddc);
|
||||
|
||||
return retval;
|
||||
}
|
||||
17
src/business/business-gnome/dialog-date-close.h
Normal file
17
src/business/business-gnome/dialog-date-close.h
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* dialog-date-close.h -- Dialog to ask a question and request a date
|
||||
* Copyright (C) 2002 Derek Atkins
|
||||
* Author: Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
||||
#ifndef _DIALOG_DATE_CLOSE_H
|
||||
#define _DIALOG_DATE_CLOSE_H
|
||||
|
||||
#include "date.h"
|
||||
|
||||
gboolean
|
||||
gnc_dialog_date_close_parented (GtkWidget *parent, const char *message,
|
||||
const char *label_message,
|
||||
gboolean ok_is_default, Timespec *date);
|
||||
|
||||
#endif /* _DIALOG_DATE_CLOSE_H */
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* dialog-order.c -- Dialog for Order entry
|
||||
* Copyright (C) 2001 Derek Atkins
|
||||
* Copyright (C) 2001,2002 Derek Atkins
|
||||
* Author: Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
||||
@@ -26,14 +26,17 @@
|
||||
#include "dialog-order.h"
|
||||
#include "business-chooser.h"
|
||||
#include "business-utils.h"
|
||||
#include "dialog-date-close.h"
|
||||
|
||||
#define DIALOG_NEW_ORDER_CM_CLASS "dialog-new-order"
|
||||
#define DIALOG_EDIT_ORDER_CM_CLASS "dialog-edit-order"
|
||||
#define DIALOG_VIEW_ORDER_CM_CLASS "dialog-edit-order"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NEW_ORDER,
|
||||
EDIT_ORDER
|
||||
EDIT_ORDER,
|
||||
VIEW_ORDER
|
||||
} OrderDialogType;
|
||||
|
||||
struct _order_select_window {
|
||||
@@ -44,6 +47,7 @@ typedef struct _order_window {
|
||||
GtkWidget * dialog;
|
||||
|
||||
GtkWidget * id_entry;
|
||||
GtkWidget * ref_entry;
|
||||
GtkWidget * owner_choice;
|
||||
GtkWidget * notes_text;
|
||||
GtkWidget * opened_date;
|
||||
@@ -57,6 +61,7 @@ typedef struct _order_window {
|
||||
gint component_id;
|
||||
GNCBook * book;
|
||||
GncOrder * created_order;
|
||||
GncOwner owner;
|
||||
|
||||
} OrderWindow;
|
||||
|
||||
@@ -85,33 +90,59 @@ static void gnc_ui_to_order (OrderWindow *ow, GncOrder *order)
|
||||
timespecFromTime_t (&ts, tt);
|
||||
gncOrderSetDateOpened (order, &ts);
|
||||
|
||||
tt = gnome_date_edit_get_date (GNOME_DATE_EDIT (ow->closed_date));
|
||||
timespecFromTime_t (&ts, tt);
|
||||
gncOrderSetDateClosed (order, &ts);
|
||||
|
||||
gncOrderSetActive (order, gtk_toggle_button_get_active
|
||||
(GTK_TOGGLE_BUTTON (ow->active_check)));
|
||||
|
||||
/* XXX: Set the owner? */
|
||||
gnc_owner_get_owner (ow->owner_choice, &(ow->owner));
|
||||
gncOrderSetOwner (order, &(ow->owner));
|
||||
|
||||
gncOrderCommitEdit (order);
|
||||
gnc_resume_gui_refresh ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gnc_order_window_verify_ok (OrderWindow *ow)
|
||||
{
|
||||
const char *res;
|
||||
GncOrder *order;
|
||||
GncOwner *owner;
|
||||
|
||||
/* Check the ID */
|
||||
res = gtk_entry_get_text (GTK_ENTRY (ow->id_entry));
|
||||
if (safe_strcmp (res, "") == 0) {
|
||||
gnc_error_dialog_parented (GTK_WINDOW (ow->dialog),
|
||||
_("The Order must be given an ID."));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Check the Owner */
|
||||
// owner = gnc_owner_get_owner (ow->owner_choice);
|
||||
// res = gncOrderGetName (owner);
|
||||
// if (res == NULL || safe_strcmp (res, "") == 0) {
|
||||
// gnc_error_dialog_parented (GTK_WINDOW (ow->dialog),
|
||||
// _("The Order must be givenan Owner."));
|
||||
// return FALSE;
|
||||
// }
|
||||
|
||||
/* Check that there is at least one Entry */
|
||||
order = ow_get_order (ow);
|
||||
if (gncOrderGetEntries (order) == NULL) {
|
||||
gnc_error_dialog_parented (GTK_WINDOW (ow->dialog),
|
||||
_("The Order must have at least one Entry."));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_order_window_ok_cb (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
OrderWindow *ow = data;
|
||||
|
||||
{
|
||||
const char *res = gtk_entry_get_text (GTK_ENTRY (ow->id_entry));
|
||||
if (safe_strcmp (res, "") == 0) {
|
||||
gnc_error_dialog_parented (GTK_WINDOW (ow->dialog),
|
||||
_("The Order must be given an ID."));
|
||||
if (!gnc_order_window_verify_ok (ow))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Now save it off */
|
||||
{
|
||||
GncOrder *order = ow_get_order (ow);
|
||||
@@ -142,6 +173,71 @@ gnc_order_window_help_cb (GtkWidget *widget, gpointer data)
|
||||
helpWindow(NULL, NULL, help_file);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_order_window_invoice_cb (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
/* XXX: create a new invoice for this customer/vendor */
|
||||
|
||||
fprintf (stderr, "I would create an invoice now... \n");
|
||||
|
||||
/* XXX: now refresh this window */
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_order_window_close_order_cb (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
OrderWindow *ow = data;
|
||||
GncOrder *order;
|
||||
GList *entries;
|
||||
char *message, *label;
|
||||
gboolean non_inv = FALSE;
|
||||
Timespec ts;
|
||||
|
||||
/* Make sure the order is ok */
|
||||
if (!gnc_order_window_verify_ok (ow))
|
||||
return;
|
||||
|
||||
/* Make sure we can close the order. Are there any uninvoiced entries? */
|
||||
order = ow_get_order (ow);
|
||||
if (!order)
|
||||
return;
|
||||
|
||||
entries = gncOrderGetEntries (order);
|
||||
for ( ; entries ; entries = entries->next) {
|
||||
GncEntry *entry = entries->data;
|
||||
if (gncEntryGetInvoice (entry) == NULL) {
|
||||
non_inv = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (non_inv) {
|
||||
/* Damn; yes. Well, ask the user to make sure they REALLY want to
|
||||
* close this order!
|
||||
*/
|
||||
|
||||
message = _("This order contains entries that have not been invoiced.\n"
|
||||
"Are you sure you want to close it out before\n"
|
||||
"you invoice all the entries?");
|
||||
|
||||
if (gnc_verify_dialog_parented (ow->dialog, message, FALSE) == FALSE)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Ok, we can close this. Ask for verification and set the closed date */
|
||||
message = _("Do you really want to close the order?");
|
||||
label = _("Close Date");
|
||||
|
||||
timespecFromTime_t (&ts, time(NULL));
|
||||
if (!gnc_dialog_date_close_parented (ow->dialog, message, label, TRUE, &ts))
|
||||
return;
|
||||
|
||||
gncOrderSetDateClosed (order, &ts);
|
||||
|
||||
/* And close the order */
|
||||
return gnc_order_window_ok_cb (widget, data);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_order_window_destroy_cb (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
@@ -243,19 +339,30 @@ gnc_configure_register_colors (void)
|
||||
|
||||
static OrderWindow *
|
||||
gnc_order_new_window (GtkWidget *parent, GNCBook *bookp,
|
||||
GncOrder *order, GncOwner *owner)
|
||||
OrderDialogType type, GncOrder *order, GncOwner *owner)
|
||||
{
|
||||
OrderWindow *ow;
|
||||
GladeXML *xml;
|
||||
GtkWidget *label, *hbox, *vbox, *regWidget;
|
||||
GncEntryLedger *entry_ledger;
|
||||
GtkWidget *label, *hbox, *vbox, *regWidget, *cd_label;
|
||||
GncEntryLedger *entry_ledger = NULL;
|
||||
GnomeDialog *owd;
|
||||
GList *entries;
|
||||
GtkWidget *hide1, *hide2;
|
||||
|
||||
gnc_configure_register_colors ();
|
||||
|
||||
ow = g_new0 (OrderWindow, 1);
|
||||
ow->book = bookp;
|
||||
ow->dialog_type = type;
|
||||
|
||||
if (type == NEW_ORDER) {
|
||||
order = gncOrderCreate (bookp);
|
||||
gncOrderSetOwner (order, owner);
|
||||
} else
|
||||
owner = gncOrderGetOwner (order); /* Overwrite what was passed in */
|
||||
|
||||
/* Save this for later */
|
||||
gncOwnerCopy (owner, &(ow->owner));
|
||||
|
||||
/* Find the dialog */
|
||||
xml = gnc_glade_xml_new ("order.glade", "Order Entry Dialog");
|
||||
@@ -266,10 +373,12 @@ gnc_order_new_window (GtkWidget *parent, GNCBook *bookp,
|
||||
|
||||
/* Grab the widgets */
|
||||
ow->id_entry = glade_xml_get_widget (xml, "id_entry");
|
||||
ow->ref_entry = glade_xml_get_widget (xml, "ref_entry");
|
||||
ow->notes_text = glade_xml_get_widget (xml, "notes_text");
|
||||
ow->opened_date = glade_xml_get_widget (xml, "opened_date");
|
||||
ow->closed_date = glade_xml_get_widget (xml, "closed_date");
|
||||
ow->active_check = glade_xml_get_widget (xml, "active_check");
|
||||
cd_label = glade_xml_get_widget (xml, "cd_label");
|
||||
|
||||
hbox = glade_xml_get_widget (xml, "owner_hbox");
|
||||
label = glade_xml_get_widget (xml, "owner_label");
|
||||
@@ -279,17 +388,26 @@ gnc_order_new_window (GtkWidget *parent, GNCBook *bookp,
|
||||
gnome_dialog_set_default (owd, 0);
|
||||
|
||||
/* Build the ledger */
|
||||
entry_ledger = gnc_entry_ledger_new (ow->book, GNCENTRY_LEDGER);
|
||||
switch (type) {
|
||||
case NEW_ORDER:
|
||||
case EDIT_ORDER:
|
||||
entry_ledger = gnc_entry_ledger_new (ow->book, GNCENTRY_ORDER_ENTRY);
|
||||
break;
|
||||
case VIEW_ORDER:
|
||||
default:
|
||||
entry_ledger = gnc_entry_ledger_new (ow->book, GNCENTRY_ORDER_VIEWER);
|
||||
break;
|
||||
}
|
||||
entries = gncOrderGetEntries (order);
|
||||
/* Set watches on entries*/
|
||||
/* Set watches on entries */
|
||||
gnc_entry_ledger_load (entry_ledger, entries);
|
||||
|
||||
/* Watch the order of operations, here... */
|
||||
gnucash_register_set_initial_rows( 6 );
|
||||
gnucash_register_set_initial_rows( 10 );
|
||||
regWidget = gnucash_register_new (gnc_entry_ledger_get_table (entry_ledger));
|
||||
gnc_table_init_gui( regWidget, entry_ledger );
|
||||
ow->reg = GNUCASH_REGISTER(regWidget);
|
||||
GNUCASH_SHEET(ow->reg->sheet)->window = GTK_WIDGET(ow->dialog);
|
||||
ow->reg = GNUCASH_REGISTER (regWidget);
|
||||
GNUCASH_SHEET (ow->reg->sheet)->window = GTK_WIDGET(ow->dialog);
|
||||
gnc_entry_ledger_set_parent (entry_ledger, ow->dialog);
|
||||
|
||||
vbox = glade_xml_get_widget (xml, "ledger_vbox");
|
||||
@@ -309,36 +427,42 @@ gnc_order_new_window (GtkWidget *parent, GNCBook *bookp,
|
||||
gnome_dialog_button_connect (owd, 2,
|
||||
GTK_SIGNAL_FUNC(gnc_order_window_help_cb), ow);
|
||||
|
||||
gnome_dialog_button_connect
|
||||
(owd, 3, GTK_SIGNAL_FUNC(gnc_order_window_invoice_cb), ow);
|
||||
|
||||
gnome_dialog_button_connect
|
||||
(owd, 4, GTK_SIGNAL_FUNC(gnc_order_window_close_order_cb), ow);
|
||||
|
||||
/* Setup initial values */
|
||||
if (order != NULL) {
|
||||
ow->dialog_type = EDIT_ORDER;
|
||||
ow->order_guid = *gncOrderGetGUID (order);
|
||||
owner = gncOrderGetOwner (order); /* Overwrite what was passed in */
|
||||
ow->order_guid = *gncOrderGetGUID (order);
|
||||
|
||||
ow->owner_choice = gnc_owner_edit_create (label, hbox, bookp, owner);
|
||||
{
|
||||
char * class_name = NULL;
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (ow->id_entry), gncOrderGetID (order));
|
||||
switch (type) {
|
||||
case VIEW_ORDER:
|
||||
default:
|
||||
class_name = DIALOG_VIEW_ORDER_CM_CLASS;
|
||||
/* FALLTHROUGH */
|
||||
case EDIT_ORDER:
|
||||
ow->owner_choice = gnc_owner_edit_create (label, hbox, bookp, owner);
|
||||
gtk_entry_set_text (GTK_ENTRY (ow->id_entry), gncOrderGetID (order));
|
||||
|
||||
if (class_name == NULL)
|
||||
class_name = DIALOG_EDIT_ORDER_CM_CLASS;
|
||||
break;
|
||||
|
||||
case NEW_ORDER:
|
||||
ow->owner_choice = gnc_owner_select_create (label, hbox, bookp, owner);
|
||||
gtk_entry_set_text (GTK_ENTRY (ow->id_entry),
|
||||
g_strdup_printf ("%.6d", gncOrderNextID(bookp)));
|
||||
|
||||
class_name = DIALOG_NEW_ORDER_CM_CLASS;
|
||||
break;
|
||||
}
|
||||
|
||||
ow->component_id =
|
||||
gnc_register_gui_component (DIALOG_EDIT_ORDER_CM_CLASS,
|
||||
gnc_order_window_refresh_handler,
|
||||
gnc_order_window_close_handler,
|
||||
ow);
|
||||
|
||||
} else {
|
||||
order = gncOrderCreate (bookp);
|
||||
ow->order_guid = *gncOrderGetGUID (order);
|
||||
gncOrderSetOwner (order, owner);
|
||||
|
||||
ow->owner_choice = gnc_owner_select_create (label, hbox, bookp, owner);
|
||||
|
||||
ow->dialog_type = NEW_ORDER;
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (ow->id_entry),
|
||||
g_strdup_printf ("%.6d", gncOrderNextID(bookp)));
|
||||
|
||||
ow->component_id =
|
||||
gnc_register_gui_component (DIALOG_NEW_ORDER_CM_CLASS,
|
||||
gnc_register_gui_component (class_name,
|
||||
gnc_order_window_refresh_handler,
|
||||
gnc_order_window_close_handler,
|
||||
ow);
|
||||
@@ -367,8 +491,12 @@ gnc_order_new_window (GtkWidget *parent, GNCBook *bookp,
|
||||
ts = gncOrderGetDateClosed (order);
|
||||
if (timespec_equal (&ts, &ts_zero)) {
|
||||
tt = time(NULL);
|
||||
hide1 = ow->closed_date;
|
||||
hide2 = cd_label;
|
||||
} else {
|
||||
tt = ts.tv_sec; /* XXX */
|
||||
hide1 = glade_xml_get_widget (xml, "hide1");
|
||||
hide2 = glade_xml_get_widget (xml, "hide2");
|
||||
}
|
||||
gnome_date_edit_set_time (GNOME_DATE_EDIT (ow->closed_date), tt);
|
||||
|
||||
@@ -386,22 +514,42 @@ gnc_order_new_window (GtkWidget *parent, GNCBook *bookp,
|
||||
gtk_widget_show_all (ow->dialog);
|
||||
gnc_table_refresh_gui (gnc_entry_ledger_get_table (entry_ledger), TRUE);
|
||||
|
||||
gtk_widget_hide_all (hide1);
|
||||
gtk_widget_hide_all (hide2);
|
||||
|
||||
if (type == VIEW_ORDER) {
|
||||
/* Setup viewer for read-only access */
|
||||
gtk_widget_set_sensitive (ow->id_entry, FALSE);
|
||||
gtk_widget_set_sensitive (ow->opened_date, FALSE);
|
||||
gtk_widget_set_sensitive (ow->closed_date, FALSE);
|
||||
gtk_widget_set_sensitive (ow->notes_text, FALSE);
|
||||
|
||||
/* Hide the 'close order' button */
|
||||
hide1 = glade_xml_get_widget (xml, "close_order_button");
|
||||
gtk_widget_hide_all (hide1);
|
||||
hide1 = glade_xml_get_widget (xml, "new_invoice_button");
|
||||
gtk_widget_hide_all (hide1);
|
||||
}
|
||||
|
||||
return ow;
|
||||
}
|
||||
|
||||
GncOrder *
|
||||
gnc_order_new (GtkWidget *parent, GNCBook *bookp)
|
||||
gnc_order_new (GtkWidget *parent, GncOwner *ownerp, GNCBook *bookp)
|
||||
{
|
||||
OrderWindow *ow;
|
||||
GncOrder *created_order = NULL;
|
||||
GncOwner owner;
|
||||
|
||||
gncOwnerInitCustomer (&owner, NULL);
|
||||
if (ownerp)
|
||||
gncOwnerCopy (ownerp, &owner);
|
||||
else
|
||||
gncOwnerInitCustomer (&owner, NULL); /* XXX: pass in the owner type? */
|
||||
|
||||
/* Make sure required options exist */
|
||||
if (!bookp) return NULL;
|
||||
|
||||
ow = gnc_order_new_window (parent, bookp, NULL, &owner);
|
||||
ow = gnc_order_new_window (parent, bookp, NEW_ORDER, NULL, &owner);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (ow->dialog), "close",
|
||||
GTK_SIGNAL_FUNC (gnc_order_on_close_cb),
|
||||
@@ -418,10 +566,19 @@ void
|
||||
gnc_order_edit (GtkWidget *parent, GncOrder *order)
|
||||
{
|
||||
OrderWindow *ow;
|
||||
OrderDialogType type;
|
||||
|
||||
if (!order) return;
|
||||
|
||||
ow = gnc_order_new_window (parent, gncOrderGetBook(order), order, NULL);
|
||||
type = EDIT_ORDER;
|
||||
{
|
||||
Timespec ts = gncOrderGetDateClosed (order);
|
||||
if (ts.tv_sec || ts.tv_nsec)
|
||||
type = VIEW_ORDER;
|
||||
}
|
||||
|
||||
ow = gnc_order_new_window (parent, gncOrderGetBook(order), type, order,
|
||||
NULL);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (ow->dialog), "close",
|
||||
GTK_SIGNAL_FUNC (gnc_order_on_close_cb),
|
||||
@@ -442,7 +599,7 @@ static gpointer gnc_order_edit_new_cb (gpointer arg, GtkWidget *toplevel)
|
||||
|
||||
if (!arg) return NULL;
|
||||
|
||||
return gnc_order_new (toplevel, sw->book);
|
||||
return gnc_order_new (toplevel, NULL, sw->book); /* XXX, set owner type? */
|
||||
}
|
||||
|
||||
static void gnc_order_edit_edit_cb (gpointer arg, gpointer obj, GtkWidget *toplevel)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* dialog-order.h -- Dialog(s) for Order search and entry
|
||||
* Copyright (C) 2001 Derek Atkins
|
||||
* Copyright (C) 2001,2002 Derek Atkins
|
||||
* Author: Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define GNC_DIALOG_ORDER_H_
|
||||
|
||||
/* Functions to create and edit orders */
|
||||
GncOrder * gnc_order_new (GtkWidget *parent, GNCBook *book);
|
||||
GncOrder * gnc_order_new (GtkWidget *parent, GncOwner *owner, GNCBook *book);
|
||||
void gnc_order_edit (GtkWidget *parent, GncOrder *order);
|
||||
|
||||
/* Callbacks to select a order that match the necessary functions
|
||||
|
||||
@@ -146,7 +146,7 @@
|
||||
'gnc:order-new
|
||||
'<gnc:GncOrder*>
|
||||
"gnc_order_new"
|
||||
'((<gnc:UIWidget> parent) (<gnc:Book*> book))
|
||||
'((<gnc:UIWidget> parent) (<gnc:GncOwner*> owner) (<gnc:Book*> book))
|
||||
"Dialog: create a new GncOrder. Parent may be NULL.")
|
||||
|
||||
(gw:wrap-function
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<type>GTK_WINDOW_TOPLEVEL</type>
|
||||
<position>GTK_WIN_POS_NONE</position>
|
||||
<modal>False</modal>
|
||||
<default_width>800</default_width>
|
||||
<default_width>890</default_width>
|
||||
<allow_shrink>True</allow_shrink>
|
||||
<allow_grow>True</allow_grow>
|
||||
<auto_shrink>False</auto_shrink>
|
||||
@@ -46,7 +46,7 @@
|
||||
<class>GtkHButtonBox</class>
|
||||
<child_name>GnomeDialog:action_area</child_name>
|
||||
<name>dialog-action_area1</name>
|
||||
<layout_style>GTK_BUTTONBOX_SPREAD</layout_style>
|
||||
<layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style>
|
||||
<spacing>8</spacing>
|
||||
<child_min_width>85</child_min_width>
|
||||
<child_min_height>27</child_min_height>
|
||||
@@ -82,6 +82,22 @@
|
||||
<can_focus>True</can_focus>
|
||||
<stock_button>GNOME_STOCK_BUTTON_HELP</stock_button>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>new_invoice_button</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<label>New Invoice</label>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>close_order_button</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<label>Close Order</label>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
@@ -145,8 +161,8 @@
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>owner_label</name>
|
||||
<label></label>
|
||||
<name>label3</name>
|
||||
<label>Date Opened</label>
|
||||
<justify>GTK_JUSTIFY_RIGHT</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>1</xalign>
|
||||
@@ -162,7 +178,24 @@
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label2</name>
|
||||
<name>cd_label</name>
|
||||
<label>Date Closed</label>
|
||||
<justify>GTK_JUSTIFY_RIGHT</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>1</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>hide1</name>
|
||||
<label></label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
@@ -170,41 +203,6 @@
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
<pack>GTK_PACK_END</pack>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label3</name>
|
||||
<label>Opened</label>
|
||||
<justify>GTK_JUSTIFY_RIGHT</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>1</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label4</name>
|
||||
<label>Closed</label>
|
||||
<justify>GTK_JUSTIFY_RIGHT</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>1</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
@@ -216,13 +214,13 @@
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<name>vbox3</name>
|
||||
<border_width>2</border_width>
|
||||
<border_width>3</border_width>
|
||||
<homogeneous>True</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>True</fill>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
@@ -240,37 +238,6 @@
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>owner_hbox</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>Placeholder</class>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkCheckButton</class>
|
||||
<name>active_check</name>
|
||||
<can_focus>True</can_focus>
|
||||
<label>Active</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
<pack>GTK_PACK_END</pack>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GnomeDateEdit</class>
|
||||
<name>opened_date</name>
|
||||
@@ -300,6 +267,145 @@
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>hide2</name>
|
||||
<label></label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>0.5</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<name>vbox8</name>
|
||||
<border_width>3</border_width>
|
||||
<homogeneous>True</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>owner_label</name>
|
||||
<label>(owner)</label>
|
||||
<justify>GTK_JUSTIFY_RIGHT</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>1</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label7</name>
|
||||
<label>Reference</label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>0.5</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<name>label2</name>
|
||||
<label></label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>0.5</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<name>vbox9</name>
|
||||
<border_width>3</border_width>
|
||||
<homogeneous>True</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>owner_hbox</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>Placeholder</class>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkEntry</class>
|
||||
<name>ref_entry</name>
|
||||
<can_focus>True</can_focus>
|
||||
<editable>False</editable>
|
||||
<text_visible>True</text_visible>
|
||||
<text_max_length>0</text_max_length>
|
||||
<text></text>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkCheckButton</class>
|
||||
<name>active_check</name>
|
||||
<can_focus>True</can_focus>
|
||||
<label>Active</label>
|
||||
<active>False</active>
|
||||
<draw_indicator>True</draw_indicator>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
@@ -340,7 +446,7 @@
|
||||
<spacing>0</spacing>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
|
||||
@@ -44,6 +44,20 @@ Account * gnc_entry_ledger_get_account (GncEntryLedger *ledger,
|
||||
gnc_get_account_separator ());
|
||||
}
|
||||
|
||||
char gnc_entry_ledger_get_inv (GncEntryLedger *ledger, const char * cell_name)
|
||||
{
|
||||
const char *value;
|
||||
|
||||
if (!gnc_table_layout_get_cell_changed (ledger->table->layout, cell_name,
|
||||
TRUE))
|
||||
return '\0';
|
||||
|
||||
value = gnc_table_layout_get_cell_value (ledger->table->layout, cell_name);
|
||||
if (value)
|
||||
return *value;
|
||||
return '\0';
|
||||
}
|
||||
|
||||
gint gnc_entry_ledger_get_type (GncEntryLedger *ledger, const char * cell_name)
|
||||
{
|
||||
const char *typeval;
|
||||
@@ -182,12 +196,12 @@ GncEntryLedger * gnc_entry_ledger_new (GNCBook *book, GncEntryLedgerType type)
|
||||
vloc.phys_col_offset = 0;
|
||||
|
||||
cursor = gnc_table_layout_get_cursor (ledger->table->layout, "cursor");
|
||||
|
||||
|
||||
gnc_table_set_vcell (ledger->table, cursor, NULL, TRUE, TRUE, vloc.vcell_loc);
|
||||
|
||||
if (gnc_table_find_close_valid_cell (ledger->table, &vloc, FALSE))
|
||||
gnc_table_move_cursor (ledger->table, vloc);
|
||||
else
|
||||
else
|
||||
{
|
||||
g_warning ("Can't find valid initial location");
|
||||
}
|
||||
|
||||
@@ -13,8 +13,10 @@
|
||||
#include "table-allgui.h"
|
||||
|
||||
typedef enum {
|
||||
GNCENTRY_LEDGER,
|
||||
GNCENTRY_CHOOSER,
|
||||
GNCENTRY_ORDER_ENTRY,
|
||||
GNCENTRY_ORDER_VIEWER,
|
||||
GNCENTRY_INVOICE_ENTRY,
|
||||
GNCENTRY_INVOICE_VIEWER,
|
||||
GNCENTRY_NUM_REGISTER_TYPES
|
||||
} GncEntryLedgerType;
|
||||
|
||||
@@ -41,6 +43,9 @@ typedef struct entry_ledger_colors
|
||||
#define ENTRY_TAXTYPE_CELL "tax-type"
|
||||
#define ENTRY_TAX_CELL "tax"
|
||||
|
||||
#define ENTRY_INV_CELL "invoiced-p"
|
||||
#define ENTRY_VALUE_CELL "line-value"
|
||||
|
||||
typedef struct GncEntryLedger_s GncEntryLedger;
|
||||
|
||||
/** Prototypes ***************************************************/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* gncEntryLedgerControl.c -- Control for GncEntry ledger
|
||||
* Copyright (C) 2001 Derek Atkins
|
||||
* Copyright (C) 2001,2002 Derek Atkins
|
||||
* Author: Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
||||
@@ -210,6 +210,13 @@ static gboolean gnc_entry_ledger_traverse (VirtualLocation *p_new_virt_loc,
|
||||
|
||||
} while (FALSE);
|
||||
|
||||
/*
|
||||
* XXX: Note well that there is no verification that the Entry has
|
||||
* an account or taxaccount, which could cause trouble come invoice
|
||||
* time. Should we check that here? Note that we only need an
|
||||
* account or taxaccount if there is a value or tax. E.g., if the
|
||||
* tax is zero, then we don't need a taxaccount.
|
||||
*/
|
||||
|
||||
/* See if we are tabbing off the end of the very last line */
|
||||
do
|
||||
@@ -285,18 +292,58 @@ static gboolean gnc_entry_ledger_traverse (VirtualLocation *p_new_virt_loc,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX GNCENTRY_INVOICE_EDIT processing to be added:
|
||||
* 1) check if the qty field changed.
|
||||
* 2) if so, check if this entry is part of an order.
|
||||
* 3) if so, ask if they want to change the entry or
|
||||
* split the entry into two parts.
|
||||
*/
|
||||
|
||||
/* Ok, we are changing entries and the current entry has
|
||||
* changed. See what the user wants to do. */
|
||||
{
|
||||
const char *message;
|
||||
|
||||
message = _("The current entry has been changed.\n"
|
||||
"Would you like to record it?");
|
||||
switch (ledger->type) {
|
||||
case GNCENTRY_INVOICE_ENTRY:
|
||||
{
|
||||
char inv_value;
|
||||
char only_inv_changed;
|
||||
|
||||
inv_value = gnc_entry_ledger_get_inv (ledger, ENTRY_INV_CELL);
|
||||
only_inv_changed = 0; /* XXX */
|
||||
|
||||
if (inv_value == 'X' && only_inv_changed) {
|
||||
/* If the only change is that the 'inv' entry was clicked
|
||||
* "on", then just accept the change it without question.
|
||||
*/
|
||||
result = GNC_VERIFY_YES;
|
||||
goto dontask;
|
||||
}
|
||||
}
|
||||
/* Ok, something else has changed -- we should ask the user */
|
||||
|
||||
if (gncEntryGetOrder (entry) != NULL) {
|
||||
message = _("The current entry has been changed.\n"
|
||||
"However, this entry is part of an existing order\n"
|
||||
"Would you like to record the change and\n"
|
||||
"effectively change your order?");
|
||||
break;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
message = _("The current entry has been changed.\n"
|
||||
"Would you like to record the change?");
|
||||
break;
|
||||
}
|
||||
|
||||
result = gnc_verify_cancel_dialog_parented (ledger->parent,
|
||||
message, GNC_VERIFY_YES);
|
||||
}
|
||||
|
||||
dontask:
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case GNC_VERIFY_YES:
|
||||
@@ -374,7 +421,18 @@ gboolean gnc_entry_ledger_save (GncEntryLedger *ledger, gboolean do_commit)
|
||||
gnc_suspend_gui_refresh ();
|
||||
|
||||
if (entry == blank_entry)
|
||||
gncOrderAddEntry (ledger->order, blank_entry);
|
||||
switch (ledger->type) {
|
||||
case GNCENTRY_ORDER_ENTRY:
|
||||
gncOrderAddEntry (ledger->order, blank_entry);
|
||||
break;
|
||||
case GNCENTRY_INVOICE_ENTRY:
|
||||
/* Anything entered on an invoice entry must be part of the invoice! */
|
||||
gncInvoiceAddEntry (ledger->invoice, blank_entry);
|
||||
break;
|
||||
default:
|
||||
/* Nothing to do for viewers */
|
||||
break;
|
||||
}
|
||||
|
||||
gnc_table_save_cells (ledger->table, entry);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* gncEntryLedgerLayout.c -- Layout for GncEntry ledger
|
||||
* Copyright (C) 2001 Derek Atkins
|
||||
* Copyright (C) 2001,2002 Derek Atkins
|
||||
* Author: Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
||||
@@ -73,6 +73,10 @@ static void gnc_entry_ledger_layout_add_cells (GncEntryLedger *ledger,
|
||||
{ ENTRY_TAXTYPE_CELL, RECN_CELL_TYPE_NAME, N_("sample:TT")+7,
|
||||
CELL_ALIGN_RIGHT, FALSE, FALSE },
|
||||
{ ENTRY_DISTYPE_CELL, RECN_CELL_TYPE_NAME, N_("sample(DT):+%")+11,
|
||||
CELL_ALIGN_RIGHT, FALSE, FALSE },
|
||||
{ ENTRY_INV_CELL, RECN_CELL_TYPE_NAME, N_("sample:X")+7,
|
||||
CELL_ALIGN_RIGHT, FALSE, FALSE },
|
||||
{ ENTRY_VALUE_CELL, PRICE_CELL_TYPE_NAME, N_("sample:999,999.00")+7,
|
||||
CELL_ALIGN_RIGHT, FALSE, FALSE }
|
||||
};
|
||||
int i;
|
||||
@@ -90,9 +94,11 @@ static void gnc_entry_ledger_layout_add_cursors (GncEntryLedger *ledger,
|
||||
int num_cols;
|
||||
|
||||
switch (ledger->type) {
|
||||
case GNCENTRY_LEDGER:
|
||||
case GNCENTRY_CHOOSER:
|
||||
num_cols = 11; /* ??? */
|
||||
case GNCENTRY_ORDER_ENTRY:
|
||||
case GNCENTRY_ORDER_VIEWER:
|
||||
case GNCENTRY_INVOICE_ENTRY:
|
||||
case GNCENTRY_INVOICE_VIEWER:
|
||||
num_cols = 13;
|
||||
break;
|
||||
default:
|
||||
g_assert (FALSE);
|
||||
@@ -114,10 +120,13 @@ static void gnc_entry_ledger_set_cells (GncEntryLedger *ledger,
|
||||
int x = 0;
|
||||
|
||||
switch (ledger->type) {
|
||||
case GNCENTRY_LEDGER:
|
||||
case GNCENTRY_CHOOSER:
|
||||
curs = gnc_table_layout_get_cursor (layout, "cursor");
|
||||
case GNCENTRY_ORDER_ENTRY:
|
||||
case GNCENTRY_ORDER_VIEWER:
|
||||
case GNCENTRY_INVOICE_ENTRY:
|
||||
case GNCENTRY_INVOICE_VIEWER:
|
||||
|
||||
curs = gnc_table_layout_get_cursor (layout, "cursor");
|
||||
gnc_table_layout_set_cell (layout, curs, ENTRY_INV_CELL, 0, x++);
|
||||
gnc_table_layout_set_cell (layout, curs, ENTRY_DATE_CELL, 0, x++);
|
||||
gnc_table_layout_set_cell (layout, curs, ENTRY_DESC_CELL, 0, x++);
|
||||
gnc_table_layout_set_cell (layout, curs, ENTRY_ACTN_CELL, 0, x++);
|
||||
@@ -129,6 +138,7 @@ static void gnc_entry_ledger_set_cells (GncEntryLedger *ledger,
|
||||
gnc_table_layout_set_cell (layout, curs, ENTRY_TAXTYPE_CELL, 0, x++);
|
||||
gnc_table_layout_set_cell (layout, curs, ENTRY_TAX_CELL, 0, x++);
|
||||
gnc_table_layout_set_cell (layout, curs, ENTRY_TAXACC_CELL, 0, x++);
|
||||
gnc_table_layout_set_cell (layout, curs, ENTRY_VALUE_CELL, 0, x++);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* gncEntryLedgerLoad.c -- a Ledger widget for entering GncEntry objects
|
||||
* Copyright (C) 2001 Derek Atkins
|
||||
* Copyright (C) 2001,2002 Derek Atkins
|
||||
* Author: Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
||||
@@ -66,6 +66,21 @@ static void load_discount_type_cells (GncEntryLedger *ledger)
|
||||
gnc_recn_cell_set_string_getter (cell, gnc_entry_ledger_type_string_getter);
|
||||
}
|
||||
|
||||
static void load_inv_type_cells (GncEntryLedger *ledger)
|
||||
{
|
||||
RecnCell *cell;
|
||||
|
||||
if (!ledger) return;
|
||||
|
||||
cell = (RecnCell *)
|
||||
gnc_table_layout_get_cell (ledger->table->layout, ENTRY_INV_CELL);
|
||||
|
||||
if (!cell) return;
|
||||
|
||||
gnc_recn_cell_set_valid_flags (cell, " X", ' ');
|
||||
gnc_recn_cell_set_flag_order (cell, " X");
|
||||
}
|
||||
|
||||
static void load_xfer_cell (ComboCell * cell, AccountGroup * grp)
|
||||
{
|
||||
GList *list;
|
||||
@@ -130,14 +145,23 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
|
||||
/* Load up cells */
|
||||
load_discount_type_cells (ledger);
|
||||
load_tax_type_cells (ledger);
|
||||
load_inv_type_cells (ledger);
|
||||
load_xfer_type_cells (ledger);
|
||||
|
||||
blank_entry = gncEntryLookup (ledger->book, &(ledger->blank_entry_guid));
|
||||
|
||||
if (blank_entry == NULL) {
|
||||
blank_entry = gncEntryCreate (ledger->book);
|
||||
gncEntrySetDate (blank_entry, &ledger->last_date_entered);
|
||||
ledger->blank_entry_guid = *gncEntryGetGUID (blank_entry);
|
||||
switch (ledger->type) {
|
||||
case GNCENTRY_ORDER_ENTRY:
|
||||
case GNCENTRY_INVOICE_ENTRY:
|
||||
blank_entry = gncEntryCreate (ledger->book);
|
||||
gncEntrySetDate (blank_entry, &ledger->last_date_entered);
|
||||
ledger->blank_entry_guid = *gncEntryGetGUID (blank_entry);
|
||||
break;
|
||||
default:
|
||||
ledger->blank_entry_guid = *xaccGUIDNULL ();
|
||||
break;
|
||||
}
|
||||
ledger->blank_entry_edited = FALSE;
|
||||
}
|
||||
|
||||
@@ -209,9 +233,11 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
|
||||
}
|
||||
|
||||
/* Add the blank entry at the end. */
|
||||
gnc_table_set_vcell (table, cursor, gncEntryGetGUID (blank_entry),
|
||||
TRUE, start_primary_color, vcell_loc);
|
||||
vcell_loc.virt_row++;
|
||||
if (blank_entry) {
|
||||
gnc_table_set_vcell (table, cursor, gncEntryGetGUID (blank_entry),
|
||||
TRUE, start_primary_color, vcell_loc);
|
||||
vcell_loc.virt_row++;
|
||||
}
|
||||
|
||||
/* Resize the table */
|
||||
gnc_table_set_size (table, vcell_loc.virt_row, 1);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* gncEntryLedgerModel.c -- Model for GncEntry ledger
|
||||
* Copyright (C) 2001 Derek Atkins
|
||||
* Copyright (C) 2001,2002 Derek Atkins
|
||||
* Author: Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "datecell.h"
|
||||
#include "pricecell.h"
|
||||
#include "recncell.h"
|
||||
|
||||
#include "gncEntryLedgerP.h"
|
||||
#include "gncEntryLedgerModel.h"
|
||||
@@ -89,6 +90,16 @@ static const char * get_tax_label (VirtualLocation virt_loc, gpointer data)
|
||||
return _("Tax");
|
||||
}
|
||||
|
||||
static const char * get_inv_label (VirtualLocation virt_loc, gpointer data)
|
||||
{
|
||||
return _("I?");
|
||||
}
|
||||
|
||||
static const char * get_value_label (VirtualLocation virt_loc, gpointer data)
|
||||
{
|
||||
return _("Value");
|
||||
}
|
||||
|
||||
/* GET_ENTRY */
|
||||
|
||||
static const char * get_acct_entry (VirtualLocation virt_loc,
|
||||
@@ -281,6 +292,50 @@ static const char * get_tax_entry (VirtualLocation virt_loc,
|
||||
return xaccPrintAmount (tax, gnc_default_price_print_info ());
|
||||
}
|
||||
|
||||
static const char * get_inv_entry (VirtualLocation virt_loc,
|
||||
gboolean translate,
|
||||
gboolean *conditionally_changed,
|
||||
gpointer user_data)
|
||||
{
|
||||
GncEntryLedger *ledger = user_data;
|
||||
GncEntry *entry;
|
||||
static char s[2] = { ' ', '\0' };
|
||||
|
||||
entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
|
||||
if (gncEntryGetInvoice (entry) != NULL)
|
||||
s[0] = 'X';
|
||||
|
||||
/* XXX: what if this entry doesn't belong to this invoice?
|
||||
* Or, better question, what if this is the blank_entry on
|
||||
* an invoice page? For the latter, don't worry about it;
|
||||
* it will be added automatically during the Save operation
|
||||
*/
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
static const char * get_value_entry (VirtualLocation virt_loc,
|
||||
gboolean translate,
|
||||
gboolean *conditionally_changed,
|
||||
gpointer user_data)
|
||||
{
|
||||
GncEntryLedger *ledger = user_data;
|
||||
gnc_numeric value;
|
||||
GncEntry *entry;
|
||||
|
||||
entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
|
||||
|
||||
if (entry == gncEntryLookup (ledger->book, &(ledger->blank_entry_guid)))
|
||||
return NULL;
|
||||
|
||||
gncEntryGetValue (entry, &value, NULL);
|
||||
|
||||
if (gnc_numeric_zero_p (value))
|
||||
return NULL;
|
||||
|
||||
return xaccPrintAmount (value, gnc_default_price_print_info ());
|
||||
}
|
||||
|
||||
/* GET_HELP */
|
||||
|
||||
static char * get_acct_help (VirtualLocation virt_loc, gpointer user_data)
|
||||
@@ -436,18 +491,103 @@ static char * get_tax_help (VirtualLocation virt_loc, gpointer user_data)
|
||||
return g_strdup (help);
|
||||
}
|
||||
|
||||
static char * get_inv_help (VirtualLocation virt_loc, gpointer user_data)
|
||||
{
|
||||
GncEntryLedger *ledger = user_data;
|
||||
const char *help;
|
||||
|
||||
help = gnc_table_get_entry (ledger->table, virt_loc);
|
||||
if (!help || *help == '\0')
|
||||
switch (ledger->type) {
|
||||
case GNCENTRY_ORDER_ENTRY:
|
||||
case GNCENTRY_ORDER_VIEWER:
|
||||
help = _("Is this entry Invoiced?");
|
||||
break;
|
||||
case GNCENTRY_INVOICE_ENTRY:
|
||||
case GNCENTRY_INVOICE_VIEWER:
|
||||
help = _("Include this entry on this invoice?");
|
||||
break;
|
||||
default:
|
||||
help = _("Unknown EntryLedger Type");
|
||||
}
|
||||
|
||||
return g_strdup (help);
|
||||
}
|
||||
|
||||
static char * get_value_help (VirtualLocation virt_loc, gpointer user_data)
|
||||
{
|
||||
GncEntryLedger *ledger = user_data;
|
||||
const char *help;
|
||||
|
||||
help = gnc_table_get_entry (ledger->table, virt_loc);
|
||||
if (!help || *help == '\0')
|
||||
help = _("The value of this entry ");
|
||||
|
||||
return g_strdup (help);
|
||||
}
|
||||
|
||||
/* GET_IO_FLAGS */
|
||||
|
||||
static CellIOFlags get_standard_io_flags (VirtualLocation virt_loc,
|
||||
gpointer user_data)
|
||||
{
|
||||
return XACC_CELL_ALLOW_ALL;
|
||||
GncEntryLedger *ledger = user_data;
|
||||
switch (ledger->type) {
|
||||
case GNCENTRY_ORDER_VIEWER:
|
||||
case GNCENTRY_INVOICE_VIEWER:
|
||||
/* Viewers are always immutable */
|
||||
|
||||
/* XXX: This is a problem... */
|
||||
return XACC_CELL_ALLOW_SHADOW;
|
||||
|
||||
case GNCENTRY_ORDER_ENTRY:
|
||||
{
|
||||
GncEntry *entry =
|
||||
gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
|
||||
|
||||
/*
|
||||
* If the type is an order_entry and the entry was invoiced,
|
||||
* make the entry immutable
|
||||
*/
|
||||
if (gncEntryGetInvoice (entry) != NULL)
|
||||
return XACC_CELL_ALLOW_SHADOW;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
return XACC_CELL_ALLOW_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
static CellIOFlags get_typecell_io_flags (VirtualLocation virt_loc,
|
||||
gpointer user_data)
|
||||
{
|
||||
return XACC_CELL_ALLOW_ALL | XACC_CELL_ALLOW_EXACT_ONLY;
|
||||
CellIOFlags retval = get_standard_io_flags (virt_loc, user_data);
|
||||
|
||||
if (retval & XACC_CELL_ALLOW_ALL)
|
||||
retval |= XACC_CELL_ALLOW_EXACT_ONLY;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static CellIOFlags get_inv_io_flags (VirtualLocation virt_loc,
|
||||
gpointer user_data)
|
||||
{
|
||||
GncEntryLedger *ledger = user_data;
|
||||
|
||||
switch (ledger->type) {
|
||||
case GNCENTRY_ORDER_ENTRY:
|
||||
case GNCENTRY_ORDER_VIEWER:
|
||||
case GNCENTRY_INVOICE_VIEWER:
|
||||
return XACC_CELL_ALLOW_SHADOW;
|
||||
default:
|
||||
return XACC_CELL_ALLOW_ALL | XACC_CELL_ALLOW_EXACT_ONLY;
|
||||
}
|
||||
}
|
||||
|
||||
static CellIOFlags get_value_io_flags (VirtualLocation virt_loc,
|
||||
gpointer user_data)
|
||||
{
|
||||
return XACC_CELL_ALLOW_SHADOW;
|
||||
}
|
||||
|
||||
/* GET BG_COLORS */
|
||||
@@ -618,6 +758,29 @@ static void gnc_entry_ledger_save_cells (gpointer save_data,
|
||||
amount = gnc_price_cell_get_value (cell);
|
||||
gncEntrySetTax (entry, amount);
|
||||
}
|
||||
|
||||
{
|
||||
char inv_value;
|
||||
|
||||
inv_value = gnc_entry_ledger_get_inv (ledger, ENTRY_INV_CELL);
|
||||
|
||||
if (inv_value != '\0') {
|
||||
/* It's changed. Note that this should only be changed in
|
||||
* INVOICE_ENTRY. But we don't check here (should we)?
|
||||
*/
|
||||
|
||||
if (inv_value == 'X') {
|
||||
/* Add this to the invoice (if it's not already attached) */
|
||||
if (gncEntryGetInvoice (entry) == NULL)
|
||||
gncInvoiceAddEntry (ledger->invoice, entry);
|
||||
|
||||
} else {
|
||||
/* Remove from the invoice iff we're attached to an order */
|
||||
if (gncEntryGetOrder (entry) != NULL)
|
||||
gncInvoiceRemoveEntry (ledger->invoice, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Set Cell Handlers */
|
||||
@@ -641,7 +804,9 @@ static void gnc_entry_ledger_model_new_handlers (TableModel *model)
|
||||
{ ENTRY_QTY_CELL, get_qty_entry, get_qty_label, get_qty_help, get_standard_io_flags },
|
||||
{ ENTRY_TAXACC_CELL, get_taxacc_entry, get_taxacc_label, get_taxacc_help, get_standard_io_flags },
|
||||
{ ENTRY_TAXTYPE_CELL, get_taxtype_entry, get_taxtype_label, get_taxtype_help, get_typecell_io_flags },
|
||||
{ ENTRY_TAX_CELL, get_tax_entry, get_tax_label, get_tax_help, get_standard_io_flags }
|
||||
{ ENTRY_TAX_CELL, get_tax_entry, get_tax_label, get_tax_help, get_standard_io_flags },
|
||||
{ ENTRY_INV_CELL, get_inv_entry, get_inv_label, get_inv_help, get_inv_io_flags },
|
||||
{ ENTRY_VALUE_CELL, get_value_entry, get_value_label, get_value_help, get_value_io_flags },
|
||||
};
|
||||
int i;
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ struct GncEntryLedger_s {
|
||||
GNCBook * book;
|
||||
Table * table;
|
||||
GncOrder * order;
|
||||
GncInvoice * invoice;
|
||||
GncEntryLedgerType type;
|
||||
};
|
||||
|
||||
@@ -30,7 +31,9 @@ GncEntry * gnc_entry_ledger_get_entry (GncEntryLedger *ledger,
|
||||
VirtualCellLocation vcell_loc);
|
||||
Account * gnc_entry_ledger_get_account (GncEntryLedger *ledger,
|
||||
const char * cell_name);
|
||||
|
||||
gint gnc_entry_ledger_get_type (GncEntryLedger *ledger, const char * cell_name);
|
||||
char gnc_entry_ledger_get_inv (GncEntryLedger *ledger, const char * cell_name);
|
||||
|
||||
const char * gnc_entry_ledger_type_string_getter (char flag);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user