-
Notifications
You must be signed in to change notification settings - Fork 146
load_submission
load_submission is responsible for pulling File A, B, C data and Submission metadata from Broker for a single DABS submission. It is executed from the command line via ./manage.py load_submission submission_id and is an integral part of the nightly USAspending pipeline where its execution is initiated indirectly via the load_multiple_submissions command, which is the entrypoint of the Broker Submission Loader.
load_submission accepts two command line arguments:
-
submission_idis a required positional argument used to indicate a single Brokersubmission.submission_idto be loaded. -
--testis an optional switch that causes the loader to utilize a "phony cursor" that reads data fromusaspending_api/etl/tests/etl_test_data.jsonrather than attempting to pull data from Broker. As the name implies, this is strictly for testing.
A quick word about submission chaining. This is a concept that exists in USAspending that is not found in Broker. Many numeric values in submissions are reported as CPE (Current Period End) which means they are cumulative for the fiscal year right up until the end of the period they represent. In order to calculate periodic net values, we link submissions to their previous submission in the fiscal year which allows us to quickly calculate a period's net values by subtracting period N-1's CPE values from period N's. This will be important in a minute.
- Attempt to find USAspending submission using
broker_submission_id. - If it does not exist:
- Create a stub.
- If it does exist:
- Drop and recalculate
tas_program_activity_object_class_quarterlyvalues for the submission in question and all of its downstream chained submissions. (See! I told you chaining would be important!) - Delete the existing submission using rm_submission.
- Drop and recalculate
- Find the agency to which this submission belongs.
- Find the previous submission for submission chaining.
- There is a little bit of confusing logic here for handling edge cases where there are chaining collisions. This would be a good place for a little cleanup. I would rather see us just always renumber all of the submissions for an agency for the entire fiscal year than attempt to track which need to be fixed. At most, there should only be 12, so it should be a relatively cheap operation.
- Fill in the stub or recreate the submission record if it was deleted.
- Fix submission chaining collsions.
- Retrieve File A data from Broker's
certified_appropriationtable.- Generate any new TAS records if we found any in File A that do not exist in USAspending's
treasury_appropriation_accounttable. - Save File A record in USAspending's
appropriation_account_balancestable, reversing the sign of thegross_outlay_amount_by_tas_cpecolumn. - Calculate
final_of_fyforappropriation_account_balances. - Calculate quarterly balances for the
appropriation_account_balances_quarterlytable.
- Generate any new TAS records if we found any in File A that do not exist in USAspending's
- Retrieve File B data from Broker's
certified_object_class_program_activitytable.- Generate any new TAS records if we found any in File B that do not exist in USAspending's
treasury_appropriation_accounttable. - Save File B record in USAspending's
financial_accounts_by_program_activity_object_classtable, reversing the sign of thetransaction_obligated_amountcolumn or any columns that end in_cpeorfyb. - Calculate
final_of_fyforfinancial_accounts_by_program_activity_object_class. - Calculate quarterly balances for the
tas_program_activity_object_class_quarterlytable.
- Generate any new TAS records if we found any in File B that do not exist in USAspending's
- Retrieve File C data from Broker's
certified_award_financialtable where rows have a non-zero, non-nulltransaction_obligated_amouamount.- Uppercase all text fields in the
certified_award_financialrecord. - Generate any new TAS records if we found any in File C that do not exist in USAspending's
treasury_appropriation_accounttable. - Look up File D award using
piid,fain, oruri. - Save File C record in USAspending's
financial_accounts_by_awardstable, reversing the sign of thetransaction_obligated_amountcolumn or any columns that end in_cpeorfyb.
- Uppercase all text fields in the
- Home
- The DATA Act
-
Data
- Account Data (A/B/C)
-
Award Data (D1/D2)
- Contract Data (D1)
- Assistance Data (D2)
- Recipient Data (E)
- Subaward Data (F)
- File C to D Linkage
- Agency Data (Federal Hierarchy)
- Location Data
- Management Commands
- Release Notes
- Resources