/// <summary>
/// This method inserts data into the temporary table.
/// </summary>
/// <param name="_vendPurchOrderJour">
/// Vendor Purchase Order Confirmation journal record.
/// </param>
/// <remarks>
/// Inserts data into the temporary table.
/// </remarks>
private void insertIntoTempTable(VendPurchOrderJour _vendPurchOrderJour)
{
PurchTable purchTable;
PurchLine _PurchLine;
PurchLineAllVersions purchLineAllVersions;
PurchTableAllVersions purchTableAllVersions;
VendTable vendTable;
VendParameters vendParameters;
str coutryname;
DirPartyLocation dirPartyLocation;
LogisticsElectronicAddress logisticsElectronicAddress;
DataArea dataArea;
PurchtotalsForm totalsForm;
DirPartyPostalAddressView _DirPartyPostalAddressView;
;
purchTable = PurchTable::find(_vendPurchOrderJour.PurchId);
vendTable = VendTable::find(purchTable.OrderAccount);
select purchTableAllVersions where purchTableAllVersions.PurchTableVersionRecId == _vendPurchOrderJour.PurchTableVersion;
purchaseOrderHeaderTmp.OrderNo = purchTable.PurchId;
purchaseOrderHeaderTmp.vendName = purchTable.vendorName();
purchaseOrderHeaderTmp.VendorAddress = purchTable.vendorAddress();
purchaseOrderHeaderTmp.VendorRef = purchTableAllVersions.VendorRef;
purchaseOrderHeaderTmp.Attention = purchTableAllVersions.contactPersonName();
purchaseOrderHeaderTmp.Date = DateTimeUtil::date(purchTable.createdDateTime);//_vendPurchOrderJour.PurchOrderDate; //by 29224
purchaseOrderHeaderTmp.Orderer = HcmWorker::find(purchTable.WorkerPurchPlacer).name();
purchaseOrderHeaderTmp.DlvTerm = DlvTerm::find(purchTable.DlvTerm).Txt;//DlvMode::find(purchTableAllVersions.DlvMode).Txt;//DlvTerm::find(purchTableAllVersions.DlvTerm).Txt;
purchaseOrderHeaderTmp.DlvMode = DlvMode::find(purchTable.DlvMode).Txt;
purchaseOrderHeaderTmp.PaymTermId = PaymTerm::find(purchTable.Payment).Description;
purchaseOrderHeaderTmp.DeliveryName = purchTableAllVersions.DeliveryName;
purchaseOrderHeaderTmp.DeliveryDate = purchTable.DeliveryDate;
purchaseOrderHeaderTmp.DeliveryAddress = LogisticsPostalAddress::addressFromRecId(purchTableAllVersions.DeliveryPostalAddress);
purchaseOrderHeaderTmp.Currency = purchTableAllVersions.CurrencyCode;
purchaseOrderHeaderTmp.Warehouse = purchTableAllVersions.InventLocationId;
purchaseOrderHeaderTmp.Remark = purchTableAllVersions.ReqAttention;
purchaseOrderHeaderTmp.Notes = FormLetterRemarks::find(CompanyInfo::find().LanguageId,FormTextType::PurchPurchaseOrder).Txt;
// AT Add this code
Select FirstOnly * from _PurchLine where _PurchLine.PurchId == PurchTable.PurchId;
purchaseOrderHeaderTmp.God_Customer = CustTable::find(SalesTable::find(_PurchLine.GITL_SalesId).CustAccount).name();
purchaseOrderHeaderTmp.ReasonComment = ReasonTableRef::find(purchTable.ReasonTableRef).ReasonComment;
// End
//
coutryname = logisticspostaladdress::findbylocation(companyinfo::find().postaladdress().location).CountryRegionId;
purchaseOrderHeaderTmp.God_invoiceAddressto = logisticspostaladdress::findbylocation(companyinfo::find().postaladdress().location).City +' , '+coutryname;
purchaseOrderHeaderTmp.God_issuefrom = logisticspostaladdress::findbylocation(companyinfo::find().postaladdress().location).City +' , '+coutryname;
purchaseOrderHeaderTmp.God_Shippingmark = purchTable.GITL_ShippingMark;
purchaseOrderHeaderTmp.God_Port = purchTable.Port;
purchaseOrderHeaderTmp.God_site = InventSite::find(purchTable.InventSiteId).Name;
// For Vendor Fax only
select firstOnly dirPartyLocation
order by dirPartyLocation.RecId desc
where
dirPartyLocation.Party == vendTable.Party
join logisticsElectronicAddress
where
logisticsElectronicAddress.Location == dirPartyLocation.Location
&& logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Fax;
purchaseOrderHeaderTmp.God_VendorFax = logisticsElectronicAddress.GITL_CountryCodeForPhoneNumber + "-" + logisticsElectronicAddress.Locator;
select firstOnly dirPartyLocation
order by dirPartyLocation.RecId desc
where
dirPartyLocation.Party == vendTable.Party
join logisticsElectronicAddress
where
logisticsElectronicAddress.Location == dirPartyLocation.Location
&& logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Phone;
purchaseOrderHeaderTmp.God_VendorPhone = logisticsElectronicAddress.GITL_CountryCodeForPhoneNumber + logisticsElectronicAddress.Locator;
select firstOnly dirPartyLocation
order by dirPartyLocation.RecId desc
where
dirPartyLocation.Party == vendTable.Party
join logisticsElectronicAddress
where
logisticsElectronicAddress.Location == dirPartyLocation.Location
&& logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Email;
purchaseOrderHeaderTmp.God_VendorEmail = logisticsElectronicAddress.GITL_CountryCodeForPhoneNumber + logisticsElectronicAddress.Locator;
select * from _DirPartyPostalAddressView Where
_DirPartyPostalAddressView.Party == vendTable::find(purchTable.OrderAccount).Party;
purchaseOrderHeaderTmp.Street = _DirPartyPostalAddressView.Street;
purchaseOrderHeaderTmp.City = _DirPartyPostalAddressView.City;
purchaseOrderHeaderTmp.County = _DirPartyPostalAddressView.County;
purchaseOrderHeaderTmp.State = _DirPartyPostalAddressView.State;
purchaseOrderHeaderTmp.CountryRegionId = _DirPartyPostalAddressView.CountryRegionId;
purchaseOrderHeaderTmp.ZipCode = _DirPartyPostalAddressView.ZipCode;
//For Subtotal part only//
select sum(PurchQty) from purchLineAllVersions order by purchLineAllVersions.LineNumber
where purchLineAllVersions.PurchTableVersionRecId == _vendPurchOrderJour.PurchTableVersion
&& purchLineAllVersions.PurchId == _vendPurchOrderJour.PurchId;
totalsForm = PurchtotalsForm::newPurchTotalsForm(PurchTable::find(purchTable.PurchId),1);//PurchTable::find(purchTable.PurchId),2);//purchLineAllVersions.PurchQty);
totalsForm.calctotals();
purchaseOrderHeaderTmp.God_Subtotal = totalsForm.sumLinesValue();
totalsForm = PurchtotalsForm::newPurchTotalsForm(PurchTable::find(purchTable.PurchId),1);//PurchTable::find(purchTable.PurchId),2);//purchLineAllVersions.PurchQty);
totalsForm.calctotals();
purchaseOrderHeaderTmp.God_Totalvalue = totalsForm.invoiceAmountValue();
totalsForm = PurchtotalsForm::newPurchTotalsForm(PurchTable::find(purchTable.PurchId),1);
totalsForm.calctotals();
purchaseOrderHeaderTmp.God_Discount = totalsForm.endDiscValue();
purchaseOrderHeaderTmp.God_StrAmount = Global::numeralsToTxt_Number(purchaseOrderHeaderTmp.God_Totalvalue);
//
this.insertCompanyDetails();
purchaseOrderHeaderTmp.insert();
while select purchLineAllVersions order by purchLineAllVersions.LineNumber
where purchLineAllVersions.PurchTableVersionRecId == _vendPurchOrderJour.PurchTableVersion
&& purchLineAllVersions.PurchId == _vendPurchOrderJour.purchid
{
purchaseOrderTmp.clear();
purchaseOrderTmp.UOM = purchLineAllVersions.PurchUnit;
//purchaseOrderTmp.PartCode = purchLineAllVersions.GOD_partCode();
purchaseOrderTmp.ItemId = purchLineAllVersions.ItemId;
if(purchLineAllVersions.ItemId)
purchaseOrderTmp.Description = purchLineAllVersions.itemName();
else
purchaseOrderTmp.Description = purchLineAllVersions.Name;
//purchaseOrderTmp.NameTxt = purchLineAllVersions.GOD_dispItemText();
purchaseOrderTmp.Qty = purchLineAllVersions.PurchQty;
purchaseOrderTmp.PurchPrice = purchLineAllVersions.PurchPrice;
purchaseOrderTmp.DiscPercent = purchLineAllVersions.DiscPercent;
purchaseOrderTmp.netPrice = purchLineAllVersions.PurchPrice - ((purchLineAllVersions.PurchPrice*purchLineAllVersions.LinePercent)/100);//purchLineAllVersions.PurchPrice * ((100 - purchLineAllVersions.DiscPercent)/100);
purchaseOrderTmp.TotalPrice = purchLineAllVersions.LineAmount;//purchaseOrderTmp.netPrice * purchaseOrderTmp.Qty;
purchaseOrderTmp.insert();
}
}
private void insertCompanyDetails()
{
CompanyInfo companyInfo;
RecId company;
Common record;
CompanyImage companyImage;
LogisticsElectronicAddress logisticsElectronicAddress;
DirPartyLocation dirPartyLocation;
DataArea dataArea;
;
company = CompanyInfo::current();
companyInfo = CompanyInfo::find();
record = CompanyInfo::findRecId(company);
companyImage = CompanyImage::findByRecord(record);
select firstOnly dataArea
where dataArea.id == curext();
// PurchaseOrderHeaderTmp.CompanyBackImage = GOD_CompanyBackgroundImage::findByRecord(record).Image;
//PurchaseOrderHeaderTmp.FooterImage = GOD_CompanyFooterImage::findByRecord(record).Image;
PurchaseOrderHeaderTmp.Logo = companyImage.Image;
PurchaseOrderHeaderTmp.CompanyName = companyInfo.Name;
purchaseOrderHeaderTmp.CompanyAddess = companyInfo.postalAddress().Address;
select firstOnly dirPartyLocation
order by dirPartyLocation.RecId desc
where
dirPartyLocation.Party == companyInfo.RecId
join logisticsElectronicAddress
where
logisticsElectronicAddress.Location == dirPartyLocation.Location
&& logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Phone;
purchaseOrderHeaderTmp.CompanyTel =logisticsElectronicAddress.Locator; //companyInfo.telex();
select firstOnly dirPartyLocation
order by dirPartyLocation.RecId desc
where
dirPartyLocation.Party == companyInfo.RecId
join logisticsElectronicAddress
where
logisticsElectronicAddress.Location == dirPartyLocation.Location
&& logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Fax;
purchaseOrderHeaderTmp.companyFax = logisticsElectronicAddress.Locator;//companyInfo.teleFax();
select firstOnly dirPartyLocation
order by dirPartyLocation.RecId desc
where
dirPartyLocation.Party == companyInfo.RecId
join logisticsElectronicAddress
where
logisticsElectronicAddress.Location == dirPartyLocation.Location
&& logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Email;
purchaseOrderHeaderTmp.Companyemail = logisticsElectronicAddress.Locator;
//any2str(DirPartyTable::find(companyInfo.PartyNumber).PrimaryContactEmail);//LogisticsElectronicAddress::findElectronicAddress().;//companyInfo.email();
//logisticspostaladdress::findbylocation(companyinfo::find().postaladdress().location).CountryRegionId;
}
/// This method inserts data into the temporary table.
/// </summary>
/// <param name="_vendPurchOrderJour">
/// Vendor Purchase Order Confirmation journal record.
/// </param>
/// <remarks>
/// Inserts data into the temporary table.
/// </remarks>
private void insertIntoTempTable(VendPurchOrderJour _vendPurchOrderJour)
{
PurchTable purchTable;
PurchLine _PurchLine;
PurchLineAllVersions purchLineAllVersions;
PurchTableAllVersions purchTableAllVersions;
VendTable vendTable;
VendParameters vendParameters;
str coutryname;
DirPartyLocation dirPartyLocation;
LogisticsElectronicAddress logisticsElectronicAddress;
DataArea dataArea;
PurchtotalsForm totalsForm;
DirPartyPostalAddressView _DirPartyPostalAddressView;
;
purchTable = PurchTable::find(_vendPurchOrderJour.PurchId);
vendTable = VendTable::find(purchTable.OrderAccount);
select purchTableAllVersions where purchTableAllVersions.PurchTableVersionRecId == _vendPurchOrderJour.PurchTableVersion;
purchaseOrderHeaderTmp.OrderNo = purchTable.PurchId;
purchaseOrderHeaderTmp.vendName = purchTable.vendorName();
purchaseOrderHeaderTmp.VendorAddress = purchTable.vendorAddress();
purchaseOrderHeaderTmp.VendorRef = purchTableAllVersions.VendorRef;
purchaseOrderHeaderTmp.Attention = purchTableAllVersions.contactPersonName();
purchaseOrderHeaderTmp.Date = DateTimeUtil::date(purchTable.createdDateTime);//_vendPurchOrderJour.PurchOrderDate; //by 29224
purchaseOrderHeaderTmp.Orderer = HcmWorker::find(purchTable.WorkerPurchPlacer).name();
purchaseOrderHeaderTmp.DlvTerm = DlvTerm::find(purchTable.DlvTerm).Txt;//DlvMode::find(purchTableAllVersions.DlvMode).Txt;//DlvTerm::find(purchTableAllVersions.DlvTerm).Txt;
purchaseOrderHeaderTmp.DlvMode = DlvMode::find(purchTable.DlvMode).Txt;
purchaseOrderHeaderTmp.PaymTermId = PaymTerm::find(purchTable.Payment).Description;
purchaseOrderHeaderTmp.DeliveryName = purchTableAllVersions.DeliveryName;
purchaseOrderHeaderTmp.DeliveryDate = purchTable.DeliveryDate;
purchaseOrderHeaderTmp.DeliveryAddress = LogisticsPostalAddress::addressFromRecId(purchTableAllVersions.DeliveryPostalAddress);
purchaseOrderHeaderTmp.Currency = purchTableAllVersions.CurrencyCode;
purchaseOrderHeaderTmp.Warehouse = purchTableAllVersions.InventLocationId;
purchaseOrderHeaderTmp.Remark = purchTableAllVersions.ReqAttention;
purchaseOrderHeaderTmp.Notes = FormLetterRemarks::find(CompanyInfo::find().LanguageId,FormTextType::PurchPurchaseOrder).Txt;
// AT Add this code
Select FirstOnly * from _PurchLine where _PurchLine.PurchId == PurchTable.PurchId;
purchaseOrderHeaderTmp.God_Customer = CustTable::find(SalesTable::find(_PurchLine.GITL_SalesId).CustAccount).name();
purchaseOrderHeaderTmp.ReasonComment = ReasonTableRef::find(purchTable.ReasonTableRef).ReasonComment;
// End
//
coutryname = logisticspostaladdress::findbylocation(companyinfo::find().postaladdress().location).CountryRegionId;
purchaseOrderHeaderTmp.God_invoiceAddressto = logisticspostaladdress::findbylocation(companyinfo::find().postaladdress().location).City +' , '+coutryname;
purchaseOrderHeaderTmp.God_issuefrom = logisticspostaladdress::findbylocation(companyinfo::find().postaladdress().location).City +' , '+coutryname;
purchaseOrderHeaderTmp.God_Shippingmark = purchTable.GITL_ShippingMark;
purchaseOrderHeaderTmp.God_Port = purchTable.Port;
purchaseOrderHeaderTmp.God_site = InventSite::find(purchTable.InventSiteId).Name;
// For Vendor Fax only
select firstOnly dirPartyLocation
order by dirPartyLocation.RecId desc
where
dirPartyLocation.Party == vendTable.Party
join logisticsElectronicAddress
where
logisticsElectronicAddress.Location == dirPartyLocation.Location
&& logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Fax;
purchaseOrderHeaderTmp.God_VendorFax = logisticsElectronicAddress.GITL_CountryCodeForPhoneNumber + "-" + logisticsElectronicAddress.Locator;
select firstOnly dirPartyLocation
order by dirPartyLocation.RecId desc
where
dirPartyLocation.Party == vendTable.Party
join logisticsElectronicAddress
where
logisticsElectronicAddress.Location == dirPartyLocation.Location
&& logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Phone;
purchaseOrderHeaderTmp.God_VendorPhone = logisticsElectronicAddress.GITL_CountryCodeForPhoneNumber + logisticsElectronicAddress.Locator;
select firstOnly dirPartyLocation
order by dirPartyLocation.RecId desc
where
dirPartyLocation.Party == vendTable.Party
join logisticsElectronicAddress
where
logisticsElectronicAddress.Location == dirPartyLocation.Location
&& logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Email;
purchaseOrderHeaderTmp.God_VendorEmail = logisticsElectronicAddress.GITL_CountryCodeForPhoneNumber + logisticsElectronicAddress.Locator;
select * from _DirPartyPostalAddressView Where
_DirPartyPostalAddressView.Party == vendTable::find(purchTable.OrderAccount).Party;
purchaseOrderHeaderTmp.Street = _DirPartyPostalAddressView.Street;
purchaseOrderHeaderTmp.City = _DirPartyPostalAddressView.City;
purchaseOrderHeaderTmp.County = _DirPartyPostalAddressView.County;
purchaseOrderHeaderTmp.State = _DirPartyPostalAddressView.State;
purchaseOrderHeaderTmp.CountryRegionId = _DirPartyPostalAddressView.CountryRegionId;
purchaseOrderHeaderTmp.ZipCode = _DirPartyPostalAddressView.ZipCode;
//For Subtotal part only//
select sum(PurchQty) from purchLineAllVersions order by purchLineAllVersions.LineNumber
where purchLineAllVersions.PurchTableVersionRecId == _vendPurchOrderJour.PurchTableVersion
&& purchLineAllVersions.PurchId == _vendPurchOrderJour.PurchId;
totalsForm = PurchtotalsForm::newPurchTotalsForm(PurchTable::find(purchTable.PurchId),1);//PurchTable::find(purchTable.PurchId),2);//purchLineAllVersions.PurchQty);
totalsForm.calctotals();
purchaseOrderHeaderTmp.God_Subtotal = totalsForm.sumLinesValue();
totalsForm = PurchtotalsForm::newPurchTotalsForm(PurchTable::find(purchTable.PurchId),1);//PurchTable::find(purchTable.PurchId),2);//purchLineAllVersions.PurchQty);
totalsForm.calctotals();
purchaseOrderHeaderTmp.God_Totalvalue = totalsForm.invoiceAmountValue();
totalsForm = PurchtotalsForm::newPurchTotalsForm(PurchTable::find(purchTable.PurchId),1);
totalsForm.calctotals();
purchaseOrderHeaderTmp.God_Discount = totalsForm.endDiscValue();
purchaseOrderHeaderTmp.God_StrAmount = Global::numeralsToTxt_Number(purchaseOrderHeaderTmp.God_Totalvalue);
//
this.insertCompanyDetails();
purchaseOrderHeaderTmp.insert();
while select purchLineAllVersions order by purchLineAllVersions.LineNumber
where purchLineAllVersions.PurchTableVersionRecId == _vendPurchOrderJour.PurchTableVersion
&& purchLineAllVersions.PurchId == _vendPurchOrderJour.purchid
{
purchaseOrderTmp.clear();
purchaseOrderTmp.UOM = purchLineAllVersions.PurchUnit;
//purchaseOrderTmp.PartCode = purchLineAllVersions.GOD_partCode();
purchaseOrderTmp.ItemId = purchLineAllVersions.ItemId;
if(purchLineAllVersions.ItemId)
purchaseOrderTmp.Description = purchLineAllVersions.itemName();
else
purchaseOrderTmp.Description = purchLineAllVersions.Name;
//purchaseOrderTmp.NameTxt = purchLineAllVersions.GOD_dispItemText();
purchaseOrderTmp.Qty = purchLineAllVersions.PurchQty;
purchaseOrderTmp.PurchPrice = purchLineAllVersions.PurchPrice;
purchaseOrderTmp.DiscPercent = purchLineAllVersions.DiscPercent;
purchaseOrderTmp.netPrice = purchLineAllVersions.PurchPrice - ((purchLineAllVersions.PurchPrice*purchLineAllVersions.LinePercent)/100);//purchLineAllVersions.PurchPrice * ((100 - purchLineAllVersions.DiscPercent)/100);
purchaseOrderTmp.TotalPrice = purchLineAllVersions.LineAmount;//purchaseOrderTmp.netPrice * purchaseOrderTmp.Qty;
purchaseOrderTmp.insert();
}
}
private void insertCompanyDetails()
{
CompanyInfo companyInfo;
RecId company;
Common record;
CompanyImage companyImage;
LogisticsElectronicAddress logisticsElectronicAddress;
DirPartyLocation dirPartyLocation;
DataArea dataArea;
;
company = CompanyInfo::current();
companyInfo = CompanyInfo::find();
record = CompanyInfo::findRecId(company);
companyImage = CompanyImage::findByRecord(record);
select firstOnly dataArea
where dataArea.id == curext();
// PurchaseOrderHeaderTmp.CompanyBackImage = GOD_CompanyBackgroundImage::findByRecord(record).Image;
//PurchaseOrderHeaderTmp.FooterImage = GOD_CompanyFooterImage::findByRecord(record).Image;
PurchaseOrderHeaderTmp.Logo = companyImage.Image;
PurchaseOrderHeaderTmp.CompanyName = companyInfo.Name;
purchaseOrderHeaderTmp.CompanyAddess = companyInfo.postalAddress().Address;
select firstOnly dirPartyLocation
order by dirPartyLocation.RecId desc
where
dirPartyLocation.Party == companyInfo.RecId
join logisticsElectronicAddress
where
logisticsElectronicAddress.Location == dirPartyLocation.Location
&& logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Phone;
purchaseOrderHeaderTmp.CompanyTel =logisticsElectronicAddress.Locator; //companyInfo.telex();
select firstOnly dirPartyLocation
order by dirPartyLocation.RecId desc
where
dirPartyLocation.Party == companyInfo.RecId
join logisticsElectronicAddress
where
logisticsElectronicAddress.Location == dirPartyLocation.Location
&& logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Fax;
purchaseOrderHeaderTmp.companyFax = logisticsElectronicAddress.Locator;//companyInfo.teleFax();
select firstOnly dirPartyLocation
order by dirPartyLocation.RecId desc
where
dirPartyLocation.Party == companyInfo.RecId
join logisticsElectronicAddress
where
logisticsElectronicAddress.Location == dirPartyLocation.Location
&& logisticsElectronicAddress.Type == LogisticsElectronicAddressMethodType::Email;
purchaseOrderHeaderTmp.Companyemail = logisticsElectronicAddress.Locator;
//any2str(DirPartyTable::find(companyInfo.PartyNumber).PrimaryContactEmail);//LogisticsElectronicAddress::findElectronicAddress().;//companyInfo.email();
//logisticspostaladdress::findbylocation(companyinfo::find().postaladdress().location).CountryRegionId;
}
No comments:
Post a Comment