Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function withTotals() {
- $criteria = new CDbCriteria;
- $criteria->alias = $this->alias;
- $criteria->together = true;
- $criteria->with = array(
- 'sales' => array('alias' => 'sls'),
- 'quotationDetails' => array('alias'=>'qd'),
- );
- $criteria->select = array("*",
- "ROUND(SUM(qd.selling_price * qd.quantity),2) as totalAmount",
- "ROUND(SUM(qd.selling_price * qd.quantity)*(1-($this->alias.discount/100)),2) as totalDiscountedAmount",
- "ROUND(SUM(qd.selling_price * qd.quantity)*(1-($this->alias.discount/100))*(1+($this->alias.tax/100)),2) as totalTaxedAmount",
- "SUM(sls.amount) as totalSalesCredited",
- );
- $criteria->group = "$this->alias.id";
- $this->getDbCriteria()->mergeWith($criteria);
- return $this;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement