Skip to content

Instantly share code, notes, and snippets.

View worstn8mare's full-sized avatar

Ariel Pepito worstn8mare

View GitHub Profile
select
t1.id, t1.title, IF(t2.amount is not null,SUM(t2.amount),0) as amount, t1.f1,t1.f2,t1.f3,t1.f4
from gl_accounts as t1
left join (
select
a.id as title_id,
a.f1,a.f2,a.f3,a.f4,
b.amount as amount
from gl_accounts as a
LEFT JOIN posting_gls as b on b.gl_account_id = a.id
select
t1.id, t1.title, IF(t2.amount is not null,SUM(t2.amount),0) as amount, t1.f1,t1.f2,t1.f3,t1.f4,
CASE
WHEN (t1.f1>0 and t1.f2 = 0 and t1.f3 = 0 and t1.f4 = 0) THEN
(SELECT count(*) from gl_accounts as g where g.f1 = t1.f1 )
WHEN (t1.f1>0 and t1.f2 > 0 and t1.f3 = 0 and t1.f4 = 0) THEN
(SELECT count(*) from gl_accounts as g where g.f1 = t1.f1 and g.f2 = t1.f2 )
WHEN (t1.f1>0 and t1.f2 > 0 and t1.f3 > 0 and t1.f4 = 0) THEN
(SELECT count(*) from gl_accounts as g where g.f1 = t1.f1 and g.f2 = t1.f2 and g.f3 = t1.f3)
WHEN (t1.f1>0 and t1.f2 > 0 and t1.f3 > 0 and t1.f4 > 0) THEN
select
a.id, a.posting_id, a.entry_type, a.gl_account_id,
b.doc_type, b.ref_doc_id,sum(amount) as amount
from posting_gls as a
INNER JOIN (
SELECT
a1.cv_header_id as ref_doc_id, c1.doc_type as doc_type, c1.id as posting_id
from cv_post_details as a1
LEFT JOIN cv_headers b1 on a1.cv_header_id = b1.id
INSERT INTO postings (id,cb,partner_id,post_date,posting_type,status,doc_type,doc_no,attachment_no)
(
SELECT
a.posting_id as id,
a.cb as cb,
a.partner_id as partner_id,
c.date as date,
"Purchases" as posting_type,
"Posted" as status,
INSERT INTO posting_gls (posting_id,entry_type,gl_account_id,amount)
(
select
posting_id,
entry_type, gl_account_id, amount
from gl_entries where doc_no = 20283 and doc_type = "RR" and status != "Void"
)
SELECT * from posting_gls WHERE posting_id in (
SELECT id from postings where DATE(post_date) < "2017-01-01"
)
SELECT
a.id as rr_id, b.id as attachment_id,a.status, a.rr_date, a.posted, c.status as status_posted, c.post_date
from receive_headers as a
INNER JOIN receive_post_details as b on a.id = b.rr_id
LEFT JOIN postings as c on c.attachment_no = b.id
where c.doc_type = "RR"
and DATE(a.rr_date) >= "2017-01-01"
and a.posted = "Y" and c.status !="Posted"
select
CONCAT(SUM(b.amount),'|',c.cb) as detail
from gl_accounts as a
LEFT JOIN posting_gls as b on b.gl_account_id = a.id
LEFT JOIN postings as c on c.id = b.posting_id
LEFT JOIN cv_post_details as d on d.id = IF(c.doc_type = 'CV',c.attachment_no,1)
where d.type = 'Posting'
and c.status = 'Posted'
-- -----------------------------------
and (
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
$posted = DB::select("
SELECT
a.id,
(
SELECT COUNT(*) FROM
pc_attachment_files as c
WHERE c.detail_id = b.id
) as attachment_file_count
FROM
pc_headers as a