/// <summary> /// fixing table a_ap_document /// </summary> public static bool FixAPDocument(StringCollection AColumnNames, ref string[] ANewRow) { TSequenceWriter.LoadSequences(); LoadAPDocumentNumberToId(); string LedgerNumberAndAPNumber = GetValue(AColumnNames, ANewRow, "a_ledger_number_i") + "_" + GetValue(AColumnNames, ANewRow, "a_ap_number_i"); if (APDocumentNumberToId.ContainsKey(LedgerNumberAndAPNumber)) { SetValue(AColumnNames, ref ANewRow, "a_ap_document_id_i", APDocumentNumberToId[LedgerNumberAndAPNumber].ToString()); } else { long newValue = TSequenceWriter.GetNextSequenceValue("seq_ap_document"); SetValue(AColumnNames, ref ANewRow, "a_ap_document_id_i", newValue.ToString()); APDocumentNumberToId.Add(LedgerNumberAndAPNumber, newValue); } if (GetValue(AColumnNames, ANewRow, "a_date_issued_d") == "\\N") { SetValue(AColumnNames, ref ANewRow, "a_date_issued_d", GetValue(AColumnNames, ANewRow, "a_date_entered_d")); } // we need to set a_currency_code_c which is stored with the supplier SetValue(AColumnNames, ref ANewRow, "a_currency_code_c", GetSupplierCurrency(Convert.ToInt64(GetValue(AColumnNames, ANewRow, "p_partner_key_n")))); return(true); }
/// <summary> /// Load the data from the 2.x Petra CSV file, and create psql load file /// </summary> public void LoadTablesToPostgresql(string ATableName) { GetStoreOld(); GetStoreNew(); DataDefinitionDiff.newVersion = "3.0"; TTable.GEnabledLoggingMissingFields = false; TParseProgressCSV.InitProgressCodePage(); TSequenceWriter.InitSequences(GetStoreNew().GetSequences()); CreatePostcodeRegionRangeTable(); CreateGiftDestinationTable(); if (ATableName.Length == 0) { List <TTable> newTables = storeNew.GetTables(); foreach (TTable newTable in newTables) { LoadTable(newTable); } GC.Collect(); } else { LoadTable(storeNew.GetTable(ATableName)); } // write some tables, if they have been used TFinanceAccountsPayableUpgrader.WriteAPDocumentNumberToId(); TSequenceWriter.WriteSequences(); TLogging.Log("Success: finished exporting the data"); TTable.GEnabledLoggingMissingFields = true; }
/// <summary> /// fixing table a_ap_document_payment /// </summary> public static bool FixAPDocumentPayment(StringCollection AColumnNames, ref string[] ANewRow) { TSequenceWriter.LoadSequences(); LoadAPDocumentNumberToId(); // a_ap_document_payment does not contain a_ap_number_i anymore, but the value has been copied into a_ap_document_id_i string LedgerNumberAndAPNumber = GetValue(AColumnNames, ANewRow, "a_ledger_number_i") + "_" + GetValue(AColumnNames, ANewRow, "a_ap_document_id_i"); if (APDocumentNumberToId.ContainsKey(LedgerNumberAndAPNumber)) { SetValue(AColumnNames, ref ANewRow, "a_ap_document_id_i", APDocumentNumberToId[LedgerNumberAndAPNumber].ToString()); } else { long newValue = TSequenceWriter.GetNextSequenceValue("seq_ap_document"); SetValue(AColumnNames, ref ANewRow, "a_ap_document_id_i", newValue.ToString()); APDocumentNumberToId.Add(LedgerNumberAndAPNumber, newValue); } return(true); }