X00TAX - How do I use the Load and Retrieve Quantum Tax Cache Function?

wlanderson

Member
I am trying to write a report that displays the Vertex State, County and City tax rates for existing transactions. I have searched through the treads here and have found similar questions but I have not had any luck using the answers.

As far as I understand it, I should be able to use the LoadAndRetrieveQuantumTaxCache function (X00TAX) to retrieve the information. The notes for the function indicate that the calling application should add a record to the cache, call the tax calculator, retrieve the cache and finally delete the cache. I read this to mean that I should call the cache in mode 1, call the calculator, call the cache in mode 3 and finally call the cache in mode 4 to clean up.

I have tried multiple combinations of these calls and the tax amounts are correctly returned by the tax calculation but no values are being returned in the rate fields of the cache calls.

If anyone could point me in the correct direction it would be greatly appreciated.

This is for 9.1 with tools 9.1.4.7.

Thanks
 
Great timing. I was just fixing a bug in a block of code that does pretty much what you are asking for. Here is snippet of code that should give you the basics of what you need to do:

Code:
	/********** Calc Tax for Line **********/

	/***** Get a new Jobnumber for vertex to use *****/
	if(acmeIsMathZero(&pSession->mnVertexJobnumberA))
		LongToMathNumeric(JDB_GetInternalNextNumber(), &pSession->mnVertexJobnumberA);

		
	/***** Load Vertex Cache *****/
	loadvertex.cCalledFromFlag											= _J('2');
	MathCopy(&loadvertex.mnSupplierOrShipTo,						&pF4211->sdshan);
	loadvertex.jdDateTransactionJulian								= pF4211->sdtrdj;
	jdeStrncpy(loadvertex.szHeaderBranchPlant,					pF4211->sdemcu, DIM(loadvertex.szHeaderBranchPlant)-1);
	jdeStrncpy(loadvertex.szDetailBranchPlant,					pF4211->sdmcu, DIM(loadvertex.szDetailBranchPlant)-1);
	MathCopy(&loadvertex.mnJobnumberA,								&pSession->mnVertexJobnumberA);
	loadvertex.cModeProcessing											= _J('1');
	MathCopy(&loadvertex.mnIdentifierShortItem,					&pF4211->sditm);
	jdeStrncpy(loadvertex.szOrderType,								pF4211->sddcto, DIM(loadvertex.szOrderType)-1);
	jdeStrncpy(loadvertex.szLineType,								pF4211->sdlnty, DIM(loadvertex.szLineType)-1);
	jdeStrncpy(loadvertex.szShipToGeoCode,							pF4211->sdtxa1, DIM(loadvertex.szShipToGeoCode)-1);
	MathCopy(&loadvertex.mnUnitsTransactionQty,					&pF4211->sdsoqs);
	MathCopy(&loadvertex.mnDocumentOrderInvoiceE,				&pF4211->sddoco);
	jdeStrncpy(loadvertex.szCompanyKeyOrderNo,					pF4211->sdkcoo, DIM(loadvertex.szCompanyKeyOrderNo)-1);
	jdeStrcpy(loadvertex.szOrderSuffix,								_J("000"));
	MathCopy(&loadvertex.mnLineNumber,								&pF4211->sdlnid);

	if(acmeCallObject(LoadAndRetrieveVertexCache, lpBhvrCom, lpVoid, &loadvertex) == ER_ERROR)
	{
		jdeErrorSet(lpBhvrCom, lpVoid, (ID) 0, _J("155W"), (LPVOID) NULL);
		return ER_ERROR;
	}

	pSession->bVertexCacheLoaded = TRUE;


	/***** Call Tax Calculator *****/
	jdeStrncpy(taxcalc.szTaxArea1,					pF4211->sdtxa1, DIM(taxcalc.szTaxArea1)-1);
	jdeStrncpy(taxcalc.szTaxExplanationCode1,		pF4211->sdexr1, DIM(taxcalc.szTaxExplanationCode1)-1);
	taxcalc.jdTransactionDate							= pF4211->sdtrdj;
	jdeStrncpy(taxcalc.szPaymentTermsCode1,		pF4211->sdptc, DIM(taxcalc.szPaymentTermsCode1)-1);
	jdeStrncpy(taxcalc.szCompany,						pF4211->sdkcoo, DIM(taxcalc.szCompany)-1);
	MathCopy(&taxcalc.mnShortItemNumber,			&pF4211->sditm);
	MathCopy(&taxcalc.mnUnitsPrimaryQtyOrder,		&pF4211->sdsoqs);
	MathCopy(&taxcalc.mnAmountTaxable,				&pF4211->sdaexp);
	taxcalc.cSystemCode									= _J('4');
	MathCopy(&taxcalc.mnJobnumberA,					&pSession->mnVertexJobnumberA);
	taxcalc.cIsVertexActive								= pSession->dsIsVertexActive.cUseVertexFlag;
	MathCopy(&taxcalc.mnDocumentOrderInvoiceE,	&pF4211->sddoco );
	jdeStrncpy(taxcalc.szOrderType,					pF4211->sddcto, DIM(taxcalc.szOrderType)-1);
	jdeStrncpy(taxcalc.szCompanyKeyOrderNo,		pF4211->sdkcoo, DIM(taxcalc.szCompanyKeyOrderNo)-1);
	jdeStrcpy(taxcalc.szOrderSuffix,					_J("000") );
	MathCopy(&taxcalc.mnLineNumber,					&pF4211->sdlnid );

	/* You must have the MATH_NUMERIC.nDecimalPosition AND nCurrencyDecimals set correctly or 
		* TaxCalculator WILL screw up */
	jdeStrcpy(dsDecimalPosition.szCurrencyCode,			_J("USD") );
	MathCopy(&dsDecimalPosition.mnDomOrFornAmount01,	&taxcalc.mnAmountTaxable	);
	MathCopy(&dsDecimalPosition.mnDomOrFornAmount02,	&taxcalc.mnAmtTax2	);
	MathCopy(&dsDecimalPosition.mnDomOrFornAmount03,	&taxcalc.mnAmountTaxExempt );

	if(acmeCallObject(DecimalTriggerGetByCurrency, lpBhvrCom, lpVoid,  &dsDecimalPosition) == ER_SUCCESS) 
	{
		taxcalc.mnAmountTaxable.nCurrencyDecimals			= dsDecimalPosition.mnDomOrFornAmount01.nCurrencyDecimals;
		taxcalc.mnAmtTax2.nCurrencyDecimals					= dsDecimalPosition.mnDomOrFornAmount02.nCurrencyDecimals;
		taxcalc.mnAmountTaxExempt.nCurrencyDecimals		= dsDecimalPosition.mnDomOrFornAmount03.nCurrencyDecimals;
	}


	if(acmeCallObject(TaxCalculator, lpBhvrCom, lpVoid, &taxcalc) == ER_ERROR) 
	{
		jdeErrorSet(lpBhvrCom, lpVoid, (ID) 0, _J("2097"), (LPVOID) NULL);
		return ER_ERROR;
	}


	/***** Save the returned info from the tax calculator *****/
	MathCopy(&pdata->mnAmountTax,				&taxcalc.mnAmtTax2);
	MathCopy(&pdata->mnTotalTaxRate,			&taxcalc.mnTotalAreaTaxRate);
	MathSubtract(&pdata->mnAmountTaxable,	&pdata->mnAmountOrder, &taxcalc.mnAmountTaxExempt);
	MathAdd(&pdata->mnAmountGross,			&pdata->mnAmountOrder, &pdata->mnAmountTax);
	MathCopy(&pdata->mnAmountOpen,			&pdata->mnAmountGross);


	
..........	and at some point you will need to do some cleanup on the vertex cache


	/********** Destroy Session Objects **********/

	/* vertex cache */
	if(pSession->bVertexCacheLoaded && 
		!acmeIsMathZero(&pSession->mnVertexJobnumberA))
	{
		DSD4000050A		term={0};

		term.cCalledFromFlag				= _J('2');
		MathCopy(&term.mnJobnumberA,	&pSession->mnVertexJobnumberA);
		term.cModeProcessing	= _J('3');
		acmeCallObject(LoadAndRetrieveVertexCache, lpBhvrCom, lpVoid, &term);
	}
 
Back
Top