-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added new apis #56
base: master
Are you sure you want to change the base?
Added new apis #56
Conversation
- Purchase api for posting and canceling invoice added - Customer Payment posting and canceling invoice api added - In customer creation api response ( added branch id which automatically gets created for a new customer )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this Pull Request. It looks pretty good. Summary of the comments:
- It would be nice to see tests for the code added as much as possible.
- There's shouldn't be unnecessary ui code in the api.
api_error(412, 'Failed to add invoice.'); | ||
} | ||
}else{ | ||
api_error(500, 'Invoice data is invalid.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User code, like this php, shouldn't return a 5xx response. Use a 4xx response instead. I'd recommend 400 Bad Request. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses
{ | ||
if (!get_post('supplier_id')) | ||
{ | ||
display_error(_("There is no supplier selected.")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why "display_error" is being called from the API which has no ui? I'm not sure why this code is here.
} catch (Exception $e) { | ||
error_log($e->getMessage(), 3, "/var/tmp/sales_cancel.log"); | ||
$resp['msg']='Could not cancel invoice. '; | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails very quietly. Why not use an api_error
if (is_closed_trans($_POST['filterType'],$_POST['trans_no'])) | ||
{ | ||
display_error(_("The selected transaction was closed for edition and cannot be voided.")); | ||
set_focus('trans_no'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
display_error and set_focus looks like ui code from FA. Not sure that this is appropriate for the API
} | ||
|
||
|
||
?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closing tags aren't needed these days. But, does no harm.
class Purchase_Test extends Crud_Base | ||
{ | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test seems to do very little. Can you add a full CRUD test for the purchase cycle. list, count, add, list count+1, read, update, delete, list (count).
'trans_no' => 3, | ||
'date_' => '10/10/2021', | ||
'memo_' => substr('Comment should be limited to 255 characters only. As this is setup in the database field size',0,255), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With your addition of sales_cancel this should be testable. It would be nice to see a test here for this.
class CustomerPayment_Test extends Crud_Base | ||
{ | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is incomplete. It would be nice to see tests for the code you've added.
I have added the following changes to the api module. For extending its further functionality .