ICH Stewardship calculation

From OpenPetra Wiki
Jump to navigation Jump to search

Intro

The stewardship calculation helps each office to calculate how much money they owe to other fields, and how much money they should be receiving from other fields.

Functionality involved

Generate and post the ICH stewardship batch

  • UI: gl2150-1.w to select the period for which the stewardship should be run.
  • Progress code: gl2160.p (called from accounts.w)


  • check that there are still open periods (a_ledger.a_provisional_year_end_flag_l)
  • Generate Admin Fee batch gl2150.p (read also: How Admin fees are calculated)
  • create a GL batch with name "ICH Stewardship"
  • for all foreign cost centres, find all gl transactions that have been posted but not been part of an ICH calculation
    • process income
    • process expense
    • process direct transfers
    • mark the gl transactions as processed
    • mark all gift details as processed (a_gift_detail.a_ich_number_i)
    • Balance the cost centre by entering an opposite transaction to ICH settlement
  • Update the balance of the ICH account (like a bank account).
  • Post the ICH Stewardship batch
  • print report if needed (not done for the moment)

after the calculation

UI

  • The user selects the output options.
  • Progress code: gi3000o.w

Print Admin Fee calculation

  • Progress code: gl2150p.p

DROP: Recalculate the balances of the ledger

This might not be necessary in OpenPetra anymore. For the moment we should assume all balances are correct all the time.

  • Progress code: gs5530.p


Calculate the report

  • Progress code: gl2161p.p (for the moment ignore gl2160p.p, since it is slower, and only needed for previous years)

Generate the HOSA file

Home office statement of accounts, is sent to all offices that this office has financial dealings with.

  • Progress code: gl2120-1.i, gl2120p.p, gi3200.p etc

Generate and Email the report

  • Generate ICH Stewardship FILE and send it via email to the ICH office
  • Progress code: gi3100.p
  • for creating CSV files: there is a class that allows you to create an XmlDocument, and then write it to CSV, and the names of the attributes are used as column headers. see csharp\ICT\Common\IO\Csv2Xml.cs, Ict.Common.IO TCsv2Xml, public static bool Xml2Csv(XmlDocument ADoc, string AOutCSVFile)
  • For sending emails with OpenPetra, please use the class at csharp\ICT\Common\IO\SmtpEmail.cs
    • A sample smtp email server is available from Timotheus on request, and you can add the Host, username and password to your config files.

DROP: Recipient gift statements

  • send a report of received gifts to the recipients.
  • not needed anymore, should be uploaded the Intranet solution
  • Progress code: gr1121p.p

Special treatment for branch processing

  • this is for departments within the current field.
  • for the moment we should ignore this.
  • Progress code: gi3400.p

Import all available stewardship reports

This is run only at the International Clearing House itself, eg on Ledger 4.

  • It imports all the stewardship Files that have been sent by all the offices via Email.
  • It also creates a stewardship batch on the ICH ledger
      File Name: giStewardshipImport.p
 Procedure Name: Import all available Stewardship Reports

NUnit tests for stewardship

  • Open the solution OpenPetra.Testing.sln in SharpDevelop
  • find the project Ict.Testing.lib.MFinance.server.Gift
  • have a look at file PostGiftBatch.test.cs
    • there is a test for importing a gift batch and posting it: TestPostGiftBatch. See if that still works
      • find the dll that contains the test in delivery/bin, ie. Ict.Testing.lib.MFinance.server.Gift.dll. Open that in NUnit GUI. Run the test.
    • there is an unimplemented test for the admin fees: TestProcessAdminFees
      • you will need to create admin fees first, if they do not exist in the database yet. You can load an sql file directly, similar to csharp\ICT\Testing\lib\MFinance\GL\Test.GL.Import.cs, line 113:
       private void PrepareTestCaseData()
       {
           TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction();

           // Check if some special test data are available - otherwise load ...
           bool CostCentreTestCasesAvailable = ACostCentreAccess.Exists(intLedgerNumber, "4301", Transaction);

           DBAccess.GDBAccessObj.RollbackTransaction();

           if (!CostCentreTestCasesAvailable)
           {
               CommonNUnitFunctions.LoadTestDataBase("csharp\\ICT\\Testing\\lib\\MFinance\\GL\\" +
                   "test-sql\\gl-test-costcentre-data.sql");
           }
       }
      • then see if processing the admin fees will change the amounts on the accounts, eg of the GIF account
        • see csharp\ICT\Testing\lib\MFinance\GL\Test.GL.CommonAccountingTool.cs, line 94:
           TGet_GLM_Info getGLM_InfoBeforeStart = new TGet_GLM_Info(LedgerNumber, strAccountStart, strCostCentre);
           [... do your process fee ...]
           TGet_GLM_Info getGLM_InfoAfterStart = new TGet_GLM_Info(LedgerNumber, strAccountStart, strCostCentre);
           // strAccountStart is a debit account -> in this case "+"
           Assert.AreEqual(getGLM_InfoBeforeStart.YtdActual + 10, getGLM_InfoAfterStart.YtdActual,
               "Check if 10 has been accounted to " + strAccountStart);
  • same idea should be tested for other operations of ICH Stewardship.
  • the goal is to have a test, that can be re-run, and that also works on a database that has been reset with nant resetDatabase. All extra data (eg. admin fees) need to be imported as part of the test, if they are not in the database yet.