Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Tuesday, April 16, 2024

File: [Platon] / tucniak / lib / lt.h (download)

Revision 1.1.1.1 (vendor branch), Fri Nov 11 16:08:31 2005 UTC (18 years, 5 months ago) by koli


Changes since 1.1: +0 -0 lines

Initial import

// Copyright (c) 2003,2004,2005 Juraj Kolesár <koli@koli.sk>               
#include "../db/tdb.h"
/* ABOUT {{{ */
/*
Project TUCNIAK
  -its goal is to create package of mostly accounting programs used in SOHO
  -it is designed primary for Slovak (Czech) companies that buy and sell
  anything. It's primary outputs will be done according to slovak law, but
  in future we want to make these according to European Union standards
  -"tucniak" means "penguin" in slovak, 
  but it's other meaning could be also "fat boy"
lt - Library Tucniak is core library. 
  All executable programs in this project should use this library, 
  where are defined data structures. It is kind of bridge between database
  and aplication, thats why it is based on tdb (Tucniak's DB library).
    So the data integrity in database is shared somehow between 'lt' and 'tdb'.
    This solution makes project independent of concrete DB SQL server, because
    we use only ANSI SQL commands. 
  Changing the SQL server is then depending only on porting tdb to concrete
    server. Now we are supporting only MySQL, but volunteers for creating support
  for other servers are welcome.
    -it works with specified data objects and its dependecies.
/* }}} */
/* CONSTANTS {{{ */
#define __LT_ERR    -1
#define __LT_OK        0

#define __LT_FILLED    1
#define __LT_EMPTY    0

#define __LT_EDIT    1
#define __LT_UPDATE    2
#define __LT_DELETE    3
#define __LT_END    4
/* }}} */

/* T_STATUS {{{ */
typedef bool T_STATUS;
    /*
    Each T_* data object (resp. struct lt_%_*) has its T_STATUS array 
    For now it is created just of bool flags, but maybe in future there will
  be usefull create larger variaty of flags. 
  These show, if actual data obtained from db are original or were changed. 
    Then only values with 'false' status are updated to (or read from) db 
    or otherwise handeled by user or code. This should minimalize comunication
    between aplication and db server.
    
    During operations with data objects these values could be changed
    *_get, functions sets these values to 'true', because all 'false flaged'
    values are get fresh from db
      *_init functions sets these to 'false',    because structs were only 
      initialized and are empty. 
    *_set functions update all 'false flaged' values to DB

  Every data object is defined as struct(ure) that could have 3 main "areas"
    1.  T_STATUS area - already described (see up)
    2.  T_CELL area - this are primary informations about object
          -there can be only ONE primary information connected to object
          -it is usualy stored in the same table as object's primary key
    3.  T_MATRIX area - these are secondary informations about object
          -there can be MANY secondary informations of some KIND
          -these informations are stored in another table and are linked
  T_CELL and T_MATRIX are described in "tdb.h"
  Constants define the mostly the UI and are something like "TabStop" numbers.
  (but I think here is the best place to define things like _PARAM_COUNT...)
/* }}} */

/* CONTACTS {{{1 */
/* ABOUT {{{2 */
/******************************************************************************/
/*******************            LT CONTACTS             **********************************/
/******************************************************************************/
/*
    'lt_c_*' means 'Contacts' 
    -These objects contains data about real objects (Persons,Companies) 
  from the external    environment of 'Tucniak user' that are somehow connected 
  to internal    data (e.g. Customers, Supplyiers)
  
  These objects often shares "communication channels" 
    -Address - now it is popular to work at home, 
        so many companies has the same address as their owners
    -Phone - many employees of one company has the same phone number 
  So why to put one information more times into database 
  (Like the Other Aplications Do - LOAD). Main idea of Contact database model is
  only to link to any information when it already exists in database. 
  
  When you fill contact database in this way you know more than contact
  information about your externals, you know the connections between them.
    "And the more you know externals the more you could use their sources"
    This is kind a new approach to this problematics, but I think it could be very 
  usefull. Of course it brings a lot of problems to create user friendly 
  interface but it is not unreal to make it this way. 
/* }}}2 */
/* T_COMPANY {{{2 */                                                
/* CONST {{{3 */
#define __LT_C_COMPANY_PK            0
#define __LT_C_COMPANY_NAME            1
#define __LT_C_COMPANY_IDN            2    //Identification Number (ICO)
#define __LT_C_COMPANY_TXN            3    //Tax Number (DIC)
#define __LT_C_COMPANY_EMPLOYEES    4    
#define __LT_C_COMPANY_ADDRESS        5
#define __LT_C_COMPANY_PHONE        6
#define __LT_C_COMPANY_EMAIL        7
#define __LT_C_COMPANY_ACCOUNT        8
#define __LT_C_COMPANY_NOTES        9
#define __LT_C_COMPANY_PARAM_COUNT    10
#define __LT_C_COMPANY_WIDTH_PK        0
#define __LT_C_COMPANY_WIDTH_NAME    20
#define __LT_C_COMPANY_WIDTH_IDN    10
#define __LT_C_COMPANY_WIDTH_TXN    10
/* }}}3 */
/* STRUCT {{{3 */
struct lt_c_company {
    T_STATUS status[__LT_C_COMPANY_PARAM_COUNT];
    T_CELL pk;
    T_CELL name;
    T_CELL idn;
    T_CELL txn;
    T_MATRIX employees;
    T_MATRIX address;
    T_MATRIX phone;
    T_MATRIX email;
    T_MATRIX account;
    T_MATRIX notes;
};
typedef struct lt_c_company T_COMPANY;
/* }}}3 */
/* }}}2 */
/* T_PERSON {{{2 */
/* CONST {{{3 */
#define __LT_C_PERSON_PK        0
#define __LT_C_PERSON_NAME        1
#define __LT_C_PERSON_SURNAME    2
#define __LT_C_PERSON_NICKNAME    3
#define __LT_C_PERSON_COMPANY    4
#define __LT_C_PERSON_ADDRESS    5
#define __LT_C_PERSON_PHONE        6
#define __LT_C_PERSON_EMAIL        7
#define __LT_C_PERSON_ACCOUNT    8
#define __LT_C_PERSON_NOTES        9
#define __LT_C_PERSON_PARAM_COUNT    10
/* }}}3 */
/* STRUCT {{{3 */
struct lt_c_person {
    bool status[__LT_C_PERSON_PARAM_COUNT];
    T_CELL pk;
    T_CELL name;
    T_CELL surname;
    T_CELL nickname;
    T_MATRIX company;
    T_MATRIX address;
    T_MATRIX phone;
    T_MATRIX email;
    T_MATRIX account;
    T_MATRIX notes;
};
typedef struct lt_c_person T_PERSON;
/* }}}3 */
/* }}}2 */
/* COMMON {{{2 */
#define __LT_C_PHONE_PK            0
#define __LT_C_PHONE_NUMBER        1
#define __LT_C_PHONE_NOTE        2
#define __LT_C_PHONE_PARAM_COUNT    3
#define __LT_C_PHONE_WIDTH_PK        0
#define __LT_C_PHONE_WIDTH_NUMBER    13
#define __LT_C_PHONE_WIDTH_NOTE        10

#define __LT_C_EMAIL_PK            0
#define __LT_C_EMAIL_NUMBER        1
#define __LT_C_EMAIL_NOTE        2
#define __LT_C_EMAIL_PARAM_COUNT    3
#define __LT_C_EMAIL_WIDTH_PK        0
#define __LT_C_EMAIL_WIDTH_URL        30
#define __LT_C_EMAIL_WIDTH_NOTE        10
/* }}}2 */
#include "lt_c_company.h"
#include "lt_c_person.h"
/* }}}1 */                            
/* STORE {{{1 */
/* ABOUT {{{2 */
/******************************************************************************/
/******************         LT STORE      *************************************/
/******************************************************************************/
/*
    'lt_s_*' means 'Store'
    -These objects contains data about comodities that are dealed by Tucniak user'
  
  Data model is designed so, that there is no table containig actual number
  of some product in my store. Actual number is get as the difference between
  all inputs and outputs of some kind of product in my store. 
  
  This is also unconventional approach to this problematics. Usualy (LOAD)
  there is table containing information about actual number of some kind of 
  product in store. And when I output something, then this number is updated
  to new decreased (or by input increased) number. But by this aproach I lose
  information about which concrete product I am putting out. This is special
  problem by companies that sell the same product which buy price is not stable.
  
  Example:
  I sell computer mouses. There are different types of mouses 
  (Logitech, Genius, Microsoft,...). Each mouse type I should have identified 
  only once in my store(one store card). I am buyng from wholesale these mouses
  every week, but the price for the same type is different every week. 
  First week I bought 10 mouses (Genius scroll PS2) for 3$/one. And the same
  week I sell 5 of these mouses for 4$/one. Next week the price goes up and 
  I buy 10 mouses (same type) for 4$/one. I have still 5 of the cheaper 
  mouses in my store. And now comes my good customer and wants 3 mouses,
  and I want to make a special price for him. I know that I have still those
  5 cheaper mouses in store, so I can offer him price 3,1$/one. I know that
  I am still making profit (0,1$/one) but my software doesn't, because it is
  using one of two LOAD methods (FIFO, or method of sliding averages). 
    FIFO method shows me that I have lost 0,9$/one mouse
    MOSA shows me I lost 0,56$/one mouse
  But I know that I still make profit when I sell the 10 more expensive mouses
  for more than 4$ and the 2 cheaper mouses I can still offer with profit
  in some kind of sale for 3,5$. 
    Many bussinesmans know this and do this but because of their software they 
  sell with lost, or when they want to have evidence about the REAL profit, they
  have to create new evidence for the same product everytime the buying price 
  changes. I know about companies that have 1000 different store cards for 
  the same product and imagine how many items they have in software when they 
  sell 10000 different products. And of course imagine the costs on employees
  that are loosing time by creating new evidence everytime some price changes.
 
  In reality my approach is doing the same, creating new evidence, and not
  only when the price changes, but everytime I am buyng new products. 
  BUT ALL THIS HAPPENS AUTOMATICLY
  Difference is then by putting out. Goal is to make UI the same as LOAD
  but with one except, that I have possibility to make special prices for
  special customers when I want to. 
  
  There are already these objects to make it work
  T_INPUT - data of every input of some kind of product 
  T_ITEM - identification of some kind of product
  
  following TODO
  T_OUTPUT
/* }}}2 */
/* T_INPUT {{{2 */
/* CONST {{{3 */
#define __LT_S_INPUT_PK            0
#define __LT_S_INPUT_CODE        1
#define __LT_S_INPUT_DATE        2
#define __LT_S_INPUT_LETTER        3
#define __LT_S_INPUT_WHERE        4
#define __LT_S_INPUT_FROM        5
#define __LT_S_INPUT_ITEMS        6
#define __LT_S_INPUT_PARAM_COUNT    7
/* }}}3 */
/* STRUCT {{{3 */
struct lt_s_input {
    T_STATUS status[__LT_S_INPUT_PARAM_COUNT];
    T_CELL pk;
    T_CELL code;   //internal numbering of input evidence
    T_CELL date;
    T_CELL letter; //linking info to accounting evidence
    T_CELL where;  
    T_CELL from;   //linking info to supplier
    T_MATRIX items;//table of items of this input
};
typedef struct lt_s_input T_INPUT;
/* }}}3 */
/* }}}2 */
/* T_ITEM {{{2 */
/* CONST {{{3 */
#define __LT_S_ITEM_PK        0
#define __LT_S_ITEM_FK        1
#define __LT_S_ITEM_NUMBER    2
#define __LT_S_ITEM_NAME    3
#define __LT_S_ITEM_CODE    4
#define __LT_S_ITEM_MESSURE    5
#define __LT_S_ITEM_PRICE    6
#define __LT_S_ITEM_PARAM_COUNT        7
//#define __LT_S_ITEM_COUNT    6
//#define __LT_S_ITEM_PRICE    7
//#define __LT_S_ITEM_SERIALS    8
//#define __LT_S_ITEM_PARAM_COUNT        9
#define __LT_S_ITEM_WIDTH_NAME        30
#define __LT_S_ITEM_WIDTH_CODE        10
#define __LT_S_ITEM_WIDTH_MESSURE    5
/* }}}3 */
/* STRUCT {{{3 */
struct lt_s_item {
    T_STATUS status[__LT_S_INPUT_PARAM_COUNT];
    T_CELL pk;
    T_CELL number;
    T_CELL name;
    T_CELL code; //internal code for indentification 
    T_CELL messure;
    T_CELL price;
};
typedef struct lt_s_item T_ITEM;
/* }}}3 */
/* }}}2 */
#include "lt_s_input.h"
#include "lt_s_item.h"
/* }}}1 */

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top