예제 #1
1
파일: Report.php 프로젝트: JC5/marauder
 /**
  * @param        $query
  * @param Carbon $date
  */
 public function scopeInMonth($query, Carbon $date)
 {
     $date->startOfMonth();
     $end = clone $date;
     $end->endOfMonth();
     $query->where('reports.time', '>=', $date->format('Y-m-d 00:00:00'));
     $query->where('reports.time', '<=', $end->format('Y-m-d 23:59:59'));
 }
예제 #2
1
 public function Execute()
 {
     $conn = \ZCL\DB\DB::getConnect();
     $store_id = $this->headerdata['store_id'];
     $item = \ZippyERP\ERP\Entity\Item::getSumItem();
     $stock = \ZippyERP\ERP\Entity\Stock::getStock($store_id, $item->item_id, 1, true);
     $discont = 0;
     //скидки  704  счет
     $date = new Carbon();
     $date->setTimestamp($this->document_date);
     $end = $date->endOfMonth()->getTimestamp();
     $begin = $date->startOfMonth()->getTimestamp();
     $sql = " select coalesce(abs(sum(amount)),0) from erp_account_subconto where amount < 0  and account_id=285 and  extcode  = {$store_id} and  document_date  <= " . $conn->DBDate($end);
     $tm = $conn->GetOne($sql);
     //торговая  наценка на  конец периода
     //остатки на  конец периода
     $sql = " select coalesce(sum(quantity),0) AS quantity,coalesce(price,0) as price  from erp_account_subconto sc join erp_store_stock  st on sc.stock_id = st.stock_id where    store_id = {$store_id} and date(document_date) <= " . $conn->DBDate($end);
     $row = $conn->GetRow($sql);
     $ost = $row['quantity'] / 1000;
     $ost = $ost * $row['price'];
     if ($ost == 0) {
         return;
     }
     //выручка
     $sql = " select coalesce(abs(sum(amount)),0) from erp_account_subconto where amount < 0  and account_id=702 and  extcode  = {$store_id} and date(document_date) <= " . $conn->DBDate($end) . " and date(document_date) >= " . $conn->DBDate($begin);
     $saled = $conn->GetOne($sql);
     //выручка сданная в кассу
     $k = ($tm - $discont) / ($ost - $discont);
     $sb = (1 - $k) * $saled;
     //себестоимость
     // списываем  наценку
     Entry::AddEntry("285", "282", $saled - $sb, $this->document_id, $this->document_date);
     // себестоимость реализации
     Entry::AddEntry("902", "282", $sb, $this->document_id, $this->document_date);
     $item = \ZippyERP\ERP\Entity\Item::getSumItem();
     $stockto = \ZippyERP\ERP\Entity\Stock::getStock($store_id, $item->item_id, 1, true);
     $sc = new SubConto($this, 282, 0 - $saled);
     $sc->setStock($stockto->stock_id);
     $sc->setQuantity(0 - $saled * 1000);
     //цена  единицы  товара - 1 копейка.
     $sc->save();
     // НДС
     $nds = H::nds(true);
     Entry::AddEntry("702", "641", $saled * $nds, $this->document_id, $this->document_date);
     return true;
 }
예제 #3
1
 /**
  * Returns default javascript options
  *
  * Available options:
  * @see https://github.com/dangrossman/bootstrap-daterangepicker#options
  *
  * @return array
  */
 protected function getDefaultJsOptions()
 {
     $carbon = new Carbon();
     $prev_month = Carbon::now()->startOfMonth()->subWeek();
     $today = Carbon::now();
     $res = ['format' => 'YYYY-MM-DD', 'ranges' => ['previous_month' => ['Previous month (' . $prev_month->format('F') . ')', [$prev_month->startOfMonth()->format('Y-m-d'), $prev_month->endOfMonth()->format('Y-m-d')]], 'current_month' => ['Cur. month (' . date('F') . ')', [$carbon->startOfMonth()->format('Y-m-d'), $carbon->endOfMonth()->format('Y-m-d')]], 'last_week' => ['This Week', [$carbon->startOfWeek()->format('Y-m-d'), $carbon->endOfWeek()->format('Y-m-d')]], 'last_14' => ['Last 14 days', [Carbon::now()->subDays(13)->format('Y-m-d'), $today->format('Y-m-d')]]]];
     // will not set dates when '' passed but set default date when null passed
     if ($this->getStartValue()) {
         $res['startDate'] = $this->getStartValue();
     }
     if ($this->getEndValue()) {
         $res['endDate'] = $this->getEndValue();
     }
     return $res;
 }
예제 #4
0
 /**
  * Returns default javascript options
  *
  * Available options:
  * @see https://github.com/dangrossman/bootstrap-daterangepicker#options
  *
  * @return array
  */
 protected function getDefaultJsOptions()
 {
     $carbon = new Carbon();
     $prev_month = Carbon::now()->startOfMonth()->subWeek();
     $today = Carbon::now();
     return ['format' => 'YYYY-MM-DD', 'ranges' => ['previous_month' => ['Previous month (' . $prev_month->format('F') . ')', [$prev_month->startOfMonth()->format('Y-m-d'), $prev_month->endOfMonth()->format('Y-m-d')]], 'current_month' => ['Cur. month (' . date('F') . ')', [$carbon->startOfMonth()->format('Y-m-d'), $carbon->endOfMonth()->format('Y-m-d')]], 'last_week' => ['This Week', [$carbon->startOfWeek()->format('Y-m-d'), $carbon->endOfWeek()->format('Y-m-d')]], 'last_14' => ['Last 14 days', [Carbon::now()->subDays(13)->format('Y-m-d'), $today->format('Y-m-d')]]], 'startDate' => $this->getStartValue(), 'endDate' => $this->getEndValue()];
 }
예제 #5
0
 public function scopeThismonth($query)
 {
     $carbon = new Carbon();
     return $query->whereBetween(DB::raw('date(task_date)'), [$carbon->startOfMonth()->format('y-m-d'), $carbon->endOfMonth()->format('Y-m-d')])->get();
 }
예제 #6
0
 /**
  * @param string $period
  *
  * @return Carbon
  */
 public function getStartDateForPeriod($period)
 {
     $start = new Carbon();
     switch ($period) {
         default:
         case 'month':
             $start->startOfDay();
             $start->subMonth();
             break;
         case 'year':
             $start->startOfMonth();
             $start->subYear();
             break;
     }
     return $start;
 }
예제 #7
0
echo $dtBerlin->toAtomString() . "\n";
echo $dtBerlin->toCookieString() . "\n";
echo $dtBerlin->toRssString() . "\n";
$dtBerlin->setToStringFormat('l jS \\of F Y');
echo $dtBerlin . "\n";
echo (int) $dtBerlin->isLeapYear() . "\n";
// is* range of functions test
printf("Is yesterday? %s\n", $dtBerlin->isYesterday() ? "yes" : "no");
printf("Is a Thursday? %s\n", $dtBerlin->isThursday() ? "yes" : "no");
printf("Is in the future? %s\n", $dtBerlin->isFuture() ? "yes" : "no");
printf("Is a leap year? %s\n", $dtBerlin->isLeapYear() ? "yes" : "no");
// first and last of the month
printf("First of the month %s\n", $dtBerlin->firstOfMonth());
printf("Last of the month %s\n", $dtBerlin->lastOfMonth());
// nthOf* function test
printf("Start of the month %s\n", $dtBerlin->startOfMonth());
printf("End of the month %s\n", $dtBerlin->endOfMonth());
printf("End of the decade %s\n", $dtBerlin->endOfDecade());
// Date manipulation
print $dtBerlin->addHours(5)->addDays(2)->addWeeks(1)->addMonths(3);
print $dtBerlin->subMonths(8)->subHours(7);
// Find UK Bank Holidays
$dtLondon = CitcoCarbon::today('Europe/London');
list($date, $name) = each($dtLondon->nextBankHoliday());
printf("The next bank holiday is %s on %s\n", $name, $date);
foreach ($dtLondon->getBankHolidays([2016, 2017]) as $date => $name) {
    printf("The next bank holiday is %s on %s\n", $name, $date);
}
// Find end of the current financial year
$fyCalculator = new Calculator(7, 1);
/* FY starts on July 1 */
예제 #8
0
echo $dtBerlin->toAtomString() . "\n";
echo $dtBerlin->toCookieString() . "\n";
echo $dtBerlin->toRssString() . "\n";
$dtBerlin->setToStringFormat('l jS \\of F Y');
echo $dtBerlin . "\n";
echo (int) $dtBerlin->isLeapYear() . "\n";
// is* range of functions test
echo "Is yesterday? " . ($dtBerlin->isYesterday() ? "yes" : "no") . PHP_EOL;
echo "Is a Thursday? " . ($dtBerlin->isThursday() ? "yes" : "no") . PHP_EOL;
echo "Is in the future? " . ($dtBerlin->isFuture() ? "yes" : "no") . PHP_EOL;
echo "Is a leap year? " . ($dtBerlin->isLeapYear() ? "yes" : "no") . PHP_EOL;
// first and last of the month
echo "First of the month " . $dtBerlin->firstOfMonth() . PHP_EOL;
echo "Last of the month " . $dtBerlin->lastOfMonth() . PHP_EOL;
// nthOf* function test
echo "Start of the month ", $dtBerlin->startOfMonth() . PHP_EOL;
echo "End of the month ", $dtBerlin->endOfMonth() . PHP_EOL;
echo "End of the decade ", $dtBerlin->endOfDecade() . PHP_EOL;
// Date manipulation
echo $dtBerlin->addHours(5)->addDays(2)->addWeeks(1)->addMonths(3) . PHP_EOL;
echo $dtBerlin->subMonths(8)->subHours(7) . PHP_EOL;
// Find UK Bank Holidays
$dtLondon = CitcoCarbon::today('Europe/London');
list($date, $name) = each($dtLondon->nextBankHoliday());
printf("The next bank holiday is %s on %s\n", $name, $date);
foreach ($dtLondon->getBankHolidays([2016, 2017]) as $date => $name) {
    printf("The next bank holiday is %s on %s\n", $name, $date);
}
// Find end of the current financial year
$fyCalculator = new Calculator(7, 1);
/* FY starts on July 1 */
예제 #9
0
 /**
  * Returns default javascript options
  *
  * Available options:
  * @see https://github.com/dangrossman/bootstrap-daterangepicker#options
  *
  * @return array
  */
 protected function getDefaultJsOptions()
 {
     $carbon = new Carbon();
     $prev_month = Carbon::now()->startOfMonth()->subWeek();
     $today = Carbon::today();
     $yesterday = Carbon::yesterday();
     $res = ['format' => 'YYYY-MM-DD', 'ranges' => ['Today' => [$today->format('Y-m-d'), $today->format('Y-m-d')], 'Previous Day' => [$yesterday->format('Y-m-d'), $yesterday->format('Y-m-d')], 'This Week' => [$carbon->startOfWeek()->format('Y-m-d'), $carbon->endOfWeek()->format('Y-m-d')], 'This Month (' . date('F') . ')' => [$carbon->startOfMonth()->format('Y-m-d'), $carbon->endOfMonth()->format('Y-m-d')], 'Previous Month (' . $prev_month->format('F') . ')' => [$prev_month->startOfMonth()->format('Y-m-d'), $prev_month->endOfMonth()->format('Y-m-d')]]];
     $res['opens'] = 'left';
     // will not set dates when '' passed but set default date when null passed
     if ($this->getStartValue()) {
         $res['startDate'] = $this->getStartValue();
     }
     if ($this->getEndValue()) {
         $res['endDate'] = $this->getEndValue();
     }
     return $res;
 }