Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: moved billing_calculate to a laravel command. #13021

Closed
wants to merge 9 commits into from
Closed

feature: moved billing_calculate to a laravel command. #13021

wants to merge 9 commits into from

Conversation

kennysinkeler
Copy link

Please give a short description what your pull request is for
Moved the billing_calculate.php to a laravel command and new code to billing_calculate.php for legacy purpose.
DO NOT DELETE THE UNDERLYING TEXT

Please note

Please read this information carefully. You can run ./lnms dev:check to check your code before submitting.

  • Have you followed our code guidelines?
  • If my Pull Request does some changes/fixes/enhancements in the WebUI, I have inserted a screenshot of it.

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926
After you are done testing, you can remove the changes with ./scripts/github-remove. If there are schema changes, you can ask on discord how to revert.

@CLAassistant
Copy link

CLAassistant commented Jul 9, 2021

CLA assistant check
All committers have signed the CLA.

use Illuminate\Console\Command;
use LibreNMS\Util\Number;

require_once base_path() . '/includes/init.php';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this needs to be removed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean this line?(so this functions need also converted to laravel?

use LibreNMS\Util\Number;
require_once base_path() . '/includes/init.php';

This file is required for commands

use Illuminate\Console\Command;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and within there lies the pain ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this line be removed now?

$datefrom = $day_data['0'];
$dateto = $day_data['1'];
$check = BillHistory::where(['bill_id' => $bill->bill_id, 'bill_datefrom' => $datefrom, 'bill_dateto' => $dateto])->first();
$period = getPeriod($bill['bill_id'], $datefrom, $dateto);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can port these functions to class based ones, and if they are used in other places just replace the original function with a return myNewFunction()

we done that in many places.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exact function probably should be in a model tho

$dateto = $day_data['1'];
$check = BillHistory::where(['bill_id' => $bill->bill_id, 'bill_datefrom' => $datefrom, 'bill_dateto' => $dateto])->first();
$period = getPeriod($bill['bill_id'], $datefrom, $dateto);
$date_updated = str_replace('-', '', str_replace(':', '', str_replace(' ', '', $check['updated'])));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only a hint: str_replace([' ', ':', '-'], '', $check['updated']) is easier to read

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks your input! I changed this line :)

@murrant
Copy link
Member

murrant commented Sep 24, 2021

Closing due to inactivity.

@murrant murrant closed this Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants