feat(clientes): alta de cliente in one screen, opening balance as a payment
Build and Push Images / Build jorgecuadros-web (push) Successful in 1m57s
Build and Push Images / Build jorgecuadros-api (push) Successful in 2m51s

The 2026-10-08 ask: open an account without four screens — cliente,
propiedad, servicios and the saldo inicial, taken as the first payment.

POST /customers/onboard writes it all in one Prisma transaction; a bad
service or a taken folder number leaves nothing behind (rolled back on dev).
A cash opening balance goes through the EFE receipt book inside that same
transaction, so it gets its folio and its C<folio> credit; a check posts a
CHECK DEPOSIT against the number given. /clientes/alta pre-fills the next
free folder number and links the receipt for printing. The old
customer-only form stays as "Solo cliente".

Built without the screen sketch from the meeting (it never arrived); the
fields are the legacy ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rmancinasandClaude Opus 5.5 committed 2026-10-12 19:27:00 -07:00
1 parent ca76f4d57a
commit 6468811955
11 files changed
+568 -8

No files matched your search

@@ -19,6 +19,7 @@ import { CustomersService } from "./customers.service";
import { NumidService } from "./numid.service";
import { CreateCustomerDto } from "./create-customer.dto";
import { UpdateCustomerDto } from "./update-customer.dto";
import { OnboardCustomerDto } from "./onboard-customer.dto";
@UseGuards(AuthenticatedGuard, AbilityGuard)
@Controller("customers")
@@ -83,6 +84,26 @@ export class CustomersController {
return c;
}
/**
* Alta en una pantalla. Gated on customer:create; the property, service and
* ledger abilities it also exercises sit at the same STAFF tier.
*/
@Post("onboard")
@RequireAbility("customer:create")
async onboard(@Body() dto: OnboardCustomerDto, @Req() req: Request) {
const r = await this.customers.onboard(dto, this.actingId(req));
void this.audit.log(this.actingId(req), "customer.onboard", {
customerId: r.customer.id,
name: r.customer.name,
folderNumber: r.customer.folderNumber,
propertyId: r.property?.id,
services: dto.services?.length ?? 0,
folio: r.receipt?.folio,
openingTransactionId: r.receipt?.transactionId ?? r.payment?.id,
});
return r;
}
@Patch(":id")
@RequireAbility("customer:update")
async update(