How to reverse a batch and voucher?

Hello, my first post here, be kind

I am trying to reverse a batch and associated vouchers in a financial system
here is what I am trying to accomplish

  1. get json using the http module, example provided
  2. the voucher rows needs to be modified and the amountDomestic values reveresed , plus to minus
  3. a new graphql mutation structure needs to be created with the same batch and vouchers with the values reveresed. example output provided

this is the incoming json data, the number of voucher rows is dynamic

{
  "data": {
    "useCompany": {
      "batch": {
        "items": [
          {
            "batchNo": 11,
            "valueDate": 20241213
          }
        ]
      },
      "voucher": {
        "items": [
          {
            "voucherNo": 0,
            "voucherDate": 0,
            "debitAccountNo": 0,
            "creditAccountNo": 2920,
            "amountDomestic": 200
          },
          {
            "voucherNo": 0,
            "voucherDate": 0,
            "debitAccountNo": 7519,
            "creditAccountNo": 0,
            "amountDomestic": 200
          }
          
        ]
      }
    }
  },
  "extensions": {
    "id": "a90ffd7b31d8edcf35a2792119df5401"
  }
}

This is an example of what I want to send to the graphql server
please note that this is not json, it is graphql

mutation create_batch_and_vouchers($batchno: Int = 0) {
  useCompany(no: 12345) {
    batch_create(
      values: [{valueDate: 20250102, description: "testfile"}]
    ) {
      items {
        batchNo @export(as: "batchno")
      }
    }
    voucher_create(
      values: [
        {
          batchNo: $batchno, 
          amountDomestic: -200
          debitAccountNo: 7519, 
          valueDate: 20250101, 
          voucherDate: 20250101, 
          voucherType: 1
        }, 
        {
          batchNo: $batchno,
          amountDomestic: -200
          creditAccountNo: 2920, 
          valueDate: 20250101, 
          voucherDate: 20250101, 
          voucherType: 1
        }]
      suggest: {voucherNo: true}
    ) {
      affectedRows
    }
  }
}

when I ask AI I get so many confusing answers

can someone help me to layout a scenario for which apps to use and in which order

thanks

2 Likes

Hi @tadrian

Sorry but your problem is not clear to us. Could you please elaborate what are you trying to achieve?

Regards
Msquare Automation - Platinum partner of Make
@Msquare_Automation

1 Like