Skip to content

Commit

Permalink
Updates of 1.6.8 (#1136)
Browse files Browse the repository at this point in the history
* Updated export import permission

* Added filter at WP ERP title

* Added filter at CRM title

* Fixed name and city validation issues

* Updated string validation function name

* update sales transaction system for separating transaction charge and invoice amout

* update employee display name whenn update

* Product duplicate Issue (#1123)

* solve Product duplication problem and response message

* Fix some issues

* fix some issues

* update some issues

* update some issues

* update some issues

* update text domain

* add product duplicate prevent in update

Co-authored-by: alemran <emrancu1@gmail.com>

* Update expense, purchase and github issues (#1116)

* update expense for Transaction charge

* update purchase payment with Transaction charge and Update.6.4.php

* Update for Category Parent

* Update Github Issue #1094

* update expense , bill, purchase reference no , show in details payment and voucher

* Update refrence no in purchase list

* Update github Issue 1076 for tag payment not support decimal value

* update git issue #942 . Expense, bill and bill payment refrence no add and show in list and single voucher

* add reference no,due date to PDF export invoice

* Update expense, sales, purchase filtering system with type and people

* Update expense, sales, purchase filtering system with type and people

* fix some issue in Expense filtering

* Set Estimate title in PDF when Estimate

* Update simple select UI, remove custom arrow, enable default select

* update expense create page for redirecting when save expense

* update PDF export system for Expense, bill, bill pay, purchase, purchase pay voucher

* update customer transaction or ledger

* update migration file

* dev build for VUE change

* fix phpcs issues

* fix phpcs issues

* update phpcs issue

* update phpcs issue

* update phpcs issue

* update phpcs issues

* update formating issues

* remove duplicate method

* fix github isues

* update translate issue

* update translate issue

* dev build

* change transaction charge system for purchase and expense

* update filtering query for sales , purchase , expense

* update migration for 1.6.8

Co-authored-by: alemran <emrancu1@gmail.com>

* UPDATE INSTALL FILE

Co-authored-by: tanmayjay <jktanmay@gmail.com>
Co-authored-by: Al Emran <emran@wedevs.com>
Co-authored-by: emran-wedevs <69339029+emran-wedevs@users.noreply.github.com>
Co-authored-by: alemran <emrancu1@gmail.com>
  • Loading branch information
5 people committed Nov 12, 2020
1 parent a726bf7 commit b4f44dd
Show file tree
Hide file tree
Showing 61 changed files with 9,530 additions and 4,927 deletions.
2,424 changes: 1,331 additions & 1,093 deletions assets/js/i18n.js

Large diffs are not rendered by default.

8,033 changes: 5,807 additions & 2,226 deletions assets/js/vendor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion includes/admin/class-menu.php
Expand Up @@ -108,7 +108,7 @@ public function get_menu_position() {
* @return void
*/
public function admin_menu() {
add_menu_page( __( 'WP ERP', 'erp' ), 'WP ERP', 'manage_options', 'erp', [ $this, 'overview_page' ], 'data:image/svg+xml;base64,' . base64_encode( '<?xml version="1.0" encoding="UTF-8"?><svg width="37px" height="37px" viewBox="0 0 37 37" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g fill="#82878C" fill-rule="nonzero"><path d="M30.3450389,6.04059132 C25.6652413,7.67566309 21.1099947,9.64748663 16.7150389,11.9405913 C15.7850389,12.4605913 14.8150389,13.0405913 13.7150389,13.7205913 C13.0443119,14.2840176 12.1907283,14.5827719 11.3150389,14.5605913 C10.3150389,14.4305913 8.90503889,13.5605913 9.00503889,12.4205913 C9.14503889,10.8305913 11.7350389,9.50059132 12.9150389,8.73059132 C14.7401826,7.56812598 16.67637,6.58998289 18.6950389,5.81059132 C21.1378916,4.73528564 23.7587368,4.12160777 26.4250389,4.00059132 C26.9947028,3.99290686 27.5629047,4.06014969 28.1150389,4.20059132 C28.9137259,4.74357385 29.6602644,5.35955176 30.3450389,6.04059132 Z"></path><path d="M30.7933348,15.9696304 C29.4433348,16.4596304 17.5233348,20.8296304 15.7933348,24.3896304 C15.3633836,25.3434159 15.3633836,26.4358449 15.7933348,27.3896304 C16.3919857,28.7511327 17.7917314,29.5797177 19.2733348,29.4496304 C19.6790059,29.4462835 20.0837104,29.4094922 20.4833348,29.3396304 C21.6712939,29.1478656 22.8417823,28.8602599 23.9833348,28.4796304 C24.9833348,28.1296304 25.9833348,27.6996304 26.9833348,27.2896304 L27.8133348,26.9496304 C30.7383636,25.6650404 33.5343329,24.1046551 36.1633348,22.2896304 C34.4182609,29.8341877 28.08799,35.4468207 20.3887538,36.2759094 C12.6895175,37.104998 5.30944369,32.968757 1.99813915,25.9686936 C-1.31316539,18.9686301 0.170333077,10.6395718 5.69491091,5.21327782 C11.2194887,-0.213016153 19.5738319,-1.54678143 26.5133348,1.88963044 C16.9833348,3.59963044 12.0633348,7.18963044 9.18333477,9.75963044 L8.86333477,10.0896304 C7.93333477,11.0396304 6.66333477,12.3296304 7.47333477,14.4196304 C7.9783997,15.5890182 9.06827343,16.4007074 10.3333348,16.5496304 L10.7033348,16.5496304 C11.6270831,16.4741709 12.5076261,16.1261302 13.2333348,15.5496304 C14.2333348,14.8796304 15.2333348,14.3096304 16.1533348,13.7996304 C21.2778133,11.1185988 26.6326398,8.90303934 32.1533348,7.17963044 C33.6733348,7.84963044 36.5733348,11.2496304 36.3833348,14.1796304 C34.6633348,14.7396304 32.2733348,15.4396304 30.7933348,15.9696304 Z"></path><path d="M34.3722313,17.49 C34.3726197,18.4970161 34.2754999,19.501704 34.0822313,20.49 C31.869491,22.1051295 29.5283527,23.5365684 27.0822313,24.77 C24.8622313,25.93 22.7822313,27.32 20.2422313,27.89 C19.0122313,28.16 16.9222313,27.42 17.0022313,25.89 C17.0622313,24.8 19.0022313,23.54 19.7922313,22.98 C21.2689784,21.9825786 22.8358063,21.1255103 24.4722313,20.42 C27.682491,19.0175052 30.9997216,17.8738632 34.3922313,17 C34.3622313,17.16 34.3722313,17.32 34.3722313,17.49 Z"></path></g></g></svg>' ), 2 );
add_menu_page( __( 'WP ERP', 'erp' ), apply_filters( 'erp_title', 'WP ERP'), 'manage_options', 'erp', [ $this, 'overview_page' ], 'data:image/svg+xml;base64,' . base64_encode( '<?xml version="1.0" encoding="UTF-8"?><svg width="37px" height="37px" viewBox="0 0 37 37" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g fill="#82878C" fill-rule="nonzero"><path d="M30.3450389,6.04059132 C25.6652413,7.67566309 21.1099947,9.64748663 16.7150389,11.9405913 C15.7850389,12.4605913 14.8150389,13.0405913 13.7150389,13.7205913 C13.0443119,14.2840176 12.1907283,14.5827719 11.3150389,14.5605913 C10.3150389,14.4305913 8.90503889,13.5605913 9.00503889,12.4205913 C9.14503889,10.8305913 11.7350389,9.50059132 12.9150389,8.73059132 C14.7401826,7.56812598 16.67637,6.58998289 18.6950389,5.81059132 C21.1378916,4.73528564 23.7587368,4.12160777 26.4250389,4.00059132 C26.9947028,3.99290686 27.5629047,4.06014969 28.1150389,4.20059132 C28.9137259,4.74357385 29.6602644,5.35955176 30.3450389,6.04059132 Z"></path><path d="M30.7933348,15.9696304 C29.4433348,16.4596304 17.5233348,20.8296304 15.7933348,24.3896304 C15.3633836,25.3434159 15.3633836,26.4358449 15.7933348,27.3896304 C16.3919857,28.7511327 17.7917314,29.5797177 19.2733348,29.4496304 C19.6790059,29.4462835 20.0837104,29.4094922 20.4833348,29.3396304 C21.6712939,29.1478656 22.8417823,28.8602599 23.9833348,28.4796304 C24.9833348,28.1296304 25.9833348,27.6996304 26.9833348,27.2896304 L27.8133348,26.9496304 C30.7383636,25.6650404 33.5343329,24.1046551 36.1633348,22.2896304 C34.4182609,29.8341877 28.08799,35.4468207 20.3887538,36.2759094 C12.6895175,37.104998 5.30944369,32.968757 1.99813915,25.9686936 C-1.31316539,18.9686301 0.170333077,10.6395718 5.69491091,5.21327782 C11.2194887,-0.213016153 19.5738319,-1.54678143 26.5133348,1.88963044 C16.9833348,3.59963044 12.0633348,7.18963044 9.18333477,9.75963044 L8.86333477,10.0896304 C7.93333477,11.0396304 6.66333477,12.3296304 7.47333477,14.4196304 C7.9783997,15.5890182 9.06827343,16.4007074 10.3333348,16.5496304 L10.7033348,16.5496304 C11.6270831,16.4741709 12.5076261,16.1261302 13.2333348,15.5496304 C14.2333348,14.8796304 15.2333348,14.3096304 16.1533348,13.7996304 C21.2778133,11.1185988 26.6326398,8.90303934 32.1533348,7.17963044 C33.6733348,7.84963044 36.5733348,11.2496304 36.3833348,14.1796304 C34.6633348,14.7396304 32.2733348,15.4396304 30.7933348,15.9696304 Z"></path><path d="M34.3722313,17.49 C34.3726197,18.4970161 34.2754999,19.501704 34.0822313,20.49 C31.869491,22.1051295 29.5283527,23.5365684 27.0822313,24.77 C24.8622313,25.93 22.7822313,27.32 20.2422313,27.89 C19.0122313,28.16 16.9222313,27.42 17.0022313,25.89 C17.0622313,24.8 19.0022313,23.54 19.7922313,22.98 C21.2689784,21.9825786 22.8358063,21.1255103 24.4722313,20.42 C27.682491,19.0175052 30.9997216,17.8738632 34.3922313,17 C34.3622313,17.16 34.3722313,17.32 34.3722313,17.49 Z"></path></g></g></svg>' ), 2 );
add_submenu_page( 'erp', __( 'Dashboard', 'erp' ), __( 'Dashboard', 'erp' ), 'manage_options', 'erp', [ $this, 'overview_page' ] );

// add_menu_page( __( 'ERP', 'erp' ), 'ERP Settings', 'manage_options', 'erp-company', array( $this, 'company_page' ), 'dashicons-admin-settings', $this->get_menu_position() );
Expand Down
4 changes: 4 additions & 0 deletions includes/class-install.php
Expand Up @@ -1269,6 +1269,7 @@ public function create_tables() {
`trn_by` varchar(255) DEFAULT NULL,
`trn_by_ledger_id` int(11) DEFAULT NULL,
`particulars` varchar(255) DEFAULT NULL,
`ref` varchar(255) NULL DEFAULT NULL,
`attachments` varchar(255) DEFAULT NULL,
`status` int(11) DEFAULT NULL,
`created_at` date DEFAULT NULL,
Expand Down Expand Up @@ -1298,6 +1299,8 @@ public function create_tables() {
`trn_date` date DEFAULT NULL,
`amount` decimal(20,2) DEFAULT 0,
`trn_by` varchar(255) DEFAULT NULL,
`transaction_charge` decimal(20,2) DEFAULT 0,
`ref` varchar(255) NULL DEFAULT NULL,
`trn_by_ledger_id` int(11) DEFAULT NULL,
`particulars` varchar(255) DEFAULT NULL,
`attachments` varchar(255) DEFAULT NULL,
Expand Down Expand Up @@ -1597,6 +1600,7 @@ public function create_tables() {
`particulars` varchar(255) DEFAULT NULL,
`status` int(11) DEFAULT NULL,
`trn_by` int(11) DEFAULT NULL,
`transaction_charge` decimal(20,2) DEFAULT 0,
`trn_by_ledger_id` int(11) DEFAULT NULL,
`attachments` varchar(255) DEFAULT NULL,
`created_at` date DEFAULT NULL,
Expand Down
1 change: 1 addition & 0 deletions includes/class-updates.php
Expand Up @@ -51,6 +51,7 @@ class Updates {
'1.6.0' => 'updates/update-1.6.0.php',
'1.6.3' => 'updates/update-1.6.3.php',
'1.6.5' => 'updates/update-1.6.5.php',
'1.6.8' => 'updates/update-1.6.8.php',
];

/**
Expand Down
4 changes: 2 additions & 2 deletions includes/class-validate-data.php
Expand Up @@ -35,7 +35,7 @@ public function pre_validate_csv_data( $data ) {

$errors = new ERP_Errors( 'import_csv_data' );
// Check if current user has permission
if ( ! current_user_can( 'erp_hr_manager' ) ) {
if ( ! current_user_can( 'administrator' ) ) {
$errors->add( new \WP_Error( 'no-permission', __( 'Sorry ! You do not have permission to access this page', 'erp' ) ) );
}

Expand Down Expand Up @@ -294,7 +294,7 @@ public function validate( $dt_key, $dt_value, $type ) {
return $this->validate_field( "Description", $dt_value, $type, "max:200|" );
break;
default:
return apply_filters( 'validate_field', $dt_key, $dt_value, $type );
return apply_filters( 'validate_field', [], $dt_key, $dt_value, $type );
}
}

Expand Down
4 changes: 2 additions & 2 deletions includes/functions-people.php
Expand Up @@ -514,7 +514,7 @@ function erp_insert_people( $args = [], $return_object = false ) {
if ( empty( $args['company'] ) || empty( $args['email'] ) ) {
return new WP_Error( 'no-company', esc_attr__( 'You must need to fill up both Company name and email fields', 'erp' ) );
} else {
if ( ! erp_is_valid_company( $args['company'] ) ) {
if ( erp_contains_disallowed_chars( $args['company'] ) ) {
return new WP_Error( 'invalid-company', esc_attr__( 'Please provide a valid company name', 'erp' ) );
}
}
Expand Down Expand Up @@ -553,7 +553,7 @@ function erp_insert_people( $args = [], $return_object = false ) {
return new WP_Error( 'invalid-fax', esc_attr__( 'Please provide a valid fax number', 'erp' ) );
}

if ( ! empty( $args['city'] ) && ! erp_is_valid_name( $args['city'] ) ) {
if ( ! empty( $args['city'] ) && erp_contains_disallowed_chars( $args['city'] ) ) {
return new WP_Error( 'invalid-city', esc_attr__( 'Please provide a valid city name', 'erp' ) );
}

Expand Down
16 changes: 8 additions & 8 deletions includes/functions.php
Expand Up @@ -1574,7 +1574,7 @@ function erp_process_import_export() {
return;
}

if ( ! current_user_can( 'erp_hr_manager' ) ) {
if ( ! current_user_can( 'administrator' ) ) {
return new \WP_Error( 'no-permission', __( 'Sorry ! You do not have permission to access this page', 'erp' ) );
}

Expand Down Expand Up @@ -3675,7 +3675,7 @@ function erp_is_timestamp( $string ) {
}

/**
* Validates people's name
* Checks if people's name contains some specific special charecters which should not e allowed
*
* @since 1.6.7
*
Expand All @@ -3684,20 +3684,20 @@ function erp_is_timestamp( $string ) {
* @return bool
*/
function erp_is_valid_name( $name ) {
return ctype_alpha( iconv( 'UTF-8', 'ISO-8859-1', preg_replace( '/\s/', '', $name ) ) );
return ! preg_match_all( '/[_@!%#&:;"=<>\\/\*\+\?\$\^\{\}\[\]0-9]/', $name );
}

/**
* Validates company's name
* Checks if a string contains some disallowed special charecters
*
* @since 1.6.7
* @since 1.6.8
*
* @param string $company
* @param string $str
*
* @return bool
*/
function erp_is_valid_company( $company ) {
return preg_match( '/^[A-Z0-9][ ._\-A-Z0-9]+$/i', $company );
function erp_contains_disallowed_chars( $str ) {
return preg_match_all( '/[%;"=<>\\/\*\+\?\$\^\{\}\[\]]/', $str );
}

/**
Expand Down
65 changes: 65 additions & 0 deletions includes/updates/update-1.6.8.php
@@ -0,0 +1,65 @@
<?php
namespace WeDevs\ERP\HRM\Update;

/*
* Add transaction_charge column in `erp_acct_expenses` table
*/
function erp_acct_alter_acct_expenses_1_6_8() {
global $wpdb;

$cols = $wpdb->get_col( "DESC {$wpdb->prefix}erp_acct_expenses" );

if ( ! in_array( 'transaction_charge', $cols, true ) ) {
$wpdb->query(
$wpdb->prepare(
"ALTER TABLE {$wpdb->prefix}erp_acct_expenses ADD `transaction_charge` decimal(20,2) DEFAULT 0 AFTER `trn_by`;"
)
);
}
}

/*
* Add transaction_charge and ref column in `erp_acct_pay_purchase` table
*/
function erp_acct_alter_pay_purchase_1_6_8() {
global $wpdb;

$cols = $wpdb->get_col( "DESC {$wpdb->prefix}erp_acct_pay_purchase" );

if ( ! in_array( 'transaction_charge', $cols, true ) ) {
$wpdb->query(
$wpdb->prepare(
"ALTER TABLE {$wpdb->prefix}erp_acct_pay_purchase ADD `transaction_charge` decimal(20,2) DEFAULT 0 AFTER `trn_by`;"
)
);
}

if ( ! in_array( 'ref', $cols, true ) ) {
$wpdb->query(
$wpdb->prepare(
"ALTER TABLE {$wpdb->prefix}erp_acct_pay_purchase ADD `ref` varchar(255) NULL DEFAULT NULL AFTER `trn_by`;"
)
);
}
}

/*
* Add transaction_charge column in `erp_acct_pay_bill` table
*/
function erp_acct_alter_pay_bill_1_6_8() {
global $wpdb;

$cols = $wpdb->get_col( "DESC {$wpdb->prefix}erp_acct_pay_bill" );

if ( ! in_array( 'ref', $cols, true ) ) {
$wpdb->query(
$wpdb->prepare(
"ALTER TABLE {$wpdb->prefix}erp_acct_pay_bill ADD `ref` varchar(255) NULL DEFAULT NULL AFTER `particulars`;"
)
);
}
}

erp_acct_alter_acct_expenses_1_6_8();
erp_acct_alter_pay_purchase_1_6_8();
erp_acct_alter_pay_bill_1_6_8();
8 changes: 1 addition & 7 deletions modules/accounting/api/class-rest-api-bills.php
Expand Up @@ -187,13 +187,9 @@ public function get_bill( $request ) {
}

$bill_data = erp_acct_get_bill( $id );
// $bill_data['id'] = $id;

// $bill_data['created_by'] = $this->get_user( $bill_data['created_by'] );

$additional_fields['namespace'] = $this->namespace;
$additional_fields['rest_base'] = $this->rest_base;

$data = $this->prepare_item_for_response( $bill_data, $request, $additional_fields );
$formatted_items = $this->prepare_response_for_collection( $data );
$response = rest_ensure_response( $formatted_items );
Expand Down Expand Up @@ -230,12 +226,10 @@ public function create_bill( $request ) {

$this->add_log( $bill, 'add' );

// $bill_data['voucher_no'] = $bill_id;
$additional_fields['namespace'] = $this->namespace;
$additional_fields['rest_base'] = $this->rest_base;

$bill_data = $this->prepare_item_for_response( $bill, $request, $additional_fields );

$response = rest_ensure_response( $bill_data );
$response->set_status( 201 );

Expand Down Expand Up @@ -281,7 +275,6 @@ public function update_bill( $request ) {

$this->add_log( $bill, 'update' );

// $bill_data['voucher_no'] = $bill_id;
$additional_fields['namespace'] = $this->namespace;
$additional_fields['rest_base'] = $this->rest_base;

Expand Down Expand Up @@ -492,6 +485,7 @@ public function prepare_item_for_response( $item, $request, $additional_fields =
'trn_date' => $item->trn_date,
'due_date' => $item->due_date,
'billing_address' => ! empty( $item->billing_address ) ? $item->billing_address : erp_acct_get_people_address( $item->vendor_id ),
'pdf_link' => $item->pdf_link ,
'bill_details' => ! empty( $item->bill_details ) ? $item->bill_details : [],
'amount' => (int) $item->amount,
'due' => ! empty( $item->due ) ? $item->due : $item->amount,
Expand Down
41 changes: 23 additions & 18 deletions modules/accounting/api/class-rest-api-expenses.php
Expand Up @@ -241,7 +241,6 @@ public function create_expense( $request ) {
$expense_data['amount'] = array_sum( $item_total );

$expense = erp_acct_insert_expense( $expense_data );

$this->add_log( $expense, 'add' );

$additional_fields['namespace'] = $this->namespace;
Expand Down Expand Up @@ -392,6 +391,10 @@ protected function prepare_item_for_database( $request ) {
$prepared_item['trn_by'] = $request['trn_by'];
}

if ( isset( $request['bank_trn_charge'] ) ) {
$prepared_item['bank_trn_charge'] = $request['bank_trn_charge'];
}

if ( isset( $request['bill_details'] ) ) {
$prepared_item['bill_details'] = $request['bill_details'];
}
Expand Down Expand Up @@ -444,23 +447,25 @@ public function prepare_item_for_response( $item, $request, $additional_fields =
$item = (object) $item;

$data = [
'id' => (int) $item->id,
'voucher_no' => (int) $item->voucher_no,
'people_id' => (int) $item->people_id,
'people_name' => $item->people_name,
'date' => $item->trn_date,
'address' => $item->address,
'bill_details' => $item->bill_details,
'total' => (float) $item->amount,
'ref' => ! empty( $item->ref ) ? $item->ref : '',
'check_no' => $item->check_no,
'particulars' => $item->particulars,
'status' => $item->status,
'attachments' => maybe_unserialize( $item->attachments ),
'trn_by' => $item->trn_by,
'created_at' => $item->created_at,
'deposit_to' => $item->trn_by_ledger_id,
'check_data' => ! empty( $item->check_data ) ? $item->check_data : [],
'id' => (int) $item->id,
'voucher_no' => (int) $item->voucher_no,
'people_id' => (int) $item->people_id,
'people_name' => $item->people_name,
'date' => $item->trn_date,
'address' => $item->address,
'bill_details' => $item->bill_details,
'pdf_link' => $item->pdf_link,
'total' => (float) $item->amount,
'ref' => ! empty( $item->ref ) ? $item->ref : '',
'check_no' => $item->check_no,
'particulars' => $item->particulars,
'status' => $item->status,
'attachments' => maybe_unserialize( $item->attachments ),
'trn_by' => $item->trn_by,
'transaction_charge' => $item->transaction_charge,
'created_at' => $item->created_at,
'deposit_to' => $item->trn_by_ledger_id,
'check_data' => ! empty( $item->check_data ) ? $item->check_data : [],
];

$data = array_merge( $data, $additional_fields );
Expand Down
2 changes: 2 additions & 0 deletions modules/accounting/api/class-rest-api-pay-bills.php
Expand Up @@ -381,10 +381,12 @@ public function prepare_item_for_response( $item, $request, $additional_fields =
'trn_date' => $item->trn_date,
'amount' => $item->amount,
'billing_address' => ! empty( $item->billing_address ) ? $item->billing_address : erp_acct_get_people_address( $item->vendor_id ),
'pdf_link' => $item->pdf_link ,
'bill_details' => ! empty( $item->bill_details ) ? $item->bill_details : [],
'type' => ! empty( $item->type ) ? $item->type : 'pay_bill',
'status' => $item->status,
'particulars' => $item->particulars,
'ref' => $item->ref,
'trn_by' => erp_acct_get_payment_method_by_id( $item->trn_by )->name,
'created_at' => $item->created_at,
'attachments' => maybe_unserialize( $item->attachments ),
Expand Down

0 comments on commit b4f44dd

Please sign in to comment.