1

(86 replies, posted in Modules Add-on's)

Thanks @apmuthu. I will go through the code and try my best.

Regards
Sume

2

(86 replies, posted in Modules Add-on's)

apmuthu wrote:

You cannot get the price and price after tax from the inventory item call.
You need to make a tax call and some other calls - check out the various API constructs as to what will get you what you want. If there is a value in some table's field that is not there in the standard API calls, let us know.

I have found some API which returns unit cost ,tax types and tax  groups with the below results

{"stock_id":"102","unit_cost":"150"}
[{"id":"1","name":"Regular","exempt":"0"}]
[{"id":"1","name":"Tax","inactive":"0"},{"id":"2","name":"Tax Exempt","inactive":"0"}]

I could not relate these to the sales price.
Also in FA sales pricing, I see the manual entry for sales price!! Is sales price auto calculated from unit_price with taxes??

Sorry for the basic questions. I am trying to do a POS demo for the FA and stuck with this.

Thanks

3

(86 replies, posted in Modules Add-on's)

Hello Apmuthu

I have retrieved one inventory item using API

{"stock_id":"101","category_id":"1","tax_type_id":"1","description":"iPad Air 2 16GB","long_description":"","units":"each","mb_flag":"B","sales_account":"4010","cogs_account":"5010","inventory_account":"1510","adjustment_account":"5040","wip_account":"1530","purchase_cost":"0","last_cost":null,"material_cost":"200","labour_cost":"0","overhead_cost":"0","inactive":"0","no_sale":"0","no_purchase":"0"}

I need to calculate the "Price after Tax " same as in the  Direct invoice( that is 300 for stock_id 101) in my custom program for POSTing the sales using API. How can I calculate the "Price after Tax" value?

I need to POST something like this

{"stock_id":"101","qty":1,"price":"300","discount":"0","description":"iPad Air 2 16GB"}

Help much appreciated

Regards
Sume

4

(86 replies, posted in Modules Add-on's)

Hello @apmuthu

Excellent reply, it is clear now.

Thanks very much.

Regards
Sume

5

(86 replies, posted in Modules Add-on's)

Hello @apmuthu

Does your version have the same result on returning "sales"?

Regards
Sume

6

(86 replies, posted in Modules Add-on's)

Hello Cambell

Finally I got it working

Sorry to say it was because of duplicate "ref"  element in the entry.

Another question is : when I GET the following  I expected to get all the sales transactions I have done including the sales I have entered through API.

http://URL/modules/api/sales/10/

But I always get two transactions only:
[{"trans_no":"1","type":"10",.................................

{"trans_no":"2","type":"10",..................................
]

Any hints on this?

Regards
Sume

7

(86 replies, posted in Modules Add-on's)

Dear Cambell

Can you please look at this screenshot?

https://ibb.co/cmmDJ7

I have followed the JSON structure from Sales_Test.php to POST a sale,  but I couldn't add.


{
"trans_type":"10",
"ref":"005/2016",
"comments":"REST POST",
"order_date":"12/31/2016",
"delivery_date":"12/31/2016",
"cust_ref":"TPS",
"deliver_to":"QQ-1",
"delivery_address":"QQ-1",
"phone":"36390908",
"ship_via":"1",
"location":"DEF",
"freight_cost":"0",
"customer_id":"1",
"branch_id":"1",
"sales_type":"1",
"dimension_id":"0",
"dimension2_id":"0",
"items":[{"stock_id":"102","qty":"2","price":"250","discount":"0","description":"iPhone 6 64GB"}]

Message as I got as

{
    "success": 0,
    "msg": "Could Not Save to Database"
}

Regards

8

(86 replies, posted in Modules Add-on's)

Hello Cambell
The error is

Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /var/www/fa/fa243/frontaccounting/modules/apitest/tests/Sales_Test.php on line 13

I  have composer.json in the "tests" folder as below and ran composer update

  "require-dev": {
        "phpunit/phpunit": "3.7.*"
     
    }

Is this the correct path, or any specific version should I specify?

Regards

9

(86 replies, posted in Modules Add-on's)

cambell wrote:
s4m3shms wrote:

I was testing the sales APIs from your latest repository, none of the methods worked for me.

For example:

http://url/modules/api/sales/
or
http://url/modules/api/sales/5

returns nothing.

@s4m3shms The endpoint for the sales url needs to have a transaction type on the end, and its not optional.  So:

http://url/modules/api/sales/10

Have a look at the Sales_Test file to see an example of how to use the api using php.

https://github.com/cambell-prince/FrontAccountingSimpleAPI/blob/master-upstream/tests/Sales_Test.php


would give you all the sales invoices for example.  To get a particular invoice it would be:

http://url/modules/api/sales/5/10

assuming there was an invoice number 5.

Have a look at the Sales_Test.php file to see an example of using the api in php

https://github.com/cambell-prince/FrontAccountingSimpleAPI/blob/master-upstream/tests/Sales_Test.php

Thanks Cambell
In fact I was not aware of the API format, its working now.
I am trying to run your Sales_Test.php page, its not going through due to PHPUnit dependency issue.
Am trying to sort it out and update here.

Thanks again

10

(86 replies, posted in Modules Add-on's)

cambell wrote:

@apmuthu we have the same definition of 'end user'; installers and maintainers of installations of Front Accounting.

For those in the community who want to use my releases I can assure them that they do not need to concern themselves about composer.  They can download a released zip or tar.gz file from:

https://github.com/cambell-prince/FrontAccountingSimpleAPI/releases

Hello Cambell

I was testing the sales APIs from your latest repository, none of the methods worked for me.

For example:

http://url/modules/api/sales/
or
http://url/modules/api/sales/5

returns nothing.

Whilst other api method are working fine.

Is there any updates?

Regards

11

(86 replies, posted in Modules Add-on's)

Thanks guys for the excellent works!

I have tested @cambell's version , as you said GET, POST and PUT behaviors are more consistant.

Both @apmuthu and @cambell versions work without any hastle without any dependancy configuration.

I will continue my testing and post the updates.

Regards
Sume MS



cambell wrote:

I've released version v2.4-1.4 of the Simple API for Front Accounting.  You can download it here:

https://github.com/cambell-prince/FrontAccountingSimpleAPI/releases/tag/v2.4-1.4

This release ensures consistency in the api parameters between POST (Create) and PUT (Update). Also ensures parameters are named consistently with their use in Front Accounting 2.4.

- Refactor tests to ensure consistency in POST and PUT api.
- Added tests/Crud_Base.php
- Add api_ensureAssociateArray to remove the numeric index elements that come from the Front Accounting functions.
- The category end point now follows the database schema more closely for property names.
- The customers end point now follows the database schema more closely for property names.

Thanks @apmuthu and @s4m3shms for testing and providing feedback.

@s4m3shms Hopefully you will now find the GET, POST and PUT behavior more consistent.

12

(86 replies, posted in Modules Add-on's)

Thanks Cambell

Update us on the progress please.

Regards
Sume

13

(86 replies, posted in Modules Add-on's)

Hi Cambell

It worked with Content-Type: application/json!

There is a mismatch in the parameters with GET and POST. I had to go through the source to get the correct parameter.
Or can I get the correct parameter type somewhere?

For example when using GET api/category we get:

{"category_id":"1","description":"Components","dflt_tax_type":"1","dflt_units":"each","dflt_mb_flag":"B","dflt_sales_act":"4010","dflt_cogs_act":"5010","dflt_inventory_act":"1510","dflt_adjustment_act":"5040","dflt_wip_act":"1530","dflt_no_sale":"0"}

but I had to POST with this

{"tax_type_id":"1","units":"each","description":"Test9","mb_flag":"B","sales_account":"4010","cogs_account":"5010","inventory_account":"1510","adjustment_account":"5040","wip_account":"1530","dflt_no_sale":"0"}

where dflt_units is replaced with units
dflt_mb_flag is replaced with mb_flag
dflt_sales_act is replaced with sales_account .. and so on

Thanks anyway , keep going..



cambell wrote:

A new release of FrontAccountingSimpleAPI is available here:

https://github.com/cambell-prince/FrontAccountingSimpleAPI/releases/tag/v2.4-1.3

This includes support for json sent in requests using Content-Type: application/json with json encoded data in the body.

14

(86 replies, posted in Modules Add-on's)

Hello Cambell

This is extremely useful. I am going through all of them.

Regards
Sume MS





cambell wrote:

@s4m3shms I have started some documentation here but it is a long way from complete.  It is auto-generated from comments in the code and I haven't the time to do that all in one go.  But its a start.

In the mean time you can learn how to use the SimpleAPI from the tests that are in the source (but excluded from the package).

https://github.com/cambell-prince/Front … r-cp/tests

As an example, the sales test shows how to list, create, update, and delete a sale.

If anyone wants to see the source annotations for the documentation you can have a look at the feature/docs branch in GitHub.

15

(86 replies, posted in Modules Add-on's)

Hello

I am trying to post a category items using this method  http://myurl/modules/api/category/

For example, when I do POST with this
{"category_id":"6","description":"Components6","dflt_tax_type":"1","dflt_units":"each","dflt_mb_flag":"B","dflt_sales_act":"4010","dflt_cogs_act":"5010","dflt_inventory_act":"1510","dflt_adjustment_act":"5040","dflt_assembly_act":"1530","dflt_no_sale":"0"}

The output return a validation error as

{"success":0,"msg":"Description is required"}

But the description is already in the content.

Same for Locations too

http://myurl/modules/api/locations/       and POST content as

{"stock_id":"TEST","loc_code":"DEF","location_name":"Default","delivery_address":"Delivery 1\nDelivery 2\nDelivery 3","phone":"","phone2":"","fax":"","email":"","contact":""}

Message returned is {"success":0,"msg":"Stock Id is required"}

I use this repo : https://github.com/apmuthu/FA24extensions/tree/master/Extensions/api24

Regards

Sume MS

Excellent support!

17

(86 replies, posted in Modules Add-on's)

Fantastic ApMuthu, I will follow this and update.
I appreciate that you all have supported me much here, and I will contribute once the testing is done.

Many thanks.
Regards
Sume MS

18

(86 replies, posted in Modules Add-on's)

Hello ApMuthu / Cambell

I have found the endpoints and routes from the source code. Thanks

@ApMuthu can you give an example how a direct sales can be posted through the "Insert sales" method?

Regards
Sume MS

19

(86 replies, posted in Modules Add-on's)

Thanks @apmuthu and @cambell for your great works.

I am testing the API now.

Do you have a list of added endpoints or methods for the new release?

Regards
Sume MS

20

(86 replies, posted in Modules Add-on's)

Thanks ApMuthu, your comments are very much appreciated.

I totally understand your point and update my findings here.

Regards
Sume MS

21

(86 replies, posted in Modules Add-on's)

Many Thanks ApMuthu

My  API started working. The uploaded file directsales_anatomy is very interesting.
Can you confirm if you or anyone have written an API for direct sales posting?

Regards
Sume MS

22

(86 replies, posted in Modules Add-on's)

One more question :

Any notes on how to install and configure Slim framework to use with this API?

Thanks

23

(86 replies, posted in Modules Add-on's)

Many Thanks ApMuthu

Thanks very much, I will go through the steps and update you.

Regards

24

(86 replies, posted in Modules Add-on's)

Thank ApMuthu

How can I get parameters for a POST method? For example invoice posting.

Regards
Sume Ms

25

(86 replies, posted in Modules Add-on's)

hi

Also I have downloaded and extracted the zip file for REST API to modules folder.
while testing directory browsing there is no respose.

Regards
Sume MS