credit note not appearing in dashboard but appears under contacts - xero-api

I am trying to create a credit note via the api. I can do this successfully and i can see the response it creates the record. How ever this does not appear in the business under invoices but i can see it under the contact. How can i fix this so it appears under the business on invoices
I am coding in PhP
$creditNote = new CreditNote();
$creditNote->setType(CreditNote::TYPE_ACCPAYCREDIT);
$creditNote->setContact($contact);
$creditNote->setDate($model->created_at);
$creditNote->setDueDate($model->created_at);
$creditNote->setLineItems($lineItems);
$creditNote->setCreditNoteNumber('GF-'.$model->number);
$creditNote->setCurrencyCode($currencyCode);
$creditNotes = new CreditNotes();
$arr_credit_notes = [];
array_push($arr_credit_notes, $creditNote);
$creditNotes->setCreditNotes($arr_credit_notes);
try {
return $this->accountingApi->createCreditNotes(
$this->xero_account->tenantId,
$creditNotes,
$summarizeErrors,
$unitdp
);
} catch (Exception $e) {
$this->logger->debug($e);
$this->logger->debug($e->getMessage());
throw new CustomException(
'Exception when calling AccountingApi->updateOrCreateCreditNotes: ' .
$e->getMessage(),
422
);
}
If I create a manual credit note in xero it appears in the business->invoices
in contact this is how it looks. Grren ones from api and the blue one i created in xero

It looks to me like you are creating the wrong type of credit note. "ACCPAYCREDIT" would show up under "bills to pay" rather than invoices. You would want to be creating an "ACCRECCREDIT" for it to show up under invoices

Related

lucene query filter not working

I am using this filter hook in my Auth0 Delegated Administration Extension.
function(ctx, callback) {
// Get the company from the current user's metadata.
var company = ctx.request.user.app_metadata && ctx.request.user.app_metadata.company;
if (!company || !company.length) {
return callback(new Error('The current user is not part of any company.'));
}
// The GREEN company can see all users.
if (company === 'GREEN') {
return callback();
}
// Return the lucene query.
return callback(null, 'app_metadata.company:"' + company + '"');
}
When user logged in whose company is GREEN can see all users. But when user logged in whose company is RED can't see any users whose company is RED.
I need to make this when user logged in, user should only be able to access users within his company. (except users from GREEN company).
But above code is not giving expected result. What could be the issue?
This might be related to a little warning note on the User Search documentation page
Basically they don't let you search for properties in the app_metadata field anymore. Unfortunately, this change was breaking and unannounced.
We had to make changes to our API so that we keep a copy of the app_metadatas in a separate database and convert lucene syntax to MongoDB queries, so that we can query by a chain of user_id:"<>" OR user_id:"<>" OR ....
One caveat though, you can't pass a query that's longer than 72 user_ids long. This number is so far undocumented and obtained empirically.
Also, you can't rely on Auth0's hooks to add new users to your database, as these don't fire for social logins, only for Username-Password-Authentication connections.
I hope this gave you some explanation as for why it wasn't working as well as a possible solution.
If I were you, I would look for an alternative for Auth0, which is what we are currently doing.
I finally ended up with this solution.
Used search functionality to filter users. I had to change below two files.
fetchUsers function in client\actions\user.js
changed
export function fetchUsers(search = '', reset = false, page = 0)
to
export function fetchUsers(search = '#red.com', reset = false,
page = 0)
AND
onReset function in client\containers\Users\Users.jsx
changed
onReset = () => { this.props.fetchUsers('', true); }
to
onReset = () => { this.props.fetchUsers('#red.com', true); }

Rally addnew interrupt creation using beforecreate event

The Problem
I am trying to get around one of the known issues of the rallyaddnew button by setting fields based on different combobox values. This works fine, but there are some combinations the user can enter than I can only catch after they have elected to create a rollup or feature.
The Question
I made a listener for the beforecreate event, and I can tell when I want to prevent the creation of this portfolioitem. Is there any way to prevent it from being created?
All I am doing right now is:
Ext.Msg.alert('Error', 'You are creating a feature/rollup with invalid options. Please delete this record and try again.');
But, the record is still created
Here is an example where a card is created on a board, and based on the selection in the Iteration box,a story is scheduled accordingly. Except a creation of a new card is interrupted if a certain condition is met. If the condition is met, it returns false:
return false;
and new item is not created:
_onBeforeCreate: function(addNewComponent, record) {
var currentDate = new Date();
console.log(this.iterationCombobox.getValue());
var startDate = this.iterationCombobox.getRecord().get("StartDate");
if (startDate > currentDate){
console.log("in the future");
return false;
}
record.set('Iteration', this.iterationCombobox.getValue());
}

What ActionResult should you return to update just the ActionLink text?

I'm using MVC4 with Entity Framework and like many people I'm new to MVC and trying to get my head around the design patterns.
I have a partial view that displays a list of sessions followed by actionlinks allowing the authenticated member to book into the sessions.
Note: for clarity, I've chopped out most of the code, if a member is booked into a session, it displays "Booked" instead of the action link.
#using OnlineBookings.Website.Models
#{ DateTime currentDate = DateTime.MinValue.Date; }
<form method="post" action="~/Controllers/BookSessionController.cs">
#foreach (SessionsWithBookingInformation s in Model)
{
<p>#s.StartTime.ToString("t")
#s.Description
#Html.ActionLink(
"Book",
"BookSession",
new { sessionId = s.SessionId }
)
</p>
}
</form>
This then displays as part of a larger view:
The actionlinks pass the guid of the session to be booked through to the following function in my controller, which retrieves the memberId from the cookie and uses Entity Framework to create a booking for that member and session.
public ActionResult BookSession(Guid sessionId)
{
using (var db = new OnlineBookingsEntities())
{
// see if the member id is stored in a cookie
if (Request.Cookies["memberId"] != null)
{
var memberId = new Guid(Request.Cookies["memberId"].Value);
db.Bookings.Add(new Booking
{
BookingId = Guid.NewGuid(),
MemberId = memberId,
SessionId = sessionId,
BookingTime = DateTime.Now
});
db.SaveChanges();
}
}
// this refreshes the entire page
/// is there a better way to just replace the actionlink they clicked on?
return RedirectToAction("Index", "Home");
}
All this is working nicely and bookings are being effectively recorded.
But, I'm trying to figure is if the return from the BookSession function can just update the actionlink text.
Ideally, on success, I want to replace the ActionLink in my partial view with the word "Booked" and on failure I want to replace it with the failure condition like "Session full".
Or I could just update my partial view, because that will do the same thing.
Am I missing something simple here? Or, am I barking up entirely the wrong tree?
Your question is great and really well explained, but it's also a little vague since it's a bit of a "What should I do?" question. Here are a few options that might help you develop a solution.
Redisplay the same view. Return whichever view the user was on for them to submit the link. This will look like a simple refresh.
return View();
Submit the request via AJAX and update via a partial view. Put an id tag on a span or similar HTML element with an individual booking's details inside. Submit the request with AJAX, perhaps via #Ajax.ActionLink, and have your action return a partial view.
return PartialView("_OnlineBookingPartial", model);
Once your partial view is returned, update the specific booking with the data returned.
Use AJAX again, but return JSON. Another way might be that you use AJAX again but instead you return JSON and do something with it. You could, for example, return text in which you would replace Book with; i.e. "Session full" or "Booked!".
return new JsonResult
{
Data = "Booked!"
}
Personally, I'd probably use AJAX to update with a non-AJAX (non-Javascript) fallback.
You can do this by using #Ajax.ActionLink and checking if the request is AJAX or not inside your controller action.
if (Request.IsAjaxRequest) {
return PartialView("_OnlineBookingPartial", model);
}
return View();
This means that if the browser has Javascript enabled and supports AJAX, it will be used and the whole process will be seamless and instant for the user. If Javascript is disabled, the page will simply refresh.

Open graph stories of action I do show up on my ticker but not on my friends' ticker

I created a canvas app and defined action, object and aggregation. When I publish an action using javascript sdk by doing -
FB.api('/me/namespace:action?object=object_url', 'post',
function (response) {
if (!response || response.error) {
//failure
} else {
//success
}
});
I get success and it shows up on my ticker and timeline but my friend is not able to see anything related to this activity neither on his ticker nor in the news feed. The visibility of activity in this app is set to friends but still nothing shows up in firends' accounts.
It was because I had delete 4 aggregations created automatically and created a single aggregation that I thought would only be required. I deleted this action and aggregation, created a new one from scratch and updated aggregations with action/object and it worked.

InAppPurchases not working on PhoneGap App

I'm having some problems trying to get running inAppPurchases inside my iPhone phoneGap-based app.
I got the inAppPurchase-plugin on gitHub https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/InAppPurchaseManager
Then i created my developer account, purchased de u$d 99, and made my inAppPurchase Catalog
Created my iTunes Connect account to get a Test User for this.
I placed all the plugins file where it says... And, if i try to run "alert(typeof window.plugins.inAppPurchaseManager)" it shows "object" so, plugins are being loaded correctly!
The problem appears when i try to do my purchase..
I logout my itunes account, run my binary inside my iphone, and when i make the purchase i should see a prompt asking me for my test account information in order to make a symbolic purchase! But it never happens!
The javascript code (very basic) im trying to run is the following
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady(event) {
window.plugins.inAppPurchaseManager.onPurchased = function(transactionIdentifier, productId, transactionReceipt) {
alert("purchased");
};
window.plugins.inAppPurchaseManager.onRestored = function(originalTransactionIdentifier, productId, originalTransactionReceipt) {
alert("restored");
};
window.plugins.inAppPurchaseManager.onFailed = function(errorCode, errorText) {
alert("error");
};
window.plugins.inAppPurchaseManager.requestProductData(
"com.mycompany.myproduct.myproductid",
function(productId, title, description, price) {
alert("data retrieved");
window.plugins.inAppPurchaseManager.makePurchase(productId, 1);
},
function(id) {
alert("Invalid product id: " + id);
}
);
}
Hope you can help me! thank you!
You need to call js functions like window.plugins.inAppPurchaseManager.onPurchased in html.index for these functions to work.i.e these functions call onPurchased in js and correspondingly it will call obj-C functions.
(js function in index.html)->(js function in js file)->(objective-C function)...is the sequence.
Are you getting any invalid product ID's back? There are a lot of gotchas on Apple's end. Try reading through this guide to find what you need to get the product info request to return valid products.