/*
Def: A/R (Default) Account Type: The Account Type code set here in System Manager is the individual default part
Account Type code used by the Sales Order Processing module to define the following default account codes:
Account Types: A/R, Misc, Sales, Discount, Commission, Expense, Freight

COGS Part Dependent: This flag is used by MAX for Sales Order Entry.
If set to Y, the Account Type Code assigned to a Part ID is used to obtain the Cost of Goods account.
If set to N, the Default Account Type Code Cost of Goods account will be used for every line item on every sales order.

Sales Part Dependent: This flag is used by MAX for Sales Order Entry.
If set to Y, the Account Type Code assigned to a Part ID is used to obtain the Sales GL account.
If set to N, the Default Account Type Code Sales GL account will be used for every line item on every sales order.
* MAX overrides a general statement that the “order” SLSACT is a default value for everything on the order and does the Sales (Price) aspect of the accounting based on account type code. Thus the SO_Master always receives the default value and if overriden by downstream accounting calculations in the Posting Process which occurs after shipment.
*/

— SOP GL Account Data:
SELECT
[CFGKEY_04],substring(CAST([CFG006_04] as VARCHAR(7)),5,3) AS ‘AR Default’
,[CFGKEY_04],substring(CAST([CFG006_04] as VARCHAR(7)),3,1) AS ‘COGs Dependent’
,[CFGKEY_04],substring(CAST([CFG006_04] as VARCHAR(7)),4,1) AS ‘Sales Dependent’
FROM [Configuration_Data]
where CFGKEY_04 = ‘SOECFG’

/*
If AR Default Blank then MAX has aa default for AR etc as defined above.

If Y for COGs Flag do Account Type Lookup on Part Master for Part for account type XXX lookup in General_Ledger_Account
RECTYP_19 = D KEY_19 = CSTOFSLS ACTTYP=XXX and apply it to the line.

If Y for Sales Dep Flag do Account Type from [CFGKEY_04],substring(CAST([CFG006_04] as VARCHAR(7)),5,3) AS ‘AR Default’
and lookup in General_Ledger_Account RECTYP_19 = D KEY_19 = SLSACT ACTTYP=XXX and apply it to the SO_Master