Skip to content

Commit

Permalink
Merge pull request #36 from LinkNacional/dev
Browse files Browse the repository at this point in the history
3.3.0 - ajust parameters of somo notifs
  • Loading branch information
brunoferreiralkn authored Nov 13, 2023
2 parents cc1c018 + 8fcd9f5 commit ab14baf
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"neilbrayfield.php-docblocker",
"dbaeumer.vscode-eslint",
"aswinkumar863.smarty-template-support",
"MehediDracula.php-namespace-resolver"
"MehediDracula.php-namespace-resolver",
"Natizyskunk.sftp"
],
"settings": {
"[html]": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ public function defineParameters(): void
'label' => $this->lang['invoice_id_and_first_item'],
'parser' => fn () => $this->getInvoiceIdAndFirstItsFirstItem(),
],
'invoice_pdf_url' => [
'label' => $this->lang['invoice_pdf_url'],
'parser' => fn () => self::getInvoicePdfUrlByInvocieId($this->hookParams['invoice_id'])
],
'client_first_name' => [
'label' => $this->lang['client_first_name'],
'parser' => fn () => $this->getClientFirstNameByClientId($this->clientId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
$lang['invoice_id_and_first_item'] = 'Invoice ID + First item';
$lang['client_first_name'] = 'Client first name';
$lang['client_full_name'] = 'Client full name';
$lang['invoice_pdf_url'] = 'Invoice PDF URL';

return $lang;
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
$lang['invoice_id_and_first_item'] = 'ID da fatura + primeiro item';
$lang['client_first_name'] = 'Nome do cliente';
$lang['client_full_name'] = 'Nome completo do cliente';
$lang['invoice_pdf_url'] = 'URL do PDF da fatura';

return $lang;
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
$lang['invoice_id_and_first_item'] = 'ID da fatura + primeiro item';
$lang['client_first_name'] = 'Nome do cliente';
$lang['client_full_name'] = 'Nome completo do cliente';
$lang['invoice_pdf_url'] = 'URL do PDF da fatura';

return $lang;
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public function defineParameters(): void
'label' => $this->lang['invoice_due_date'],
'parser' => fn () => self::getInvoiceDueDateByInvoiceId($this->hookParams['invoiceId'])
],
'invoice_pdf_url' => [
'label' => $this->lang['invoice_pdf_url'],
'parser' => fn () => self::getInvoicePdfUrlByInvocieId($this->hookParams['invoiceId'])
],
'client_id' => [
'label' => $this->lang['client_id'],
'parser' => fn () => $this->clientId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
$lang['client_id'] = 'Client ID';
$lang['client_first_name'] = 'Client first name';
$lang['client_full_name'] = 'Client full name';
$lang['invoice_pdf_url'] = 'Invoice PDF URL';

return $lang;
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
$lang['client_id'] = 'ID do cliente';
$lang['client_first_name'] = 'Primeiro nome do cliente';
$lang['client_full_name'] = 'Nome completo do cliente';
$lang['invoice_pdf_url'] = 'URL do PDF da fatura';

return $lang;
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
$lang['client_id'] = 'ID do cliente';
$lang['client_first_name'] = 'Primeiro nome do cliente';
$lang['client_full_name'] = 'Nome completo do cliente';
$lang['invoice_pdf_url'] = 'URL do PDF da fatura';

return $lang;
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ public function defineParameters(): void
],
'invoice_balance' => [
'label' => $this->lang['invoice_balance'],
'parser' => fn (): string => self::getInvoiceBalance($this->hookParams['invoiceid'])
'parser' => fn (): string => self::getInvoiceBalance($this->hookParams['invoiceId'])
],
'invoice_total' => [
'label' => $this->lang['invoice_total'],
'parser' => fn (): string => self::getInvoiceTotal($this->hookParams['invoiceid'])
'parser' => fn (): string => self::getInvoiceTotal($this->hookParams['invoiceId'])
],
'invoice_subtotal' => [
'label' => $this->lang['invoice_subtotal'],
'parser' => fn (): string => self::getInvoiceSubtotal($this->hookParams['invoiceid'])
'parser' => fn (): string => self::getInvoiceSubtotal($this->hookParams['invoiceId'])
],
'client_id' => [
'label' => $this->lang['client_id'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Lkn\HookNotification\Config\Hooks;
use Lkn\HookNotification\Config\ReportCategory;
use Lkn\HookNotification\Domains\Platforms\WhatsApp\AbstractWhatsAppNotifcation;
use Lkn\HookNotification\Notifications\Chatwoot\WhatsAppPrivateNote\WhatsAppPrivateNoteNotification;

/**
* Runs when a recurring existing service invoice is created.
Expand Down Expand Up @@ -80,25 +79,8 @@ function (array $item): bool {
}
);

if (count($invoiceItemRelatedToProduct) === 0) {
return false;
}

// Loops over each item on the invoice to check if any item is a service with nextduedate for today.
foreach ($invoiceItemRelatedToProduct as $item) {
$clientProductInfo = localAPI('GetClientsProducts', [
'pid' => $item['product_id'],
'serviceid' => $item['relid'],
'clientid' => self::getClientIdByInvoiceId($invoiceId)
])['products']['product'];

/**
* Acordding to https://docs.whmcs.com/Billing_Logic
* Next Due Date/Next Invoice Date is updated after WHMCS triggers InvoiceCreated hook.
*/
if ($clientProductInfo[0]['nextduedate'] === date('Y-m-d')) {
return true;
}
if (count($invoiceItemRelatedToProduct) > 0) {
return true;
}

return false;
Expand All @@ -113,7 +95,7 @@ public function defineParameters(): void
],
'invoice_items' => [
'label' => $this->lang['invoice_items'],
'parser' => fn () => self::getOrderItemsDescripByOrderId($this->reportCategoryId)
'parser' => fn () => self::getOrderItemsDescripByOrderId(self::getOrderIdByInvoiceId($this->reportCategoryId))
],
'invoice_due_date' => [
'label' => $this->lang['invoice_due_date'],
Expand Down

0 comments on commit ab14baf

Please sign in to comment.