> For the complete documentation index, see [llms.txt](https://help.dollarlabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.dollarlabs.io/dollarback-store-credit/analytics-data-and-account/move-balance-to-company-location.md).

# Move a customer's balance to their company location

{% hint style="info" %}
**Plan:** the bulk import route needs a plan with bulk import and B2B store credit; check your plan's feature list. The Shopify Flow route uses only Shopify's own Flow app.
{% endhint %}

When you're done, a customer who registers as a business (becomes a contact on a company location) will be able to spend the cashback they earned as an individual, because the balance now sits on their company location.

## Why the balance needs to move

Once a customer is a contact on a company location, their checkout becomes a B2B checkout. At a B2B checkout, Shopify only offers store credit held on the **company location**, not on the buyer's personal account (see Shopify's [considerations for B2B store credit](https://help.shopify.com/en/manual/b2b/checkout-and-orders/store-credit#considerations-for-accepting-store-credit-as-a-payment-method-for-b2b)). The personal balance isn't lost, it just can't be spent until it's on the location.

There are two ways to move it:

| Route                                          | Best for                                                                         | Effort                |
| ---------------------------------------------- | -------------------------------------------------------------------------------- | --------------------- |
| [Shopify Flow](#automate-it-with-shopify-flow) | Every new registration, automatically                                            | One-time setup        |
| [Bulk import](#move-a-balance-by-hand)         | Customers who registered before you set up the workflow, or fixing a single case | A minute per customer |

## Prerequisites

* Shopify B2B set up, with companies and company locations.
* **Give store credit to B2B buyers on company locations** turned on in **DollarBack admin → Settings → Advanced**, so future B2B orders earn on the location. See [B2B store credit](https://help.dollarlabs.io/dollarback-store-credit/analytics-data-and-account/b2b-store-credit.md).
* For the Flow route: the Shopify Flow app installed on your store.

<figure><img src="https://2844543096-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcVBfwy7Yj4tU8TsxkHEr%2Fuploads%2Fgit-blob-259cc2529e62e4e71aab1766703fceb724a292f7%2Fdb-settings-advanced-annotated.png?alt=media" alt="The expanded Advanced card in Settings with the order edit tracking and B2B store credit checkboxes and the Exclude customers by tag field." width="560"><figcaption><p>Give store credit to B2B buyers on company locations is in the Advanced section of Settings.</p></figcaption></figure>

## Automate it with Shopify Flow

The workflow has one trigger, one condition and two actions:

```
Trigger    Company contact assigned permission
Condition  The customer has a store credit balance above 0
Action 1   Send Admin API request → storeCreditAccountCredit  (credit the location)
Action 2   Send Admin API request → storeCreditAccountDebit   (debit the customer)
```

{% hint style="warning" %}
This workflow moves real store credit. Run it once on your own customer account before you rely on it, and check the result in Flow's run history.
{% endhint %}

### 1. Create the workflow and pick the trigger

1. In Shopify admin, open **Apps → Flow** and click **Create workflow**.
2. Click **Select a trigger** and choose **Company contact assigned permission**. It runs whenever a customer is given access to a company location, including when a registration form creates the company.

### 2. Add a condition

1. Click **+** → **Condition**.
2. Choose **Company contact → Customer → Store credit accounts**, set it to **At least one of**, then **Balance → Amount** **is greater than** `0`.

The condition also keeps the workflow from doing anything when the same customer is added to a second location later, because their personal balance is already zero.

### 3. Credit the company location

1. On the **Then** branch, add the action **Send Admin API request**.
2. Set **Mutation** to `storeCreditAccountCredit`.
3. Paste this into **Mutation inputs**. Change `EUR` to your store credit currency.

{% code title="Mutation inputs: storeCreditAccountCredit" %}

```liquid
{%- assign amount = 0 -%}
{%- assign currency = "EUR" -%}
{%- for account in companyContact.customer.storeCreditAccounts -%}
  {%- if account.balance.currencyCode == currency -%}
    {%- assign amount = account.balance.amount -%}
  {%- endif -%}
{%- endfor -%}
{%- for assignment in companyContact.roleAssignments -%}
  {%- if forloop.first -%}
{
  "id": "{{ assignment.companyLocation.id }}",
  "creditInput": {
    "creditAmount": { "amount": "{{ amount }}", "currencyCode": "{{ currency }}" }
  }
}
  {%- endif -%}
{%- endfor -%}
```

{% endcode %}

### 4. Debit the customer's personal balance

1. Below the first action, add a second **Send Admin API request**.
2. Set **Mutation** to `storeCreditAccountDebit`.
3. Paste this into **Mutation inputs**, using the same currency as step 3.

{% code title="Mutation inputs: storeCreditAccountDebit" %}

```liquid
{%- assign amount = 0 -%}
{%- assign currency = "EUR" -%}
{%- for account in companyContact.customer.storeCreditAccounts -%}
  {%- if account.balance.currencyCode == currency -%}
    {%- assign amount = account.balance.amount -%}
  {%- endif -%}
{%- endfor -%}
{
  "id": "{{ companyContact.customer.id }}",
  "debitInput": {
    "debitAmount": { "amount": "{{ amount }}", "currencyCode": "{{ currency }}" }
  }
}
```

{% endcode %}

Keep the credit action first and the debit action second, so the customer never ends up with less than they had.

### 5. Turn it on

Name the workflow (for example *Move cashback to company location*) and click **Turn on workflow**.

### Good to know

* **Currency:** the workflow moves one currency. If you issue store credit in several currencies, make one copy of the workflow per currency.
* **Several locations:** the balance goes to the first location the customer is assigned to. For a new registration, that's the location the form creates.
* **Expiry:** the moved balance has no expiry date. To set one, add `"expiresAt": "2027-06-30T00:00:00Z"` inside `creditInput`.
* **Where it shows up:** the move happens directly in Shopify, so both transactions appear on the customer and the company location in Shopify admin. It doesn't appear in DollarBack's **Activity** log.
* **Credit still on hold** from a personal order lands on the personal account when it releases, after the workflow has run. Move it by hand with the steps below.

## Move a balance by hand

Use two one-row [bulk imports](https://help.dollarlabs.io/dollarback-store-credit/analytics-data-and-account/bulk-import-credit-csv.md): first credit the location, then debit the customer. Both appear in DollarBack's **Activity** log.

### 1. Find the balance and the location ID

1. In Shopify admin, open the customer and note their store credit balance and currency.
2. Open **Customers → Companies**, then the company, then the location. The location ID is the number at the end of the page address: `.../companies/.../locations/1234567890`.

{% hint style="warning" %}
Enter the location ID as a number only (`1234567890`), not in the `gid://shopify/CompanyLocation/...` form.
{% endhint %}

### 2. Credit the company location

Create a CSV with one row:

```
Email,CompanyLocationId,Amount,Currency,ExpiryDays
customer@example.com,1234567890,10.00,EUR,0
```

1. Open **DollarBack admin → Home** and, in the **Quick links** card, click **Open** next to **Bulk import**.
2. Set **Action Type** to **Credit** and turn on **B2B Mode**.
3. Leave **Notify Customers** off.
4. In **Reason**, enter something like *Moved personal balance to company location*.
5. Upload the file and click **Import CSV**.

<figure><img src="https://2844543096-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcVBfwy7Yj4tU8TsxkHEr%2Fuploads%2Fgit-blob-f3b877e4cdaba9ac9d6a2b12aa6a42fb01601083%2Fdb-bulk-import-b2b-move-annotated.png?alt=media" alt="The Upload CSV File card with Action Type, Credit expires, the Notify Customers, Send to Integrations and B2B Mode switches, and the Reason field." width="560"><figcaption><p>For a balance move, run two one-row imports: a Credit with B2B Mode on, then a Debit with B2B Mode off.</p></figcaption></figure>

`ExpiryDays` is optional: `0` means no expiry.

### 3. Debit the customer

Create a second CSV for the same customer and amount, without the location column:

```
Email,Amount,Currency
customer@example.com,10.00,EUR
```

1. Open **DollarBack admin → Home** and, in the **Quick links** card, click **Open** next to **Bulk import**.
2. Set **Action Type** to **Debit** and make sure **B2B Mode** is **off**.
3. Leave **Notify Customers** off.
4. Upload the file and click **Import CSV**.

To move several customers at once, put one row per customer in each file. Duplicate rows are not removed.

## Verify it works

* The company location in Shopify admin shows the moved balance.
* The customer's personal store credit is zero.
* A B2B checkout as that customer offers store credit as a payment method.

## Common issues

* **The Flow run failed:** open the run in Flow's run history to see which action failed. If the credit action failed, nothing was taken from the customer; move the balance by hand.
* **Bulk import rows failed with a location error:** the `CompanyLocationId` is wrong or belongs to another company. See [My bulk import failed](https://help.dollarlabs.io/dollarback-store-credit/troubleshooting-and-faq/bulk-import-failed.md).
* **Store credit isn't offered at checkout:** confirm the buyer is checking out on the location that holds the balance. See [Store credit isn't available at checkout](https://help.dollarlabs.io/dollarback-store-credit/troubleshooting-and-faq/store-credit-isnt-available-at-checkout.md).
* **Every buyer at the company can spend the balance:** that's expected. Location credit belongs to the business, not to one buyer.

## Related articles

* [B2B store credit](https://help.dollarlabs.io/dollarback-store-credit/analytics-data-and-account/b2b-store-credit.md)
* [Bulk import credit (CSV)](https://help.dollarlabs.io/dollarback-store-credit/analytics-data-and-account/bulk-import-credit-csv.md)
* [Shopify Flow: triggers and actions](https://help.dollarlabs.io/dollarback-store-credit/integrations/shopify-flow-triggers-and-actions.md)
