Created
September 2, 2020 18:28
-
-
Save tejavarma-aln/a8c242bd5d6058ee2191aaae4ecb2bc9 to your computer and use it in GitHub Desktop.
Part -2 of web services in tally tutorial (creating stock items)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// data class for stockitem | |
class StockModel{ | |
public $itemName; | |
public $itemUnit; | |
public $itemGrate; | |
public $itemHsn; | |
public $itemApplicable; | |
// constuctor | |
function __construct($name,$unit,$rate,$hsn,$applicablefrom){ | |
$this->itemName = $name; | |
$this->itemUnit = $unit; | |
$this->itemGrate = $rate; | |
$this->itemHsn = $hsn; | |
$this->itemApplicable = $applicablefrom; | |
} | |
} | |
$item_list = array(); | |
//sample items | |
array_push($item_list,new StockModel("item-1","Nos","18","1234","1-4-20")); | |
array_push($item_list,new StockModel("item-2","Nos","12","1235","1-4-20")); | |
array_push($item_list,new StockModel("item-3","Nos","28","1236","1-4-20")); | |
array_push($item_list,new StockModel("item-4","Nos","5","1237","1-4-20")); | |
array_push($item_list,new StockModel("item-5","Nos","18","1238","1-4-20")); | |
$item_response = array(); | |
$item_response['Items'] = $item_list; | |
print_r(json_encode($item_response)); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Main Collection | |
[Collection:RemoteStockColl] | |
Data Source:HTTP JSON:"http://localhost/StockItems.php":UTF8 | |
;summary collection | |
[Collection:RemoteStockExtract] | |
Source Collection:RemoteStockColl | |
Walk:Items | |
Compute:Name:$itemName | |
Compute:Unit:$itemUnit | |
Compute:Grate:$itemGrate | |
Compute:Applicable:$itemApplicable | |
Compute:Hsn:$itemHsn | |
; MODIFYING MENU TO ADD ITEM | |
[#Menu:GateWayOfTally] | |
Add:Item:Post Items:Call:CreateStockItems | |
; calling function | |
;function to create stockitems from response | |
[Function:CreateStockItems] | |
00:Walk Collection:RemoteStockExtract | |
01:New Object:StockItem | |
02:Set Value:Name:$Name | |
03:Set Value:BaseUnits:$Unit | |
04:SET VALUE : GSTApplicable : $$SysName:Applicable | |
05:SET VALUE : GSTTypeofSupply : "Goods" | |
055 : INSERT COLLECTION OBJECT : GSTDetails | |
06 : SET VALUE : APPLICABLEFROM : $$Date:$Applicable | |
07 : SET VALUE : CALCULATIONTYPE : $$String:"On Value" | |
08 : SET VALUE : HSNCODE : $$Number:$Hsn | |
09 : SET VALUE : TAXABILITY : $$String:"Taxable" | |
10 : SET VALUE : ISREVERSECHARGEAPPLICABLE : No | |
11 : SET VALUE : ISNONGSTGOODS : No | |
12 : SET VALUE : GSTINELIGIBLEITC : No | |
13 : INSERT COLLECTION OBJECT : STATEWISEDETAILS | |
14 : SET VALUE : STATENAME : $$SysName:Any | |
15 : INSERT COLLECTION OBJECT : RATEDETAILS | |
16 : SET VALUE : GSTRATEDUTYHEAD : $$String:"Central Tax" | |
17 : SET VALUE : GSTRATEVALUATIONTYPE : $$String:"Based on Value" | |
18 : SET VALUE : GSTRATE : $$Number:$Grate / $$Number:"2" | |
19 : SET TARGET : .. | |
20 : INSERT COLLECTION OBJECT : RATEDETAILS | |
21 : SET VALUE : GSTRATEDUTYHEAD : $$String:"State Tax" | |
22 : SET VALUE : GSTRATEVALUATIONTYPE : $$String:"Based on Value" | |
23 : SET VALUE : GSTRATE : $$Number:$Grate / $$Number:"2" | |
24 : SET TARGET : .. | |
25 : INSERT COLLECTION OBJECT : RATEDETAILS | |
26 : SET VALUE : GSTRATEDUTYHEAD : $$String:"Integrated Tax" | |
27 : SET VALUE : GSTRATEVALUATIONTYPE : $$String:"Based on Value" | |
28 : SET VALUE : GSTRATE : $$Number:$Grate | |
29 : SET TARGET : .. | |
30 : INSERT COLLECTION OBJECT : RATEDETAILS | |
31 : SET VALUE : GSTRATEDUTYHEAD : "Cess" | |
32 : SET VALUE : GSTRATEVALUATIONTYPE : "Based on Value" | |
33 : Set Target : .. | |
34 : Insert Collection Object : GstDetails | |
35 : Set Value : HSNCode : $$Number:$Hsn | |
36 : Set Target : .. | |
37 : Save Target | |
38 : End Walk | |
39 : Msg Box:"Success":"Items Posted Successfully" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment