Project Integrations
Project Contract
class AIFProjectService
{
}
[SysEntryPointAttribute(true), AifCollectionTypeAttribute('_Project',Types::Class)]
public void CreateAndUpdate_ProjectContract (AIFProjectContract _Project)
{
ProjFundingSource projFundingSource;
str ErrorMessage;
projInvoiceTable projInvoiceTable;
ProjFundingRule projFundingRule;
ProjTable ProjTable;
ProjFundingRuleAllocation ProjFundingRuleAllocation;
;
ErrorMessage = this.ValidateProjcet(_Project);
if(ErrorMessage != "")
{
throw Error(strFmtLB(ErrorMessage));
}
try
{
changeCompany (_Project.Company())
{
ttsBegin;
// Projcet Details
projinvoiceTable = projinvoiceTable::find(_Project.ProjectContractId(), true);
if(!projinvoiceTable.RecId)
{
projinvoiceTable.ProjInvoiceProjId = _Project.ProjectContractId();
projInvoiceTable.CurrencyId = _Project.ContractCurrencyId();
projinvoiceTable.Description = _Project.ContractDescription();
projInvoiceTable.insert();
}
else
{
while select forUpdate projinvoiceTable where projinvoiceTable.ProjInvoiceProjId == _Project.ProjectContractId()
{
// Projcet Details update
projinvoiceTable.ProjInvoiceProjId = _Project.ProjectContractId();
projInvoiceTable.CurrencyId = _Project.ContractCurrencyId();
projinvoiceTable.Description = _Project.ContractDescription();
projInvoiceTable.update();
}
}
//projFundingSource Details
projFundingSource = projFundingSource::findCustAccount(_Project.FundingSourceId(),true);
if(!projFundingSource.RecId)
{
projFundingSource.ContractId = projInvoiceTable.ProjInvoiceProjId;
projFundingSource.CustAccount = _Project.CustomerAccountNum();
projFundingSource.FundingType = ProjFundingType::Customer;
projFundingSource.PaymentTermsId = _Project.PaymentTermsId();
projFundingSource.PaymentscheduleId = _Project.PaymentscheduleId();
projFundingSource.editProjFunder(true,projFundingSource.CustAccount);
projFundingSource.insert();
}
else
{
while select forUpdate projFundingSource where projFundingSource.FundingSourceId == _Project.FundingSourceId()
projFundingSource.ContractId = projInvoiceTable.ProjInvoiceProjId;
projFundingSource.CustAccount = _Project.CustomerAccountNum();
projFundingSource.FundingType = ProjFundingType::Customer;
projFundingSource.PaymentTermsId = _Project.PaymentTermsId();
projFundingSource.PaymentscheduleId = _Project.PaymentscheduleId();
projFundingSource.editProjFunder(true,projFundingSource.CustAccount);
projFundingSource.update();
}
if(!ProjFundingRule.RecId)
{
ProjFundingRule.Priority = _Project.FundingRulesPriority();
ProjFundingRule.ContractId = projInvoiceTable.ProjInvoiceProjId;
ProjFundingRule.ItemId = _Project.FundingRulesItemIdNumber();
ProjFundingRule.ProjId = _Project.ProjId();
projFundingRule.CategoryGroupId = _Project.FundingRulesCategoryGroupId();
projFundingRule.CategoryId = _Project.FundingRulesCategoryId();
projFundingRule.StartDate = _Project.startDate();
projFundingRule.EndDate = _Project.EndDate();
projFundingRule.insert();
}
else
{
while select forUpdate ProjFundingRule where ProjFundingRule.ContractId == _Project.ProjectContractId()
ProjFundingRule.Priority = _Project.FundingRulesPriority();
ProjFundingRule.ContractId = projInvoiceTable.ProjInvoiceProjId;
ProjFundingRule.ProjId = _Project.ProjId();
ProjFundingRule.ItemId = _Project.FundingRulesItemIdNumber();
projFundingRule.CategoryGroupId = _Project.FundingRulesCategoryGroupId();
projFundingRule.CategoryId = _Project.FundingRulesCategoryId();
projFundingRule.StartDate = _Project.startDate();
projFundingRule.EndDate = _Project.EndDate();
projFundingRule.update();
}
if(!ProjFundingRuleAllocation.RecId)
{
ProjFundingRuleAllocation.AllocateRounding = NoYes::Yes;
ProjFundingRuleAllocation.FundingSource = projFundingSource.RecId;
ProjFundingRuleAllocation.AllocationPercentage = _Project.AllocationPercentage();
ProjFundingRuleAllocation.FundingRule = projFundingRule.RecId;
ProjFundingRuleAllocation.insert();
}
else
{
ProjFundingRuleAllocation.AllocateRounding = NoYes::Yes;
ProjFundingRuleAllocation.FundingSource = projFundingSource.RecId;
ProjFundingRuleAllocation.AllocationPercentage = _Project.AllocationPercentage();
ProjFundingRuleAllocation.FundingRule = projFundingRule.RecId;
ProjFundingRuleAllocation.update();
}
ttsCommit;
}
}
catch (Exception::Error)
{
ttsAbort;
throw Exception::Error;
}
}
Project
[SysEntryPointAttribute(true), AifCollectionTypeAttribute('__Project',Types::Class)]
public void CreateAndUpdate_Project(AIFProjectContract _Project)
{
ProjTable projTable;
str ErrorMessage;
CustTable custTable;
DirPartyTable dirPartyTable;
HcmWorker hcmWorker;
DirPerson dirPerson;
ProjinvoiceTable projinvoiceTable;
try
changeCompany (_Project.Company())
{
ttsBegin;
projTable = ProjTable::find(_Project.ProjId(),true);
if(!ProjTable.ProjId)
{
projTable.ProjId = _Project.ProjId();
projTable.Name = _Project.projectName();
projTable.ProjGroupId = _Project.ProjectGroupId();
projTable.ProjInvoiceProjId = _Project.ProjectContractId();
projTable.CustAccount = _Project.CustomerAccountNum();
projTable.Email = _Project.Email();
projTable.StartDate = _Project.StartDate();
projTable.EndDate = _Project.EndDate();
projTable.ProjectedStartDate = _Project.ProjectedStartDate();
projTable.ProjectedEndDate = _Project.ProjectedEndDate();
projTable.ExtensionDate = _Project.ExtensionDate();
projTable.Created = _Project.Created();
projTable.WorkerResponsible = hcmWorker::findByPersonnelNumber(_Project.ProjectManager()).RecId;
hcmWorker.RecId = projTable.WorkerResponsible;
projTable.WorkerResponsibleFinancial = hcmWorker::findByPersonnelNumber(_Project.ProjectController()).RecId;
hcmWorker.RecId = projTable.WorkerResponsibleFinancial;
projTable.WorkerResponsibleSales = hcmWorker::findByPersonnelNumber(_Project.SalesManager()).RecId;
hcmWorker.RecId = projTable.WorkerResponsibleSales;
projTable.insert();
}
else
{
projTable.ProjId = _Project.ProjId();
projTable.Name = _Project.projectName();
projTable.ProjGroupId = _Project.ProjectGroupId();
projTable.ProjInvoiceProjId = _Project.ProjectContractId();
projTable.CustAccount = _Project.CustomerAccountNum();
projTable.Email = _Project.Email();
projTable.StartDate = _Project.StartDate();
projTable.EndDate = _Project.EndDate();
projTable.ProjectedStartDate = _Project.ProjectedStartDate();
projTable.ProjectedEndDate = _Project.ProjectedEndDate();
projTable.ExtensionDate = _Project.ExtensionDate();
projTable.Created = _Project.Created();
projTable.WorkerResponsible = hcmWorker::findByPersonnelNumber(_Project.ProjectManager()).RecId;
hcmWorker.RecId = projTable.WorkerResponsible;
projTable.WorkerResponsibleFinancial = hcmWorker::findByPersonnelNumber(_Project.ProjectController()).RecId;
hcmWorker.RecId = projTable.WorkerResponsibleFinancial;
projTable.WorkerResponsibleSales = hcmWorker::findByPersonnelNumber(_Project.SalesManager()).RecId;
hcmWorker.RecId = projTable.WorkerResponsibleSales;
projTable.update();
}
ttsCommit;
}
catch (Exception::Error)
{
ttsAbort;
throw Exception::Error;
}
}
Colling for Job
static void Job_Project(Args _args)
{
AIFProjectContract _AIFProjcetContract = new AIFProjectContract();
AIFProjectService _AIFProjcetService = new AIFProjectService();
_AIFProjcetContract.ProjectContractId("");
_AIFProjcetContract.CustomerAccountNum("");
_AIFProjcetContract.ProjId("");
_AIFProjcetContract.FundingRulesItemIdNumber("");
_AIFProjcetContract.ContractDescription("pramod ");
_AIFProjcetContract.projectName("pramod ");
_AIFProjcetContract.ProjectManager("");
_AIFProjcetContract.ProjectController("");
_AIFProjcetContract.SalesManager("");
_AIFProjcetContract.Email("pramod@gmail.com");
_AIFProjcetContract.PaymentscheduleId("");
_AIFProjcetContract.ContractCurrencyId("SAR");
_AIFProjcetContract.LanguageId("EN");
_AIFProjcetContract.PaymentTermsId("");
_AIFProjcetContract.FundingSourceId("");
_AIFProjcetContract.startDate(1\1\2017);
_AIFProjcetContract.EndDate(2\8\2019);
_AIFProjcetContract.ProjectedStartDate(1\3\2017);
_AIFProjcetContract.ProjectedEndDate(3\6\2020);
_AIFProjcetContract.ExtensionDate(3\3\2023);
_AIFProjcetContract.Created(9\3\2017);
_AIFProjcetContract.ProjectGroupId("T & M-P&L");
_AIFProjcetContract.FundingRulesPriority(1);
_AIFProjcetContract.FundingRulesCategoryGroupId("sdss");
_AIFProjcetContract.FundingRulesCategoryId("iuyss");
_AIFProjcetContract.AllocationPercentage(100);
_AIFProjcetContract.Company("");
_AIFProjcetService.CreateAndUpdate_ProjectContract(_AIFProjcetContract);
_AIFProjcetService.CreateAndUpdate_Project(_AIFProjcetContract);
info(_AIFProjcetContract.ProjId());
}
Project Contract
class AIFProjectService
{
}
[SysEntryPointAttribute(true), AifCollectionTypeAttribute('_Project',Types::Class)]
public void CreateAndUpdate_ProjectContract (AIFProjectContract _Project)
{
ProjFundingSource projFundingSource;
str ErrorMessage;
projInvoiceTable projInvoiceTable;
ProjFundingRule projFundingRule;
ProjTable ProjTable;
ProjFundingRuleAllocation ProjFundingRuleAllocation;
;
ErrorMessage = this.ValidateProjcet(_Project);
if(ErrorMessage != "")
{
throw Error(strFmtLB(ErrorMessage));
}
try
{
changeCompany (_Project.Company())
{
ttsBegin;
// Projcet Details
projinvoiceTable = projinvoiceTable::find(_Project.ProjectContractId(), true);
if(!projinvoiceTable.RecId)
{
projinvoiceTable.ProjInvoiceProjId = _Project.ProjectContractId();
projInvoiceTable.CurrencyId = _Project.ContractCurrencyId();
projinvoiceTable.Description = _Project.ContractDescription();
projInvoiceTable.insert();
}
else
{
while select forUpdate projinvoiceTable where projinvoiceTable.ProjInvoiceProjId == _Project.ProjectContractId()
{
// Projcet Details update
projinvoiceTable.ProjInvoiceProjId = _Project.ProjectContractId();
projInvoiceTable.CurrencyId = _Project.ContractCurrencyId();
projinvoiceTable.Description = _Project.ContractDescription();
projInvoiceTable.update();
}
}
//projFundingSource Details
projFundingSource = projFundingSource::findCustAccount(_Project.FundingSourceId(),true);
if(!projFundingSource.RecId)
{
projFundingSource.ContractId = projInvoiceTable.ProjInvoiceProjId;
projFundingSource.CustAccount = _Project.CustomerAccountNum();
projFundingSource.FundingType = ProjFundingType::Customer;
projFundingSource.PaymentTermsId = _Project.PaymentTermsId();
projFundingSource.PaymentscheduleId = _Project.PaymentscheduleId();
projFundingSource.editProjFunder(true,projFundingSource.CustAccount);
projFundingSource.insert();
}
else
{
while select forUpdate projFundingSource where projFundingSource.FundingSourceId == _Project.FundingSourceId()
projFundingSource.ContractId = projInvoiceTable.ProjInvoiceProjId;
projFundingSource.CustAccount = _Project.CustomerAccountNum();
projFundingSource.FundingType = ProjFundingType::Customer;
projFundingSource.PaymentTermsId = _Project.PaymentTermsId();
projFundingSource.PaymentscheduleId = _Project.PaymentscheduleId();
projFundingSource.editProjFunder(true,projFundingSource.CustAccount);
projFundingSource.update();
}
if(!ProjFundingRule.RecId)
{
ProjFundingRule.Priority = _Project.FundingRulesPriority();
ProjFundingRule.ContractId = projInvoiceTable.ProjInvoiceProjId;
ProjFundingRule.ItemId = _Project.FundingRulesItemIdNumber();
ProjFundingRule.ProjId = _Project.ProjId();
projFundingRule.CategoryGroupId = _Project.FundingRulesCategoryGroupId();
projFundingRule.CategoryId = _Project.FundingRulesCategoryId();
projFundingRule.StartDate = _Project.startDate();
projFundingRule.EndDate = _Project.EndDate();
projFundingRule.insert();
}
else
{
while select forUpdate ProjFundingRule where ProjFundingRule.ContractId == _Project.ProjectContractId()
ProjFundingRule.Priority = _Project.FundingRulesPriority();
ProjFundingRule.ContractId = projInvoiceTable.ProjInvoiceProjId;
ProjFundingRule.ProjId = _Project.ProjId();
ProjFundingRule.ItemId = _Project.FundingRulesItemIdNumber();
projFundingRule.CategoryGroupId = _Project.FundingRulesCategoryGroupId();
projFundingRule.CategoryId = _Project.FundingRulesCategoryId();
projFundingRule.StartDate = _Project.startDate();
projFundingRule.EndDate = _Project.EndDate();
projFundingRule.update();
}
if(!ProjFundingRuleAllocation.RecId)
{
ProjFundingRuleAllocation.AllocateRounding = NoYes::Yes;
ProjFundingRuleAllocation.FundingSource = projFundingSource.RecId;
ProjFundingRuleAllocation.AllocationPercentage = _Project.AllocationPercentage();
ProjFundingRuleAllocation.FundingRule = projFundingRule.RecId;
ProjFundingRuleAllocation.insert();
}
else
{
ProjFundingRuleAllocation.AllocateRounding = NoYes::Yes;
ProjFundingRuleAllocation.FundingSource = projFundingSource.RecId;
ProjFundingRuleAllocation.AllocationPercentage = _Project.AllocationPercentage();
ProjFundingRuleAllocation.FundingRule = projFundingRule.RecId;
ProjFundingRuleAllocation.update();
}
ttsCommit;
}
}
catch (Exception::Error)
{
ttsAbort;
throw Exception::Error;
}
}
Project
[SysEntryPointAttribute(true), AifCollectionTypeAttribute('__Project',Types::Class)]
public void CreateAndUpdate_Project(AIFProjectContract _Project)
{
ProjTable projTable;
str ErrorMessage;
CustTable custTable;
DirPartyTable dirPartyTable;
HcmWorker hcmWorker;
DirPerson dirPerson;
ProjinvoiceTable projinvoiceTable;
try
changeCompany (_Project.Company())
{
ttsBegin;
projTable = ProjTable::find(_Project.ProjId(),true);
if(!ProjTable.ProjId)
{
projTable.ProjId = _Project.ProjId();
projTable.Name = _Project.projectName();
projTable.ProjGroupId = _Project.ProjectGroupId();
projTable.ProjInvoiceProjId = _Project.ProjectContractId();
projTable.CustAccount = _Project.CustomerAccountNum();
projTable.Email = _Project.Email();
projTable.StartDate = _Project.StartDate();
projTable.EndDate = _Project.EndDate();
projTable.ProjectedStartDate = _Project.ProjectedStartDate();
projTable.ProjectedEndDate = _Project.ProjectedEndDate();
projTable.ExtensionDate = _Project.ExtensionDate();
projTable.Created = _Project.Created();
projTable.WorkerResponsible = hcmWorker::findByPersonnelNumber(_Project.ProjectManager()).RecId;
hcmWorker.RecId = projTable.WorkerResponsible;
projTable.WorkerResponsibleFinancial = hcmWorker::findByPersonnelNumber(_Project.ProjectController()).RecId;
hcmWorker.RecId = projTable.WorkerResponsibleFinancial;
projTable.WorkerResponsibleSales = hcmWorker::findByPersonnelNumber(_Project.SalesManager()).RecId;
hcmWorker.RecId = projTable.WorkerResponsibleSales;
projTable.insert();
}
else
{
projTable.ProjId = _Project.ProjId();
projTable.Name = _Project.projectName();
projTable.ProjGroupId = _Project.ProjectGroupId();
projTable.ProjInvoiceProjId = _Project.ProjectContractId();
projTable.CustAccount = _Project.CustomerAccountNum();
projTable.Email = _Project.Email();
projTable.StartDate = _Project.StartDate();
projTable.EndDate = _Project.EndDate();
projTable.ProjectedStartDate = _Project.ProjectedStartDate();
projTable.ProjectedEndDate = _Project.ProjectedEndDate();
projTable.ExtensionDate = _Project.ExtensionDate();
projTable.Created = _Project.Created();
projTable.WorkerResponsible = hcmWorker::findByPersonnelNumber(_Project.ProjectManager()).RecId;
hcmWorker.RecId = projTable.WorkerResponsible;
projTable.WorkerResponsibleFinancial = hcmWorker::findByPersonnelNumber(_Project.ProjectController()).RecId;
hcmWorker.RecId = projTable.WorkerResponsibleFinancial;
projTable.WorkerResponsibleSales = hcmWorker::findByPersonnelNumber(_Project.SalesManager()).RecId;
hcmWorker.RecId = projTable.WorkerResponsibleSales;
projTable.update();
}
ttsCommit;
}
catch (Exception::Error)
{
ttsAbort;
throw Exception::Error;
}
}
Validate
private str ValidateProjcet(AIFProjectContract _Projcet)
{
boolean valid = true;
str Message = "";
if(_Projcet.ProjectContractId() == "")
{
Message = Message + "ProjInvoiceProjId number is required!\n";
valid = false;
}
if(!custTable::exist(_Projcet.CustomerAccountNum()))
{
Message = Message + "AccountNum does not exits!\n";
valid = false;
}
if(_Projcet.ProjId() == "")
{
Message = Message + "ProjId is required!\n";
valid = false;
}
if(_Projcet.projectName() == "")
{
Message = Message + "Name is required!\n";
valid = false;
}
if(_Projcet.ProjectContractId() == "")
{
Message = Message + "Project Contract Id is required!\n";
valid = false;
}
return Message;
}
Colling for Job
static void Job_Project(Args _args)
{
AIFProjectContract _AIFProjcetContract = new AIFProjectContract();
AIFProjectService _AIFProjcetService = new AIFProjectService();
_AIFProjcetContract.ProjectContractId("");
_AIFProjcetContract.CustomerAccountNum("");
_AIFProjcetContract.ProjId("");
_AIFProjcetContract.FundingRulesItemIdNumber("");
_AIFProjcetContract.ContractDescription("pramod ");
_AIFProjcetContract.projectName("pramod ");
_AIFProjcetContract.ProjectManager("");
_AIFProjcetContract.ProjectController("");
_AIFProjcetContract.SalesManager("");
_AIFProjcetContract.Email("pramod@gmail.com");
_AIFProjcetContract.PaymentscheduleId("");
_AIFProjcetContract.ContractCurrencyId("SAR");
_AIFProjcetContract.LanguageId("EN");
_AIFProjcetContract.PaymentTermsId("");
_AIFProjcetContract.FundingSourceId("");
_AIFProjcetContract.startDate(1\1\2017);
_AIFProjcetContract.EndDate(2\8\2019);
_AIFProjcetContract.ProjectedStartDate(1\3\2017);
_AIFProjcetContract.ProjectedEndDate(3\6\2020);
_AIFProjcetContract.ExtensionDate(3\3\2023);
_AIFProjcetContract.Created(9\3\2017);
_AIFProjcetContract.ProjectGroupId("T & M-P&L");
_AIFProjcetContract.FundingRulesPriority(1);
_AIFProjcetContract.FundingRulesCategoryGroupId("sdss");
_AIFProjcetContract.FundingRulesCategoryId("iuyss");
_AIFProjcetContract.AllocationPercentage(100);
_AIFProjcetContract.Company("");
_AIFProjcetService.CreateAndUpdate_ProjectContract(_AIFProjcetContract);
_AIFProjcetService.CreateAndUpdate_Project(_AIFProjcetContract);
info(_AIFProjcetContract.ProjId());
}
No comments:
Post a Comment