Skip to content

Accounting & GST

Accounting, GST and state-code helpers.

14 functions. All require apis/main_webservices.php to be included.


On this page: AcTypeFullList ยท CompState ยท CompStateCode ยท GetGstAmt ยท GetGstCap ยท GetJBCAdjDocFieldTotal ยท GetJBCAdjDocModule ยท GetStateCode ยท PtyState ยท PtyStateCode ยท acTypeList ยท isIGST ยท isKeywordMappedGst ยท is_uomok


AcTypeFullList()

Prototype

AcTypeFullList()

Description

  • Returns the full list of system account types, delimited by the DOS pipe (|).
  • Use to populate account-type selectors in masters.

Parameters

  • none

Returns

  • String โ€” account types joined by |.

Return example

$types = AcTypeFullList();
// e.g. 'ASSET|LIABILITY|INCOME|EXPENSE'

:material-file-code: Source: apis/core.php


CompState()

Prototype

CompState( $lRetStateCode )

Description

  • Returns the current company's state code.
  • Used to decide intra- vs inter-state GST treatment.

Parameters

  • [$lRetStateCode]: Default TRUE, prefixes the state code to the state name

Returns

  • State code of the current company (numeric/string per config).

Return example

$st = CompState();
// e.g. '24' (Gujarat)

Usage example

$companystate = CompState();  //returns 24 GUJARAT

:material-file-code: Source: apis/gstr.php


CompStateCode()

Prototype

CompStateState()

Description

  • Returns the current company's state code as a 2-digit code.
  • Matches the GSTIN state prefix used on documents.

Parameters

  • NONE

Returns

  • String โ€” the 2-digit company state code.

Return example

echo CompStateCode();
// e.g. '24'

Usage example

$CompStateCode = CompStateCode();  //returns 24

:material-file-code: Source: apis/gstr.php


GetGstAmt()

Prototype

GetGstAmt( $cType, $nGstAmt, $acid )

Description

  • Returns the GST amount of a given type (IGST/CGST/SGST) for an amount and account.
  • Use to compute the tax value to post/print per component.

Parameters

  • <$cType>: GST TYPE can be 'IGST' or 'CGST' or 'SGST'

Returns

  • Number โ€” the computed GST amount for that component.

Return example

$amt = GetGstAmt('CGST', 1000, 52);
// e.g. 25.00

Usage example

$nIGST = GetGstAmt( 'IGST', 20000, 52 );  //0
$nCGST = GetGstAmt( 'CGST', 20000, 52 );  //10000
$nSGST = GetGstAmt( 'SGST', 20000, 52 );  //10000

:material-file-code: Source: apis/gstr.php


GetGstCap()

Prototype

GetGstCap( $cType, $nGstPer, $acid )

Description

  • Returns the GST caption (IGST/CGST/SGST label with rate) for a type, percentage and account.
  • Use to build correctly-labelled tax columns on invoices.

Parameters

  • <$cType>: GST TYPE can be 'IGST' or 'CGST' or 'SGST'

Returns

  • String โ€” the applicable GST caption.

Return example

$c = GetGstCap('CGST', 5, 52);
// e.g. 'CGST @2.5%'

:material-file-code: Source: apis/gstr.php


GetJBCAdjDocFieldTotal()

Prototype

GetJBCAdjDocModule( $nID, $cTableName, $fieldname )

Description

  • Returns the sum of a field across all items of the document that an entry has been adjusted against.
  • Use to total the adjusted document's quantities/amounts.

Parameters

  • $nID โ€” ID of table (base_bv or base_cv)
  • $cTableName โ€” base_bv or base_cv
  • $fieldname โ€” adla4

Returns

  • Number โ€” the summed field value for the adjusted document.

Return example

$amt = GetJBCAdjDocFieldTotal(1024, 'trn_receipt', 'amount');
// e.g. 25000.00

Usage example

$modules = GetJBCAdjDocModule( 121, 'base_bv' );
returns: Sales

:material-file-code: Source: apis/funcs_ac.php


GetJBCAdjDocModule()

Prototype

GetJBCAdjDocModule( $nID, $cTableName )

Description

  • Computes the module of the document against which an entry has been adjusted (JBC adjustment).
  • Use to trace where a knock-off/adjustment was applied.

Parameters

  • $nID โ€” ID of table (base_bv or base_cv)
  • $cTableName โ€” base_bv or base_cv

Returns

  • String โ€” the module name of the adjusted document.

Return example

$mod = GetJBCAdjDocModule(1024, 'trn_receipt');
// e.g. 'trn_salesinvoice'

Usage example

$modules = GetJBCAdjDocModule( 121, 'base_bv' );
returns: Sales

:material-file-code: Source: apis/funcs_ac.php


GetStateCode()

Prototype

PtyStateState($acid)

Description

  • Returns the state name prefixed with its state code for a given state code.
  • Use to display a friendly state label from a code.

Parameters

  • <$cStateCode>: 2 digit state code
  • [$lRetStateCode]: Default TRUE, prefixes the state code to the state name

Returns

  • String โ€” '<code> <State Name>'.

Return example

echo GetStateCode('24');
// e.g. '24-Gujarat'

Usage example

$cStateCode = GetStateCode(24);  //returns 24 GUJARAT
$cStateCode = GetStateCode(24, false);  //returns GUJARAT

:material-file-code: Source: apis/gstr.php


PtyState()

Prototype

PtyState( $acid, $lRetStateCode )

Description

  • Returns the state code of a given party/account id.
  • Compare with the company state to determine IGST vs CGST/SGST.

Parameters

  • <$acid>: Account ID
  • [$lRetStateCode]: Default TRUE, prefixes the state code to the state name

Returns

  • State code of the requested account.

Return example

$st = PtyState(52);
// e.g. '27' (Maharashtra)

Usage example

$partystate = PtyState(102);  //returns 24 GUJARAT

:material-file-code: Source: apis/gstr.php


PtyStateCode()

Prototype

PtyStateState($acid)

Description

  • Returns a party/account's state code as a 2-digit code.
  • Use for GSTIN/state validation on the counterparty.

Parameters

  • <$acid>: Account ID

Returns

  • String โ€” the 2-digit state code for the account.

Return example

echo PtyStateCode(52);
// e.g. '27'

Usage example

$PartyStateCode = PartyStateCode(101);  //returns 24

:material-file-code: Source: apis/gstr.php


acTypeList()

Prototype

AcTypeList()

Description

  • Returns the list of account types in the system, pipe-delimited.
  • Lighter companion to AcTypeFullList().

Parameters

  • none

Returns

  • String โ€” account types separated by |.

Return example

$types = AcTypeList();
// e.g. 'DR|CR|...'

Usage example

$actypes = AcTypeList();

:material-file-code: Source: apis/core2_a.php


isIGST()

Prototype

isIGST( $acid )

Description

  • Determines whether a party's invoice should be treated as IGST (inter-state).
  • Compares the party's state to the company's state.

Parameters

  • <$acid>: Account ID

Returns

  • Boolean โ€” true if IGST applies, false for CGST/SGST.

Return example

if (isIGST(52)) { /* apply IGST */ }
// returns: true | false

Usage example

$isIGST = PtyState(102);  //returns true if company gstin is of same state as of party

:material-file-code: Source: apis/gstr.php


isKeywordMappedGst()

Prototype

isKeywordMappedGst($keyword)

Description

  • Checks whether a keyword (e.g. GST/GSTP/GSTR or a custom key) is mapped in the sys_keys table.
  • Use to confirm a GST-related account mapping exists before posting.

Parameters

  • $keyword โ€” Word or Phrase to be checked. Eg. GST / GSTP / GSTR / any other custom keyword.

Returns

  • Boolean โ€” true if the keyword is present in sys_keys, else false.

Return example

$ok = isKeywordMappedGst('GSTP');
// returns: true | false

Usage example

$isGstKeyWord = isKeywordMappedGst('GSTP');  //will return true if GSTP keyname is present in sys_keys table.
returns: true / false.

!!! note Sample entry in sys_keys table: keyname=GSTP keyvalue=PAYABLE A/C

!!! note Sample entry in sys_keys table: keyname=GSTZ keyvalue=PAYABLE A/C

!!! note Sample entry in sys_keys table: keyname=GSTX keyvalue=RECEIVABLE A/C

:material-file-code: Source: apis/funcs_ac.php


is_uomok()

Prototype

is_uomok($opt_values)

Description

  • Checks whether a unit-of-measure list complies with government norms.
  • Use to validate UOMs before GST filing/e-invoicing.

Parameters

  • <$opt_values>: array|string list (Separated by dospipe |) of UOM to check

Returns

  • Boolean โ€” true if the UOM list is compliant, else false.

Return example

$ok = is_uomok($uomValues);
// returns: true | false

Usage example

$logo = logoFile();

:material-file-code: Source: apis/core2_a.php