|
@@ -21,7 +21,7 @@ public function __construct(AsaasClient $client)
|
|
|
*/
|
|
*/
|
|
|
public function ensureFranchiseeCustomer(Unit $unit): string
|
|
public function ensureFranchiseeCustomer(Unit $unit): string
|
|
|
{
|
|
{
|
|
|
- $cpfCnpj = preg_replace('/[^0-9]/', '', $unit->cnpj);
|
|
|
|
|
|
|
+ $cpfCnpj = $unit->cnpj->value();
|
|
|
|
|
|
|
|
if (empty($cpfCnpj)) {
|
|
if (empty($cpfCnpj)) {
|
|
|
throw new Exception("Unidade {$unit->fantasy_name} não possui CNPJ para ser cobrada.");
|
|
throw new Exception("Unidade {$unit->fantasy_name} não possui CNPJ para ser cobrada.");
|
|
@@ -36,13 +36,13 @@ public function ensureFranchiseeCustomer(Unit $unit): string
|
|
|
|
|
|
|
|
// Se não existe, cria um novo
|
|
// Se não existe, cria um novo
|
|
|
$payload = [
|
|
$payload = [
|
|
|
- 'name' => $unit->social_reason ?? $unit->fantasy_name ?? 'Franquia',
|
|
|
|
|
- 'cpfCnpj' => $cpfCnpj,
|
|
|
|
|
- 'email' => $unit->email,
|
|
|
|
|
- 'postalCode' => preg_replace('/[^0-9]/', '', $unit->postal_code),
|
|
|
|
|
- 'address' => $unit->street,
|
|
|
|
|
|
|
+ 'name' => $unit->social_reason ?? $unit->fantasy_name ?? 'Franquia',
|
|
|
|
|
+ 'cpfCnpj' => $cpfCnpj,
|
|
|
|
|
+ 'email' => $unit->email,
|
|
|
|
|
+ 'postalCode' => preg_replace('/[^0-9]/', '', $unit->postal_code),
|
|
|
|
|
+ 'address' => $unit->street,
|
|
|
'addressNumber' => $unit->address_number ?? 'S/N',
|
|
'addressNumber' => $unit->address_number ?? 'S/N',
|
|
|
- 'province' => $unit->neighborhood,
|
|
|
|
|
|
|
+ 'province' => $unit->neighborhood,
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
$mobilePhone = preg_replace('/[^0-9]/', '', $unit->cell_number ?? $unit->phone_number ?? '');
|
|
$mobilePhone = preg_replace('/[^0-9]/', '', $unit->cell_number ?? $unit->phone_number ?? '');
|
|
@@ -75,13 +75,13 @@ public function ensureStudentCustomer(Student $student): string
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$payload = [
|
|
$payload = [
|
|
|
- 'name' => $student->payer_name ?? $student->name,
|
|
|
|
|
- 'cpfCnpj' => $cpfCnpj,
|
|
|
|
|
- 'email' => $student->email,
|
|
|
|
|
- 'postalCode' => preg_replace('/[^0-9]/', '', $student->postal_code ?? ''),
|
|
|
|
|
- 'address' => $student->street,
|
|
|
|
|
|
|
+ 'name' => $student->payer_name ?? $student->name,
|
|
|
|
|
+ 'cpfCnpj' => $cpfCnpj,
|
|
|
|
|
+ 'email' => $student->email,
|
|
|
|
|
+ 'postalCode' => preg_replace('/[^0-9]/', '', $student->postal_code ?? ''),
|
|
|
|
|
+ 'address' => $student->street,
|
|
|
'addressNumber' => $student->address_number ?? 'S/N',
|
|
'addressNumber' => $student->address_number ?? 'S/N',
|
|
|
- 'province' => $student->neighborhood,
|
|
|
|
|
|
|
+ 'province' => $student->neighborhood,
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
$mobilePhone = preg_replace('/[^0-9]/', '', $student->phone ?? '');
|
|
$mobilePhone = preg_replace('/[^0-9]/', '', $student->phone ?? '');
|