v.2.28
This commit is contained in:
@@ -1368,8 +1368,8 @@ class GETDataReport extends HRCCommand implements HRCCommandInterface
|
||||
$average_sum_one_guest = round($clients_sum / $one_client_count, 2);
|
||||
//Pay methods
|
||||
$pay_cash_sum = ExchangeOrders::where('who_open', '>', 0)
|
||||
->where('order_sum', '>', 0)
|
||||
->where('cash', '>', 0)
|
||||
//->where('order_sum', '>', 0)
|
||||
//->where('cash', '>', 0)
|
||||
->where('is_deleted', 0)
|
||||
->where('shift_id', $shift_id)
|
||||
->sum('cash');
|
||||
@@ -1455,42 +1455,42 @@ class GETDataReport extends HRCCommand implements HRCCommandInterface
|
||||
->count();
|
||||
|
||||
if ($settings > 0) {
|
||||
$pay_echeck_orders = ExchangeOrders::where('who_open', '>', 0)
|
||||
->where('is_closed', 1)
|
||||
->where('check_number', 0)
|
||||
->where('cash', 0)
|
||||
->where('credit', 0)
|
||||
->where('clearing', 0)
|
||||
->where('presale', 0)
|
||||
->where('self', 0)
|
||||
->where('is_deleted', 0)
|
||||
->where('is_returned', 0)
|
||||
->where('table_name', '<>', '0')
|
||||
->where('shift_id', $shift_id)
|
||||
->get();
|
||||
foreach ($pay_echeck_orders as $pay_echeck_order) {
|
||||
$count_echeck_open = ExchangeActions::where('shift_id', $shift_id)
|
||||
->where('order_code', $pay_echeck_order['code'])
|
||||
->where('action_type', 6)
|
||||
->count();
|
||||
if ($count_echeck_open == 0 && $pay_echeck_order['is_closed'] == 1) {
|
||||
$pay_echeck_sum += $pay_echeck_order['order_sum'];
|
||||
$pay_echeck_orders = ExchangeOrders::where('who_open', '>', 0)
|
||||
->where('is_closed', 1)
|
||||
->where('check_number', 0)
|
||||
->where('cash', 0)
|
||||
->where('credit', 0)
|
||||
->where('clearing', 0)
|
||||
->where('presale', 0)
|
||||
->where('self', 0)
|
||||
->where('is_deleted', 0)
|
||||
->where('is_returned', 0)
|
||||
->where('table_name', '<>', '0')
|
||||
->where('shift_id', $shift_id)
|
||||
->get();
|
||||
foreach ($pay_echeck_orders as $pay_echeck_order) {
|
||||
$count_echeck_open = ExchangeActions::where('shift_id', $shift_id)
|
||||
->where('order_code', $pay_echeck_order['code'])
|
||||
->where('action_type', 6)
|
||||
->count();
|
||||
if ($count_echeck_open == 0 && $pay_echeck_order['is_closed'] == 1) {
|
||||
$pay_echeck_sum += $pay_echeck_order['order_sum'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pay_delivery_sum = ExchangeOrders::where('who_open', '>', 0)
|
||||
->where('is_closed', 1)
|
||||
->where('check_number', 0)
|
||||
->where('cash', 0)
|
||||
->where('credit', 0)
|
||||
->where('clearing', 0)
|
||||
->where('presale', 0)
|
||||
->where('self', 0)
|
||||
->where('is_deleted', 0)
|
||||
->where('is_returned', 0)
|
||||
->where('table_name', '0')
|
||||
->where('shift_id', $shift_id)
|
||||
->sum('order_sum');
|
||||
$pay_delivery_sum = ExchangeOrders::where('who_open', '>', 0)
|
||||
->where('is_closed', 1)
|
||||
->where('check_number', 0)
|
||||
->where('cash', 0)
|
||||
->where('credit', 0)
|
||||
->where('clearing', 0)
|
||||
->where('presale', 0)
|
||||
->where('self', 0)
|
||||
->where('is_deleted', 0)
|
||||
->where('is_returned', 0)
|
||||
->where('table_name', '0')
|
||||
->where('shift_id', $shift_id)
|
||||
->sum('order_sum');
|
||||
}
|
||||
return [
|
||||
'status' => 'success',
|
||||
@@ -1545,6 +1545,7 @@ class GETDataReport extends HRCCommand implements HRCCommandInterface
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
if (isset($input['start_date']) && isset($input['end_date'])) {
|
||||
$end_date = date('Y-m-d H:i:s', strtotime($input['end_date'] . ' 23:59:59'));
|
||||
$start_date = date('Y-m-d H:i:s', strtotime($input['start_date'] . ' 00:00:01'));
|
||||
@@ -1702,8 +1703,8 @@ class GETDataReport extends HRCCommand implements HRCCommandInterface
|
||||
$average_sum_one_guest = round($clients_sum / $one_client_count, 2);
|
||||
//Pay methods
|
||||
$pay_cash_sum += ExchangeOrders::where('who_open', '>', 0)
|
||||
->where('order_sum', '>', 0)
|
||||
->where('cash', '>', 0)
|
||||
//->where('order_sum', '>', 0)
|
||||
//->where('cash', '>', 0)
|
||||
->where('is_deleted', 0)
|
||||
->where('shift_id', $shift_id)
|
||||
->sum('cash');
|
||||
@@ -1827,6 +1828,17 @@ class GETDataReport extends HRCCommand implements HRCCommandInterface
|
||||
->sum('order_sum');
|
||||
}
|
||||
}
|
||||
if (Report::where('start_date', $start_date)->where('end_date', $end_date)->where('report_type', 'statistics')->count() < 1) {
|
||||
$report = new Report;
|
||||
$report->user_id = intval($input['admin_user_id']);
|
||||
$report->name = 'Отчет по статистике';
|
||||
$report->shift_id = 0;
|
||||
$report->start_date = $start_date;
|
||||
$report->end_date = $end_date;
|
||||
$report->report_type = 'statistics';
|
||||
$report->save();
|
||||
}
|
||||
|
||||
return [
|
||||
'status' => 'success',
|
||||
'fiscal' => [
|
||||
@@ -1882,6 +1894,200 @@ class GETDataReport extends HRCCommand implements HRCCommandInterface
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($reportType == 'payment') {
|
||||
if (isset($input['shift_id'])) {
|
||||
$shift_id = $input['shift_id'];
|
||||
$shift_time = ExchangeShifts::where('id', $shift_id)->first();
|
||||
$shift_start_time = $shift_time['opened'];
|
||||
$shift_end_time = $shift_time['closed'];
|
||||
$printers = Printer::get();
|
||||
foreach ($printers as $printer) {
|
||||
$report[$printer['code']]['cash'] = $report[$printer['code']]['credit'] = 0;
|
||||
$report[$printer['code']]['presale'] = $report[$printer['code']]['self'] = 0;
|
||||
$report[$printer['code']]['clearing'] = $report[$printer['code']]['emoney'] = 0;
|
||||
$report[$printer['code']]['online'] = 0;
|
||||
}
|
||||
$report[0]['cash'] = $report[0]['credit'] = 0;
|
||||
$report[0]['presale'] = $report[0]['self'] = 0;
|
||||
$report[0]['clearing'] = $report[0]['emoney'] = 0;
|
||||
$report[0]['online'] = 0;
|
||||
$orders = ExchangeOrders::where('shift_id', $shift_id)
|
||||
->where('is_deleted', 0)
|
||||
->where('is_closed', 1)
|
||||
->where('order_sum', '>=', 0)
|
||||
->get();
|
||||
foreach ($orders as $order) {
|
||||
$order_emoney = 0;
|
||||
$order_online = 0;
|
||||
$sum_payments = $order['cash'] + $order['credit'] + $order['presale'] + $order['self'] + $order['clearing'] + $order_emoney + $order_online;
|
||||
if ($sum_payments == 0) {
|
||||
$count_online_open = ExchangeActions::where('shift_id', $shift_id)
|
||||
->where('order_code', $order['code'])
|
||||
->where('action_type', 45)
|
||||
->where('more', '<>', '0')
|
||||
->count();
|
||||
$count_online_close = ExchangeActions::where('shift_id', $shift_id)
|
||||
->where('order_code', $order['code'])
|
||||
->where('action_type', 6)
|
||||
->count();
|
||||
if ($count_online_open > 0 && $count_online_close > 0) {
|
||||
$order_online = $order['order_sum'];
|
||||
}
|
||||
$count_another = ExchangeActions::where('order_code', $order['code'])
|
||||
->where('action_type', 51)
|
||||
->where('shift_id', $shift_id)
|
||||
->count();
|
||||
if ($count_another > 0) {
|
||||
$order_emoney = $order['order_sum'];
|
||||
}
|
||||
}
|
||||
$sum_payments = $order['cash'] + $order['credit'] + $order['presale'] + $order['self'] + $order['clearing'] + $order_emoney + $order_online;
|
||||
if ($sum_payments == 0) {
|
||||
continue;
|
||||
}
|
||||
$cash_cof = round($order['cash'] / $sum_payments, 2);
|
||||
$credit_cof = round($order['credit'] / $sum_payments, 2);
|
||||
$presale_cof = round($order['presale'] / $sum_payments, 2);
|
||||
$self_cof = round($order['self'] / $sum_payments, 2);
|
||||
$clearing_cof = round($order['clearing'] / $sum_payments, 2);
|
||||
$online_cof = round($order_online / $sum_payments, 2);
|
||||
$emoney_cof = round($order_emoney / $sum_payments, 2);
|
||||
$items = ExchangeItems::where('shift_id', $shift_id)
|
||||
->where('order_code', $order['code'])
|
||||
->get();
|
||||
foreach ($items as $item) {
|
||||
$sum = round(($item['count'] - $item['count_return']) * $item['sale_price'], 2);
|
||||
$printer_code = Dishes::GetPrinterCode($item['dishes_code']);
|
||||
$report[$printer_code]['cash'] += round($sum * $cash_cof, 2);
|
||||
$report[$printer_code]['credit'] += round($sum * $credit_cof, 2);
|
||||
$report[$printer_code]['presale'] += round($sum * $presale_cof, 2);
|
||||
$report[$printer_code]['self'] += round($sum * $self_cof, 2);
|
||||
$report[$printer_code]['clearing'] += round($sum * $clearing_cof, 2);
|
||||
$report[$printer_code]['emoney'] += round($sum * $emoney_cof, 2);
|
||||
$report[$printer_code]['online'] += round($sum * $online_cof, 2);
|
||||
}
|
||||
}
|
||||
foreach ($report as $key => $item) {
|
||||
$item['cash'] = round($item['cash'], 2);
|
||||
$item['credit'] = round($item['credit'], 2);
|
||||
$item['presale'] = round($item['presale'], 2);
|
||||
$item['self'] = round($item['self'], 2);
|
||||
$item['clearing'] = round($item['clearing'], 2);
|
||||
$item['emoney'] = round($item['emoney'], 2);
|
||||
$item['online'] = round($item['online'], 2);
|
||||
$out[] = array(
|
||||
'printer_name' => Printer::getName($key),
|
||||
'full_sum' => round($item['cash'] + $item['credit'] + $item['presale'] + $item['self'] + $item['clearing'] + $item['emoney'] + $item['online'], 2),
|
||||
'payments' => $item
|
||||
);
|
||||
}
|
||||
$return = [
|
||||
'status' => 'success',
|
||||
'items' => $out
|
||||
];
|
||||
return $return;
|
||||
|
||||
}
|
||||
if (isset($input['start_date']) && isset($input['end_date'])) {
|
||||
$end_date = date('Y-m-d H:i:s', strtotime($input['end_date'] . ' 23:59:59'));
|
||||
$start_date = date('Y-m-d H:i:s', strtotime($input['start_date'] . ' 00:00:01'));
|
||||
$printers = Printer::get();
|
||||
foreach ($printers as $printer) {
|
||||
$report[$printer['code']]['cash'] = $report[$printer['code']]['credit'] = 0;
|
||||
$report[$printer['code']]['presale'] = $report[$printer['code']]['self'] = 0;
|
||||
$report[$printer['code']]['clearing'] = $report[$printer['code']]['emoney'] = 0;
|
||||
$report[$printer['code']]['online'] = 0;
|
||||
}
|
||||
$report[0]['cash'] = $report[0]['credit'] = 0;
|
||||
$report[0]['presale'] = $report[0]['self'] = 0;
|
||||
$report[0]['clearing'] = $report[0]['emoney'] = 0;
|
||||
$report[0]['online'] = 0;
|
||||
$shifts = ExchangeShifts::select('id')
|
||||
->where('opened', '>', $start_date)
|
||||
->where('closed', '<', $end_date)
|
||||
->get();
|
||||
foreach ($shifts as $shift) {
|
||||
$shift_id = $shift['id'];
|
||||
$orders = ExchangeOrders::where('shift_id', $shift_id)
|
||||
->where('is_deleted', 0)
|
||||
->where('is_closed', 1)
|
||||
->where('order_sum', '>=', 0)
|
||||
->get();
|
||||
foreach ($orders as $order) {
|
||||
$order_emoney = 0;
|
||||
$order_online = 0;
|
||||
$sum_payments = $order['cash'] + $order['credit'] + $order['presale'] + $order['self'] + $order['clearing'] + $order_emoney + $order_online;
|
||||
if ($sum_payments == 0) {
|
||||
$count_online_open = ExchangeActions::where('shift_id', $shift_id)
|
||||
->where('order_code', $order['code'])
|
||||
->where('action_type', 45)
|
||||
->where('more', '<>', '0')
|
||||
->count();
|
||||
$count_online_close = ExchangeActions::where('shift_id', $shift_id)
|
||||
->where('order_code', $order['code'])
|
||||
->where('action_type', 6)
|
||||
->count();
|
||||
if ($count_online_open > 0 && $count_online_close > 0) {
|
||||
$order_online = $order['order_sum'];
|
||||
}
|
||||
$count_another = ExchangeActions::where('order_code', $order['code'])
|
||||
->where('action_type', 51)
|
||||
->where('shift_id', $shift_id)
|
||||
->count();
|
||||
if ($count_another > 0) {
|
||||
$order_emoney = $order['order_sum'];
|
||||
}
|
||||
}
|
||||
$sum_payments = $order['cash'] + $order['credit'] + $order['presale'] + $order['self'] + $order['clearing'] + $order_emoney + $order_online;
|
||||
if ($sum_payments == 0) {
|
||||
continue;
|
||||
}
|
||||
$cash_cof = round($order['cash'] / $sum_payments, 2);
|
||||
$credit_cof = round($order['credit'] / $sum_payments, 2);
|
||||
$presale_cof = round($order['presale'] / $sum_payments, 2);
|
||||
$self_cof = round($order['self'] / $sum_payments, 2);
|
||||
$clearing_cof = round($order['clearing'] / $sum_payments, 2);
|
||||
$online_cof = round($order_online / $sum_payments, 2);
|
||||
$emoney_cof = round($order_emoney / $sum_payments, 2);
|
||||
$items = ExchangeItems::where('shift_id', $shift_id)
|
||||
->where('order_code', $order['code'])
|
||||
->get();
|
||||
foreach ($items as $item) {
|
||||
$sum = round(($item['count'] - $item['count_return']) * $item['sale_price'], 2);
|
||||
$printer_code = Dishes::GetPrinterCode($item['dishes_code']);
|
||||
Log::debug($printer_code);
|
||||
$report[$printer_code]['cash'] += round($sum * $cash_cof, 2);
|
||||
$report[$printer_code]['credit'] += round($sum * $credit_cof, 2);
|
||||
$report[$printer_code]['presale'] += round($sum * $presale_cof, 2);
|
||||
$report[$printer_code]['self'] += round($sum * $self_cof, 2);
|
||||
$report[$printer_code]['clearing'] += round($sum * $clearing_cof, 2);
|
||||
$report[$printer_code]['emoney'] += round($sum * $emoney_cof, 2);
|
||||
$report[$printer_code]['online'] += round($sum * $online_cof, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($report as $key => $item) {
|
||||
$item['cash'] = round($item['cash'], 2);
|
||||
$item['credit'] = round($item['credit'], 2);
|
||||
$item['presale'] = round($item['presale'], 2);
|
||||
$item['self'] = round($item['self'], 2);
|
||||
$item['clearing'] = round($item['clearing'], 2);
|
||||
$item['emoney'] = round($item['emoney'], 2);
|
||||
$item['online'] = round($item['online'], 2);
|
||||
$out[] = array(
|
||||
'printer_name' => Printer::getName($key),
|
||||
'full_sum' => round($item['cash'] + $item['credit'] + $item['presale'] + $item['self'] + $item['clearing'] + $item['emoney'] + $item['online'], 2),
|
||||
'payments' => $item
|
||||
);
|
||||
}
|
||||
$return = [
|
||||
'status' => 'success',
|
||||
'items' => $out
|
||||
];
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return [
|
||||
'status' => 'success',
|
||||
|
||||
Reference in New Issue
Block a user