Public Void with parameter using x++ :
public void addData(TransDate fromDate, TransDate
toDate,
InventLocationId warehouse,
RefRecId planVersionId)
{
TIDBOB BOB, BOB2;
TIDBOBTmp BOBTmp;
InventDim inventDim;
ItemId tmpItemId;
TransDate date1, date2;
str datetmp1, datetmp2;
int m, y;
;
m = mthOfYr(fromDate);
m = m - 1;
y = year(fromDate);
if (m == 0)
{
m = 12;
y = y - 1;
}
datetmp1 = int2str(m)+'/25/'+int2str(y);
date1 = str2Date(datetmp1, 213);
date2 = dateEndMth(date1);
inventDim.InventLocationId =
warehouse;
inventDim.InventSiteId =
InventLocation::find(warehouse).InventSiteId;
inventDim =
InventDim::findOrCreate(inventDim);
if (warehouse != '')
{
while
select BOB order by
BOB.ItemId
where
BOB.ReqDateDlv >= dateStartMth(fromDate)
&& BOB.ReqDateDlv <=
dateEndMth(toDate)
&& BOB.InventLocationId
== warehouse
&& BOB.PlanVersionid ==
planVersionId
{
if
(tmpItemId == BOB.ItemId) || !tmpItemId)
{
this.PrintDate = dateStartMth(fromDate);
this.InventLocationId = warehouse;
this.ItemId = BOB.ItemId;
this.UnitId =
InventTable::find(BOB.ItemId).inventUnitId();
this.CreateDate = BOB.CreateDate;
this.PlanVersionId = BOB.PlanVersionid;
if
(dayOfMth(BOB.ReqDateDlv) >= 1 && dayOfMth(BOB.ReqDateDlv)
<= 5)
{
this.qtyperiode1 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 6 && dayOfMth(BOB.ReqDateDlv)
<= 10)
{
this.qtyperiode2 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 11 && dayOfMth(BOB.ReqDateDlv)
<= 15)
{
this.qtyperiode3 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 16 && dayOfMth(BOB.ReqDateDlv)
<= 20)
{
this.qtyperiode4 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 21 && dayOfMth(BOB.ReqDateDlv)
<= 25)
{
this.qtyperiode5 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 26 && dayOfMth(BOB.ReqDateDlv)
<= 31)
{
this.qtyperiode6 +=
BOB.Qty;
}
}
else
{
this.insert();
this.PrintDate = dateStartMth(fromDate);
this.InventLocationId = warehouse;
this.ItemId = BOB.ItemId;
this.UnitId =
InventTable::find(BOB.ItemId).inventUnitId();
this.CreateDate = BOB.CreateDate;
this.PlanVersionId = BOB.PlanVersionid;
this.qtyperiode1 = 0;
this.qtyperiode2 = 0;
this.qtyperiode3 = 0;
this.qtyperiode4 = 0;
this.qtyperiode5 = 0;
this.qtyperiode6 = 0;
if
(dayOfMth(BOB.ReqDateDlv) >= 1 && dayOfMth(BOB.ReqDateDlv)
<= 5)
{
this.qtyperiode1 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 6 && dayOfMth(BOB.ReqDateDlv)
<= 10)
{
this.qtyperiode2 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 11 && dayOfMth(BOB.ReqDateDlv)
<= 15)
{
this.qtyperiode3 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 16 && dayOfMth(BOB.ReqDateDlv)
<= 20)
{
this.qtyperiode4 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 21 && dayOfMth(BOB.ReqDateDlv)
<= 25)
{
this.qtyperiode5 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 26 && dayOfMth(BOB.ReqDateDlv)
<= 31)
{
this.qtyperiode6 +=
BOB.Qty;
}
//
Menambahkan quantity period terakhir 1 bulan sebelumnya
select
sum(Qty) from
BOB2
where
BOB2.ReqDateDlv >= date1
&&
BOB2.ReqDateDlv <= date2
&&
BOB2.InventLocationId == warehouse
&& BOB2.ItemId
== tmpItemId;
update_recordSet
BOBTmp
setting qtyperiode0 = BOB2.qty
where BOBTmp.ItemId == tmpItemId;
}
tmpItemId = BOB.ItemId;
}
this.insert();
//
Menambahkan quantity period terakhir 1 bulan sebelumnya
select
sum(Qty) from
BOB2
where
BOB2.ReqDateDlv >= date1
&&
BOB2.ReqDateDlv <= date2
&&
BOB2.InventLocationId == warehouse
&& BOB2.ItemId
== tmpItemId;
update_recordSet
BOBTmp
setting qtyperiode0 = BOB2.qty
where BOBTmp.ItemId == tmpItemId;
}
else
{
while
select BOB order by
BOB.ItemId
where
BOB.ReqDateDlv >= dateStartMth(fromDate)
&& BOB.ReqDateDlv <=
dateEndMth(toDate)
{
if
(tmpItemId == BOB.ItemId || !tmpItemId)
{
this.PrintDate = dateStartMth(fromDate);
this.InventLocationId = warehouse;
this.ItemId = BOB.ItemId;
this.UnitId =
InventTable::find(BOB.ItemId).inventUnitId();
this.CreateDate = BOB.CreateDate;
if (dayOfMth(BOB.ReqDateDlv)
>= 1 && dayOfMth(BOB.ReqDateDlv) <= 5)
{
this.qtyperiode1 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 6 && dayOfMth(BOB.ReqDateDlv)
<= 10)
{
this.qtyperiode2 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 11 && dayOfMth(BOB.ReqDateDlv)
<= 15)
{
this.qtyperiode3 +=
BOB.Qty;
}
if (dayOfMth(BOB.ReqDateDlv) >= 16 && dayOfMth(BOB.ReqDateDlv)
<= 20)
{
this.qtyperiode4 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 21 && dayOfMth(BOB.ReqDateDlv)
<= 25)
{
this.qtyperiode5 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 26 && dayOfMth(BOB.ReqDateDlv)
<= 31)
{
this.qtyperiode6 +=
BOB.Qty;
}
}
else
{
this.insert();
this.PrintDate = dateStartMth(fromDate);
this.InventLocationId = warehouse;
this.ItemId = BOB.ItemId;
this.UnitId =
InventTable::find(BOB.ItemId).inventUnitId();
this.CreateDate = BOB.CreateDate;
this.qtyperiode1 = 0;
this.qtyperiode2 = 0;
this.qtyperiode3 = 0;
this.qtyperiode4 = 0;
this.qtyperiode5 = 0;
this.qtyperiode6 = 0;
if
(dayOfMth(BOB.ReqDateDlv) >= 1 && dayOfMth(BOB.ReqDateDlv)
<= 5)
{
this.qtyperiode1 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 6 && dayOfMth(BOB.ReqDateDlv)
<= 10)
{
this.qtyperiode2 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 11 && dayOfMth(BOB.ReqDateDlv)
<= 15)
{
this.qtyperiode3 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 16 && dayOfMth(BOB.ReqDateDlv)
<= 20)
{
this.qtyperiode4 +=
BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 21 && dayOfMth(BOB.ReqDateDlv)
<= 25)
{
this.qtyperiode5 += BOB.Qty;
}
if
(dayOfMth(BOB.ReqDateDlv) >= 26 && dayOfMth(BOB.ReqDateDlv)
<= 31)
{
this.qtyperiode6 +=
BOB.Qty;
}
//
Menambahkan quantity period terakhir 1 bulan sebelumnya
select
sum(Qty) from
BOB2
where
BOB2.ReqDateDlv >= date1
&&
BOB2.ReqDateDlv <= date2
&&
BOB2.InventLocationId == warehouse
&& BOB2.ItemId
== tmpItemId;
update_recordSet
BOBTmp
setting qtyperiode0 = BOB2.qty
where BOBTmp.ItemId == tmpItemId;
}
tmpItemId = BOB.ItemId;
}
this.insert();
//
Menambahkan quantity period terakhir 1 bulan sebelumnya
select
sum(Qty) from
BOB2
where
BOB2.ReqDateDlv >= date1
&&
BOB2.ReqDateDlv <= date2
&& BOB2.InventLocationId
== warehouse
&& BOB2.ItemId
== tmpItemId;
update_recordSet
BOBTmp
setting qtyperiode0 = BOB2.qty
where BOBTmp.ItemId == tmpItemId;
}
}
0 comments:
Post a Comment