Conta DIY Integration

PubSub Events

All events are pushed to /trittFS.php.

The most important events are:

  • Created

  • ReadyForAccounting

  • Reopened

Any fs event received when a user is performing "closing the accounting year" in DIY is probably a problem; somebody has done something they shouldn’t.
FinancialStatementEvent.java
public class FinancialStatementEvent {

    @NonNull private EventType eventType;

    @NonNull private String tenantId;
    @NonNull private String userId;
    @NonNull private UUID fsUuid;

    @Nullable private Map<String, Object> info;

    public enum EventType {
        Created,
        Deleted,

        TaxReturnSentToSigning,                // previously TaxReturnSubmitted
        TaxReturnSignedByRepresentative,
        TaxReturnSignedByAuditor,
        TaxReturnFeedbackReceived,             // submitted successfully
        TaxReturnApproved,                     // usually takes time (months)

        AnnualStatementSentToSigning,          // previously AnnualStatementSubmitted
        AnnualStatementSignedByRepresentative,
        AnnualStatementFeedbackReceived,       // submitted successfully
        AnnualStatementApproved,               // usually takes time (days|week)

        ReadyForAccounting,                    // needs new functionality in finsta
        AccountingCompleted,                   // when DIY reports back
        Reopened;
    }
}

Create an fs draft

The request body is identical to /financial-statements/:create, but the response body is different.

Use the draftUuid from the response to direct the users to:

https://{host}/organization/{tenantId}/financial-statements/new?draftUuid={draftUuid}

Unused drafts can or should be abandoned.

It is better to create a new draft when a user starts the process again at a later time, instead of a re-using a (possibly expired) draft.

Creating a new draft will ensure that the accounting data is up-to-date.

Request example: HTTP fs create draft
# variables
@host = http://api.tritt.test/finsta
@tenantId = _313887944aab3c375c5ef
@orgNo = 313887944
@auth = Bearer <jwt>

@contaDiyOrgId = 293567
@contaDiyHost = https://app.conta.no/regnskap

### create draft

POST {{host}}/financial-statements/:create-draft
Accept: */*
OrganizationId: {{tenantId}}
X-ORG-NO: {{orgNo}}
Authorization: {{auth}}
Content-Type: application/json

{
  "orgNo": "{{orgNo}}",
  "year": 2024,
  "name": "Created from DIY",
  "accounts": [
    {
      "accountNo": "2000",
      "accountName": "Aksjekapital",
      "previousClosingBalance": -30000,
      "temporaryClosingBalance": -30000
    },
    {
      "accountNo": "1920",
      "accountName": "Bankkonto",
      "previousClosingBalance": 30000,
      "temporaryClosingBalance": 30000
    }
  ],
  "attributes": {
    "assessmentType": "AdvanceAssessment",
    "liquidation": {
      "liquidatedAt": "2024-11-19"
    }
  },
  "accountingSystemReference":  {
    "systemKey": "conta-diy",
    "orgIdentifier": {
      "key": "orgId",
      "value": "{{contaDiyOrgId}}"
    },
    "hostUri": "{{contaDiyHost}}"
  }
}

> {%
  const draftUuid = response.body.draftUuid
  client.log(draftUuid)
  client.global.set('createdDraftUuid', draftUuid)
%}

### get the created draft

@draftUuid = dd167393-6564-4db9-844c-dacf378b8d2e

GET {{host}}/financial-statements/drafts/{{createdDraftUuid}}
Accept: application/json
OrganizationId: {{tenantId}}
X-ORG-NO: {{orgNo}}
Authorization: {{auth}}

### get all drafts

GET {{host}}/financial-statements/drafts
Accept: application/json
OrganizationId: {{tenantId}}
X-ORG-NO: {{orgNo}}
Authorization: {{auth}}
Response example: fs create draft
{
  "draftUuid": "9add1a98-78c6-4617-9683-f7946c8f9eb1",
  "cmdClass": "tritt.finsta.api.finsta.CreateFinancialStatementCommand",
  "cmdBody": {
    "orgNo": "313887944",
    "year": 2024,
    "accounts": [
      {
        "accountNo": "2000",
        "accountName": "Aksjekapital",
        "previousClosingBalance": -30000,
        "temporaryClosingBalance": -30000
      },
      {
        "accountNo": "1920",
        "accountName": "Bankkonto",
        "previousClosingBalance": 30000,
        "temporaryClosingBalance": 30000
      }
    ],
    "accountingSystemReference": {
      "systemKey": "conta-diy",
      "orgIdentifier": {
        "key": "orgId",
        "value": "293567"
      },
      "hostUri": "https://app.conta.foo/regnskap"
    }
  }
}
OpenAPI excerpt
openapi: 3.0.1
paths:
  /financial-statements/:create-draft:
    post:
      operationId: createFinancialStatementDraft
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateFinancialStatementCommand'
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateFinancialStatementCommandDraft'
CreateFinancialStatementCommand.java
public class CreateFinancialStatementCommand implements Command, DryRunEnabled, ForkEnabled {


    @Nullable private ForkSource forkFrom;

    @NonNull @ValidOrgNo private String orgNo;
    @NonNull @NotNull private Integer year;
    @Nullable SpecVersion specVersion;

    @Nullable private String name;
    @Nullable private String description;

    @Nullable @Valid private List<BalanceAccount> accounts;
    @Nullable private ExternalSystemReference accountingSystemReference;

    @FunctionalInterface
    public interface BalanceAccountsProvider {

        @NonNull
        List<BalanceAccount> parseFromCsvs(@Nullable String currentCsv, @Nullable String previousCsv);

    }

    @LegacyJsonSupport
    private void setCurrentCsv(@Nullable String currentCsv) {
        setTbParams(CreateTrialBalanceParams.merge(getTbParams(), "currentCsv", currentCsv));
    }

    @LegacyJsonSupport
    private void setPreviousCsv(@Nullable String previousCsv) {
        setTbParams(CreateTrialBalanceParams.merge(getTbParams(), "previousCsv", previousCsv));
    }

    @LegacyJsonSupport
    private void setCurrentCsvFileUuid(@Nullable String s) {
        if (s == null || s.isBlank()) {
            return;
        }
        setTbParams(CreateTrialBalanceParams.merge(getTbParams(), "currentCsvFileUuid", s));
    }

    @LegacyJsonSupport
    private void setPreviousCsvFileUuid(@Nullable String s) {
        if (s == null || s.isBlank()) {
            return;
        }
        setTbParams(CreateTrialBalanceParams.merge(getTbParams(), "previousCsvFileUuid", s));
    }
}
BalanceAccount.java
public class BalanceAccount implements BalanceAccountAdapter {

    @NonNull @NotNull private String accountNo;
    @Nullable private String accountName;
    @Nullable private BigDecimal previousClosingBalance;
    @NonNull @NotNull private BigDecimal temporaryClosingBalance;
    @NonNull private BigDecimal finalClosingBalance;
}
ExternalSystemReference.java
@Data
@Introspected
public class ExternalSystemReference {

    public static final String SYSTEM_KEY_CONTA_DIY = "conta-diy";

    @NonNull private String systemKey;         // example: conta-diy
    @NonNull private Identifier orgIdentifier; // example: orgId:293567
    @Nullable private URI hostUri;             // example: https://app.conta.no/regnskap

}
TransactionLine.java
public class TransactionLine implements AmountAware {

    @NonNull @NotNull private String accountNo;
    @Nullable private String accountName;
    @NonNull @NotNull private BigDecimal amount;
    @Nullable private String description;
}
CreateFinancialStatementCommandDraft.java
public class CreateFinancialStatementCommandDraft implements CommandDraft<CreateFinancialStatementCommand> {

    @NonNull private final UUID draftUuid;
    @NonNull private final String cmdClass;
    @NonNull private final CreateFinancialStatementCommand cmdBody;
}

Get the list of financial statements

Returns a list of all (non-deleted) financial statements.

Request example: HTTP fs list all
# variables
@host = http://api.tritt.test/finsta
@tenantId = _313887944aab3c375c5ef
@orgNo = 313887944
@fsUuid = e42fbd6d-496e-4f65-ade2-5221bf4f33f6
@auth = Bearer <jwt>

### fs list all
GET {{host}}/financial-statements
Accept: */*
OrganizationId: {{tenantId}}
X-ORG-NO: {{orgNo}}
Authorization: {{auth}}
Content-Type: application/json

### fs list one
GET {{host}}/financial-statements/{{fsUuid}}
Accept: */*
OrganizationId: {{tenantId}}
X-ORG-NO: {{orgNo}}
Authorization: {{auth}}
Content-Type: application/json
Response example: fs list all
[
  {
    "uuid": "e42fbd6d-496e-4f65-ade2-5221bf4f33f6",
    "orgNo": "313887944",
    "year": 2023,
    "period": {
      "startsAt": "2023-01-01",
      "endsAt": "2023-12-31"
    },
    "name": "Årsoppgjør",
    "businessType": "LimitedStockCompany",
    "accountingObligationType": "Obliged",
    "attributes": {
      "assessmentType": "AdvanceAssessment",
      "liquidated": false
    },
    "registries": {
      "assregUuid": "c3558560-05c6-46dc-af96-e3779bc3cb1c",
      "finregUuid": "d93b6240-4312-475f-bbea-a67fd84ef221",
      "cogregUuid": "a5137b48-907b-4caa-81cc-9a96d4eced70"
    },
    "readyForAccountingAt": "2024-11-01T13:22:44.420003Z",
    "accountingCompletedAt": "2024-11-01T13:49:52.367610Z",
    "states": {
      "fs": "AccountingCompleted",
      "taxret": "SignedByRepresentative",
      "annsta": "SignedByRepresentative"
    },
    "keyInfo": {
      "annualResult": -141384.85,
      "estimatedBusinessIncome": -277699.880,
      "tax": 0,
      "reconciliationResult": 0.00,
      "taxReturnDraftInfo": {
        "self": "Ok"
      },
      "backgroundInfo": {
        "self": "Started",
        "traits": [
          "AdvanceAssessment",
          "FixedAssets",
          "Estate",
          "Securities",
          "Stocks"
        ],
        "numAnswered": 7,
        "numQuestions": 12,
        "checksum": "0aabe4ed5e939a3b30470606d839b4a4"
      },
      "businessInformationInfo": {
        "self": "Started",
        "business": "Ok",
        "result": "Ok",
        "balance": "Ok",
        "fixedAssets": {
          "state": "Started",
          "remarks": [
            {
              "field": "1130",
              "type": "Warning",
              "code": 23014,
              "info": {
                "registered": [
                  {
                    "added": 0,
                    "ingoing": 16386.0,
                    "remarks": [],
                    "removed": 0,
                    "accountNo": "1130",
                    "taxIngoing": 17711.0,
                    "depreciated": 0.0,
                    "identifyingValue": "Bom, brygge"
                  }
                ]
              }
            }
          ]
        },
        "currentAssets": {
          "state": "Ok",
          "remarks": [
            {
              "field": "inventory",
              "type": "Note",
              "code": 23051,
              "info": {
                "code": "CurrentAssetsInventoryNotPresent",
                "numLines": 7,
                "numAmountLines": 0
              }
            },
            {
              "field": "taxableReceivables",
              "type": "Note",
              "code": 23055,
              "info": {
                "code": "CurrentAssetsTaxableReceivablesNotPresent"
              }
            }
          ]
        },
        "differences": {
          "state": "Ok",
          "remarks": [
            {
              "field": "pd",
              "type": "Ok",
              "code": 23006,
              "info": {}
            },
            {
              "field": "td",
              "type": "Ok",
              "code": 23003,
              "info": {
                "all": [
                  "101"
                ],
                "pending": [],
                "numTotal": 1,
                "numPending": 0,
                "numRegistered": 1
              }
            }
          ]
        },
        "estimatedBusinessIncome": {
          "state": "Ok",
          "remarks": []
        },
        "reconciliationOfEquity": {
          "state": "Ok",
          "remarks": [
            {
              "field": "result",
              "type": "Ok",
              "code": 23043,
              "info": {}
            }
          ]
        },
        "otherCircumstances": {
          "state": "Ok",
          "remarks": [
            {
              "field": "from",
              "type": "Tip",
              "code": 23091,
              "info": {
                "possiblyPendingPostNos": [
                  "AF100"
                ]
              }
            },
            {
              "field": "to",
              "type": "Tip",
              "code": 23091,
              "info": {
                "possiblyPendingPostNos": [
                  "AF201",
                  "AF202A"
                ]
              }
            }
          ]
        },
        "debtAndWealthAssets": {
          "state": "Ok"
        },
        "checksum": "410eee6d718e984017a8f7e577f1029a"
      },
      "yearEndClosingInfo": {
        "self": "Started",
        "remarks": [
          {
            "field": "",
            "type": "Warning",
            "code": 24010,
            "info": {
              "pendingThemes": [
                "FixedAssets"
              ]
            }
          }
        ],
        "checksum": "b5082350150e0d9085c785f2189e0498"
      },
      "taxReturnInfo": {
        "self": "Started",
        "informationAboutTaxSubject": {
          "state": "Ok",
          "remarks": []
        },
        "incomeAndDeficit": "Ok",
        "specificationOfInformationRelevantForTaxation": "Ok",
        "wealthAndDebt": "Started",
        "stockValuation": {
          "state": "Started",
          "remarks": [
            {
              "field": "SV002",
              "type": "Warning",
              "code": 25011,
              "info": {}
            }
          ]
        },
        "checksum": "06397ebf829f6dc20414ccd63700bf8a"
      },
      "taxReturnSubmissionInfo": {
        "state": "SignedByRepresentative"
      },
      "annualStatementInfo": {
        "self": "Started",
        "result": "Ok",
        "balance": "Ok",
        "board": "Started",
        "notes": {
          "state": "Started"
        },
        "details": {
          "state": "Ok"
        },
        "checksum": "8de32dfe3e9c6f798c10f0dd75405b48"
      },
      "annualStatementSubmissionInfo": {
        "state": "SignedByRepresentative"
      }
    },
    "sourceUpdatesAt": {
      "AssetRegistry": "2024-11-01T11:54:49.621558380Z"
    },
    "createdAt": "2024-10-17T07:16:56.016744Z",
    "modifiedAt": "2024-11-01T13:49:52.381786Z",
    "remarks": []
  }
]
OpenAPI excerpt
openapi: 3.0.1
paths:
  /financial-statements:
    get:
      operationId: findFinancialStatements
      parameters:
        - name: year
          in: query
          schema:
            type: string
            nullable: true
      responses:
        "200":
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/FinancialStatement'
FinancialStatement.java
public class FinancialStatement implements ForkSourcesAware, RemarkAware, Deletable<FinancialStatement>, SelfChainable<FinancialStatement> {

    @NonNull private UUID uuid;
    @NonNull private String orgNo;
    @NonNull private Integer year;
    @NonNull private FinstaPeriod period;
    @NonNull private String name;

    @NonNull private FinancialStatementStates states;

    @NonNull List<Remark> remarks;
}
FinancialStatementStates.java
public class FinancialStatementStates {

    @NonNull private FinancialStatementState fs;
    @NonNull private TaxReturnSubmissionState taxret;
    @NonNull private AnnualStatementSubmissionState annsta;

}
FinancialStatementState.java
public enum FinancialStatementState {
    InProgress,
    ReportsSentToSigning, // recently added to the api, but actual usage depends on DIY support
    ReportsSubmitted,
    ReadyForAccounting,
    AccountingCompleted
}
TaxReturnSubmissionState.java
public enum TaxReturnSubmissionState {
    NotReady,
    Ready,
    Rejected,
    Validated,
    SentToSigning,
    SignedByRepresentative,
    SignedByAuditor,
    FeedbackReceived,
    Approved,
    NotApproved,
    @JsonEnumDefaultValue @Deprecated Unknown;
}
AnnualStatementSubmissionState.java
public enum AnnualStatementSubmissionState {
    NotReady,
    Ready,
    Initiated,
    Rejected,
    Validated,
    SentToSigning,
    SignedByRepresentative,
    FeedbackReceived,
    Approved,
    NotApproved,
    @JsonEnumDefaultValue @Deprecated Unknown;
}

Get the list of transaction suggestions

Request example: HTTP fs txs suggestions
# variables
@host = http://api.tritt.test/finsta
@tenantId = _313887944aab3c375c5ef
@orgNo = 313887944
@fsUuid = e42fbd6d-496e-4f65-ade2-5221bf4f33f6
@auth = Bearer <jwt>

### fs list txs suggestions
GET {{host}}/financial-statements/-/trial-balances/{{fsUuid}}/transactions?translate=Yes&language=nb_NO&state=ReadyForAccounting
Accept: */*
OrganizationId: {{tenantId}}
X-ORG-NO: {{orgNo}}
Authorization: {{auth}}
Content-Type: application/json
Response example: fs list txs suggestions
[
  {
    "txUuid": "90888f83-1a52-49d9-b6da-f5a774c2ea89",
    "date": "2023-12-31",
    "type": "Additional",
    "description": "Overfører fra annen egenkapital",
    "amount": 2903.75,
    "lines": [
      {
        "uuid": "ba6babf1-d689-4e0c-8931-f2f1057c4954",
        "accountNo": "2050",
        "amount": 2903.75
      },
      {
        "uuid": "ce8ff731-0c69-4700-8cb4-f0c43010be00",
        "accountNo": "8961",
        "amount": -2903.75
      }
    ],
    "origin": {
      "system": "Finsta",
      "type": "YearEndClosing",
      "uuid": "0113c18e-6b01-48dc-8506-d30f14392283",
      "originatedAt": "2024-10-21T13:33:48.485597636Z"
    },
    "modifiedAt": "2024-11-01T13:48:40.592120Z",
    "acceptedAt": "2024-10-21T13:33:48.486255Z"
  },
  {
    "txUuid": "4285f10d-9020-4577-bab1-ab3bd5151db8",
    "date": "2023-12-31",
    "type": "Additional",
    "description": "Overfører til udekket tap",
    "amount": 138481.10,
    "lines": [
      {
        "uuid": "de2b384a-1713-4662-bf03-99cbbd38622a",
        "accountNo": "2080",
        "amount": 138481.10
      },
      {
        "uuid": "118b587e-4002-4de6-a3b6-34eec95372fb",
        "accountNo": "8990",
        "amount": -138481.10
      }
    ],
    "origin": {
      "system": "Finsta",
      "type": "YearEndClosing",
      "uuid": "6138302d-9131-4856-9299-2ce9cf56e92a",
      "originatedAt": "2024-10-21T13:33:48.485699178Z"
    },
    "modifiedAt": "2024-11-01T13:48:40.593210Z",
    "acceptedAt": "2024-10-21T13:33:48.486259Z"
  },
  {
    "txUuid": "371f6df1-ac8e-4ed7-adaf-72ee22369f6c",
    "date": "2023-12-31",
    "type": "Additional",
    "description": "Avskriving for \"Henger Tysse 6303 NF\"",
    "amount": 3800.09,
    "lines": [
      {
        "uuid": "c9abdcbd-bf90-457a-b592-0cf43c869a2a",
        "accountNo": "6015",
        "amount": 3800.09
      },
      {
        "uuid": "e8c07d50-f6d5-41a5-bf79-d1578476b821",
        "accountNo": "1248",
        "amount": -3800.09
      }
    ],
    "origin": {
      "system": "AssetRegistry",
      "type": "Asset",
      "uuid": "689ccfa8-4f7e-4fb4-b860-e3779bc3cb1c",
      "originatedAt": "2024-11-01T12:51:09.864451917Z"
    },
    "modifiedAt": "2024-11-01T13:48:40.577037Z",
    "acceptedAt": "2024-11-01T12:51:09.864164Z"
  },
  {
    "txUuid": "c3f3615a-c51b-4c28-8a86-2249fde765fb",
    "date": "2023-12-31",
    "type": "Additional",
    "description": "Avskriving for \"Stillaspakke 132m2\"",
    "amount": 8374.54,
    "lines": [
      {
        "uuid": "f72e7964-5422-4f21-b779-732828b0bf7e",
        "accountNo": "6015",
        "amount": 8374.54
      },
      {
        "uuid": "6b195695-a8d1-4ad7-b53c-d51935a72120",
        "accountNo": "1202",
        "amount": -8374.54
      }
    ],
    "origin": {
      "system": "AssetRegistry",
      "type": "Asset",
      "uuid": "28970b40-4cc8-4ce9-bf3e-e3779bc3cb1c",
      "originatedAt": "2024-11-01T12:51:09.864726209Z"
    },
    "modifiedAt": "2024-11-01T13:48:40.581309Z",
    "acceptedAt": "2024-11-01T12:51:09.864694Z"
  },
  {
    "txUuid": "481befb0-8bab-4ebb-b5f3-42e1e337c94f",
    "date": "2023-12-31",
    "type": "Additional",
    "description": "Avskriving for \"Carlift SL-3500-12\"",
    "amount": 4785.94,
    "lines": [
      {
        "uuid": "015d8613-834d-42f1-a704-77295a3fb423",
        "accountNo": "6015",
        "amount": 4785.94
      },
      {
        "uuid": "3f0a99b6-9a23-4cbf-88d1-bc20b5f1c74b",
        "accountNo": "1203",
        "amount": -4785.94
      }
    ],
    "origin": {
      "system": "AssetRegistry",
      "type": "Asset",
      "uuid": "f3e0f3b6-eea4-4d11-beaa-e3779bc3cb1c",
      "originatedAt": "2024-11-01T12:51:09.864746917Z"
    },
    "modifiedAt": "2024-11-01T13:48:40.582544Z",
    "acceptedAt": "2024-11-01T12:51:09.864728Z"
  },
  {
    "txUuid": "1e32c5f3-6531-4869-9e5d-b9b3996f8ae2",
    "date": "2023-12-31",
    "type": "Additional",
    "description": "Avskriving for \"Panasonic varmepumpe\"",
    "amount": 3680.07,
    "lines": [
      {
        "uuid": "51655714-628f-41fc-bdb6-1d56ac3d2431",
        "accountNo": "6015",
        "amount": 3680.07
      },
      {
        "uuid": "df2edd9f-1a7b-4c07-ae78-10288c5355de",
        "accountNo": "1204",
        "amount": -3680.07
      }
    ],
    "origin": {
      "system": "AssetRegistry",
      "type": "Asset",
      "uuid": "617cebe1-75ef-49de-8c79-e3779bc3cb1c",
      "originatedAt": "2024-11-01T12:51:09.864773001Z"
    },
    "modifiedAt": "2024-11-01T13:48:40.583723Z",
    "acceptedAt": "2024-11-01T12:51:09.864750Z"
  },
  {
    "txUuid": "4b85a336-48f6-4b1f-a89a-3eab9a39e375",
    "date": "2023-12-31",
    "type": "Additional",
    "description": "Avskriving for \"Can-Am 1000 xtp\"",
    "amount": 32319.88,
    "lines": [
      {
        "uuid": "dbe8cb49-36e1-458c-8a5a-405a781f2dd0",
        "accountNo": "6015",
        "amount": 32319.88
      },
      {
        "uuid": "3ea80e15-a7c3-4148-8959-759b1d47715a",
        "accountNo": "1241",
        "amount": -32319.88
      }
    ],
    "origin": {
      "system": "AssetRegistry",
      "type": "Asset",
      "uuid": "00f9311e-977d-425e-9259-e3779bc3cb1c",
      "originatedAt": "2024-11-01T12:51:09.864804251Z"
    },
    "modifiedAt": "2024-11-01T13:48:40.586069Z",
    "acceptedAt": "2024-11-01T12:51:09.864778Z"
  },
  {
    "txUuid": "b3a4727b-7961-441b-ba12-5859d0bf0e42",
    "date": "2023-12-31",
    "type": "Additional",
    "description": "Avskriving for \"Steady 400, 2014mod. m/Yamaha F9 motor\"",
    "amount": 13154.29,
    "lines": [
      {
        "uuid": "8bcecad0-a039-40e3-84c0-d2668752f9d6",
        "accountNo": "6015",
        "amount": 13154.29
      },
      {
        "uuid": "e330358a-2e23-4444-a875-eb253dafde1c",
        "accountNo": "1242",
        "amount": -13154.29
      }
    ],
    "origin": {
      "system": "AssetRegistry",
      "type": "Asset",
      "uuid": "19f3a5fe-2149-4c83-aa40-e3779bc3cb1c",
      "originatedAt": "2024-11-01T12:51:09.864822542Z"
    },
    "modifiedAt": "2024-11-01T13:48:40.588159Z",
    "acceptedAt": "2024-11-01T12:51:09.864808Z"
  },
  {
    "txUuid": "b30ca168-5c6a-485f-b70e-c0949c52fc2b",
    "date": "2023-12-31",
    "type": "Additional",
    "description": "Avskriving for \"Respo 1800 MR-båthenger\"",
    "amount": 5840.00,
    "lines": [
      {
        "uuid": "6b063f62-41e3-4652-9e42-46d757ce1509",
        "accountNo": "6015",
        "amount": 5840.00
      },
      {
        "uuid": "beb17734-0776-44a3-9d9d-c0fddbf1a616",
        "accountNo": "1243",
        "amount": -5840.00
      }
    ],
    "origin": {
      "system": "AssetRegistry",
      "type": "Asset",
      "uuid": "00c8da11-2143-43d2-abe8-e3779bc3cb1c",
      "originatedAt": "2024-11-01T12:51:09.864855751Z"
    },
    "modifiedAt": "2024-11-01T13:48:40.589294Z",
    "acceptedAt": "2024-11-01T12:51:09.864826Z"
  },
  {
    "txUuid": "7e2f515f-863b-42c1-a25f-f6d4b34f30f3",
    "date": "2023-12-31",
    "type": "Additional",
    "description": "Avskriving for \"Garasjebygg\"",
    "amount": 12797.00,
    "lines": [
      {
        "uuid": "17e66b85-16fd-486f-b5cf-73f038cd1b25",
        "accountNo": "6000",
        "amount": 12797.00
      },
      {
        "uuid": "aa663e6f-d6ca-46ab-813f-d07d0540ce02",
        "accountNo": "1120",
        "amount": -12797.00
      }
    ],
    "origin": {
      "system": "AssetRegistry",
      "type": "Asset",
      "uuid": "c32bebd4-00a7-46e4-9d91-e3779bc3cb1c",
      "originatedAt": "2024-11-01T12:51:09.864869626Z"
    },
    "modifiedAt": "2024-11-01T13:48:40.590373Z",
    "acceptedAt": "2024-11-01T12:51:09.864860Z"
  },
  {
    "txUuid": "b41ee5a3-2c6a-4d65-ae84-775680e14899",
    "date": "2023-12-31",
    "type": "Additional",
    "description": "Avskriving for \"Finnmaster R6 22mod. m/175XA\"",
    "amount": 48640.04,
    "lines": [
      {
        "uuid": "1285cd60-dce7-4893-844d-b25f58e1b40a",
        "accountNo": "6015",
        "amount": 48640.04
      },
      {
        "uuid": "71b81350-265d-4707-843f-83ccd2a6b52f",
        "accountNo": "1244",
        "amount": -48640.04
      }
    ],
    "origin": {
      "system": "AssetRegistry",
      "type": "Asset",
      "uuid": "1ac7f84a-508c-47bb-b8f4-e3779bc3cb1c",
      "originatedAt": "2024-11-01T12:51:09.864880417Z"
    },
    "modifiedAt": "2024-11-01T13:48:40.591248Z",
    "acceptedAt": "2024-11-01T12:51:09.864873Z"
  }
]
OpenAPI excerpt
openapi: 3.0.1
paths:
  /financial-statements/-/trial-balances/{fsUuid}/transactions:
    get:
      operationId: findAccountingTransactions
      parameters:
        - name: fsUuid
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: translate
          in: query
          schema:
            nullable: true
            allOf:
              - $ref: '#/components/schemas/Answer'
        - name: language
          in: query
          schema:
            type: string
            nullable: true
        - name: state
          in: query
          schema:
            nullable: true
            allOf:
              - $ref: '#/components/schemas/AccountingTransactionState'
      responses:
        "200":
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/AccountingTransaction'
AccountingTransactionState.java
public enum AccountingTransactionState {
    ReadyForAccounting,
    AccountingCompleted,
    NotEligibleForAccounting,
}

Update fs when accounting completed

Request example: HTTP fs accounting completed
# variables
@host = http://api.tritt.test/finsta
@tenantId = _313887944aab3c375c5ef
@orgNo = 313887944
@fsUuid = e42fbd6d-496e-4f65-ade2-5221bf4f33f6
@auth = Bearer <jwt>

### accounting completed

POST {{host}}/financial-statements/:accounting-completed
Accept: */*
OrganizationId: {{tenantId}}
X-ORG-NO: {{orgNo}}
Authorization: {{auth}}
Content-Type: application/json

{
  "fsUuid": "{{fsUuid}}",
  "bookedTransactions": []
}
Response example: fs accounting completed
{
  "uuid": "e42fbd6d-496e-4f65-ade2-5221bf4f33f6",
  "orgNo": "313887944",
  "year": 2023,
  "period": {
    "startsAt": "2023-01-01",
    "endsAt": "2023-12-31"
  },
  "name": "Årsoppgjør",
  "businessType": "LimitedStockCompany",
  "accountingObligationType": "Obliged",
  "attributes": {
    "assessmentType": "AdvanceAssessment",
    "liquidated": false
  },
  "registries": {
    "assregUuid": "c3558560-05c6-46dc-af96-e3779bc3cb1c",
    "finregUuid": "d93b6240-4312-475f-bbea-a67fd84ef221",
    "cogregUuid": "a5137b48-907b-4caa-81cc-9a96d4eced70"
  },
  "readyForAccountingAt": "2024-11-01T13:22:44.420003Z",
  "accountingCompletedAt": "2024-11-01T13:49:52.367610Z",
  "states": {
    "fs": "AccountingCompleted",
    "taxret": "SignedByRepresentative",
    "annsta": "SignedByRepresentative"
  },
  "keyInfo": {
    "annualResult": -141384.85,
    "estimatedBusinessIncome": -277699.880,
    "tax": 0,
    "reconciliationResult": 0.00,
    "taxReturnDraftInfo": {
      "self": "Ok"
    },
    "backgroundInfo": {
      "self": "Started",
      "traits": [
        "AdvanceAssessment",
        "FixedAssets",
        "Estate",
        "Securities",
        "Stocks"
      ],
      "numAnswered": 7,
      "numQuestions": 12,
      "checksum": "0aabe4ed5e939a3b30470606d839b4a4"
    },
    "businessInformationInfo": {
      "self": "Started",
      "business": "Ok",
      "result": "Ok",
      "balance": "Ok",
      "fixedAssets": {
        "state": "Started",
        "remarks": [
          {
            "field": "1130",
            "type": "Warning",
            "code": 23014,
            "info": {
              "registered": [
                {
                  "added": 0,
                  "ingoing": 16386.0,
                  "remarks": [],
                  "removed": 0,
                  "accountNo": "1130",
                  "taxIngoing": 17711.0,
                  "depreciated": 0.0,
                  "identifyingValue": "Bom, brygge"
                }
              ]
            }
          }
        ]
      },
      "currentAssets": {
        "state": "Ok",
        "remarks": [
          {
            "field": "inventory",
            "type": "Note",
            "code": 23051,
            "info": {
              "code": "CurrentAssetsInventoryNotPresent",
              "numLines": 7,
              "numAmountLines": 0
            }
          },
          {
            "field": "taxableReceivables",
            "type": "Note",
            "code": 23055,
            "info": {
              "code": "CurrentAssetsTaxableReceivablesNotPresent"
            }
          }
        ]
      },
      "differences": {
        "state": "Ok",
        "remarks": [
          {
            "field": "pd",
            "type": "Ok",
            "code": 23006,
            "info": {}
          },
          {
            "field": "td",
            "type": "Ok",
            "code": 23003,
            "info": {
              "all": [
                "101"
              ],
              "pending": [],
              "numTotal": 1,
              "numPending": 0,
              "numRegistered": 1
            }
          }
        ]
      },
      "estimatedBusinessIncome": {
        "state": "Ok",
        "remarks": []
      },
      "reconciliationOfEquity": {
        "state": "Ok",
        "remarks": [
          {
            "field": "result",
            "type": "Ok",
            "code": 23043,
            "info": {}
          }
        ]
      },
      "otherCircumstances": {
        "state": "Ok",
        "remarks": [
          {
            "field": "from",
            "type": "Tip",
            "code": 23091,
            "info": {
              "possiblyPendingPostNos": [
                "AF100"
              ]
            }
          },
          {
            "field": "to",
            "type": "Tip",
            "code": 23091,
            "info": {
              "possiblyPendingPostNos": [
                "AF201",
                "AF202A"
              ]
            }
          }
        ]
      },
      "debtAndWealthAssets": {
        "state": "Ok"
      },
      "checksum": "410eee6d718e984017a8f7e577f1029a"
    },
    "yearEndClosingInfo": {
      "self": "Started",
      "remarks": [
        {
          "field": "",
          "type": "Warning",
          "code": 24010,
          "info": {
            "pendingThemes": [
              "FixedAssets"
            ]
          }
        }
      ],
      "checksum": "b5082350150e0d9085c785f2189e0498"
    },
    "taxReturnInfo": {
      "self": "Started",
      "informationAboutTaxSubject": {
        "state": "Ok",
        "remarks": []
      },
      "incomeAndDeficit": "Ok",
      "specificationOfInformationRelevantForTaxation": "Ok",
      "wealthAndDebt": "Started",
      "stockValuation": {
        "state": "Started",
        "remarks": [
          {
            "field": "SV002",
            "type": "Warning",
            "code": 25011,
            "info": {}
          }
        ]
      },
      "checksum": "06397ebf829f6dc20414ccd63700bf8a"
    },
    "taxReturnSubmissionInfo": {
      "state": "SignedByRepresentative"
    },
    "annualStatementInfo": {
      "self": "Started",
      "result": "Ok",
      "balance": "Ok",
      "board": "Started",
      "notes": {
        "state": "Started"
      },
      "details": {
        "state": "Ok"
      },
      "checksum": "8de32dfe3e9c6f798c10f0dd75405b48"
    },
    "annualStatementSubmissionInfo": {
      "state": "SignedByRepresentative"
    }
  },
  "sourceUpdatesAt": {
    "AssetRegistry": "2024-11-01T11:54:49.621558380Z"
  },
  "createdAt": "2024-10-17T07:16:56.016744Z",
  "modifiedAt": "2024-11-01T13:49:52.381786Z",
  "remarks": []
}
OpenAPI excerpt
openapi: 3.0.1
paths:
  /financial-statements/:accounting-completed:
    post:
      operationId: accountingCompleted
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FSAccountingCompletedCommand'
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancialStatement'
FSAccountingCompletedCommand.java
public class FSAccountingCompletedCommand implements Command, FsUuidAttributeEnabled {

    @NonNull @NotNull
    private UUID fsUuid;

    @Nullable
    private Instant accountingCompletedAt;

    @NonNull @NotNull @Valid
    private List<BookedAccountingTransaction> bookedTransactions;
}
BookedAccountingTransaction.java
public class BookedAccountingTransaction {

    @NonNull @NotNull private UUID txUuid;
    @NonNull @NotNull private LocalDate date;
    @NonNull @NotNull private String description;
    @NonNull @NotNull private BigDecimal amount;

    @NonNull @NotNull @Valid
    private List<TransactionLine> lines;
}

Reopen fs when reverting "close year"

Reopen fs when accounting has been completed.

Request example: HTTP fs reopen
# variables
@host = http://api.tritt.test/finsta
@tenantId = _313887944aab3c375c5ef
@orgNo = 313887944
@fsUuid = e42fbd6d-496e-4f65-ade2-5221bf4f33f6
@auth = Bearer <jwt>

### fs reopen
POST {{host}}/finsta/financial-statements/:reopen
Accept: */*
OrganizationId: {{tenantId}}
X-ORG-NO: {{orgNo}}
Authorization: {{auth}}
Content-Type: application/json

{
  "fsUuid": "{{fsUuid}}"
}
Response example: fs reopen
{
  "uuid": "29b00d74-95a9-4fad-9d74-d0c8925d41b9",
  "orgNo": "313887944",
  "year": 2024,
  "period": {
    "startsAt": "2024-01-01",
    "endsAt": "2024-12-31"
  },
  "name": "Årsoppgjør",
  "businessType": "LimitedStockCompany",
  "accountingObligationType": "Obliged",
  "attributes": {
    "assessmentType": "SelfAssessment",
    "draftUuid": "dd167393-6564-4db9-844c-dacf378b8d2e",
    "liquidated": false
  },
  "states": {
    "fs": "InProgress"
  },
  "createdAt": "2024-11-13T20:34:07.745745Z",
  "modifiedAt": "2024-11-14T09:23:28.387364553Z",
  "remarks": []
}
OpenAPI excerpt
openapi: 3.0.1
paths:
  /financial-statements/:reopen:
    post:
      operationId: reopenFinancialStatement
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FSReopenCommand'
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancialStatement'

Update accounting system reference

Update the accounting system reference.

The accounting system reference should only be updated when it is missing, or when it refers to the wrong orgId in DIY (systemKey="conta-diy").

This will ensure that users / orgs with more than one accounting system can create financial statements with different sources / integrations.

Request example: HTTP fs update accounting system reference
# variables
@host = http://api.tritt.test/finsta
@tenantId = _3138879447923ccd27214
@orgNo = 313887944
@fsUuid = 29b00d74-95a9-4fad-9d74-d0c8925d41b9
@auth = Bearer <jwt>

### fs update accounting system reference
PUT {{host}}/financial-statements
Accept: */*
OrganizationId: {{tenantId}}
X-ORG-NO: {{orgNo}}
Authorization: {{auth}}
Content-Type: application/json

{
  "fsUuid": "{{fsUuid}}",
  "patches": [
    {
      "key": "accountingSystemReference",
      "value": {
        "systemKey": "conta-diy",
        "orgIdentifier": {
          "key": "orgId",
          "value": "1337"
        },
        "hostUri": "https://app.conta.foo/regnskap"
      }
    }
  ]
}
Response example: fs update accounting system reference
{
  "uuid": "29b00d74-95a9-4fad-9d74-d0c8925d41b9",
  "orgNo": "313887944",
  "year": 2024,
  "period": {
    "startsAt": "2024-01-01",
    "endsAt": "2024-12-31"
  },
  "name": "Årsoppgjør",
  "accountingSystemReference": {
    "systemKey": "conta-diy",
    "hostUri": "https://app.conta.foo/regnskap"
  },
  "accountingSystemInfo": {
    "systemReference": {
      "systemKey": "conta-diy",
      "hostUri": "https://app.conta.foo/regnskap"
    }
  },
  "createdAt": "2024-11-13T20:34:07.745745Z",
  "modifiedAt": "2024-11-14T10:43:03.158168678Z",
  "remarks": []
}
OpenAPI excerpt
openapi: 3.0.1
paths:
  /financial-statements:
    put:
      operationId: updateFinancialStatement
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateFinancialStatementCommand'
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinancialStatement'
components:
  schemas:
    UpdateFinancialStatementCommand:
      required:
        - fsUuid
        - patches
      type: object
      properties:
        patches:
          minItems: 1
          type: array
          items:
            $ref: '#/components/schemas/PatchTuple'
        cmdUuid:
          type: string
          format: uuid
        cmdSourceRef:
          type: string
        tenantId:
          type: string
        fsUuid:
          type: string
          format: uuid
    PatchTuple:
      required:
        - key
      type: object
      properties:
        key:
          type: string
        value:
          type: object
          nullable: true
        type:
          type: string
          nullable: true