# 3PL Storage Invoice Auditor (`afkdigital/newapi89-3pl-storage-invoice-auditor`) Actor

Audit storage-only 3PL invoice lines against daily inventory and customer-defined rates. CSV/XLSX input, decimal calculations and source row evidence.

- **URL**: https://apify.com/afkdigital/newapi89-3pl-storage-invoice-auditor.md
- **Developed by:** [AFK Digital](https://apify.com/afkdigital) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$2.00 / 1,000 invoice line revieweds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## 3PL Storage Invoice Auditor — 0.1.1

Compare **storage charges only** with customer-supplied daily inventory and contractual rates. No 3PL login, freight audit, payment execution or claim submission.

### Input files

Supply each file as a JSON descriptor: CSV `{"format":"csv","csv":"header\\nrow\\n"}`, or XLSX `{"format":"xlsx","base64":"..."}`. XLSX must contain one sheet, with headers in row 1. Formulas are rejected; export values first. Blank rows are not silently removed. CSV is UTF-8, comma-delimited, with a header. Physical spreadsheet/CSV record numbers are tracked starting at 2 (header is 1; a multiline CSV field is one logical record).

- dailyStorageFile: warehouse, storage_type, unit, date, quantity. Exactly one snapshot per warehouse/type/unit/day. Aggregate SKU detail before uploading. Missing days and duplicate snapshots require review.
- storageRateCardFile: warehouse, storage_type, unit, currency, start, end, rate, basis, rounding, money_decimals, money_rounding, minimum_charge, free_days.
- invoiceFile: invoice_line_id, warehouse, storage_type, unit, currency, start, end, quantity, charge, document_type.
- columnMapping: optional objects named dailyStorage, storageRateCard, invoice. Each maps canonical column name to uploaded column name.
- billingPeriod: inclusive ISO start/end, maximum 367 dates.
- tolerance: absolute money tolerance as a decimal string; default 0.01.
- maxInvoiceLines: 1–5000, default 1000. Exceeding a limit fails rather than silently truncating.

Empty/default input runs the synthetic two-day demo. Partial real file input never uses demo data.
Limits: each file 10 MiB; XLSX expanded archive 50 MiB; 50 columns; 20,000 characters per cell; 100,000 daily records; 1,000 rates; 5,000 invoice records. Work exceeding the documented calculation budget is rejected. Recommended Actor memory 512 MiB, timeout 300 seconds.

### Explicit rules

All money is calculated with Python Decimal and returned as decimal strings. Supply decimal point values without thousands separators. Rate dates and invoice dates are inclusive.
Units are opaque exact keys: pallet-day, shelf-day, volume-day or customer-defined units remain separate. No unit or currency conversion is inferred. Each row must state its unit.

- basis=daily_snapshot: sum daily quantity times that day's applicable rate.
- basis=period_peak: largest daily quantity, multiplied by rate. Requires peak_multiplier=once or number_of_days. Peak applies to this invoice line's period. Rate changes combined with peak billing require manual review.
- rounding=none, or ceil with a positive rounding_increment. Quantity rounding applies before daily billing or peak selection.
- money_decimals=0–6 and money_rounding=half_up or half_even are mandatory.
- minimum_charge=0 explicitly disables a minimum. A positive value requires minimum_scope=invoice_line; applied after summing and before final money rounding. Warehouse/month minima shared by multiple lines require manual review.
- free_days=0 explicitly disables free days. Positive integer values require free_days_scope=first_days_of_invoice_line. This means the first N calendar dates of this line, not receipt-based or inventory-age-based exemptions. Other free-day rules require review. Peak plus free days requires review.
- Date-based daily rates can change; each date must have exactly one matching tariff. Changes to minimum, free-day, peak or money rules require split lines.
- Partial months use only actual inclusive invoice dates. No monthly prorating is inferred.
- Negative quantities, duplicate/overlapping invoice scopes, missing/ambiguous rates and unsupported rules return null expected cost with a reason.
- Credits are identified using document_type=credit_note or negative charge, isolated for review and excluded from calculated totals. Credit allocation is never inferred.

### Results

One Dataset item per invoice line, including invoice_line_id, warehouse, storage_type, billed_period, billed_quantity, expected_quantity, expected_charge, invoiced_charge, difference, currency, calculation_breakdown, evidence_rows, status and reason.
difference = invoiced_charge minus expected_charge. Positive differences are review candidates, not confirmed overpayments or recoverable savings.
Quantity differences are shown independently of money tolerance. Missing/invalid costs return null, never zero.
Dataset exports support JSON/CSV. Key-value outputs: OUTPUT (JSON), OUTPUT_CSV (nested fields JSON encoded), SUMMARY (currency-separated invoice totals). CSV protects text against spreadsheet formula execution; negative text values may have a leading apostrophe.

### Example

2 pallet-days on February 1 and 4 on February 2 at USD 0.10:
expected quantity 6; expected charge USD 0.60; invoiced USD 1.00; difference USD 0.40.
Evidence: invoice row 2, daily rows 2 and 3, tariff row 2.

### Privacy

The Actor does not log commercial file contents, amounts or row values. Inputs and audit results contain business data and are stored in Apify run storage under the run owner's access and retention settings. No third-party requests, tracking or 3PL credentials are used by the audit. No external file download is supported. Delete run inputs/outputs and configure retention according to your policy; a public Actor does not mean customer Dataset results should be shared.

### Pricing

USD 2.00 per 1,000 reviewed invoice lines (USD 0.002 per line). Billing uses only apify-default-dataset-item at that price, one output per invoice row, including needs_review and credit lines. Daily inventory rows and rate rows carry no separate event fee. No separate Actor start charge applies. No manual charge call is made, avoiding double charging.
Current Apify published compute price: USD 0.20/CU at FREE/BRONZE, USD 0.16 SILVER, USD 0.13 GOLD. Apify commission is 20%; platform usage may be deducted from payout. Sources checked November 11, 2026:
https://docs.apify.com/actors/monetize/pricing-and-costs
https://docs.apify.com/actors/monetize/pay-per-event
At 512 MiB for 5 minutes, compute alone is 0.04167 CU = USD 0.00833 at USD 0.20/CU. Storage/data operations add cost. This is a ceiling scenario estimate, not a measured Apify cloud bill. Actual cloud test costs are recorded in the release report.
Price and paid publication authorized by the owner.

### Development

`docker build -t newapi89:0.1.0 .`
`docker run --rm newapi89:0.1.0 python -m unittest discover -s tests -v`
`docker run --rm newapi89:0.1.0`
This is a batch file audit, not continuous monitoring. Evidence refers to uploaded records; it is not independent verification of physical stock or contractual validity.

Spending limits: Dataset, JSON, CSV and SUMMARY contain the same affordable subset of invoice lines. SUMMARY reports supplied and withheld counts. Increase your spending limit to receive all lines.

# Actor input Schema

## `dailyStorageFile` (type: `object`):

CSV: {csv: string, format: csv}. XLSX: {base64: string, format: xlsx}. Maximum 10 MiB.

## `storageRateCardFile` (type: `object`):

CSV: {csv: string, format: csv}. XLSX: {base64: string, format: xlsx}. Maximum 10 MiB.

## `invoiceFile` (type: `object`):

CSV: {csv: string, format: csv}. XLSX: {base64: string, format: xlsx}. Maximum 10 MiB.

## `columnMapping` (type: `object`):

Canonical column to uploaded column mappings grouped by dailyStorage, storageRateCard and invoice.

## `billingPeriod` (type: `object`):

Inclusive ISO dates: start and end.

## `tolerance` (type: `string`):

Nonnegative absolute money tolerance as decimal string.

## `maxInvoiceLines` (type: `integer`):

Maximum reviewed invoice lines. Exceeding this limit rejects the input.

## Actor input object example

```json
{
  "columnMapping": {},
  "tolerance": "0.01",
  "maxInvoiceLines": 1000
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `summary` (type: `string`):

No description

## `csv` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("afkdigital/newapi89-3pl-storage-invoice-auditor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("afkdigital/newapi89-3pl-storage-invoice-auditor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call afkdigital/newapi89-3pl-storage-invoice-auditor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,afkdigital/newapi89-3pl-storage-invoice-auditor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/TDxKfNdHVUjcup8C0/builds/s3XOJyD2f5T4KUs0P/openapi.json
