static function addStock($item, $branch, $quantity) { $records = fRecordSet::build('Inv_stock', array('item_id=' => $item, 'branch_id=' => $branch)); if ($records->count()) { foreach ($records as $record) { $record->setQuantity($record->getQuantity() + $quantity); $record->store(); } } else { $record = new self(); $record->setBranchId($branch); $record->setItemId($item); $record->setQuantity($quantity); $record->store(); } }