Esempio n. 1
0
def import_treasury_ss(csvfile):
    import_obj(
        csvfile,
        SUB_SEGMENT_KEY,
        operator.eq,
        "Segment Department Code",
        "UKT013.GROUP",
    )
Esempio n. 2
0
def import_archived_programme(csvfile, year):
    msgerror = "Failure importing archived Programme. Error:"
    try:
        validate_year_for_archiving(year)
    except ArchiveYearError as ex:
        raise ArchiveYearError(f"{msgerror} {str(ex)}")
    success, msg = import_obj(csvfile, PROGRAMME_HISTORICAL_KEY, year=year)
    if not success:
        raise WrongChartOFAccountCodeException(f"{msgerror} {msg}")
    return success, msg
Esempio n. 3
0
def import_archived_analysis2(csvfile, year):
    msgerror = "Failure importing archived Analysis 2. Error:"
    try:
        validate_year_for_archiving(year)
    except ArchiveYearError as ex:
        raise ArchiveYearError(f"{msgerror} {str(ex)}")
    success, msg = import_obj(csvfile, ANALYSIS2_HISTORICAL_KEY, year=year)
    if not success:
        raise WrongChartOFAccountCodeException(f"{msgerror} {msg}")
    return success, msg
Esempio n. 4
0
def import_archived_cost_centre(csvfile, year):
    try:
        validate_year_for_archiving(year)
    except ArchiveYearError as ex:
        raise ArchiveYearError(
            f"Failure import Importing archived Cost Centre hierarchy  error: {str(ex)}"
        )
    success, msg = import_obj(csvfile, COST_CENTRE_HISTORICAL_KEY, year=year)
    if not success:
        raise WrongChartOFAccountCodeException(
            f"Importing archived Cost Centre hierarchy  error: "
            f"{msg}")
    return success, msg
Esempio n. 5
0
def import_archived_nac(csvfile, year):
    msgerror = "Failure importing archived NAC. Error:"
    try:
        validate_year_for_archiving(year)
    except ArchiveYearError as ex:
        raise ArchiveYearError(f"{msgerror} {str(ex)}")
    success, msg = import_obj(csvfile, NAC_HISTORICAL_KEY, year=year)
    if not success:
        raise WrongChartOFAccountCodeException(f"{msgerror} {msg}")
    else:
        # The archived NAC is not normalised, and each expenditure NAC row
        # contains the corresponding budget NAC.
        # This information is missing from the upload file, so we need to extract it
        # from the expenditure category: each expenditure category row is linked to
        # a budget NAC.
        # The classification of budget and expenditure NAC is internal to DIT:
        # budgets should be set only using budget NAC, to reduce the number of lines
        nac_qs = ArchivedNaturalCode.objects.filter(financial_year=year)
        for nac_obj in nac_qs:
            if nac_obj.expenditure_category:
                account_L6_budget_val = nac_obj.expenditure_category.linked_budget_code
                nac_obj.account_L6_budget = account_L6_budget_val
                nac_obj.save()
        category_qs = ArchivedExpenditureCategory.objects.filter(financial_year=year)
        for category_obj in category_qs:
            account_L6_budget_val = category_obj.linked_budget_code
            try:
                nac_obj = ArchivedNaturalCode.objects.get(
                    financial_year=year, natural_account_code=account_L6_budget_val
                )
                nac_obj.used_for_budget = True
                nac_obj.save()
            except ObjectDoesNotExist:
                msg = f"NAC {account_L6_budget_val} not defined for year {year}"
                raise WrongChartOFAccountCodeException(f"{msgerror} {msg}")

        return success, msg
Esempio n. 6
0
def import_cc(csvfile):
    return import_obj(csvfile, CC_KEY)
Esempio n. 7
0
def import_treasury_COA(csvfile):
    return import_obj(csvfile, L5_KEY)
Esempio n. 8
0
def import_Project(csvfile):
    import_obj(csvfile, PROJECT_KEY)
Esempio n. 9
0
def import_inter_entity(csvfile):
    import_obj(csvfile, INTER_ENTITY_KEY)
Esempio n. 10
0
def import_analysis2(csvfile):
    return import_obj(csvfile, ANALYSIS2_KEY)
Esempio n. 11
0
def import_programme(csvfile):
    return import_obj(csvfile, PROG_KEY)
Esempio n. 12
0
def import_commercial_category(csvfile):
    return import_obj(csvfile, COMMERCIAL_CATEGORY_KEY)
Esempio n. 13
0
def import_nac_expenditure_category(csvfile):
    return import_obj(csvfile, NAC_CATEGORY_KEY)
Esempio n. 14
0
def import_nac_dit_specific_fields(csvfile):
    return import_obj(csvfile, NAC_DIT_KEY)
Esempio n. 15
0
def import_nac(csvfile):
    return import_obj(csvfile, NAC_KEY)