Approved Invoices:: Should have the facility to "Revert it back to draft"
Once an invoice is approved, it should have the facility to "revert it back to draft"
It is because of the reason that mostly, my client ask me to approve the invoice and then says that it's not yet approved and then i don't have the facility, ultimately it is showing in our accounts that an overdue invoice is available, which is actually not yet approved.
Xero should facilitate us in such a way.
Thanks
Hassan
-
Yasir Sohail commented
first time invoice of xero developer is getting approve very easily, but if i have edited the invoice then it is not approving using php
function approveInvoice($access_token, $tenant_id, $invoiceID) {
$client = new Client();
$url = 'https://api.xero.com/api.xro/2.0/Invoices/'; . $invoiceID;try {
// Fetch the existing invoice details to get complete data
$invoiceResponse = $client->get($url, [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer ' . $access_token,
'Xero-tenant-id' => $tenant_id,
],
]);$invoiceData = json_decode($invoiceResponse->getBody()->getContents(), true);
// Ensure that the required fields are present
if (!isset($invoiceData['Invoices'][0])) {
return ['error' => 'Invalid invoice data fetched from Xero.'];
}// Prepare the payload with the current invoice data and set status to 'AUTHORISED'
$invoice = $invoiceData['Invoices'][0];
$invoice['Status'] = 'AUTHORISED'; // Update the status to AUTHORISED// Create the payload retaining necessary fields
$payload = [
'InvoiceID' => $invoiceID,
'Status' => 'AUTHORISED',
'LineAmountTypes' => $invoice['LineAmountTypes'], // Ensure this is set correctly (e.g., 'Exclusive', 'Inclusive', 'NoTax')
'Date' => $invoice['DateString'], // Ensure this date is in 'YYYY-MM-DD' format
'DueDate' => $invoice['DueDateString'], // Ensure this date is in 'YYYY-MM-DD' format
'Contact' => [
'ContactID' => $invoice['Contact']['ContactID'] // Make sure this ID is accurate and matches an existing contact in Xero
],
'LineItems' => array_map(function($item) {
return [
'Description' => $item['Description'],
'UnitAmount' => $item['UnitAmount'],
'TaxType' => $item['TaxType'],
'LineAmount' => $item['LineAmount'],
'Quantity' => $item['Quantity'],
'AccountCode' => $item['AccountCode'] ?? '400', // Adjust with the proper account code
'LineItemID' => $item['LineItemID'] // Include this if updating existing line items
];
}, $invoice['LineItems'])
];
// Log the payload
error_log('Payload being sent to Xero: ' . json_encode($payload, JSON_PRETTY_PRINT));// Send the updated invoice data
$response = $client->post($url, [
'headers' => [
'Accept' => 'application/json',
'Authorization' => 'Bearer ' . $access_token,
'Xero-tenant-id' => $tenant_id,
],
'json' => $payload,
]);return json_decode($response->getBody()->getContents(), true);
} catch (\GuzzleHttp\Exception\ClientException $e) {
$responseBody = $e->getResponse()->getBody()->getContents();
error_log('Error: ' . $responseBody);
error_log('Error: ' . $e->getMessage());
return ['error' => 'Failed to approve the invoice. Error: ' . $e->getMessage()];
}
} -
Anonymous commented
Can't understand why this is currently not able to be done. The idea was raised SEVEN years ago, and still nothing!
-
Jenny commented
Still waiting for this - it's really needed
-
Anonymous commented
Not sure why this feature is unavailable. Would make life alot easier
-
Helen commented
Yep XERO need to add this feature ASAP - can't see what the problem is!!!!
Mistakes are easy to make and if we could revert the invoice back to a draft it can be fixed up. Or add something to the invoice if it was missed. Come on XERO - just add the the feature already!
Please and thank you! -
Joe commented
come on Xero staff, how many more requests do you need before you add a feature?
-
Mark commented
Please add this. I've accidentally approved an invoice, which I now have to copy and void. This is simple functionality which I'm amazed is missing.
-
Anonymous commented
Please add this feature - it is very frustrating missing something a lot have asked for for many years
-
Anonymous commented
Please add this feature
-
Anonymous commented
I've just accidentally approved an invoice ... and now I have to fiddle about to void and copy it; this would be a very useful feature.
-
Anonymous commented
5 years after the initial post and this feature is still not available - not good enough
-
PAUL commented
Me too...get it sorted
-
Sarah commented
I found a way to get around not having a 'revert to draft' feature. You can copy the invoice, then save it as a draft. Then go back into the approved invoices and delete the original. Its a bit fiddly, but better than re-doing the entire invoice to save it as a draft :-)
-
Anonymous commented
still no luck
-
Anonymous commented
please add this feature. I inadvertently hit APPROVE and need to revert back to draft.
-
Neil Malcolm commented
Agreed. Shouldn't be that difficult to implement either.
-
Anonymous commented
I agree too!!!
-
Anonymous commented
Was just looking for this feature! Incredible that they don't.
-
Anonymous commented
This would be a very useful feature indeed!
-
Howard commented
Agreed - very much needed