If you want to close a sales invoice, either against a credit note, or a payment you can use the EntryMatch endpoint to do that.
The EntryMatch endpoint accepts posting line ids, so to use it you will have to do the following
In the example where you want to match an invoice to a credit note, you will have to find journal and posting line ids for both the invoice and the credit note.
Query:
query($id: ID!) {
saleInvoice(id: $id) {
id
bookkeepingJournal { id }
}
}
Example response:
{
"data": {
"saleInvoice": {
"id": "9DhWnW",
"bookkeepingJournal": { "id": "4LCGvv" }
}
}
}
(you will have to do this twice for invoice/credit note matching)
Fetching journal: Query:
query($id: ID!){
bookkeepingJournal(id: 4LCGvv) {
id
postings {
postingLines {
id
amountCents
debitAccount {
id
code
subCode
}
creditAccount {
id
code
subCode
}
}
}
}
}
(you will have to do this twice for invoice/credit note matching)
Example response:
{
"data": {
"bookkeepingJournal": {
"id": "4LCGvv",
"postings": [ {
"postingLines": [ {
"id": "JeCRVx",
"amountCents": 15000,
"debitAccount": {
"id": "24HJA4y",
"code": "1500",
"subCode": "10005"
},
"creditAccount": {
"id": "ggHNwdQ",
"code": "3100",
"subCode": null
}
} ]
} ]
}
}
}
Mutation:
mutation ($postingLineId1: ID!, $postingLineId2: ID!, $accountId: ID!) {
bookkeepingEntryMatchCreate(entryMatch: {postingLines: [{id: JeCRVx}, {id: gYCr2n}], accountId: 24HJA4y}) {
id
postingEntriesDebit {
id
}
postingEntriesCredit {
id
}
}
}
Example response:
{
"data": {
"bookkeepingEntryMatchCreate": {
"id": "kQBSpD",
"postingEntriesDebit": [ {
"id": "JeCRVx"
}],
"postingEntriesCredit": [ {
"id": "JeCRVx"
}]
}
}
}
Mutation:
mutation ($id: ID!) {
bookkeepingEntryMatchDestroy(id: kQBSpD) {
id
}
}
Response:
{
"data": {
"bookkeepingEntryMatchDestroy": {
"id": "zdKSq6"
}
}
}
Enkelt, rimelig og bekymringsfritt regnskap for små bedrifter.
For kun 99,-/måned kan du fakturere dine kunder, holde regnskapet under kontroll, og rapportere det staten skal ha.
Prøv gratis i 30 dagerRelaterte artikler