Magento incorrect amount while paying - magento

I have used this to create plugin http://www.silksoftware.com/magento-module-creator/ it is working fine and grand total is displaying correct; But when users pay the do not see this amount included in that;
Can you let me know what could be wrong?
Thanks!
Total screenshot
You can see that Totals are being added up in grand total but when users pay they don't see the amount for Refundable Damage/Loss Deposit; That's why it is still coming as due amount.

I found the problem ; It comes from the generated extension from silksoftware;
If you have similar problem; open the file in this directory
/www/app/code/local/Company/ExtraFee/Model/Order/Invoice/Total
and replace this line
$DepositTotal = $order->getDepositTotal();
if ($DepositTotal&&count($order->getInvoiceCollection())==0) {
with
$orderDepositTotal= $order->getDepositTotal();
if ($orderDepositTotal&&count($order->getInvoiceCollection())==0) {
:)
Thanks guys for no help :p I ended up debugging it myself and feeling pretty good :p
<?php
class Comapny_ExtraFee_Model_Order_Invoice_Total_Deposit
extends Mage_Sales_Model_Order_Invoice_Total_Abstract
{
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
{
$order=$invoice->getOrder();
$DepositTotal = $order->getDepositTotal();
if ($DepositTotal&&count($order->getInvoiceCollection())==0) {
$invoice->setGrandTotal($invoice->getGrandTotal()+$orderDepositTotal);
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal()+$orderDepositTotal);
}
return $this;
}
}

Related

About Codeigniter Members Count?

How can I make show the total number of members registered in Codeigniter?
I need model, controller, view codes.
I would appreciate if you help.
As you didn't give us more code and information though. I think you want to display the total number of users registered in your view, write this part of the code where you want to count the number.
<?php
$this->load->model('admindash_model');
$count_users = count($this->admindash_model->get());
print $count_users;
?>
I think this will going to help you. If you could understand and place
it properly.
Model:
public function get(){
$this->db->select('gorun');
$this->db->from('users');
$this->db->where('gorun', '0' );
return $this->db->count_all_results();
}
Controller:
public function admindash(){
$this->load->model("admindash_model");
$results = $this->admindash_model->get();
}

Laravel getStream - How to follow or add activity to a Company (non user)

an app I am creating needs to follow Companies, aside from users. And let the companies have their own activities. How is this configured in Laravel getStream. Seems the feeds are only for user types.
timelineFeed = FeedManager::getNewsFeed($user->id)['timeline'];
$aggregatedTimelineFeed = FeedManager::getNewsFeed($user->id)['timeline_aggregated'];
sample model i have is this:
namespace App;
use Illuminate\Database\Eloquent\Model;
class CompanyPost extends Model
{
use \GetStream\StreamLaravel\Eloquent\ActivityTrait;
public function company()
{
return $this->belongsTo('App\Company', 'company_id', 'id');
}
public function activityVerb()
{
return 'company_post';
}
public function activityActorMethodName()
{
return 'company';
}
}
but i have noticed the feed is still saved on the user activities instead of the company activities.
Thanks in advance guys.
Ian seems to have confused you with me in his link to the Github issue which brought this post to my attention.
The reason this is still showing up on the user feed is that this isn't a configurable option at least on a case by case (or model by model) level. You can override what Stream Laravel uses as the "user feed" in the main configuration but as far as I can tell you are stuck posting to the active logged in user's feed unless you build out the functionality yourself with the Stream-PHP libs and abstain from using the StreamLaravel Activity trait.
You can see here starting at Line: 73 of StreamLaravelManager.php what's happening when an activity is created.
public function activityCreated($instance)
{
$activity = $instance->createActivity();
$feed = $this->getFeed($this->userFeed, $instance->activityActorId());
$feed->addActivity($activity);
}
Unfortunately "$this->userFeed" ultimately is pulled from the configuration file and I don't think there is a way to override it.
Personally, I ran into this when creating "like" functionality. I didn't really want people to have to see what everyone "likes" on their timeline since most of it would be irrelevant and it would get cluttered fast so I ended up not even creating a "like" activity. Instead I'm only added it to a users notification feed when someone likes something of theirs. Of course this may not be desirable for everyone to handle it that way but I noticed you had the "like" activity in your screenshot so I figured I'd mention it.
Good luck on your app!
Our stream-laravel project has some documentation on how to change the model
class Pin extends Eloquent {
use GetStream\StreamLaravel\Eloquent\ActivityTrait;
public function author()
{
return $this->belongsTo('Author');
}
public function activityActorMethodName()
{
return 'author';
}
As far as letting volunteers follow companies and users, we have some documentation in the main README.
(edited to remove my mistaken github reference)
sorry for the late reply. I have managed to follow a company creating
a feed group:
company flat On
and the using sample code below to follow:
$feed = FeedManager::getClient()->feed('timeline', $user->id);
$feed->followFeed('company', $companyId);
Unfollow:
$feed->unfollowFeed('company', $companyId);
Add activity:
$companyFeed = FeedManager::getClient()->feed('company', $company->id);
$companyFeed->addActivity([
"actor" => "App\Company:{$company->id}",
"verb" => "company_post",
"object" => "App\CompanyPost:{$post->id}",
"foreign_id" => "App\CompanyPost:{$post->id}"
]);

Magento Different Grand Total and Invoice amount

Please check these 2 images; I am having an issue where Grand Total displays correctly on all pages throughout the site; But when admin sends an invoice to user it does not include some of the items in the invoiced amount.
I need suggestion on how to fix this.
I found the problem ; It comes from the generated extension from silksoftware;
If you have similar problem; open the file in this directory
/www/app/code/local/Company/ExtraFee/Model/Order/Invoice/Total
and replace this line
$DepositTotal = $order->getDepositTotal();
if ($DepositTotal&&count($order->getInvoiceCollection())==0) {
with
$orderDepositTotal= $order->getDepositTotal();
if ($orderDepositTotal&&count($order->getInvoiceCollection())==0) {
:)
Thanks guys for no help :p I ended up debugging it myself and feeling pretty good :p
<?php
class Comapny_ExtraFee_Model_Order_Invoice_Total_Deposit
extends Mage_Sales_Model_Order_Invoice_Total_Abstract
{
public function collect(Mage_Sales_Model_Order_Invoice $invoice)
{
$order=$invoice->getOrder();
$DepositTotal = $order->getDepositTotal();
if ($DepositTotal&&count($order->getInvoiceCollection())==0) {
$invoice->setGrandTotal($invoice->getGrandTotal()+$orderDepositTotal);
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal()+$orderDepositTotal);
}
return $this;
}
}

Magento - many of same cache requests

today I realized that the Magento doest a lot of same requests to my memcached server, it's requesting the key Zend_LocaleC_en_GB_currencynumber_ . Do you anyone know where is it generated and how can I improve it? It's probably somehow related to rendering of price box but I dont see reason why it's 50 times in a page. Thanks, Jaro.
Edited:
So far I did quick fix
Zend_Cache_Backend_Memcached::load
public function load($id, $doNotTestCacheValidity = false)
{
if ( isset($GLOBALS[$id]) ) {
return $GLOBALS[$id];
}
$tmp = $this->_memcache->get($id);
if (is_array($tmp) && isset($tmp[0])) {
$GLOBALS[$id] = $tmp[0];
return $tmp[0];
}
return false;
}
It's not nice but seems to be working. At least many of requests agains memcached server disappeared. Jaro.
It is one of the known issues in Zend Framework community. It even was reported as an improvement for 1.0.3 release (http://framework.zend.com/issues/browse/ZF-2311).
You fix make sense for Magento where a lot of calls to Zend_Currency is performed and connection to memcached having some limitations or slow enough.
For instance on most of the projects we are using memcached and haven't experienced too big loss in page load time with this calls.
However you can fix it in Magento to make a workaround with ZF:
Rewrite core/locale model in your module
Override currency() method
public function currency($currency)
{
if (!isset(self::$_currencyCache[$this->getLocaleCode()][$currency])) {
$currencyObject = parent::currency($currency);
$currencyObject->setFormat(array(
'format' => Zend_Locale_Data::getContent($this->getLocale(), 'currencynumber')
));
return $currencyObject;
}
return parent::currency($currency);
}

Get customer in Mage_Tax_Model_Calculation::getRate in magento

I have overwritten the Mage_Tax_model_Calculation::getRate, so that I want to not tax certain customers. I do not have a special customer class for them.
I have a custom field in my customer model, which I want to check after I am able to load my customer model and if this field has a value I do not tax him, otherwise I call parent::getRate($request)
Is it possible to get that in the function.
Try something like this:
function getRate($request) {
// find a customer ID
$admin_session = Mage::getSingleton('adminhtml/session_quote');
if($admin_session) {
if($admin_session->getCustomerId()) {
$customer_id = $admin_session->getCustomerId();
}
} else {
$customer_id = Mage::getSingleton("customer/session")->getCustomerId();
}
// find customer attr
if($customer_id) {
$customer = Mage::getModel("customer/customer")->load($customer_id);
if($customer->getSomeColumnValue()) {
return 0;
}
}
// fallthrough
return parent::getRate($request);
}
Hope that helps!
Thanks,
Joe
EDIT: good point ;)
Looking through the adminhtml code, it seems to be far less useful than the normal customer code. I was hoping for a call to Mage::register but that's not happening. I found a possible solution, though loading sessions in Magento seems to have side effects. See above.
RE-EDIT: to incorporate your fixes for posterity.
Try this to load the current logged-in customer:
$session = Mage::getSingleton('customer/session');
$customer = Mage::getModel('customer/customer')->load($session->getCustomerId());
$customValue = $customer->getCustomFieldName();
Cheers,
JD

Resources