Download the PHP package tmonier/sylius-trade-credit-plugin without Composer

On this page you can find all versions of the php package tmonier/sylius-trade-credit-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sylius-trade-credit-plugin

Sylius Trade Credit Plugin

Français : README.fr.md

Build

B2B trade credit for Sylius 2: let approved business customers pay on account ("net 30", "45 days end of month") within a credit limit.

Business buyers rarely pay by card: they order, receive an invoice and pay it by bank transfer 30 or 45 days later. Sylius can already show an "Offline" payment method, but it does not know who may use it, how much they still owe, when it is due, and its unpaid-orders job cancels those orders after 5 days.

This plugin turns an Offline payment method into a real payment on account: a credit account per customer with a limit, reservations made atomically at checkout, a statement in the customer account, open items and "Mark as paid" in the back office, due dates and payment terms in Factur-X invoices. B2B only: this is not consumer credit.

Features

Need What the plugin does
Decide who may pay on account Trade credit account per customer (admin, customer page): credit limit and currency, credit hold (manual block), allow exceeding the limit, block when overdue, own terms or the terms of the payment method, internal note.
Offer "pay on account" with terms Payment terms on an Offline payment method: net days and end-of-month mode (net N days, N days end of month, end of month + N days). The order stays awaiting payment: no new gateway.
Show the method only when it is allowed Through tmonier/sylius-order-hold-plugin: hidden in the shop and API method lists, never chosen as the default method, refused on method changes and at checkout completion (with a readable message), when the customer has no account, the order is not billed to a company, the account is on hold, has overdue items (if it blocks them) or not enough available credit.
Never exceed the limit, even with concurrent orders Atomic reservation when the checkout is completed: UPDATE ... SET committed = committed + :total WHERE ... AND (allow_exceed OR limit - committed >= :total). A refusal (another order used the credit meanwhile) is a redirect with a message in the shop and a 422 in the API, never a server error. Switching a placed order to or from payment on account reserves or releases.
Free the credit once, and only once The reservation is settled when the payment is completed (paid), released when the order is cancelled or the payment fails or is cancelled. A reservation is closed exactly once whatever the events (paid then refunded, order cancellation cascading to the payment...).
Keep orders on 30-day terms Orders with a reservation are excluded from sylius:cancel-unpaid-orders (in SQL).
No card payment for an order on account The shop pay page shows the thank-you page with the due date; the shop API refuses payment requests (customers cannot start, complete or refund their own payment).
Know what each customer owes Statement page in the customer account (limit, committed, available, open items with order, due date, overdue flag, invoice PDF link with sylius/invoicing-plugin) and read-only shop API GET /api/v2/shop/trade-credit/statement.
Collect payments Admin open items grid (state and overdue filters, search by order number or e-mail) with Mark as paid (core sylius_payment complete transition: invoicing listeners run as for any payment), ledger of every movement per account.
Stay within the law Warnings when terms exceed 60 days or 45 days end of month (France, L441-10; per channel limits for the sector caps of L441-11).
Factur-X invoices With tmonier/sylius-facturx-plugin 1.1: due date (BT-9) and payment terms (BT-20) of the order, with the late payment penalties and 40 EUR recovery indemnity mentions.
Detect drift tmonier:trade-credit:recalculate compares committed amounts with the open items (dry run; --apply fixes and logs an adjustment).
Record bank transfers in bulk (1.1) tmonier:trade-credit:import-payments payments.csv settles the open items of a CSV file (order number + amount, exact match): dry run by default, all or nothing (one wrong line and nothing is settled), idempotent (an order already paid is reported and skipped, never settled twice).
Remind customers (1.1) tmonier:trade-credit:send-reminders (daily cron): e-mail reminders before and after the due date, at configurable levels (default 5 days before, 1, 15 and 30 days after), one per open item and level, in the order locale (7 languages), with the L441-10 late payment mentions once overdue.
See how old the debt is (1.1) Ageing buckets (not due, 1-30, 31-60, 61-90, over 90 days) on the statement, in the shop API, on the customer card and for all accounts above the open items grid.
Use the credit position of your ERP (1.1) ExternalCreditProviderInterface: an ERP can provide the credit limit and the amount owed outside the shop; payment on account then uses them (fail closed when the ERP cannot be reached). Default: Sylius figures only.

Also included: demo fixture, translations in English, French, German, Spanish, Italian, Dutch and Polish, Twig Hooks, MySQL, MariaDB and PostgreSQL support.

Screenshots

Requirements

Version
PHP 8.2+ (8.3+ with Sylius 2.3)
Sylius 2.2.9+, 2.3
Symfony 6.4, 7.4 (Sylius 2.2); 6.4, 7.4, 8.0 (Sylius 2.3)
tmonier/sylius-order-hold-plugin 1.0 (installed as a dependency)

The checkout, order and payment graphs must use the Symfony Workflow adapter (Sylius 2 default); order-hold checks it when the container is compiled. Sylius 2.2.9 is the first 2.2 release with the fixes for GHSA-2rv4-pjmm-7fxf and GHSA-vv4h-q2x8-74g4 (payment requests).

Installation

  1. Require the package:

  2. Register both bundles in config/bundles.php:

  3. Import the configuration and the routes:

  4. Run the migration (plugin tables only, core tables are not changed):

  5. In the admin: create an Offline payment method (e.g. "On account (net 30)"), then Customers > Payment terms > Create for it; open a trade credit account from the customer page of each approved business customer.

Configuration

Optional, with the defaults:

A payment terms policy is checked against the caps of the channels of its payment method; an account with its own terms against the strictest configured cap.

Payment reminders

Run bin/console tmonier:trade-credit:send-reminders once a day (--dry-run lists them). For each open item (and each order left unpaid after leaving payment on account), only the highest level reached is sent, once: a level is recorded before the e-mail is sent (unique per order, due date and level), so running the command twice, or two runs at the same time, never sends a reminder twice; an e-mail that fails is sent by the next run. The e-mail (tmonier_trade_credit_payment_reminder, template @TmonierSyliusTradeCreditPlugin/email/payment_reminder.html.twig) goes to the customer of the order, in the order locale, with a link to the statement when the channel has a hostname.

Payments CSV import

A header line with order_number and amount (decimal, . or ,), optional currency; other columns (bank reference, date...) are ignored; ,, ; or tab separated. Each line must match an open item exactly (order number, amount, currency). Run it without --apply first:

Settling is the same as "Mark as paid" (core sylius_payment complete transition).

External credit provider (ERP)

The ERP limit (when not null) replaces the limit of the account and the amount owed outside the shop reduces the available credit, in the method lists and in the atomic reservation. If the provider throws (ERP unreachable), payment on account is refused with "temporarily unavailable" (fail closed) and the statement shows the Sylius figures. Called on each eligibility check: cache it in your provider if the ERP is slow.

Resources (account, payment_terms_policy, order_payment_terms, ledger_entry) can be overridden like any Sylius resource (tmonier_sylius_trade_credit.resources.account.classes.model, ...).

How it works

Customisation

Hook Content
sylius_admin.customer.show.content.sections → tmonier_trade_credit Trade credit card of the customer page
tmonier_trade_credit_admin.account.{create,update}.content.form.sections.general → fields Account form
tmonier_trade_credit_admin.payment_terms_policy.{create,update}.content.form.sections.general → fields Payment terms form
tmonier_trade_credit_admin.open_item.index.content → ageing Ageing of every account above the open items grid

Services: tmonier_trade_credit.reserver (only writer of committed amounts), tmonier_trade_credit.provider.account, tmonier_trade_credit.order_hold.eligibility_checker (can be decorated to add rules), tmonier_trade_credit.facturx.payment_terms_provider.

Demo data

The tmonier_trade_credit fixture (add it to a fixture suite) creates the "On account (net 30)" method and its policy, the verified B2B customer [email protected] / sylius (company "Acme Industries", 5,000.00 limit) with two orders on account, one of them overdue, and verifies the shop users of the fixtures (the demo channel requires a verified account to sign in).

Health probes

If tmonier/sylius-platform-health-plugin (^0.5) is installed, the plugin shows one probe in the Plugins category of the health page, the dashboard and tmonier:health:check. The health plugin is only suggested: without it nothing is loaded and nothing changes.

Identifier Measures ok warning
trade_credit.stale_reservations open reservations older than one hour whose order is not placed or was cancelled (the same list as tmonier:trade-credit:recalculate): the committed credit of an account is too high none at least one

Limitations

Development

See SPEC.md for the research and design decisions.

B2B demo

This plugin is used in the Sylius B2B demo: a Sylius 2.3 shop with fictitious sample data where the B2B plugins work together. The source code, setup and fixtures of the demo are in that repository.

The demo is an example, not a production setup.

License

MIT, see LICENSE.


All versions of sylius-trade-credit-plugin with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
sylius/sylius Version ^2.2.9 || ^2.3
symfony/clock Version ^6.4 || ^7.4 || ^8.0
tmonier/sylius-order-hold-plugin Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tmonier/sylius-trade-credit-plugin contains the following files

Loading the files please wait ...