static void ProjectBegBalanceJournalCreate(Args _args)
{
AxProjJournalTable header = new AxProjJournalTable();
LedgerJournalTrans_Project ledgerJournalTrans_Project;
ProjBegBalJournalTrans_CostSales projBegBalJournalTrans_CostSales;
ProjBegBalJournalTrans_Fee projBegBalJournalTrans_Fee;
ProjBegBalJournalTrans_OnAcc projBegBalJournalTrans_OnAcc;
projTable projTable;
ProjFundingSource projfundingSource;
numberSequenceTable numberSequenceTable;
Voucher voucher;
Dialog dialog;
DialogField JournalName;
DialogField dfFileName;
FileName fileName;
Struct struct = new Struct();
DimensionDefault DimensionDefault;
container ledgerDimensions,offsetDimensioncon;
DimensionDynamicAccount offsetDimensions;
Args args;
container ledgerDimension,dimm;
InventDim inventDim;
ProdBOM prodBom;
HcmWorker hcmworker;
str 64 dimension,offsetdim,dept,cc,projId;
DimensionAttributeValueCombination ledgerDimensionvalueCombination;
ProjLedgerStatus ProjLedgerStatus;
BegBalProjTransTypeCost BegBalProjTransTypeCost;
//ProjTable projTable;
str journalnameid,ProjTransType,ProjCategoryId,ActivityNumber,itemid,worker,CostAmount,CostPrice,Quantity,SalesPrice,ProjSalesCurrencyId;
str projname,ProjSalesAmount,TransDate,ProjTransDate,LinePropertyId,CategoryId,ProjLedgerCostStatus,ProjTotalRevenue,CurrencyId,Txt;
//DialogRunbase dialog = super();
CommaTextIO csvFile;
container readCon;
counter icount,inserted;
inserted =0;
#File
dialog = new Dialog("Pick the file");
dfFileName = dialog.addField(extendedTypeStr("FilenameOpen"));
dialog.filenameLookupFilter(["All files", #AllFiles]);
if (dialog.run())
{
csvFile = new CommaTextIo(dfFileName.value(), 'r');
csvFile.inFieldDelimiter(',');
readCon = csvFile.read();
ttsBegin;
header.parmJournalNameid("BegBal");
//header.parmJournalType(prodJournalType::Cost);
header.save();
//progbeg
numberSequenceTable = NumberSequenceTable::find(projJournalName::find(header.projJournalTable().JournalNameId).VoucherNumberSequenceTable);
voucher = NumberSeq::newGetVoucherFromCode(numberSequenceTable.NumberSequence).voucher();
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
icount++;
projId = conPeek(readCon,1);
ProjTransType = conPeek(readCon,2);
ProjCategoryId = conPeek(readCon,3);
ActivityNumber = conPeek(readCon,4);
ItemId = conPeek(readCon,5);
Worker = conPeek(readCon,6);
CostAmount = conPeek(readCon,7);
CostPrice = conPeek(readCon,8);
Quantity = conPeek(readCon,9);
SalesPrice = conPeek(readCon,10);
ProjSalesCurrencyId = conPeek(readCon,11);
ProjSalesAmount = conPeek(readCon,12);
ProjLedgerCostStatus = conPeek(readCon,13);
TransDate = conPeek(readCon,14);
ProjTransDate = conPeek(readCon,15);
LinePropertyId = conPeek(readCon,16);
CategoryId = conPeek(readCon,17);
ProjTotalRevenue = conPeek(readCon,18);
//CategoryId = conPeek(readCon,19);
CurrencyId = conPeek(readCon,19);
Txt = conPeek(readCon,20);
struct = new Struct();
struct.add('Department',"00000024");
struct.add('costcenter', "OU_3566");
ledgerDimension = conNull();
ledgerDimension += struct.fields();
ledgerDimension += struct.fieldName(1);
ledgerDimension += struct.valueIndex(1);
ledgerDimension += struct.fieldName(2);
ledgerDimension += struct.valueIndex(2);
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
projBegBalJournalTrans_CostSales.JournalId = header.projJournalTable().Journalid;
projBegBalJournalTrans_CostSales.ProjId = projId;
projBegBalJournalTrans_CostSales.ProjTransType = str2enum(BegBalProjTransTypeCost,ProjTransType);
projBegBalJournalTrans_CostSales.ProjCategoryId = ProjCategoryId;
projBegBalJournalTrans_CostSales.ActivityNumber = ActivityNumber;
projBegBalJournalTrans_CostSales.ItemId = itemid;
hcmworker = hcmworker::findByPersonnelNumber(Worker);
projBegBalJournalTrans_CostSales.Worker = hcmworker.RecId;
projBegBalJournalTrans_CostSales.CostAmount = any2real(CostAmount);
projBegBalJournalTrans_CostSales.CostPrice = any2real(CostPrice);
projBegBalJournalTrans_CostSales.Quantity = any2real(Quantity);
projBegBalJournalTrans_CostSales.SalesPrice = any2real(SalesPrice);
projBegBalJournalTrans_CostSales.ProjSalesCurrencyId = ProjSalesCurrencyId;
projBegBalJournalTrans_CostSales.ProjSalesAmount = any2real(ProjSalesAmount);
projBegBalJournalTrans_CostSales.ProjLedgerCostStatus = str2enum(ProjLedgerStatus,ProjLedgerCostStatus);
projBegBalJournalTrans_CostSales.Voucher = voucher;
projBegBalJournalTrans_CostSales.TransDate = str2Date(TransDate,213);
projBegBalJournalTrans_CostSales.DefaultDimension = DimensionDefault;
projBegBalJournalTrans_CostSales.ProjTransDate = str2Date(ProjTransDate,213);
projBegBalJournalTrans_CostSales.LinePropertyId = LinePropertyId;
projTable = projTable::find(projId);
select projfundingSource where projfundingSource.ContractId == projTable.ProjInvoiceProjId;
projBegBalJournalTrans_Fee.JournalId = header.projJournalTable().Journalid;
projBegBalJournalTrans_Fee.DefaultDimension = DimensionDefault;
projBegBalJournalTrans_Fee.ProjId = projId;
projBegBalJournalTrans_Fee.ProjTransDate = str2Date(ProjTransDate,213);
projBegBalJournalTrans_Fee.CategoryId = CategoryId;
projBegBalJournalTrans_Fee.Worker = hcmworker.RecId;
projBegBalJournalTrans_Fee.ProjSalesAmount = any2real(ProjSalesAmount);
projBegBalJournalTrans_Fee.ProjSalesCurrencyId = ProjSalesCurrencyId;
projBegBalJournalTrans_Fee.ProjTotalRevenue = any2real(ProjTotalRevenue);
projBegBalJournalTrans_Fee.Voucher = voucher;
projBegBalJournalTrans_Fee.TransDate = str2Date(TransDate,213);
projBegBalJournalTrans_Fee.LinePropertyId = LinePropertyId;
ProjName = projTable::find(projId).Name;
projBegBalJournalTrans_Fee.ProjFundingSource = projfundingSource.RecId;//projTable::find("10001").RecId;
ProjBegBalJournalTrans_OnAcc.JournalId = header.projJournalTable().Journalid;
ProjBegBalJournalTrans_OnAcc.ProjId = projId;
ProjBegBalJournalTrans_OnAcc.ProjTransDate = str2Date(ProjTransDate,213);
ProjBegBalJournalTrans_OnAcc.SalesPrice = str2num(SalesPrice);
ProjBegBalJournalTrans_OnAcc.CurrencyId = CurrencyId;
ProjBegBalJournalTrans_OnAcc.ProjSalesAmount = str2num(ProjSalesAmount);
ProjBegBalJournalTrans_OnAcc.DefaultDimension = DimensionDefault;
ProjBegBalJournalTrans_OnAcc.Voucher = voucher;
ProjBegBalJournalTrans_OnAcc.Txt = Txt;
ProjBegBalJournalTrans_OnAcc.ProjFundingSource = projfundingSource.RecId;
projBegBalJournalTrans_CostSales.insert();
projBegBalJournalTrans_Fee.insert();
ProjBegBalJournalTrans_OnAcc.insert();
}
}
//journalTable.insert();
ttsCommit;
}
args = new Args();
args.record(ProjJournalTable::find(header.ProjJournalTable().Journalid ));
new MenuFunction(MenuItemDisplayStr(ProjjournalTable),MenuItemType::Display).run(args);
}
{
AxProjJournalTable header = new AxProjJournalTable();
LedgerJournalTrans_Project ledgerJournalTrans_Project;
ProjBegBalJournalTrans_CostSales projBegBalJournalTrans_CostSales;
ProjBegBalJournalTrans_Fee projBegBalJournalTrans_Fee;
ProjBegBalJournalTrans_OnAcc projBegBalJournalTrans_OnAcc;
projTable projTable;
ProjFundingSource projfundingSource;
numberSequenceTable numberSequenceTable;
Voucher voucher;
Dialog dialog;
DialogField JournalName;
DialogField dfFileName;
FileName fileName;
Struct struct = new Struct();
DimensionDefault DimensionDefault;
container ledgerDimensions,offsetDimensioncon;
DimensionDynamicAccount offsetDimensions;
Args args;
container ledgerDimension,dimm;
InventDim inventDim;
ProdBOM prodBom;
HcmWorker hcmworker;
str 64 dimension,offsetdim,dept,cc,projId;
DimensionAttributeValueCombination ledgerDimensionvalueCombination;
ProjLedgerStatus ProjLedgerStatus;
BegBalProjTransTypeCost BegBalProjTransTypeCost;
//ProjTable projTable;
str journalnameid,ProjTransType,ProjCategoryId,ActivityNumber,itemid,worker,CostAmount,CostPrice,Quantity,SalesPrice,ProjSalesCurrencyId;
str projname,ProjSalesAmount,TransDate,ProjTransDate,LinePropertyId,CategoryId,ProjLedgerCostStatus,ProjTotalRevenue,CurrencyId,Txt;
//DialogRunbase dialog = super();
CommaTextIO csvFile;
container readCon;
counter icount,inserted;
inserted =0;
#File
dialog = new Dialog("Pick the file");
dfFileName = dialog.addField(extendedTypeStr("FilenameOpen"));
dialog.filenameLookupFilter(["All files", #AllFiles]);
if (dialog.run())
{
csvFile = new CommaTextIo(dfFileName.value(), 'r');
csvFile.inFieldDelimiter(',');
readCon = csvFile.read();
ttsBegin;
header.parmJournalNameid("BegBal");
//header.parmJournalType(prodJournalType::Cost);
header.save();
//progbeg
numberSequenceTable = NumberSequenceTable::find(projJournalName::find(header.projJournalTable().JournalNameId).VoucherNumberSequenceTable);
voucher = NumberSeq::newGetVoucherFromCode(numberSequenceTable.NumberSequence).voucher();
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
icount++;
projId = conPeek(readCon,1);
ProjTransType = conPeek(readCon,2);
ProjCategoryId = conPeek(readCon,3);
ActivityNumber = conPeek(readCon,4);
ItemId = conPeek(readCon,5);
Worker = conPeek(readCon,6);
CostAmount = conPeek(readCon,7);
CostPrice = conPeek(readCon,8);
Quantity = conPeek(readCon,9);
SalesPrice = conPeek(readCon,10);
ProjSalesCurrencyId = conPeek(readCon,11);
ProjSalesAmount = conPeek(readCon,12);
ProjLedgerCostStatus = conPeek(readCon,13);
TransDate = conPeek(readCon,14);
ProjTransDate = conPeek(readCon,15);
LinePropertyId = conPeek(readCon,16);
CategoryId = conPeek(readCon,17);
ProjTotalRevenue = conPeek(readCon,18);
//CategoryId = conPeek(readCon,19);
CurrencyId = conPeek(readCon,19);
Txt = conPeek(readCon,20);
struct = new Struct();
struct.add('Department',"00000024");
struct.add('costcenter', "OU_3566");
ledgerDimension = conNull();
ledgerDimension += struct.fields();
ledgerDimension += struct.fieldName(1);
ledgerDimension += struct.valueIndex(1);
ledgerDimension += struct.fieldName(2);
ledgerDimension += struct.valueIndex(2);
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
projBegBalJournalTrans_CostSales.JournalId = header.projJournalTable().Journalid;
projBegBalJournalTrans_CostSales.ProjId = projId;
projBegBalJournalTrans_CostSales.ProjTransType = str2enum(BegBalProjTransTypeCost,ProjTransType);
projBegBalJournalTrans_CostSales.ProjCategoryId = ProjCategoryId;
projBegBalJournalTrans_CostSales.ActivityNumber = ActivityNumber;
projBegBalJournalTrans_CostSales.ItemId = itemid;
hcmworker = hcmworker::findByPersonnelNumber(Worker);
projBegBalJournalTrans_CostSales.Worker = hcmworker.RecId;
projBegBalJournalTrans_CostSales.CostAmount = any2real(CostAmount);
projBegBalJournalTrans_CostSales.CostPrice = any2real(CostPrice);
projBegBalJournalTrans_CostSales.Quantity = any2real(Quantity);
projBegBalJournalTrans_CostSales.SalesPrice = any2real(SalesPrice);
projBegBalJournalTrans_CostSales.ProjSalesCurrencyId = ProjSalesCurrencyId;
projBegBalJournalTrans_CostSales.ProjSalesAmount = any2real(ProjSalesAmount);
projBegBalJournalTrans_CostSales.ProjLedgerCostStatus = str2enum(ProjLedgerStatus,ProjLedgerCostStatus);
projBegBalJournalTrans_CostSales.Voucher = voucher;
projBegBalJournalTrans_CostSales.TransDate = str2Date(TransDate,213);
projBegBalJournalTrans_CostSales.DefaultDimension = DimensionDefault;
projBegBalJournalTrans_CostSales.ProjTransDate = str2Date(ProjTransDate,213);
projBegBalJournalTrans_CostSales.LinePropertyId = LinePropertyId;
projTable = projTable::find(projId);
select projfundingSource where projfundingSource.ContractId == projTable.ProjInvoiceProjId;
projBegBalJournalTrans_Fee.JournalId = header.projJournalTable().Journalid;
projBegBalJournalTrans_Fee.DefaultDimension = DimensionDefault;
projBegBalJournalTrans_Fee.ProjId = projId;
projBegBalJournalTrans_Fee.ProjTransDate = str2Date(ProjTransDate,213);
projBegBalJournalTrans_Fee.CategoryId = CategoryId;
projBegBalJournalTrans_Fee.Worker = hcmworker.RecId;
projBegBalJournalTrans_Fee.ProjSalesAmount = any2real(ProjSalesAmount);
projBegBalJournalTrans_Fee.ProjSalesCurrencyId = ProjSalesCurrencyId;
projBegBalJournalTrans_Fee.ProjTotalRevenue = any2real(ProjTotalRevenue);
projBegBalJournalTrans_Fee.Voucher = voucher;
projBegBalJournalTrans_Fee.TransDate = str2Date(TransDate,213);
projBegBalJournalTrans_Fee.LinePropertyId = LinePropertyId;
ProjName = projTable::find(projId).Name;
projBegBalJournalTrans_Fee.ProjFundingSource = projfundingSource.RecId;//projTable::find("10001").RecId;
ProjBegBalJournalTrans_OnAcc.JournalId = header.projJournalTable().Journalid;
ProjBegBalJournalTrans_OnAcc.ProjId = projId;
ProjBegBalJournalTrans_OnAcc.ProjTransDate = str2Date(ProjTransDate,213);
ProjBegBalJournalTrans_OnAcc.SalesPrice = str2num(SalesPrice);
ProjBegBalJournalTrans_OnAcc.CurrencyId = CurrencyId;
ProjBegBalJournalTrans_OnAcc.ProjSalesAmount = str2num(ProjSalesAmount);
ProjBegBalJournalTrans_OnAcc.DefaultDimension = DimensionDefault;
ProjBegBalJournalTrans_OnAcc.Voucher = voucher;
ProjBegBalJournalTrans_OnAcc.Txt = Txt;
ProjBegBalJournalTrans_OnAcc.ProjFundingSource = projfundingSource.RecId;
projBegBalJournalTrans_CostSales.insert();
projBegBalJournalTrans_Fee.insert();
ProjBegBalJournalTrans_OnAcc.insert();
}
}
//journalTable.insert();
ttsCommit;
}
args = new Args();
args.record(ProjJournalTable::find(header.ProjJournalTable().Journalid ));
new MenuFunction(MenuItemDisplayStr(ProjjournalTable),MenuItemType::Display).run(args);
}
No comments:
Post a Comment