static void ProjectFeeJournalCreate(Args _args)
{
ProjJournalTableData JournalTableData;
ProjJournalTransData journalTransData;
ProjJournalTable journalTable;
ProjJournalTrans journalTrans;
ProjTable projTable;
CommaTextIO csvFile;
container readCon;
counter icount,inserted;
Dialog dialog;
DialogField dfFileName;
FileName fileName;
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;
journalTableData = JournalTableData::newTable(journalTable);
journalTransData = journalTableData.journalStatic().newJournalTransData(journalTrans,journalTableData);
// Init JournalTable
journalTable.clear();
journalTable.JournalId = journalTableData.nextJournalId();
journalTable.JournalType = ProjJournalType::Hour;
journalTable.JournalNameId = "fee";
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
icount++;
// Init JournalTrans
journalTableData.initFromJournalName(journalTableData.journalStatic().findJournalName(journalTable.JournalNameId));
journalTrans.clear();
journalTransData.initFromJournalTable();
projTable = ProjTable::find(conPeek(readCon,1));
journalTrans.TransDate = systemDateGet();
journalTrans.ProjTransDate = systemDateGet();
journalTrans.ProjId = conPeek(readCon,1);
journalTrans.Qty = str2num(conPeek(readCon,2));
journalTrans.SalesPrice = str2num(conPeek(readCon,3));
journalTrans.Txt = projTable.psaRetainageBillingDesc();
journalTrans.CurrencyId = ProjInvoiceTable::find(projTable.ProjInvoiceProjId).CurrencyId;
journalTrans.Worker = HcmWorker::userId2Worker(curUserId());
journalTrans.CategoryId = "consult";
journalTrans.LinePropertyId = "charge";
journalTrans.Voucher = NumberSeq::newGetVoucherFromCode(JournalTable.getNumberSequenceTable().NumberSequence).voucher();
journalTransData.create();
}
}
journalTable.insert();
ttsCommit;
}
}
{
ProjJournalTableData JournalTableData;
ProjJournalTransData journalTransData;
ProjJournalTable journalTable;
ProjJournalTrans journalTrans;
ProjTable projTable;
CommaTextIO csvFile;
container readCon;
counter icount,inserted;
Dialog dialog;
DialogField dfFileName;
FileName fileName;
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;
journalTableData = JournalTableData::newTable(journalTable);
journalTransData = journalTableData.journalStatic().newJournalTransData(journalTrans,journalTableData);
// Init JournalTable
journalTable.clear();
journalTable.JournalId = journalTableData.nextJournalId();
journalTable.JournalType = ProjJournalType::Hour;
journalTable.JournalNameId = "fee";
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
icount++;
// Init JournalTrans
journalTableData.initFromJournalName(journalTableData.journalStatic().findJournalName(journalTable.JournalNameId));
journalTrans.clear();
journalTransData.initFromJournalTable();
projTable = ProjTable::find(conPeek(readCon,1));
journalTrans.TransDate = systemDateGet();
journalTrans.ProjTransDate = systemDateGet();
journalTrans.ProjId = conPeek(readCon,1);
journalTrans.Qty = str2num(conPeek(readCon,2));
journalTrans.SalesPrice = str2num(conPeek(readCon,3));
journalTrans.Txt = projTable.psaRetainageBillingDesc();
journalTrans.CurrencyId = ProjInvoiceTable::find(projTable.ProjInvoiceProjId).CurrencyId;
journalTrans.Worker = HcmWorker::userId2Worker(curUserId());
journalTrans.CategoryId = "consult";
journalTrans.LinePropertyId = "charge";
journalTrans.Voucher = NumberSeq::newGetVoucherFromCode(JournalTable.getNumberSequenceTable().NumberSequence).voucher();
journalTransData.create();
}
}
journalTable.insert();
ttsCommit;
}
}
No comments:
Post a Comment