Round Number Into 2 Decimal in JavaScript

There is the custom function to round 2 decimal number in JavaScript

function financial(x) {
return Number.parseFloat(x).toFixed(2);
}

console.log(financial(12.786));
// expected output: "12.79"

console.log(financial(0.0078));
// expected output: "0.01"

console.log(financial('1.25e+5'));
// expected output: "125000.00"

Function Math.log() in JavaScript

The Math.log() function returns the natural logarithm (base e) of a number. The JavaScript Math.log() function is equivalent to ln(x) in mathematics. Below is example use of  Math.log() function to get base logaritma.

function getBaseLog(x, y) {
  return Math.log(y) / Math.log(x);
}

// 2^4 = 16
console.log(getBaseLog(2, 16));
// expected output: 4

// 10^3
console.log(getBaseLog(10, 1000));
// expected output: 3

Convert Laravel Collective Form to Html Form

For example, the is a form with sript in Laravel Collective to delete a record. The script like code below.

{!!Form::open(['action'=> ['UsersController@destroy', $user->id],'method'=>'POST', 'class'=>'pull-left', 'onsubmit'=>'return confirm("Are you sure?")'])!!}
{{Form::hidden('_method', 'DELETE')}}
{{Form::Submit('Delete', ['class'=>'btn btn-danger'])}}
{!!Form::close() !!}

And there is the script in html.

<form action="{{action('UsersController@destroy', $user['id'])}}" method="post">
@csrf
<input name="_method" type="hidden" value="DELETE">
<button class="btn btn-danger" type="submit" onclick="return confirm('Are you sure?')">Delete</button>
</form>

Install Laravel Collective on Laravel 5.8

Firstly, open your project location use command prompt and then run code below.

composer require "laravelcollective/html":"^5.8.0"

Edit file app/config/app.php in your project and add this line to providers array.

Collective\Html\HtmlServiceProvider::class

Add the following aliases to aliases array in the same file.

'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,

 

Primary Setting In Laravel

After install Laravel, you must set below for your project.

Open .env file on your project and then set for APP_NAME, DB_DATABASE, DB_USERNAME, and DB_PASSWORD.

Open AppServiceProvider.php which located in app/Providers/ and then add script below.

On declaration :
use Illuminate\Support\Facades\Schema;

 

On boot function :
Schema::defaultStringLength(191);

How to Redirect Laravel Into Local Domain

Normaly if you are using Laravel and XAMPP in local computer, you are using address “localhost/basicwebsite/public” (project name : basicwebsite) to access website. If you want to access more simple use local domain (example basicwebsite.id), you can follow some steps below :

Edit file httpd-vhosts.conf which located in xampp/apache/conf/extra using notepad and add script below :

<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/basicwebsite/public"
ServerName basicwebsite.id
</VirtualHost>

Edit file hosts which located in C:\Windows\System32\drivers\etc and add a script below :

127.0.0.1 basicwebsite.id

Restart your apache service and now you can access your website use address basicwebsite.id in your local computer.

Add New Report FrontAccounting

In this case, we will create a report in Purchases Module with name Supplier Invoice Transactions. Output for this report is summary of supplier invoice in the period of date. Let’s begin, firstly open file “\reporting\reports_main” and add code below to create report menu.

//Add by : Andik
$reports->addReport(RC_SUPPLIER, 211, _('Supplier Invoice &Transactions'),
 array(_('Start Date') => 'DATEBEGIN',
 _('End Date') => 'DATEENDM',
 _('Supplier') => 'SUPPLIERS_NO_FILTER',
 _('Orientation') => 'ORIENTATION',
 _('Destination') => 'DESTINATION'));
//end

and this is the result. Continue reading “Add New Report FrontAccounting”

Create New Inquiry FrontAccounting

Base on article Add Menu on “Items and Inventory” Module FrontAccounting, we want to create inquiry for that menu. Firstly create query, open file “\inventory\includes\db\items_locations_db.inc”, then add below code.

//Add by : Andik
function get_loc_details_all($description)
{
 $sql = "SELECT stock.loc_code, stock.location_name,
 reorders.stock_id, reorders.reorder_level, item.description
 FROM ".TB_PREF."locations stock"
 ." INNER JOIN ".TB_PREF."loc_stock reorders ON reorders.loc_code=stock.loc_code"
 ." INNER JOIN ".TB_PREF."stock_master item ON item.stock_id=reorders.stock_id"
 ." WHERE stock.fixed_asset = 0 and item.mb_flag <> 'D'"
 ." and item.description like " .db_escape("%" . $description . "%")
 ." ORDER BY reorders.stock_id, reorders.loc_code";
 return db_query($sql,"an item reorder could not be retreived");
}
//end

After this, create new file on directory “inventory\inquiry” and name it “stock_onhand.php” and then add code below. Continue reading “Create New Inquiry FrontAccounting”

Change Default Account on Input Work Order Additional Costs FrontAccounting

Base on article Add Parameters on “System and General GL Setup” FrontAccounting, we also want to implement it into “Work Order Additional Costs” process. This is the way, open file “\manufacturing\work_order_costs.php”, then find code below.

$item = get_item($wo_details['stock_id']);
$r = get_default_bank_account(get_company_pref('curr_default'));
$_POST['cr_acc'] = $r[0];
$_POST['costs'] = price_format(get_post('PaymentType')==WO_OVERHEAD ? $item['overhead_cost'] : $item['labour_cost']);

Then, modified like code below. Continue reading “Change Default Account on Input Work Order Additional Costs FrontAccounting”

Website Powered by WordPress.com.

Up ↑