* Sync with 3.1.3
This commit is contained in:
parent
a10b9fa885
commit
9d6ffaf60d
|
@ -1,9 +1,9 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<data>
|
||||
<AD_ENTITYTYPE ENTITYTYPE="D" AD_CLIENT_ID="0" AD_ORG_ID="0" AD_ENTITYTYPE_ID="10" ISACTIVE="Y" CREATED="2006-06-11 12:11:19.0" CREATEDBY="100" UPDATED="2006-06-11 12:12:04.0" UPDATEDBY="100" NAME="Dictionary" DESCRIPTION="Application Dictionary Ownership ** System Mainatined **" HELP="The entity is owned by the Application Dictionary. You should NOT use Disctionary as all modifications are likely to be reversed, to maintain customizations, copy the record. (Change Log & Reapply Customization allows you to maintain minor modifications)" PROCESSING="N" />
|
||||
<AD_ENTITYTYPE ENTITYTYPE="D" AD_CLIENT_ID="0" AD_ORG_ID="0" AD_ENTITYTYPE_ID="10" ISACTIVE="Y" CREATED="2006-06-11 12:11:19.0" CREATEDBY="100" UPDATED="2006-06-11 12:12:04.0" UPDATEDBY="100" NAME="Dictionary" DESCRIPTION="Application Dictionary Ownership ** System Maintained **" HELP="The entity is owned by the Application Dictionary. You should NOT use Disctionary as all modifications are likely to be reversed, to maintain customizations, copy the record. (Change Log & Reapply Customization allows you to maintain minor modifications)" PROCESSING="N" />
|
||||
<AD_ENTITYTYPE ENTITYTYPE="C" AD_CLIENT_ID="0" AD_ORG_ID="0" AD_ENTITYTYPE_ID="20" ISACTIVE="Y" CREATED="2006-06-11 12:11:46.0" CREATEDBY="100" UPDATED="2006-06-11 12:12:28.0" UPDATEDBY="100" NAME="Adempiere" DESCRIPTION="Adempiere Ownership ** System Maintained **" HELP="DO NOT USE" PROCESSING="N" />
|
||||
<AD_ENTITYTYPE ENTITYTYPE="U" AD_CLIENT_ID="0" AD_ORG_ID="0" AD_ENTITYTYPE_ID="100" ISACTIVE="Y" CREATED="2006-06-11 12:16:15.0" CREATEDBY="100" UPDATED="2006-06-11 12:16:15.0" UPDATEDBY="100" NAME="User maintained" DESCRIPTION="User maintained modifications" HELP="The default entity type for your Customizations and custom Extensions. Will be preserved during version migration." PROCESSING="N" />
|
||||
<AD_ENTITYTYPE ENTITYTYPE="A" AD_CLIENT_ID="0" AD_ORG_ID="0" AD_ENTITYTYPE_ID="200" ISACTIVE="Y" CREATED="2006-06-11 12:17:59.0" CREATEDBY="100" UPDATED="2006-06-11 12:18:59.0" UPDATEDBY="100" NAME="Appliactions" DESCRIPTION="Application modifications" HELP="Alternative to User maintained entity type. Will be preserved during version migration." PROCESSING="N" />
|
||||
<AD_ENTITYTYPE ENTITYTYPE="A" AD_CLIENT_ID="0" AD_ORG_ID="0" AD_ENTITYTYPE_ID="200" ISACTIVE="Y" CREATED="2006-06-11 12:17:59.0" CREATEDBY="100" UPDATED="2006-06-11 12:18:59.0" UPDATEDBY="100" NAME="Applications" DESCRIPTION="Application modifications" HELP="Alternative to User maintained entity type. Will be preserved during version migration." PROCESSING="N" />
|
||||
<AD_ENTITYTYPE ENTITYTYPE="EXT" AD_CLIENT_ID="0" AD_ORG_ID="0" AD_ENTITYTYPE_ID="210" ISACTIVE="Y" CREATED="2006-06-11 12:18:45.0" CREATEDBY="100" UPDATED="2006-06-11 12:18:45.0" UPDATEDBY="100" NAME="Extensions" DESCRIPTION="Application Extensions" HELP="Alternative to User maintained entity type. Will be preserved during version migration." PROCESSING="N" />
|
||||
<AD_ENTITYTYPE ENTITYTYPE="XX" AD_CLIENT_ID="0" AD_ORG_ID="0" AD_ENTITYTYPE_ID="220" ISACTIVE="Y" CREATED="2006-06-11 12:19:35.0" CREATEDBY="100" UPDATED="2006-06-11 12:19:35.0" UPDATEDBY="100" NAME="Other Extensions" DESCRIPTION="Other Application Extensions" HELP="Alternative to User maintained entity type. Will be preserved during version migration." PROCESSING="N" />
|
||||
<AD_ENTITYTYPE ENTITYTYPE="CUST" AD_CLIENT_ID="0" AD_ORG_ID="0" AD_ENTITYTYPE_ID="110" ISACTIVE="Y" CREATED="2006-06-11 12:20:10.0" CREATEDBY="100" UPDATED="2006-06-11 12:20:10.0" UPDATEDBY="100" NAME="Other Customizations" DESCRIPTION="Other Application Customizations" HELP="Alternative to User maintained entity type. Will be preserved during version migration." PROCESSING="N" />
|
||||
|
|
|
@ -20,11 +20,18 @@ RETURN NUMBER
|
|||
* Grace days are not considered!
|
||||
* If record is not found it assumes due immediately
|
||||
*
|
||||
* Test: SELECT C_PaymentTerm_DueDays(103, '01-DEC-2000', '15-DEC-2000') FROM DUAL
|
||||
* Test: SELECT paymentTermDueDays(103, '01-DEC-2000', '15-DEC-2000') FROM DUAL
|
||||
*
|
||||
* Contributor(s): Carlos Ruiz - globalqss - match with SQLJ version
|
||||
************************************************************************/
|
||||
AS
|
||||
Days NUMBER := 0;
|
||||
DueDate DATE := TRUNC(DocDate);
|
||||
DueDate DATE := NULL;
|
||||
calDueDate DATE;
|
||||
FixMonthOffset C_PaymentTerm.FixMonthOffset%TYPE;
|
||||
MaxDayCut NUMBER;
|
||||
MaxDay NUMBER;
|
||||
v_PayDate DATE;
|
||||
--
|
||||
CURSOR Cur_PT IS
|
||||
SELECT *
|
||||
|
@ -33,10 +40,20 @@ AS
|
|||
FirstDay DATE;
|
||||
NoDays NUMBER;
|
||||
BEGIN
|
||||
|
||||
IF PaymentTerm_ID = 0 OR DocDate IS NULL THEN
|
||||
RETURN 0;
|
||||
END IF;
|
||||
|
||||
v_PayDate := PayDate;
|
||||
IF v_PayDate IS NULL THEN
|
||||
v_PayDate := TRUNC(SYSDATE);
|
||||
END IF;
|
||||
|
||||
FOR p IN Cur_PT LOOP -- for convineance only
|
||||
-- DBMS_OUTPUT.PUT_LINE(p.Name || ' - Doc = ' || TO_CHAR(DocDate));
|
||||
-- Due 15th of following month
|
||||
IF (p.IsDueFixed = 'Y') THEN
|
||||
IF (p.IsDueFixed = 'Y') THEN
|
||||
-- DBMS_OUTPUT.PUT_LINE(p.Name || ' - Day = ' || p.FixMonthDay);
|
||||
FirstDay := TRUNC(DocDate, 'MM');
|
||||
NoDays := TRUNC(DocDate) - FirstDay;
|
||||
|
@ -45,14 +62,49 @@ BEGIN
|
|||
IF (NoDays > p.FixMonthCutoff) THEN
|
||||
DueDate := ADD_MONTHS(DueDate, 1);
|
||||
END IF;
|
||||
|
||||
calDueDate := TRUNC(DocDate);
|
||||
MaxDayCut := TO_NUMBER (TO_CHAR (LAST_DAY (calDueDate), 'dd'));
|
||||
IF p.FixMonthCutoff > MaxDayCut THEN
|
||||
calDueDate := LAST_DAY(TRUNC(calDueDate));
|
||||
ELSE
|
||||
-- set day fixmonthcutoff on duedate
|
||||
calDueDate := TO_DATE ( SUBSTR (TO_CHAR (TRUNC (calDueDate), 'yyyymmdd'), 1, 6)
|
||||
|| LPAD (TO_CHAR (p.FixMonthCutoff), 2, '0'),
|
||||
'yyyymmdd'
|
||||
);
|
||||
END IF;
|
||||
FixMonthOffset := p.FixMonthOffset;
|
||||
IF DocDate > calDueDate THEN
|
||||
FixMonthOffset := FixMonthOffset + 1;
|
||||
END IF;
|
||||
calDueDate := ADD_MONTHS(calDueDate, FixMonthOffset);
|
||||
MaxDay := TO_NUMBER (TO_CHAR (LAST_DAY (calDueDate), 'dd'));
|
||||
IF (p.FixMonthDay > MaxDay) -- 32 -> 28
|
||||
OR (p.FixMonthDay >= 30 AND MaxDay > p.FixMonthDay) THEN -- 30 -> 31
|
||||
calDueDate := TO_DATE ( SUBSTR (TO_CHAR (TRUNC (calDueDate), 'yyyymmdd'), 1, 6)
|
||||
|| LPAD (TO_CHAR (MaxDay), 2, '0'),
|
||||
'yyyymmdd'
|
||||
);
|
||||
ELSE
|
||||
calDueDate := TO_DATE ( SUBSTR (TO_CHAR (TRUNC (calDueDate), 'yyyymmdd'), 1, 6)
|
||||
|| LPAD (TO_CHAR (p.FixMonthDay), 2, '0'),
|
||||
'yyyymmdd'
|
||||
);
|
||||
END IF;
|
||||
DueDate := calDueDate;
|
||||
ELSE
|
||||
-- DBMS_OUTPUT.PUT_LINE('Net = ' || p.NetDays);
|
||||
DueDate := TRUNC(DocDate) + p.NetDays;
|
||||
END IF;
|
||||
END LOOP;
|
||||
-- DBMS_OUTPUT.PUT_LINE('Due = ' || TO_CHAR(DueDate) || ', Pay = ' || TO_CHAR(PayDate));
|
||||
-- DBMS_OUTPUT.PUT_LINE('Due = ' || TO_CHAR(DueDate) || ', Pay = ' || TO_CHAR(v_PayDate));
|
||||
|
||||
Days := TRUNC(PayDate) - DueDate;
|
||||
IF DueDate IS NULL THEN
|
||||
RETURN 0;
|
||||
END IF;
|
||||
|
||||
Days := TRUNC(v_PayDate) - DueDate;
|
||||
RETURN Days;
|
||||
END paymentTermDueDays;
|
||||
/
|
||||
/
|
||||
|
|
Loading…
Reference in New Issue