|
@@ -387,6 +387,21 @@ private function buildReceivable(TbrCalculation $calculation, ?FranchiseeContrac
|
|
|
|
|
|
|
|
$calculation->update(['receivable_generated' => true]);
|
|
$calculation->update(['receivable_generated' => true]);
|
|
|
|
|
|
|
|
|
|
+ // Espelho na unidade: o TBR que a matriz cobra vira uma Conta a Pagar da
|
|
|
|
|
+ // franquia (ciclo próprio, com ou sem Asaas). A dívida é registrada sempre.
|
|
|
|
|
+ \App\Models\UnitAccountPayable::create([
|
|
|
|
|
+ 'unit_id' => $receive->unit_id,
|
|
|
|
|
+ 'franchisee_account_receive_id' => $receive->id,
|
|
|
|
|
+ 'origin' => \App\Models\UnitAccountPayable::ORIGIN_TBR,
|
|
|
|
|
+ 'history' => $receive->history,
|
|
|
|
|
+ 'value' => $receive->value,
|
|
|
|
|
+ 'paid_value' => 0,
|
|
|
|
|
+ 'discount' => 0,
|
|
|
|
|
+ 'fine' => 0,
|
|
|
|
|
+ 'due_date' => $receive->due_date,
|
|
|
|
|
+ 'status' => 'pending',
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
\App\Jobs\SyncFranchiseeChargeJob::dispatch($receive);
|
|
\App\Jobs\SyncFranchiseeChargeJob::dispatch($receive);
|
|
|
|
|
|
|
|
return $receive->load('details');
|
|
return $receive->load('details');
|