mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
add blanking for zero-valued cells
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@813 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
b560bb6d01
commit
501448f64c
@ -33,10 +33,12 @@
|
||||
#include "basiccell.h"
|
||||
#include "pricecell.h"
|
||||
|
||||
static void PriceSetValue (BasicCell *, const char *);
|
||||
|
||||
#define DECIMAL_PT '.'
|
||||
|
||||
#define VERY_SMALL (1.0e-30)
|
||||
|
||||
static void PriceSetValue (BasicCell *, const char *);
|
||||
|
||||
/* hack alert -- use color for cells as per old xacc */
|
||||
|
||||
#define SET(cell,str) { \
|
||||
@ -95,6 +97,7 @@ xaccInitPriceCell (PriceCell *cell)
|
||||
{
|
||||
xaccInitBasicCell( &(cell->cell));
|
||||
cell->amount = 0.0;
|
||||
cell->blank_zero = 0;
|
||||
|
||||
SET ( &(cell->cell), "0.0");
|
||||
|
||||
@ -117,7 +120,13 @@ void xaccSetPriceCellValue (PriceCell * cell, double amt)
|
||||
{
|
||||
char buff[40];
|
||||
cell->amount = amt;
|
||||
sprintf (buff, "%.3f", amt);
|
||||
|
||||
/* if amount is zero, and blanking is set, then print blank */
|
||||
if (cell->blank_zero && (VERY_SMALL > amt) && ((-VERY_SMALL) < amt)) {
|
||||
buff[0] = 0x0;
|
||||
} else {
|
||||
sprintf (buff, "%.3f", amt);
|
||||
}
|
||||
SET ( &(cell->cell), buff);
|
||||
}
|
||||
|
||||
@ -127,7 +136,13 @@ void xaccSetAmountCellValue (PriceCell * cell, double amt)
|
||||
{
|
||||
char buff[40];
|
||||
cell->amount = amt;
|
||||
sprintf (buff, "%.2f", amt);
|
||||
|
||||
/* if amount is zero, and blanking is set, then print blank */
|
||||
if (cell->blank_zero && (VERY_SMALL > amt) && ((-VERY_SMALL) < amt)) {
|
||||
buff[0] = 0x0;
|
||||
} else {
|
||||
sprintf (buff, "%.2f", amt);
|
||||
}
|
||||
SET ( &(cell->cell), buff);
|
||||
}
|
||||
|
||||
@ -140,7 +155,11 @@ void xaccSetDebCredCellValue (PriceCell * deb,
|
||||
deb->amount = -amt;
|
||||
cred->amount = amt;
|
||||
|
||||
if (0.0 <= amt) {
|
||||
if (cred->blank_zero && (VERY_SMALL > amt) && ((-VERY_SMALL) < amt)) {
|
||||
SET ( &(cred->cell), "");
|
||||
SET ( &(deb->cell), "");
|
||||
} else
|
||||
if (0.0 < amt) {
|
||||
sprintf (buff, "%.2f", amt);
|
||||
SET ( &(cred->cell), buff);
|
||||
SET ( &(deb->cell), "");
|
||||
|
@ -49,7 +49,9 @@
|
||||
|
||||
typedef struct _PriceCell {
|
||||
BasicCell cell;
|
||||
double amount;
|
||||
double amount; /* the amount associated with this cell */
|
||||
short blank_zero; /* controls printing of zero values */
|
||||
|
||||
} PriceCell;
|
||||
|
||||
/* installs a callback to handle price recording */
|
||||
|
@ -361,6 +361,9 @@ void xaccInitBasicRegister (BasicRegister *reg, int type)
|
||||
|
||||
FANCY (balance, Price, BALN);
|
||||
reg->balanceCell->cell.input_output = 0;
|
||||
reg->debitCell->blank_zero = 1;
|
||||
reg->creditCell->blank_zero = 1;
|
||||
reg->valueCell->blank_zero = 1;
|
||||
|
||||
/* -------------------------------- */
|
||||
/* define how traversal works */
|
||||
|
Loading…
Reference in New Issue
Block a user