static void ProjectExpenseJournalCreate(Args _args)
{
AxLedgerJournalTable header = new AxLedgerJournalTable();
AxLedgerJournalTrans trans = new AxLedgerJournalTrans();
LedgerJournalTrans_Project ledgerJournalTrans_Project;
LedgerJournalTable jourTable;
LedgerJournalTrans jourTrans;
Dialog dialog;
DialogField JournalName,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;
DimensionAttributeValueCombination ledgerDimensionvalueCombination;
ProjTable projTable;
str journalnameid,ledgeraccount;
//DialogRunbase dialog = super();
NumberSequenceTable numberSequenceTable;
Voucher voucher;
int inserted =0,icount;
CommaTextIO csvFile;
container readCon;
str transdate,qty,costprice,ProjTransDate,salesprice,Txt,currencyid,worker,CategoryId,linepropertyid;
str ActivityNumber,SalesCurrencyId;
str 60 ProjId;
#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.parmJournalName("PrjJrn");
header.parmJournalType(ledgerJournalType::Cost);
header.save();
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
icount++;
projid = conPeek(readCon,1);
transdate = conPeek(readCon,2);
qty = conPeek(readCon,3);
costprice = conPeek(readCon,4);
salesprice = conPeek(readCon,5);
Txt = conPeek(readCon,6);
currencyid = conPeek(readCon,7);
worker = conPeek(readCon,8);
CategoryId = conPeek(readCon,9);
linepropertyid = conPeek(readCon,10);
SalesCurrencyId = conPeek(readCon,11);
ledgeraccount = conPeek(readCon,12);
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);
jourTable = LedgerJournalTable::find(header.LedgerJournalTable().JournalNum);
jourTrans.JournalNum = header.LedgerJournalTable().JournalNum;
jourTrans.DefaultDimension = DimensionDefault;
jourTrans.AccountType = LedgerJournalACTypE::Project;
numberSequenceTable = NumberSequenceTable::find(LedgerJournalName::find(header.LedgerJournalTable().JournalName).NumberSequenceTable);
voucher = NumberSeq::newGetVoucherFromCode(numberSequenceTable.NumberSequence).voucher();
select firstonly projTable join RecId from ledgerDimensionvalueCombination where ledgerDimensionvalueCombination.DisplayValue == projTable.ProjId && projTable.ProjId == projid;//ledgerDimensionvalueCombination
jourTrans.Voucher = voucher;
jourTrans.CurrencyCode = currencyid;
jourTrans.Qty = str2num(qty);
jourTrans.TransDate = str2Date(TransDate,213);
offsetdim = strFmt("%1,%1",ledgeraccount);
offsetDimensioncon = str2con(offsetdim);
jourTrans.ledgerDimension =ledgerDimensionvalueCombination.recid;
jourTrans.OffsetAccountType = LedgerJournalACType::Ledger;
jourTrans.ExchRate = 100;
jourTrans.insert();
ledgerJournalTrans_Project.ActivityNumber = ActivityNumber;
ledgerJournalTrans_Project.CategoryId = CategoryId;
ledgerJournalTrans_Project.Qty = str2num(qty);
ledgerJournalTrans_Project.CostPrice = str2num(CostPrice);
ledgerJournalTrans_Project.SalesPrice = str2num(SalesPrice);
ledgerJournalTrans_Project.SalesCurrencyId = SalesCurrencyId;
ledgerJournalTrans_Project.LinePropertyId = LinePropertyId;
ledgerJournalTrans_Project.ProjId = ProjId;
ledgerJournalTrans_Project.RefRecId = jourtrans.RecId;
hcmworker = hcmworker::findByPersonnelNumber(worker);
ledgerJournalTrans_Project.Worker = hcmworker.RecId;
ledgerJournalTrans_Project.insert();
ledgerJournalTrans_Project.clear();
jourtrans.clear();
}
}
ttsCommit;
}
}
{
AxLedgerJournalTable header = new AxLedgerJournalTable();
AxLedgerJournalTrans trans = new AxLedgerJournalTrans();
LedgerJournalTrans_Project ledgerJournalTrans_Project;
LedgerJournalTable jourTable;
LedgerJournalTrans jourTrans;
Dialog dialog;
DialogField JournalName,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;
DimensionAttributeValueCombination ledgerDimensionvalueCombination;
ProjTable projTable;
str journalnameid,ledgeraccount;
//DialogRunbase dialog = super();
NumberSequenceTable numberSequenceTable;
Voucher voucher;
int inserted =0,icount;
CommaTextIO csvFile;
container readCon;
str transdate,qty,costprice,ProjTransDate,salesprice,Txt,currencyid,worker,CategoryId,linepropertyid;
str ActivityNumber,SalesCurrencyId;
str 60 ProjId;
#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.parmJournalName("PrjJrn");
header.parmJournalType(ledgerJournalType::Cost);
header.save();
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
icount++;
projid = conPeek(readCon,1);
transdate = conPeek(readCon,2);
qty = conPeek(readCon,3);
costprice = conPeek(readCon,4);
salesprice = conPeek(readCon,5);
Txt = conPeek(readCon,6);
currencyid = conPeek(readCon,7);
worker = conPeek(readCon,8);
CategoryId = conPeek(readCon,9);
linepropertyid = conPeek(readCon,10);
SalesCurrencyId = conPeek(readCon,11);
ledgeraccount = conPeek(readCon,12);
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);
jourTable = LedgerJournalTable::find(header.LedgerJournalTable().JournalNum);
jourTrans.JournalNum = header.LedgerJournalTable().JournalNum;
jourTrans.DefaultDimension = DimensionDefault;
jourTrans.AccountType = LedgerJournalACTypE::Project;
numberSequenceTable = NumberSequenceTable::find(LedgerJournalName::find(header.LedgerJournalTable().JournalName).NumberSequenceTable);
voucher = NumberSeq::newGetVoucherFromCode(numberSequenceTable.NumberSequence).voucher();
select firstonly projTable join RecId from ledgerDimensionvalueCombination where ledgerDimensionvalueCombination.DisplayValue == projTable.ProjId && projTable.ProjId == projid;//ledgerDimensionvalueCombination
jourTrans.Voucher = voucher;
jourTrans.CurrencyCode = currencyid;
jourTrans.Qty = str2num(qty);
jourTrans.TransDate = str2Date(TransDate,213);
offsetdim = strFmt("%1,%1",ledgeraccount);
offsetDimensioncon = str2con(offsetdim);
jourTrans.ledgerDimension =ledgerDimensionvalueCombination.recid;
jourTrans.OffsetAccountType = LedgerJournalACType::Ledger;
jourTrans.ExchRate = 100;
jourTrans.insert();
ledgerJournalTrans_Project.ActivityNumber = ActivityNumber;
ledgerJournalTrans_Project.CategoryId = CategoryId;
ledgerJournalTrans_Project.Qty = str2num(qty);
ledgerJournalTrans_Project.CostPrice = str2num(CostPrice);
ledgerJournalTrans_Project.SalesPrice = str2num(SalesPrice);
ledgerJournalTrans_Project.SalesCurrencyId = SalesCurrencyId;
ledgerJournalTrans_Project.LinePropertyId = LinePropertyId;
ledgerJournalTrans_Project.ProjId = ProjId;
ledgerJournalTrans_Project.RefRecId = jourtrans.RecId;
hcmworker = hcmworker::findByPersonnelNumber(worker);
ledgerJournalTrans_Project.Worker = hcmworker.RecId;
ledgerJournalTrans_Project.insert();
ledgerJournalTrans_Project.clear();
jourtrans.clear();
}
}
ttsCommit;
}
}
No comments:
Post a Comment