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

Update expense, purchase and github issues #1116

Merged
merged 39 commits into from Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
cd30de0
update expense for Transaction charge
emrancu Sep 12, 2020
cf08e56
update purchase payment with Transaction charge and Update.6.4.php
emrancu Sep 12, 2020
ae644c5
Update for Category Parent
emrancu Sep 14, 2020
feae477
Update Github Issue #1094
emrancu Sep 15, 2020
7cb7152
update expense , bill, purchase reference no , show in details paymen…
emrancu Sep 16, 2020
0673e11
Update refrence no in purchase list
emrancu Sep 18, 2020
bea5bbc
Update github Issue 1076 for tag payment not support decimal value
emrancu Sep 21, 2020
1fb026c
update git issue #942 . Expense, bill and bill payment refrence no ad…
emrancu Sep 21, 2020
a274b4e
add reference no,due date to PDF export invoice
emrancu Sep 22, 2020
05c7ce5
Update expense, sales, purchase filtering system with type and people
emrancu Sep 24, 2020
3429238
Update expense, sales, purchase filtering system with type and people
emrancu Sep 24, 2020
c3341cf
fix some issue in Expense filtering
emrancu Sep 24, 2020
5d7a444
Set Estimate title in PDF when Estimate
emrancu Sep 24, 2020
7ba2344
Update simple select UI, remove custom arrow, enable default select
emrancu Sep 25, 2020
ffc0acf
update expense create page for redirecting when save expense
emrancu Sep 25, 2020
3dd2994
update PDF export system for Expense, bill, bill pay, purchase, purch…
emrancu Sep 25, 2020
be13336
update customer transaction or ledger
emrancu Sep 30, 2020
06fe2e9
update migration file
emrancu Oct 22, 2020
4580dac
fix conflick for prev work
emran-wedevs Oct 22, 2020
ceb2282
Merge branch 'develop_emran' into develop_emran_prev_work
emran-wedevs Oct 22, 2020
93283d8
dev build for VUE change
emran-wedevs Oct 22, 2020
8760d65
fix phpcs issues
emran-wedevs Oct 22, 2020
dbbab69
fix phpcs issues
emran-wedevs Oct 22, 2020
6049cb0
update phpcs issue
emran-wedevs Oct 23, 2020
47d3899
update phpcs issue
emran-wedevs Oct 23, 2020
668298e
update phpcs issue
emran-wedevs Oct 23, 2020
2f3c3e2
update phpcs issues
emran-wedevs Oct 27, 2020
351de4a
update formating issues
emran-wedevs Oct 27, 2020
6b87594
remove duplicate method
emran-wedevs Oct 28, 2020
4a4ed73
Merge branch 'develop_emran_prev_work' of https://github.com/wp-erp/w…
emran-wedevs Oct 28, 2020
16450bb
fix github isues
emran-wedevs Oct 28, 2020
c5aa256
update translate issue
emran-wedevs Nov 5, 2020
f9f3e9a
update translate issue
emran-wedevs Nov 5, 2020
63e8390
dev build
emran-wedevs Nov 9, 2020
d6916e2
change transaction charge system for purchase and expense
emran-wedevs Nov 10, 2020
a8d76bf
update merge
emran-wedevs Nov 10, 2020
448d7a0
update filtering query for sales , purchase , expense
emran-wedevs Nov 12, 2020
2fbb98d
Dev-build
emran-wedevs Nov 12, 2020
24dd57e
update migration for 1.6.8
emran-wedevs Nov 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
191 changes: 99 additions & 92 deletions assets/js/vendor.js

Large diffs are not rendered by default.

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
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
29 changes: 18 additions & 11 deletions modules/accounting/api/class-rest-api-pay-purchases.php
Expand Up @@ -317,6 +317,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['particulars'] ) ) {
$prepared_item['particulars'] = $request['particulars'];
}
Expand Down Expand Up @@ -369,17 +373,20 @@ public function prepare_item_for_response( $item, $request, $additional_fields =
$item = (object) $item;

$data = [
'id' => (int) $item->id,
'voucher_no' => (int) $item->voucher_no,
'vendor_id' => (int) $item->vendor_id,
'trn_date' => $item->trn_date,
'purchase_details' => $item->purchase_details,
'amount' => (float) $item->amount,
'particulars' => $item->particulars,
'attachments' => maybe_unserialize( $item->attachments ),
'status' => $item->status,
'created_at' => $item->created_at,
'trn_by' => erp_acct_get_payment_method_by_id( $item->trn_by )->name,
'id' => (int) $item->id,
'voucher_no' => (int) $item->voucher_no,
'vendor_id' => (int) $item->vendor_id,
'trn_date' => $item->trn_date,
'purchase_details' => $item->purchase_details,
'pdf_link' => $item->pdf_link,
'ref' => $item->ref,
'amount' => (float) $item->amount,
'particulars' => $item->particulars,
'attachments' => maybe_unserialize( $item->attachments ),
'status' => $item->status,
'created_at' => $item->created_at,
'transaction_charge' => $item->transaction_charge,
'trn_by' => erp_acct_get_payment_method_by_id( $item->trn_by )->name,
];

$data = array_merge( $data, $additional_fields );
Expand Down
1 change: 1 addition & 0 deletions modules/accounting/api/class-rest-api-purchases.php
Expand Up @@ -446,6 +446,7 @@ public function prepare_item_for_response( $item, $request, $additional_fields =
'type' => ! empty( $item->type ) ? $item->type : 'purchase',
'ref' => $item->ref,
'billing_address'=> erp_acct_format_people_address( erp_acct_get_people_address( (int) $item->vendor_id ) ),
'pdf_link' => $item->pdf_link,
'status' => $item->status,
'purchase_order' => $item->purchase_order,
'amount' => $item->amount,
Expand Down
34 changes: 17 additions & 17 deletions modules/accounting/api/class-rest-api-transactions.php
Expand Up @@ -316,15 +316,6 @@ public function get_trn_statuses( $request ) {
global $wpdb;

$statuses = $wpdb->get_results( "SELECT id, type_name as name, slug FROM {$wpdb->prefix}erp_acct_trn_status_types", ARRAY_A );
array_unshift(
$statuses,
[
'id' => '0',
'type_name' => 'all',
'name' => 'All',
'slug' => 'all',
]
);

$response = rest_ensure_response( $statuses );

Expand All @@ -347,8 +338,12 @@ public function get_sales( $request ) {
'start_date' => empty( $request['start_date'] ) ? '' : $request['start_date'],
'end_date' => empty( $request['end_date'] ) ? date( 'Y-m-d' ) : $request['end_date'],
'status' => empty( $request['status'] ) ? '' : $request['status'],
'type' => empty( $request['type'] ) ? '' : $request['type'],
'customer_id'=> empty( $request['customer_id'] ) ? '' : $request['customer_id'],
];



$formatted_items = [];
$additional_fields = [];

Expand Down Expand Up @@ -502,6 +497,8 @@ public function get_expenses( $request ) {
'start_date' => empty( $request['start_date'] ) ? '' : $request['start_date'],
'end_date' => empty( $request['end_date'] ) ? date( 'Y-m-d' ) : $request['end_date'],
'status' => empty( $request['status'] ) ? '' : $request['status'],
'type' => empty( $request['type'] ) ? '' : $request['type'],
'vendor_id' => empty( $request['vendor_id'] ) ? '' : $request['vendor_id'],
];

$formatted_items = [];
Expand Down Expand Up @@ -589,6 +586,8 @@ public function get_purchases( $request ) {
'start_date' => empty( $request['start_date'] ) ? '' : $request['start_date'],
'end_date' => empty( $request['end_date'] ) ? date( 'Y-m-d' ) : $request['end_date'],
'status' => empty( $request['status'] ) ? '' : $request['status'],
'type' => empty( $request['type'] ) ? '' : $request['type'],
'vendor_id' => empty( $request['vendor_id'] ) ? '' : $request['vendor_id'],
];

$formatted_items = [];
Expand Down Expand Up @@ -652,8 +651,7 @@ public function get_voucher_type( $request ) {
* @param object|array $item
* @param WP_REST_Request $request request object
* @param array $additional_fields (optional)
*
* @return WP_REST_Response $response response data
* @return object $response Response data.
*/
public function prepare_item_for_response( $item, $request, $additional_fields = [] ) {
$status = null;
Expand Down Expand Up @@ -688,6 +686,8 @@ public function prepare_item_for_response( $item, $request, $additional_fields =

$item['status'] = erp_acct_get_trn_status_by_id( $status );
$item['status_code'] = $status;
$item['ref'] = $item['ref'] ? $item['ref'] : $item['pay_ref'];
$item['ref'] = $item['ref'] ? $item['ref'] : $item['exp_ref']; // for set expense reference no

$data = array_merge( $item, $additional_fields );

Expand Down Expand Up @@ -771,16 +771,16 @@ public function get_people_trn_status_data( $request ) {
$sales_statuses = erp_acct_get_sales_chart_status( $args );
$purchase_statuses = erp_acct_get_purchase_chart_status( $args );

for ( $i = 0; $i < count( $chart_statuses ); $i++ ) {
$chart_statuses[ $i ]['sub_total'] = (int) $chart_statuses[ $i ]['sub_total'];
foreach ( $chart_statuses as $key => $item ) {
$chart_statuses[ $key ]['sub_total'] = (int) $chart_statuses[ $key ]['sub_total'];
}

for ( $i = 0; $i < count( $sales_statuses ); $i++ ) {
$sales_statuses[ $i ]['sub_total'] = (int) $sales_statuses[ $i ]['sub_total'];
foreach ( $sales_statuses as $key => $item) {
$sales_statuses[ $key ]['sub_total'] = (int) $sales_statuses[ $key ]['sub_total'];
}

for ( $i = 0; $i < count( $purchase_statuses ); $i++ ) {
$purchase_statuses[ $i ]['sub_total'] = (int) $purchase_statuses[ $i ]['sub_total'];
foreach ( $purchase_statuses as $key => $item) {
$purchase_statuses[ $key ]['sub_total'] = (int) $purchase_statuses[ $key ]['sub_total'];
}

if ( ! empty( $expense_status ) ) {
Expand Down
2 changes: 1 addition & 1 deletion modules/accounting/assets/css/admin.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion modules/accounting/assets/css/admin.css.map

Large diffs are not rendered by default.