Accounting component in PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello, guys. Could please someone recommend me component wiritten in PHP
which makes financial calculations with predefined logic? I have DB with
sales information in several tables and I need to implement business logic
that includes many rules of charging, different interest rates and so on. I
need some example at least. It seems to me that I'm trying to reinvent a
wheel. Design patterns have not helped me yet. I even do not know in where
should I look to find example implementation.

To describe better what I mean, I will show one of the terrible SQL that is
used to calculate some numbers in loop during further traversing:

SELECT r.CODE, 
	r.ORDER_NUM, 
	r.REG_DATE, 
	r.ORDER_EMAIL, 
	r.STATUS, 
	r.PRICE, 
	r.BILLING_PERCENT, 
	r.REGISTRATOR_PERCENT, 
	r.REFUND_DATE, 
	IF(r.MIDDLE_CONTRACT_PERCENT > 0, c.CANCEL_FEE * (1 - r.BILLING_PERCENT/100
- r.REGISTRATOR_PERCENT/100 - r.MIDDLE_CONTRACT_PERCENT/100), 
	c.CANCEL_FEE) as CANCEL_FEE, 
	IF(r.MIDDLE_CONTRACT_PERCENT > 0, c.REFUND_FEE * (1 - r.BILLING_PERCENT/100
- r.REGISTRATOR_PERCENT/100 - r.MIDDLE_CONTRACT_PERCENT/100), 
	c.REFUND_FEE) as REFUND_FEE, 
	IF(r.MIDDLE_CONTRACT_PERCENT > 0, COALESCE(r.REFUND_FEE, c.CHARGEBACK_FEE)
* (1 - r.BILLING_PERCENT/100 - r.REGISTRATOR_PERCENT/100 -
r.MIDDLE_CONTRACT_PERCENT/100), 
	COALESCE(r.REFUND_FEE, c.CHARGEBACK_FEE)) as CHARGEBACK_FEE, 
	c.PERSON_LOGIN as CLIENT, 
	r.ORDER_NAME, 
	r.ORDER_NUM, 
	r.ORDER_EMAIL, 
	r.PRICE*(1 - r.BILLING_PERCENT/100 - r.REGISTRATOR_PERCENT/100 -
IF(r.MIDDLE_CONTRACT_PERCENT IS NOT NULL, r.MIDDLE_CONTRACT_PERCENT/100, 0))
as INCOME, 
	r.PRICE*(1 - r.REGISTRATOR_PERCENT/100) as REGISTRATOR_SUM, 
	r.PRICE*r.BILLING_PERCENT/100 as BILLING_INCOME, 
	r.REFUND_TYPE, 
	r.MIDDLE_CONTRACT_PERCENT FROM SOFT_REG r, 
	SOFT_CONTRACT c, 
	SOFT_PRODUCT p 
WHERE 
	p.CODE=r.PRODUCT_CODE 
	AND p.CONTRACT_CODE=c.CODE 
	AND c.CODE=5 
	AND r.REG_DATE >= '2008-08-01 00:00:00' 
	AND r.REG_DATE <= '2008-08-02 23:59:59'

After querying this sql many other things happen to get specific results on
my page. Results of this (and other similar queries) are used in several
places on the same page. I'm totally confused with all this stuff and barely
can make the code do what I want. One of the problems is that there are even
no unit-tests to keep code tested on regressions. I make conclusion that I
need separate component with object-oriented API to have possibility of
running unit tests and to have logically structured code, which I could work
with without confusion.

ORM usage is not a solution. It would just complexify what I already have
because sometimes too many tables are joining together. But again, I don't
know what idea I can start with to manage all this.

Thanks in advance. Any suggestions will be appreciated.
-- 
View this message in context: http://www.nabble.com/Accounting-component-in-PHP-tp20897026p20897026.html
Sent from the PHP - General mailing list archive at Nabble.com.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux