# Column Addition

## **Specs**

<table><thead><tr><th width="320">Label</th><th>Value</th></tr></thead><tbody><tr><td><strong>Version</strong></td><td>0.1.0 (updated on 2023-12-08)</td></tr><tr><td><strong>Developer</strong></td><td>Labii Inc.</td></tr><tr><td><strong>Type</strong></td><td>Column</td></tr><tr><td><strong>Support Configuration</strong></td><td>Yes</td></tr><tr><td><strong>Support Readonly view</strong></td><td>Yes</td></tr><tr><td><strong>Support Edit view</strong></td><td>Yes</td></tr><tr><td><strong>Support Form view</strong></td><td>Yes</td></tr><tr><td><strong>Support Default data</strong></td><td>Yes</td></tr><tr><td><strong>Support Import</strong></td><td>Yes</td></tr><tr><td><strong>Allow multiple</strong></td><td>Yes</td></tr></tbody></table>

## Overview

The Labii Column Addition widget is designed to perform calculations on numeric columns originating from a source record, defined by a ForeignKey widget. This powerful feature enables users to effortlessly manipulate and perform calculations on specified numeric data columns associated with interconnected records.

## Use case

1. Update the stock quantity after checkin/checkout.

## Configuration

To enable the widget's functionality, it requires the provision of options. Each option comprises the following two fields:

* **Source column** - To define the data source, select one of the ForeignKey columns.
* **Field Quantity** - Choose a quantity column to be updated. The value of the column have to be numeric.
* **Calculation** - How do you want to change the quantity value. Default to addition.
* Other configurations same as the [Number](https://docs.labii.com/widgets/column-widgets/form/text-inputs/number) widget.

### Examples:

```json
{
    "column": {
        "sid": "xxx",
        "name": "source"
    },
    "quantity": {
        "sid": "xxx",
        "name": "quantity"
    },
    "calculation": "subtraction",
    "format": {
        "thousand": ","
    },
    "constraints": {
        "min": 0
    }
}
```

## Views

See the interface of the widget in the following views.

### **Readonly view**

Readonly view display the values of the column.

<figure><img src="https://github.com/Labii/labii-gitbook-docs/blob/gitbook/widgets/.gitbook/assets/widget-column-column-addition-readonly.webp" alt=""><figcaption></figcaption></figure>

### **Edit view**

The Edit view is the interface that allows you to modify the value.

<figure><img src="https://github.com/Labii/labii-gitbook-docs/blob/gitbook/widgets/.gitbook/assets/widget-column-column-addition-edit.webp" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
The change of the value will trigger the addition/subtraction of the source column.
{% endhint %}

### **Form view**

The Form view is the field integrated into the add form for collecting values when creating a new record.

The Form view is same as the Edit view.

## Data

Each widget in Labii stores data in a unique manner; refer below to understand how data from this widget is stored.

### Data format

Numeric value.

### **Default value**

The Default Value field within the column allows you to specify the default value when a record is created.

Default value shall be a number.

### **Import value**

The Import Value is the value you need to include in your Excel table for it to be imported into Labii.

Import value shall be a number.
