gcalctool r2285 - in trunk: . gcalctool glade
- From: rancell svn gnome org
- To: svn-commits-list gnome org
- Subject: gcalctool r2285 - in trunk: . gcalctool glade
- Date: Sun, 2 Nov 2008 11:31:24 +0000 (UTC)
Author: rancell
Date: Sun Nov 2 11:31:24 2008
New Revision: 2285
URL: http://svn.gnome.org/viewvc/gcalctool?rev=2285&view=rev
Log:
Added Gross Profit Margin Ration Financial Function (Robin Sonefors, Bug #150663)
Modified:
trunk/ChangeLog
trunk/gcalctool/calctool.c
trunk/gcalctool/calctool.h
trunk/gcalctool/financial.c
trunk/gcalctool/financial.h
trunk/gcalctool/gtk.c
trunk/glade/financial.glade
trunk/glade/gcalctool.glade
Modified: trunk/gcalctool/calctool.c
==============================================================================
--- trunk/gcalctool/calctool.c (original)
+++ trunk/gcalctool/calctool.c Sun Nov 2 11:31:24 2008
@@ -391,6 +391,11 @@
0
},
{
+ KEY_FINC_GPM,
+ "Gpm",
+ 0
+},
+{
KEY_FINC_PMT,
"Pmt",
0
Modified: trunk/gcalctool/calctool.h
==============================================================================
--- trunk/gcalctool/calctool.h (original)
+++ trunk/gcalctool/calctool.h Sun Nov 2 11:31:24 2008
@@ -108,6 +108,7 @@
KEY_FINC_CTRM,
KEY_FINC_DDB,
KEY_FINC_FV,
+ KEY_FINC_GPM,
KEY_FINC_PMT,
KEY_FINC_PV,
KEY_FINC_RATE,
Modified: trunk/gcalctool/financial.c
==============================================================================
--- trunk/gcalctool/financial.c (original)
+++ trunk/gcalctool/financial.c Sun Nov 2 11:31:24 2008
@@ -108,6 +108,24 @@
void
+calc_gpm(int t[MP_SIZE], int cost[MP_SIZE], int margin[MP_SIZE])
+{
+
+/* Gpm - cost (cost of sale).
+ * margin (gross profit margin.
+ *
+ * RESULT = cost / (1 - margin)
+ */
+
+ int MP1[MP_SIZE], MP2[MP_SIZE];
+
+ mp_set_from_integer(1, MP1);
+ mp_subtract(MP1, margin, MP2);
+ mpdiv(cost, MP2, t);
+}
+
+
+void
calc_pmt(int t[MP_SIZE], int prin[MP_SIZE], int pint[MP_SIZE], int n[MP_SIZE])
{
@@ -258,6 +276,9 @@
case FINC_FV_DIALOG:
calc_fv(result, arg1, arg2, arg3);
break;
+ case FINC_GPM_DIALOG:
+ calc_gpm(result, arg1, arg2);
+ break;
case FINC_PMT_DIALOG:
calc_pmt(result, arg1, arg2, arg3);
break;
Modified: trunk/gcalctool/financial.h
==============================================================================
--- trunk/gcalctool/financial.h (original)
+++ trunk/gcalctool/financial.h Sun Nov 2 11:31:24 2008
@@ -30,6 +30,7 @@
FINC_CTRM_DIALOG,
FINC_DDB_DIALOG,
FINC_FV_DIALOG,
+ FINC_GPM_DIALOG,
FINC_PMT_DIALOG,
FINC_PV_DIALOG,
FINC_RATE_DIALOG,
Modified: trunk/gcalctool/gtk.c
==============================================================================
--- trunk/gcalctool/gtk.c (original)
+++ trunk/gcalctool/gtk.c Sun Nov 2 11:31:24 2008
@@ -86,6 +86,7 @@
{"ctrm_pint", "ctrm_fv", "ctrm_pv", NULL},
{"ddb_cost", "ddb_life", "ddb_period", NULL},
{"fv_pmt", "fv_pint", "fv_n", NULL},
+ {"gpm_cost", "gpm_margin", NULL, NULL},
{"pmt_prin", "pmt_pint", "pmt_n", NULL},
{"pv_pmt", "pv_pint", "pv_n", NULL},
{"rate_fv", "rate_pv", "rate_n", NULL},
@@ -98,7 +99,7 @@
*
* | a b c d e f g h i j k l m n o p q r s t u v w x y z
*-----------+-----------------------------------------------------
- * Lower: | a b c d e f i l m n p r s t u v x
+ * Lower: | a b c d e f g i l m n p r s t u v x
* Upper: | A C D E F G J K L M N P R S T X Y
* Numeric: | 0 1 2 3 4 5 6 7 8 9
* Other: | @ . + - * / = % ( ) # < > [ ] { } | & ~ ^ ? ! :
@@ -387,6 +388,10 @@
{ 0, 0, 0 },
{ GDK_v, GDK_V, 0 }},
+ {KEY_FINC_GPM, "finc_gross_profit_margin",
+ { 0, 0, 0 },
+ { GDK_g, GDK_G, 0 }},
+
{KEY_FINC_PMT, "finc_periodic_payment",
{ GDK_SHIFT_MASK, 0 },
{ GDK_P, 0 }},
@@ -1474,6 +1479,9 @@
glade_xml_signal_connect_data(X->financial, "finc_fv_response_cb",
G_CALLBACK(finc_response_cb),
GINT_TO_POINTER(FINC_FV_DIALOG));
+ glade_xml_signal_connect_data(X->financial, "finc_gpm_response_cb",
+ G_CALLBACK(finc_response_cb),
+ GINT_TO_POINTER(FINC_GPM_DIALOG));
glade_xml_signal_connect_data(X->financial, "finc_pmt_response_cb",
G_CALLBACK(finc_response_cb),
GINT_TO_POINTER(FINC_PMT_DIALOG));
@@ -1502,6 +1510,8 @@
g_object_set_data(G_OBJECT(button), "finc_dialog", "ddb_dialog");
button = GET_WIDGET("calc_finc_future_value_button");
g_object_set_data(G_OBJECT(button), "finc_dialog", "fv_dialog");
+ button = GET_WIDGET("calc_finc_gross_profit_margin_button");
+ g_object_set_data(G_OBJECT(button), "finc_dialog", "gpm_dialog");
button = GET_WIDGET("calc_finc_periodic_payment_button");
g_object_set_data(G_OBJECT(button), "finc_dialog", "pmt_dialog");
button = GET_WIDGET("calc_finc_present_value_button");
Modified: trunk/glade/financial.glade
==============================================================================
--- trunk/glade/financial.glade (original)
+++ trunk/glade/financial.glade Sun Nov 2 11:31:24 2008
@@ -798,6 +798,219 @@
</child>
</widget>
+<widget class="GtkDialog" id="gpm_dialog">
+ <property name="border_width">6</property>
+ <property name="title" translatable="yes" comments="Title of Gross Profit Margin dialog">Gross Profit Margin</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">False</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
+ <property name="has_separator">False</property>
+ <signal name="response" handler="finc_gpm_response_cb"/>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox3">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area3">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="button5">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-6</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="button6">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes" comments="Gross Profit Margin Dialog: Calculate button">C_alculate</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-5</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkTable" id="table3">
+ <property name="border_width">6</property>
+ <property name="visible">True</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="homogeneous">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label12">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes" comments="Gross Profit Margin Dialog: Description of calculation">Calculates the resale price of a product, based on the product cost and the wanted gross profit margin.</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">True</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label13">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes" comments="Gross Profit Margin Dialog: Label before cost input">C_ost:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">gpm_cost</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label14">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes" comments="Gross Profit Margin Dialog: Label before margin input">_Margin:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">gpm_revenue</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="gpm_cost">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text">0</property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">â</property>
+ <property name="activates_default">False</property>
+ <signal name="activate" handler="finc_activate_cb"/>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="gpm_margin">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text">0</property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">â</property>
+ <property name="activates_default">False</property>
+ <signal name="activate" handler="finc_activate_cb"/>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
<widget class="GtkDialog" id="pmt_dialog">
<property name="border_width">6</property>
<property name="title" translatable="yes" comments="Title of Periodic Payment dialog">Periodic Payment</property>
Modified: trunk/glade/gcalctool.glade
==============================================================================
--- trunk/glade/gcalctool.glade (original)
+++ trunk/glade/gcalctool.glade Sun Nov 2 11:31:24 2008
@@ -808,10 +808,10 @@
<signal name="clicked" handler="button_cb"/>
</widget>
<packing>
- <property name="left_attach">7</property>
- <property name="right_attach">8</property>
- <property name="top_attach">0</property>
- <property name="bottom_attach">1</property>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
<property name="x_options">expand|shrink|fill</property>
<property name="y_options">expand|shrink|fill</property>
</packing>
@@ -833,8 +833,8 @@
<signal name="clicked" handler="button_cb"/>
</widget>
<packing>
- <property name="left_attach">6</property>
- <property name="right_attach">7</property>
+ <property name="left_attach">7</property>
+ <property name="right_attach">8</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">expand|shrink|fill</property>
@@ -862,8 +862,8 @@
<signal name="clicked" handler="button_cb"/>
</widget>
<packing>
- <property name="left_attach">5</property>
- <property name="right_attach">6</property>
+ <property name="left_attach">6</property>
+ <property name="right_attach">7</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">expand|shrink|fill</property>
@@ -887,8 +887,8 @@
<signal name="clicked" handler="button_cb"/>
</widget>
<packing>
- <property name="left_attach">4</property>
- <property name="right_attach">5</property>
+ <property name="left_attach">5</property>
+ <property name="right_attach">6</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">expand|shrink|fill</property>
@@ -912,8 +912,8 @@
<signal name="clicked" handler="button_cb"/>
</widget>
<packing>
- <property name="left_attach">3</property>
- <property name="right_attach">4</property>
+ <property name="left_attach">4</property>
+ <property name="right_attach">5</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">expand|shrink|fill</property>
@@ -947,6 +947,31 @@
</child>
<child>
+ <widget class="GtkButton" id="calc_finc_gross_profit_margin_button">
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes" comments="Tooltip for the [Gpm] button">Gross Profit Margin [g]</property>
+ <property name="label" translatable="yes" comments="Calculates the resale price of a product, based on the product cost and the wanted gross profit margin. See also:
+http://en.wikipedia.org/wiki/Gross_profit_margin">Gpm</property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">False</property>
+ <accessibility>
+ <atkproperty name="AtkObject::accessible_name" translatable="yes">Gross Profit Margin</atkproperty>
+ <atkproperty name="AtkObject::accessible_description" translatable="yes">Gross Profit Margin [g]</atkproperty>
+ </accessibility>
+ <signal name="clicked" handler="button_cb"/>
+ </widget>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="right_attach">4</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">expand|shrink|fill</property>
+ <property name="y_options">expand|shrink|fill</property>
+ </packing>
+ </child>
+
+ <child>
<widget class="GtkButton" id="calc_finc_double_declining_depreciation_button">
<property name="visible">True</property>
<property name="tooltip" translatable="yes" comments="Tooltip for the [Ddb] button">Double-declining depreciation [D]</property>
@@ -1013,8 +1038,8 @@
<signal name="clicked" handler="button_cb"/>
</widget>
<packing>
- <property name="left_attach">0</property>
- <property name="right_attach">1</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">expand|shrink|fill</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]