event

Charge Installment Paid

A payment now covers an installment of a charge a school receives: the installment after the payment, PAID or, on a credit card, PENDING_SETTLEMENT, with its charge and the payment. Published by cna-one when the school registers a payment or a credit card sale, one message per installment the payment covers. No consumer yet.

Event Topic: ChargeInstallmentKey: idNo consumer

Overview

Fact: a payment was registered for an installment of a charge the school receives. The payload is the installment right after the write, with the charge it belongs to (code, contract, student, payer) and the payment that now covers it.

When it is published. CNA OneCNA OneServicev1.0.0Franchise operating system (franchises and employees, pricing, products and learning books, school operations, receivabl...PublishesGrantApplicationAccess, EmployeeCreated +19SubscribesInviteUser, FranchiseCreated +17Ownercna-platformMapRepoView docs, through chargeInstallmentPaidProducer, after the transaction that stores the payment, its cash entries and the history of each charge, from two flows:

  • registerChargePayment: the payment the school registers for installments of one contract, or of one charge with no contract;
  • registerCardSale: the credit card sale of every open installment of a charge, one card installment each, within the limit of the charge.
  1. One message per installment the payment covers, all in a single produce call. payment.amount is the total of the payment, not the amount of this installment.
  2. A payment by any method but a credit card pays the installment: status is PAID, and the amount it was due on payment.paidOn enters a cash account of the school.
  3. A credit card payment leaves each installment PENDING_SETTLEMENT: the money has not reached the school yet, and no cash entry is written. registerChargePayment takes a credit card in a single card installment, expected 30 days after payment.paidOn. In a card sale, the first open installment by due day is expected 30 days after the sale, the second 60, and so on, and payment.cardInstallments is how many installments the sale took. When the money arrives, Charge Installment SettledCharge Installment SettledEventv1.0.0The money of a credit card payment reached the school for an installment of a charge it receives: the installment PAID, ...Ownercna-platformSchemaMapView docs publishes the installment PAID.
  4. A refused payment (an installment paid by someone else in the meantime) stores and publishes nothing.

payment.origin is SCHOOL for a payment an employee registered, the only kind today. INTEGRATION is kept for a payment with no author, such as one a payment gateway confirms.

The payload carries no CPF, contact or card data. It does not carry what the installment was due on the day of the payment, late fee and interest included, either: a credit card payment does not store that amount per installment.

No consumer yet. Activating a contract does not consume this event: cna-one moves a PENDING_PAYMENT contract to ACTIVE on its first payment of a TUITION or LEARNING_BOOK installment inside the payment’s own transaction (cna-br/cna-one#1322, not in production yet), and undoing the payment leaves the contract active. Charge Installment Payment UndoneCharge Installment Payment UndoneEventv1.0.0The school undid the payment of an installment of a charge it receives: the installment open again (PENDING), with its c...Ownercna-platformSchemaMapView docs takes the fact back.

Kafka

Topic (aggregateRoot)ChargeInstallment
Message key (routingKey)payload.id
Contract ownerONE
metadata.eventChargeInstallmentPaid
Consumer group(none yet)

Payload schema

Source of truth

ChargeInstallmentPaidPayload is exported from this file and shared with Charge Installment Payment UndoneCharge Installment Payment UndoneEventv1.0.0The school undid the payment of an installment of a charge it receives: the installment open again (PENDING), with its c...Ownercna-platformSchemaMapView docs and Charge Installment SettledCharge Installment SettledEventv1.0.0The money of a credit card payment reached the school for an installment of a charge it receives: the installment PAID, ...Ownercna-platformSchemaMapView docs.

export type ChargeInstallmentPaidPayload = {
id: string;
franchiseId: string;
chargeId: string;
chargeCode: string;
contractId: string | null;
studentId: string | null;
enrollmentId: string | null;
contractItemId: string | null;
payerPersonId: string;
revenueType: RevenueType;
number: number;
totalNumber: number;
dueOn: string;
originalAmount: string;
status: ChargeInstallmentStatus;
expectedSettlementOn: string | null;
payment: {
id: string;
origin: "SCHOOL" | "INTEGRATION";
paymentMethod: PaymentMethod;
amount: string;
paidOn: string;
externalReference: string | null;
cardInstallments: number | null;
undoneAt: string | null;
};
};
class ChargeInstallmentPaid extends Event<ChargeInstallmentPaidPayload> {
public static owner = "ONE";
public static aggregateRoot = "ChargeInstallment";
public static routingKey = "id";
public static version = "1.0.0";
}

RevenueType and ChargeInstallmentStatus come from db/enums/financial/ChargeInstallment.ts, PaymentMethod from db/enums/financial/ChargePayment.ts. The class exists only in cna-one.

Custom properties

PropertyValue
Contract Ownerx-contract-ownerONE
Kafka Topicx-kafka-topicChargeInstallment
Message Keyx-message-keyid
Sourcex-sourcecna-one api/app/events/one/chargeInstallment/ChargeInstallmentPaid.ts
25 properties
idstring
required

Id (UUID) of the installment (financial.charge_installments). Kafka message key.

franchiseIdstring
required

School (franchise) the installment belongs to.

chargeIdstring
required

Charge (financial.charges) the installment belongs to.

chargeCodestring
required

Code of the charge, unique per school: COB, the school code and seven hexadecimal digits, e.g. COB-SP-090-1A2B3C4.

contractIdstring | null

Contract (school_ops.contracts) the charge bills, or null for a charge with no contract.

studentIdstring | null

Student (school_ops.students) the charge is for, or null.

enrollmentIdstring | null

Enrollment (module) the installment is owed for. Set only when its charge bills a single item of the contract; null otherwise.

contractItemIdstring | null

Contract line the installment is owed for. Set only when its charge bills a single item of the contract; null otherwise.

payerPersonIdstring
required

Person (common.persons) who pays the charge. For the charges of a contract, the contract holder.

revenueTypestring
required

Kind of revenue the installment is (cna-one RevenueType).

Allowed values: ENROLLMENT_FEE OTHER_FEE LEARNING_BOOK TUITION TERMINATION_SETTLEMENT AD_HOC
numberinteger
required

Position of the installment in its schedule, from 1.

totalNumberinteger
required

How many installments the schedule has.

dueOnstring<date>
required

Day the installment is due, YYYY-MM-DD, no time zone.

originalAmountstring
required

Decimal as a string with two places: the amount of the installment before discounts, late fee and interest.

statusstring
required

Status of the installment after the payment (cna-one ChargeInstallmentStatus): PAID, or PENDING_SETTLEMENT for a credit card payment whose money has not reached the school yet.

Allowed values: PENDING PAID PENDING_SETTLEMENT UNDER_RENEGOTIATION CANCELLED REVERSED
expectedSettlementOnstring | null<date>

Day the credit card payment is expected to reach the school, YYYY-MM-DD. Set only for a credit card payment; null otherwise.

paymentobject
required

The payment that now covers the installment.