Re: [PHP] Accounting component in PHP

2008-12-09 Thread altern

All my queries are complex. If I will use ORM, then I still will need another
wrapper to create, for example template criteria objects. I have application
that is very similar to billing system. Such type of applications definitely
have other business logic levels in addition to ORM queries, as you might
notice.


Geek (de=German top level domain) wrote:
 
 You can do raw SQL queries with ORM as well, at least in symfony ;). An
 ORM
 makes other, rather trivial queries a whole lot easier though and a
 framework like symfony makes development of generic requirements a lot
 faster and cleaner.
 
 

-- 
View this message in context: 
http://www.nabble.com/Accounting-component-in-PHP-tp20897026p20911661.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



Re: [PHP] Accounting component in PHP

2008-12-09 Thread German Geek
You can do raw queries also... Just makes trivial queries and your model (if
you believe in modelling) easier to manage. Believe me, I thought like you
did before using symfony.

On Tue, Dec 9, 2008 at 10:52 PM, altern [EMAIL PROTECTED] wrote:


 All my queries are complex. If I will use ORM, then I still will need
 another
 wrapper to create, for example template criteria objects. I have
 application
 that is very similar to billing system. Such type of applications
 definitely
 have other business logic levels in addition to ORM queries, as you might
 notice.


 Geek (de=German top level domain) wrote:
 
  You can do raw SQL queries with ORM as well, at least in symfony ;). An
  ORM
  makes other, rather trivial queries a whole lot easier though and a
  framework like symfony makes development of generic requirements a lot
  faster and cleaner.
 
 

 --
 View this message in context:
 http://www.nabble.com/Accounting-component-in-PHP-tp20897026p20911661.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




-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support


[PHP] Accounting component in PHP

2008-12-08 Thread altern

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



Re: [PHP] Accounting component in PHP

2008-12-08 Thread German Geek
You can do raw SQL queries with ORM as well, at least in symfony ;). An ORM
makes other, rather trivial queries a whole lot easier though and a
framework like symfony makes development of generic requirements a lot
faster and cleaner.

On Tue, Dec 9, 2008 at 4:07 AM, altern [EMAIL PROTECTED] wrote:


 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




-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support