0% found this document useful (0 votes)
60 views7 pages

POCONFIRMGST

This document defines a data provider class that processes queries and retrieves data for a purchase confirmation report in Microsoft Dynamics NAV. It includes declarations for various header, line item, tax, and company tables. Methods are defined to insert records into temporary tables for the report header, lines, and charges. The processReport method contains business logic to retrieve data from the various tables and populate the temporary tables based on a purchase order record ID.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views7 pages

POCONFIRMGST

This document defines a data provider class that processes queries and retrieves data for a purchase confirmation report in Microsoft Dynamics NAV. It includes declarations for various header, line item, tax, and company tables. Methods are defined to insert records into temporary tables for the report header, lines, and charges. The processReport method contains business logic to retrieve data from the various tables and populate the temporary tables based on a purchase order record ID.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 7

[SRSReportParameterAttribute(classStr(STH_PurchConfirmGSTContractClass))]

// Data provider class process the query


class STH_PurchConfirmGSTDPClass extends SRSReportDataProviderBase
{
//Header Tables
VendPurchOrderJour vendPurchOrderJour;
PurchTable purchTable;
VendTable vendTable;
InventTable inventTable;
CompanyInfo companyInfo;
dirPartyTable dirPartyTable;
PurchLineAllVersions purchLineAllVersions;
EcoResProduct ecoResProduct;

//HSN Tables
ServiceAccountingCodeTable_IN saccode;
HSNCodeTable_IN _hsncodetable;

//Tax Tables
TaxInformationVendTable_IN taxInfoVendPan;
TaxInformationLegalEntity_IN taxForPan;
taxInformation_IN taxInformation_IN_GST;
taxRegistrationNumbers_IN taxRegistrationNumbers;

//Temp Tables
STH_PurchConfirmHeadGSTTmp sth_PurchConfirmHeadGSTTmp;
STH_PurchConfirmLineGSTTmp sth_PurchConfirmLineGSTTmp;
STH_PurchConfirmGSTChargesTmp sth_PurchConfirmGSTChargesTmp;

VendPurchOrderJour _vendPurchOrderJour1;

TaxTrans_IN taxtrans;
PurchLine purchLine;
MarkupTrans markupTrans;
HcmWorker hcmworker;

//GST Tables
ITaxDocument taxDocument;
ITaxDocumentComponentLineEnumerator componentLineEnumerator;
ITaxDocumentComponentLine componentLineObject;
ITaxDocumentMeasureEnumerator measureEnumerator;
TaxAmount taxAmount,taxValue;
TaxComponent_IN taxComponent;

// SRSReportDataSetAttributeattribute is used to indicate the temporary table


name and also tells the reporting services
// to use this method to retrieve the processed data.

[SRSReportDataSetAttribute(tableStr(STH_PurchConfirmHeadGSTTmp))]
public STH_PurchConfirmHeadGSTTmp getsth_PurchConfirmHeadGSTTmp()
{
select sth_PurchConfirmHeadGSTTmp;
return sth_PurchConfirmHeadGSTTmp;
}

[SRSReportDataSetAttribute(tableStr(STH_PurchConfirmLineGSTTmp))]
public STH_PurchConfirmLineGSTTmp getsth_PurchConfirmLineGSTTmp()
{
select sth_PurchConfirmLineGSTTmp;
return sth_PurchConfirmLineGSTTmp;
}

[SRSReportDataSetAttribute(tableStr(STH_PurchConfirmGSTChargesTmp))]
public STH_PurchConfirmGSTChargesTmp getsth_PurchConfirmGSTChargesTmp()
{
select sth_PurchConfirmGSTChargesTmp;
return sth_PurchConfirmGSTChargesTmp;
}

//process report method process the data


//contains the business logic and is called by reporting services to generate
data

public void processReport()


{
RecId recId;

STH_PurchConfirmGSTContractClass contract = this.parmDataContract() as


STH_PurchConfirmGSTContractClass;
recId = contract.parmRecId();

companyInfo = CompanyInfo::find();

// Calling Methods
while select vendPurchOrderJour where vendPurchOrderJour.RecId == recId
{
this.insertHeader(vendPurchOrderJour.PurchId);
this.insertLine(vendPurchOrderJour.PurchId, vendPurchOrderJour);
// this.insertMarkUp();

}
}

//Header info.

protected void insertHeader(PurchId _purchId)


{
//Inserting Header details into temp table
//STH_Venu - Start
sth_PurchConfirmHeadGSTTmp.PurchId = vendPurchOrderJour.PurchId;
sth_PurchConfirmHeadGSTTmp.VendorCode =
vendPurchOrderJour.OrderAccount;
sth_PurchConfirmHeadGSTTmp.PurchOrderDate =
vendPurchOrderJour.PurchOrderDate;
//Purch Table info.
while select purchTable where purchTable.PurchId ==
vendPurchOrderJour.PurchId
{
sth_PurchConfirmHeadGSTTmp.DlvDate =
purchTable.DeliveryDate;
sth_PurchConfirmHeadGSTTmp.VendDlvMode =
purchTable.DlvMode;
sth_PurchConfirmHeadGSTTmp.VendDlvTerm =
purchTable.DlvTerm;
sth_PurchConfirmHeadGSTTmp.VendPaymTermId =
purchTable.Payment;
sth_PurchConfirmHeadGSTTmp.VendPaymMode =
purchTable.PaymMode;
sth_PurchConfirmHeadGSTTmp.VendorEmail =
purchTable.Email;
select hcmWorker where hcmworker.RecId ==
PurchTable.WorkerPurchPlacer;
sth_PurchConfirmHeadGSTTmp.BuyerName =
hcmworker.name();

sth_PurchConfirmHeadGSTTmp.DeliveryAddress =
vendPurchOrderJour.deliveryAddress().Address;

select vendTable where vendTable.AccountNum ==


vendPurchOrderJour.OrderAccount;

sth_PurchConfirmHeadGSTTmp.VendorContact =
vendTable.phone();

select taxInfoVendPan where vendTable.AccountNum ==


taxInfoVendPan.VendTable;
sth_PurchConfirmHeadGSTTmp.VendorPANNumber =
taxInfoVendPan.PANNumber;

//Company info

sth_PurchConfirmHeadGSTTmp.CompanyName_STH =
companyInfo.Name();
sth_PurchConfirmHeadGSTTmp.CompanyLogo_STH =
SalesQuotationEditLinesForm::companyLogo();
sth_PurchConfirmHeadGSTTmp.VendorName =
DirParty::primaryPostalAddress(vendTable.Party).displayLocationDescription();
sth_PurchConfirmHeadGSTTmp.CompanyAddress =
companyInfo.postalAddress().Address;
sth_PurchConfirmHeadGSTTmp.VendorAddress =
DirParty::primaryPostalAddress(vendTable.Party).Address;
sth_PurchConfirmHeadGSTTmp.CompanyPhone =
companyInfo.phone();
sth_PurchConfirmHeadGSTTmp.CompanyGST =
companyInfo.CoRegNum;
sth_PurchConfirmHeadGSTTmp.CompanyFax =
CompanyInfo.teleFax();
sth_PurchConfirmHeadGSTTmp.CompanyGST =
companyInfo.CoRegNum;
sth_PurchConfirmHeadGSTTmp.CompanyFax =
CompanyInfo.teleFax();

// PAN number
while select taxForPan where companyInfo.RecId == taxForPan.LegalEntity
{
sth_PurchConfirmHeadGSTTmp.CompanyPAN =
taxForPan.PANNumber;
}

//select AccountNum, Party from vendTable


//where vendTable.AccountNum == vendPurchOrderJour.OrderAccount;
// vendTable.Party = VendTable::find(vendPurchOrderJour.OrderAccount).Party;

//Vendor GST
select dirPartyTable where dirPartyTable.RecId == vendTable.Party;

select taxInformation_IN_GST where


taxInformation_IN_GST.RegistrationLocation ==
dirPartyTable.PrimaryAddressLocation
&& (taxInformation_IN_GST.GSTIN > 0);

select taxRegistrationNumbers where


taxRegistrationNumbers.RecId == taxInformation_IN_GST.GSTIN ;

sth_PurchConfirmHeadGSTTmp.VendorGST =
taxRegistrationNumbers.RegistrationNumber;
//verndor GST End

sth_PurchConfirmHeadGSTTmp.insert();

//Inserting Header details into temp table


//STH_Venu - End

//Line Methods for line information


protected void insertLine(PurchId _purchId, VendPurchOrderJour
_vendPurchOrderJour)
{
//Inserting Line details into temp table
//STH_Venu - Start
select purchTable where vendpurchOrderJour.PurchId==purchTable.PurchId;

// purchTable = purchTable::findRecId(purchTable.RecId);

taxDocument =
TaxBusinessService::getTaxDocumentBySource(purchTable.TableId, purchTable.RecId);

componentLineEnumerator = taxDocument.componentLines();

while select purchLineAllVersions where purchLineAllVersions.PurchId ==


_purchId
&& purchLineAllVersions.PurchTableVersionRecId ==
vendPurchOrderJour.PurchTableVersion
{

sth_PurchConfirmLineGSTTmp.ItemId =
purchLineAllVersions.ItemId;
sth_PurchConfirmLineGSTTmp.ItemName =
purchLineAllVersions.Name;
sth_PurchConfirmLineGSTTmp.PurchOrderedQty =
purchLineAllVersions.PurchQty;
sth_PurchConfirmLineGSTTmp.PurchPrice =
purchLineAllVersions.PurchPrice;
sth_PurchConfirmLineGSTTmp.UOM =
purchLineAllVersions.PurchUnit;
sth_PurchConfirmLineGSTTmp.AccessableValue =
purchLineAllVersions.LineAmount;
sth_PurchConfirmLineGSTTmp.DiscAmount =
purchLineAllVersions.DiscAmount;

select purchTable where vendPurchOrderJour.PurchId ==


PurchTable.PurchId;
sth_PurchConfirmLineGSTTmp.VendCurrencyCode =
purchTable.CurrencyCode;
select inventTable where inventTable.ItemId ==
purchLineAllVersions.ItemId;
select ecoResProduct where ecoResProduct.RecId ==
inventTable.Product;

// HSN or SAC code


if (ecoResProduct.ProductType == EcoResProductType::Service)
{
select saccode where saccode.RecId ==
inventTable.ServiceAccountingCodeTable_IN;
sth_PurchConfirmLineGSTTmp.HSNCode =
saccode.SAC;
}
else if (ecoResProduct.ProductType ==
EcoResProductType::Item)
{
select _hsncodetable where _hsncodetable.RecId ==
inventTable.HSNCodeTable_IN;
sth_PurchConfirmLineGSTTmp.HSNCode =
_hsncodetable.Code;
}

//Total amounts

select vendPurchOrderJour where vendPurchOrderJour.PurchId ==


purchLineAllVersions.PurchId;
sth_PurchConfirmLineGSTTmp.TotalAmount =
vendPurchOrderJour.Amount;
sth_PurchConfirmLineGSTTmp.TotalAmountInWords =
Global::numeralsToTxt_IN(vendPurchOrderJour.Amount);

//GST
while(componentLineEnumerator.moveNext())
{
componentLineObject = componentLineEnumerator.current();
taxComponent = componentLineObject.metaData().taxComponent();
taxValue = componentLineObject.getMeasure("Rate").value().value() *
100;
taxAmount = componentLineObject.getMeasure("Tax
Amount").value().value();
if(taxComponent == 'CGST')
{
sth_PurchConfirmLineGSTTmp.CGSTAmount =
componentLineObject.getMeasure("Tax Amount").value().value();
sth_PurchConfirmLineGSTTmp.CGSTRate=
componentLineObject.getMeasure("Rate").value().value() * 100;
}
if(taxComponent == 'SGST')
{
sth_PurchConfirmLineGSTTmp.SGSTAmount =
componentLineObject.getMeasure("Tax Amount").value().value();
sth_PurchConfirmLineGSTTmp.SGSTRate=
componentLineObject.getMeasure("Rate").value().value() * 100;
break;
}
if(taxComponent == 'IGST')
{
sth_PurchConfirmLineGSTTmp.IGSTAmount =
componentLineObject.getMeasure("Tax Amount").value().value();
sth_PurchConfirmLineGSTTmp.IGSTRate=
componentLineObject.getMeasure("Rate").value().value() * 100;
break;
}

}
if(sth_PurchConfirmLineGSTTmp.CGSTAmount > 0 ||
sth_PurchConfirmLineGSTTmp.SGSTAmount > 0)
{
sth_PurchConfirmLineGSTTmp.Amount =
abs(sth_PurchConfirmLineGSTTmp.CGSTAmount+sth_PurchConfirmLineGSTTmp.SGSTAmount+
purchLineAllVersions.LineAmount);
}
else
{
sth_PurchConfirmLineGSTTmp.Amount =
abs(sth_PurchConfirmLineGSTTmp.IGSTAmount+purchLineAllVersions.LineAmount);
}

sth_PurchConfirmLineGSTTmp.insert();
//Inserting Line details into temp table
//STH_Venu - End

}
}

// Other Charges
//protected void insertMarkUp()
//{
// //Inserting Header chares details into temp table
// //STH_Venu - Start
// //Header charges
// select purchTable where purchTable.PurchId ==
vendPurchOrderJour.PurchId;
// while select Txt,Value,CalculatedAmount from markUpTrans where
markUpTrans.TransTableId == purchTable.TableId
// && markUpTrans.TransRecId == purchTable.RecId
// {
// if(markUpTrans.CalculatedAmount >= 0)
// {
// sth_PurchConfirmGSTChargesTmp.HeadTransTxt
= markUpTrans.Txt;
// sth_PurchConfirmGSTChargesTmp.HeadMarkupValue
= markUpTrans.Value;
// sth_PurchConfirmGSTChargesTmp.insert();
// //Inserting Header charges details into temp table
// //STH_Venu - End
// }
// }
// // select purchTable where vendPurchOrderJour.PurchId ==
PurchTable.PurchId;

// //Line Charges
// //while select purchLineAllVersions where vendPurchOrderJour.PurchId ==
purchLineAllVersions.PurchID
// //{
// // while select Txt,Value,CalculatedAmount from markUpTrans where
purchLineAllVersions.RecId == markUpTrans.TransRecId
// // {

// while select purchLine where purchLine.ItemId ==


purchLineAllVersions.itemId
// && purchLIne.PurchId == vendPurchOrderJour.purchId
// {

// while select * from markUpTrans where markUptrans.TransTableId ==


purchLine.TableId
// && markUpTrans.TransRecId == purchLine.RecId
// {
// if(markUpTrans.CalculatedAmount >= 0)
// {
// //Inserting Line charges details into temp table
// //STH_Venu - Start
// sth_PurchConfirmGSTChargesTmp.HeadTransTxt
= markUpTrans.Txt;
// sth_PurchConfirmGSTChargesTmp.HeadMarkupValue
= markUpTrans.Value;
// sth_PurchConfirmGSTChargesTmp.insert();
// //Inserting Line charges details into temp table
// //STH_Venu - End
// }
// }

// }
//}

You might also like