---
description: >-
  Implementation of the latest Diamant webservice to access and modify data in
  your accounting software. Here is an explanation of writing data.
---

# Writing data

### PostCustomer

Creates a new customer record.

#### Example

```javascript
let result = app.businessFunction({
    functionName: "Diamant",
    methodName: "PostCustomer", 
    companyId: 999,
    designation: "Muster GmbH",
    designation2: "Abteilung Einkauf",
    matchCode: "MUSTGMBH",
    accountId: "10050",
    dunningType: "STD",
    vatIdentNumber: "DE123456789",
    taxNumber: "31/432/70358",
    summaryAccount: "1200",
    bankId: 98765,
    bankAccountNumber: "1234567890",
    iban: "DE89370400440532013000",
    isVariousAccount: false,
    paymentCondition: "14T2%30T",
    paymentMethod: "U",
    paymentsExclusion: "2025-03-07T10:52:16.775Z",
    bankAccountHolder: "Muster GmbH",
    paymentsExclusionReason: "Dispute",
    alternativeBankDetailsTab: [
        {
            bankId: 87654,
            bankAccountNumber: "0987654321",
            iban: "DE27100777770209299700",
            bankAccountHolder: "Muster GmbH Zweitkonto"
        }
    ]
});
```

### PostVendor

Creates a new vendor record.

#### Example

```javascript
let result = app.businessFunction({
    functionName: "Diamant",
    methodName: "PostVendor",
    companyId: 999,
    designation: "Technik Supplies GmbH",
    designation2: "Büroausstattung",
    matchCode: "TECHSUPP",
    vatIdentNumber: "DE987654321",
    taxNumber: "76/543/21098",
    summaryAccount: "7000",
    bankId: 12345,
    bankAccountNumber: "9876543210",
    iban: "DE45500105174529223988",
    isVariousAccount: false,
    paymentCondition: "30T",
    paymentMethod: "T",
    paymentsExclusion: "2025-03-07T10:56:28.722Z",
    bankAccountHolder: "Technik Supplies GmbH",
    paymentsExclusionReason: "Reorg",
    accountId: "70050",
    customerIdAtVendor: "CU-78901",
    alternativeBankDetailsTab: [
        {
            bankId: 54321,
            bankAccountNumber: "1122334455",
            iban: "DE91100000000123456789",
            bankAccountHolder: "Technik Supplies International"
        }
    ]
});
```

### PostContactPerson

Creates a contact person record.

#### Example

```javascript
let result = app.businessFunction({
    functionName: "Diamant",
    methodName: "PostContactPerson", 
    companyId: 999, 
    contactPersonId: 12345,
    addressId: 5678,
    salutationId: 2, // Assuming this is an ID for Mr/Ms etc.
    title: "Dr.",
    firstName: "Anna",
    name: "Schmidt",
    function: "Purchasing Manager",
    extension: "4302",
    email: "a.schmidt@example.com",
    fax: "+49 89 1234567",
    mobileNumber: "+49 170 9876543",
    letterSelection: "BS",
    changeDate: "2025-03-07T10:58:11.107Z",
    changedBy: "SYSTEM"
});
```

### PostOpenStack

Opens a transaction stack.

#### Example

```javascript
let result = app.businessFunction({
    functionName: "Diamant",
    methodName: "PostOpenStack", 
    companyId: 999
});
```

### PostTransactionBatch

Posts a batch of transactions.

#### Example

```javascript
let result = app.businessFunction({
    functionName: "Diamant",
    methodName: "PostTransactionBatch", 
    companyId: 999,
    stackNumber: 447711,
    transactionTab: [
        {
            transactionId: 12345,
            transactionType: "INVP",
            transactionDate: "2025-03-07T11:06:54.038Z",
            transactionNumber: "INV-2025-0567",
            internalTransactionNumber: "202503-1234",
            currency: "EUR",
            rate: 1.0,
            archiveKey: "AP/2025/03/0567",
            barcode: "20250300567",
            allowDuplicateBarcode: false,
            ledgerEntryNumber: 5678,
            origin: "AP",
            accountAssignmentTab: [
                {
                    accountAssignmentId: 78901,
                    accountId: "7000",
                    taxCode: 19,
                    debit: 2380.00,
                    credit: 0,
                    turnover: 2380.00,
                    text: "Office supplies purchase",
                    fcDebit: 2380.00,
                    fcCredit: 0,
                    fcTurnover: 2380.00,
                    movementTypeId: "PURCH",
                    associatedCompanyId: "SUP123",
                    costAccountingDataTab: [
                        {
                            costAccountingDataId: 23456,
                            costCenterId: "4000",
                            costObjectId: "ADMIN",
                            projectId: "OPS2025",
                            amount: 2000.00,
                            fcAmount: 2000.00,
                            quantity: 1,
                            costElementId: "OFFICE"
                        }
                    ],
                    openItemDataTab: [
                        {
                            openItemDataId: 34567,
                            amount: 2380.00,
                            fcAmount: 2380.00,
                            valueDate: "2025-03-07T11:06:54.038Z",
                            dueDate: "2025-04-06T11:06:54.038Z",
                            cashDiscount1To: "2025-03-17T11:06:54.038Z",
                            cashDiscount1Percent: 2.0,
                            cashDiscount2To: "2025-03-27T11:06:54.038Z",
                            cashDiscount2Percent: 1.0,
                            text: "Office supplies invoice",
                            openItemInvoiceType: "I",
                            additionalField1: "PO-2025-123",
                            additionalField2: "Admin Department",
                            additionalField3: "Regular Supplier",
                            additionalField4: "",
                            additionalField5: "",
                            additionalField6: "",
                            additionalField7: "",
                            additionalField8: "",
                            additionalField9: "",
                            additionalField10: "",
                            note: "Monthly office supplies",
                            name: "Office Supply Co.",
                            name2: "Munich Branch",
                            contactPerson: "Max Mustermann",
                            street: "Hauptstrasse 123",
                            town: "Munich",
                            faxNumber: "+49 89 1234567",
                            email: "invoices@officesupply.example",
                            bankId: 98765,
                            bankAccountNumber: "1234567890",
                            iban: "DE89370400440532013000",
                            bankAccountHolder: "Office Supply Co."
                        }
                    ]
                },
                {
                    accountAssignmentId: 78902,
                    accountId: "1903",
                    taxCode: 19,
                    debit: 0,
                    credit: 380.00,
                    turnover: 380.00,
                    text: "VAT on office supplies",
                    fcDebit: 0,
                    fcCredit: 380.00,
                    fcTurnover: 380.00,
                    movementTypeId: "VAT",
                    associatedCompanyId: ""
                },
                {
                    accountAssignmentId: 78903,
                    accountId: "70050",
                    taxCode: 0,
                    debit: 0,
                    credit: 2000.00,
                    turnover: 2000.00,
                    text: "Office supplies vendor",
                    fcDebit: 0,
                    fcCredit: 2000.00,
                    fcTurnover: 2000.00,
                    movementTypeId: "VEND",
                    associatedCompanyId: "SUP123"
                }
            ],
            postingPeriod: {
                year: 2025,
                month: 3,
                periodType: "Normal"
            }
        }
    ]
});
```

### PostCloseStack

Closes a transaction stack.

#### Example

```javascript
let result = app.businessFunction({
    functionName: "Diamant",
    methodName: "PostCloseStack", 
    companyId: 999,
    stackNumber: 447711
});
```

### PostReverseTransaction

Reverses a transaction.

#### Example

```javascript
let result = app.businessFunction({
    functionName: "Diamant",
    methodName: "PostReverseTransaction", 
    companyId: 999,
    transactionId: 78901,
    reversingTransactionData: {
        transactionNumber: "INV-2025-0342",
        internalTransactionNumber: "202503-0789",
        transactionDate: "2025-03-07T11:00:49.972Z",
        postingText: "Reversal of incorrect invoice posting",
        postingPeriod: {
            year: 2025,
            month: 3,
            periodType: "Normal" 
        }
    }
});
```

### PostGenLedgerAccount

Creates a general ledger account.

#### Example

```javascript
let result = app.businessFunction({
    functionName: "Diamant",
    methodName: "PostGenLedgerAccount",
    designation: "Marketing Department",
    designation2: "Digital Campaigns",
    matchCode: "MKTDIG",
    companyId: 999, 
    accountId: "4500",
    type: "PR", 
    discountAccount: "8100",
    costElement: "MKT01"
});
```

### PostSettleOpenItems

Settles open items.

#### Example

```java
let result = app.businessFunction({
    functionName: "Diamant",
    methodName: "PostSettleOpenItems", 
    companyId: 999, 
    openItems: [
        {
            openItemId: 123456,
            transactionId: 78901,
            transactionPostingPeriod: {
                year: 2025,
                month: 3,
                periodType: "Normal"
            },
            transactionDate: "2025-03-07T11:02:57.446Z",
            transactionNumber: "INV-2025-0456",
            transactionInternalNumber: "202503-0892",
            transactionType: "SALE",
            transactionReversingTransactionId: 0,
            transactionCurrency: "EUR",
            transactionOrigin: "AP",
            transactionPostingTime: "2025-03-07T11:02:57.446Z",
            transactionPostingBy: "USER",
            accountId: "10050",
            accountClass: "KR",
            postingAmount: 1250.00,
            postingFcAmount: 1250.00,
            postingText: "Invoice payment",
            postingCode: "P",
            openItemAmount: 1250.00,
            openItemFcAmount: 1250.00,
            openItemDueDate: "2025-04-07T11:02:57.446Z",
            openItemValueDate: "2025-03-10T11:02:57.446Z",
            openItemInvoiceType: "I",
            openItemCashDiscount1To: "2025-03-21T11:02:57.446Z",
            openItemCashDiscount1Percent: 2.0,
            openItemCashDiscount2To: "2025-03-31T11:02:57.446Z",
            openItemCashDiscount2Percent: 1.0,
            openItemPayedOn: "2025-03-20T11:02:57.446Z",
            openItemDunningLevel: "00",
            openItemLastDunningLetter: "2025-03-07T11:02:57.446Z",
            openItemTaxCode1DiscountableAmount: 1050.00,
            openItemTaxCode1FcDiscountableAmount: 1050.00,
            openItemTaxCode2DiscountableAmount: 0,
            openItemTaxCode2FcDiscountableAmount: 0,
            openItemLastChange: "2025-03-07T11:02:57.446Z",
            openItemAddressIban: "DE89370400440532013000",
            openItemAdditionalField1: "Project A",
            openItemAdditionalField2: "Department 3",
            openItemAdditionalField3: "Contract 2025-034",
            openItemAdditionalField4: "",
            openItemAdditionalField5: "",
            openItemAdditionalField6: "",
            openItemAdditionalField7: "",
            openItemAdditionalField8: "",
            openItemAdditionalField9: "",
            openItemAdditionalField10: "",
            settlementRowId: 5678,
            settlementAmount: 1250.00,
            settlementFcAmount: 1250.00,
            settlementWithOpenItemId: 78654,
            settlementWithTransactionInternalNumber: "202503-0675",
            settlementWithTransactionType: "PAYM",
            settlementWithTransactionDate: "2025-03-20T10:15:00.000Z",
            settlementNumber: 20250301,
            settlementYear: 2025,
            settlementWriteOffScenarioId: 0
        }
    ]
});
```

### PostBank

Creates a new bank record.

#### Example

```javascript
let result = app.businessFunction({
    functionName: "Diamant",
    methodName: "PostBank",
    companyId: 999,
    bankId: 98765,
    bankSortingCode: 70050000,
    designation: "Sparkasse München",
    bic: "BYLADEM1KMS",
    name1: "Stadtsparkasse München",
    name2: "Hauptfiliale",
    street: "Sendlinger Str. 28",
    town: "80331 München",
    countryByNorm: "DE",
    norm4Country: "ISOa2",
    countryID: "DE",
    bankType: 2,
    branch: "0001",
    changedBy: "TEST"
})
```

### PostCostCenter

Creates a cost center record.

#### Example

```javascript
let result = app.businessFunction({
    functionName: "Diamant",
    methodName: "PostCostCenter"
    designation: "Production Department",
    designation2: "Assembly Line 3",
    matchCode: "PRODASL3",
    deleteRegistered: false,
    postBlocked: true,
    companyId: 999, 
    costCenterId: "6000",
    costCenterType: "P"
});
```

### PostCostObject

Creates a cost object record.

#### Example

```javascript
let result = app.businessFunction({
    functionName: "Diamant",
    methodName: "PostCostObject",
    designation: "Project Alpha",
    designation2: "Phase 2 Implementation",
    matchCode: "PROJALPHA2",
    deleteRegistered: false,
    postBlocked: true,
    companyId: 999,
    costObjectId: "PR2023-005",
    costObjectType: 3
});
```

### SaveIIBTransaction

Posts a single transactions using the old SOAP api.

#### Example

```javascript
let result = app.businessFunction({
    functionName: "Diamant",
    methodName: "SaveIIBTransaction",
    company: 999,
    iibStatus: 1,
    transactionType: "ERA",
    transDate: "2025-04-23T00:00:00",
    postingPeriod: "042025",
    transNumber: "CK-0423-99",
    internalTransNo: "799",
    currency: "EUR",
    rate: 1.0,
    barcode: "799",
    generalStatus: 2,
    // SOAP Flags
    flags: 0,
    allowDuplicateBarcode: true,
    postWithoutArchive: false,
    
    accountAssignments: [
        {
            key: null,
            accountNo: "70002",
            taxCode: null,
            debit: 119.0,
            credit: null,
            turnover: null,
            text: "Bueromaterial",
            fcDebit: null,
            fcCredit: null,
            fcTurnover: null,
            summaryAccount: null,
            balance: null,
            cAccData: [
                {
                    costCenter: "320",
                    costObject: null,
                    amount: 119.0,
                    fcAmount: null,
                    quantity: null,
                    unit: null
                }
            ]
        },
        {
            key: null,
            accountNo: "4930",
            taxCode: null,
            debit: null,
            credit: 119.0,
            turnover: null,
            text: "Lieferant XYZ",
            fcDebit: null,
            fcCredit: null,
            fcTurnover: null,
            summaryAccount: null,
            balance: null
        }
    ]

};
```

