Paper Industries: Difference between revisions

From eStream Software
No edit summary
No edit summary
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Introduction==
==Introduction==
 
For mostly paper industries, they have to calculate the total weight in KG converted from different packing size like REAM, PKT or MT. This total weight will be printed in the sales order, delivery order and tax invoice.
<br />
<br />


==Updates==
==Updates==
Line 51: Line 50:
   
   


3. Under Tools | DIY | SQL Control Center...Browse to Stock | Stock Item and insert the event "OnBeforeSave" with the DIY Script below:<br />
3. Under Tools | DIY | SQL Control Center...Browse to Stock | Stock Item and insert new event '''OnBeforeSave''' with the DIY Script below:<br />
 
<syntaxhighlight lang="delphi">
  '''Var''' M : TDataSource;
  Var M : TDataSource;
  <br />
   
  '''begin'''
  begin
   M := TDataSource(Self.FindComponent('dsAccess'));
   M := TDataSource(Self.FindComponent('dsAccess'));
   M.DataSet.Edit;
   M.DataSet.Edit;
Line 64: Line 63:
   M.DataSet.FindField('UDF_Weight_MT').Value := SimpleRoundToEx((M.DataSet.FindField('UDF_Weight_KG').AsFloat/1000),-4);                                                   
   M.DataSet.FindField('UDF_Weight_MT').Value := SimpleRoundToEx((M.DataSet.FindField('UDF_Weight_KG').AsFloat/1000),-4);                                                   
                                                
                                                
  '''end.'''
  end.
 
</syntaxhighlight>
<br />
<br />


Line 77: Line 76:
::* Credit Note
::* Credit Note


2. Insert and update the following DIY fields & Script into above mentions sales documents in Tools | DIY | SQL Control Center... <br />
2. Insert and update the following DIY fields & Script into above mentions sales documents in ''Tools | DIY | SQL Control Center...'' <br />
a) DIY Fields<br />
a) DIY Fields<br />
::{| class="wikitable"
::{| class="wikitable"
Line 101: Line 100:
<br />
<br />


b. DIY Script:<br />
b. DIY Script: '''OnGridColumnValueChange''' event<br />
  '''var'''
  <syntaxhighlight lang="delphi">
var
   FComServer : Variant;
   FComServer : Variant;
  <br />
   
  '''function''' ComServer: Variant;
  function ComServer: Variant;
  '''begin'''
  begin
   if FComServer = Null '''then begin'''
   if FComServer = Null then begin
     FComServer := CreateOleObject('SQLAcc.BizApp');
     FComServer := CreateOleObject('SQLAcc.BizApp');
   '''end;'''
   end;
   Result := FComServer;
   Result := FComServer;
  '''end;'''
  end;
  <br />
   
  '''var'''
  var
   lBizObj,S,S2 : Variant;
   lBizObj,S,S2 : Variant;
   lSQL    : String;
   lSQL    : String;
   lCdsDataList : TClientDataSet;
   lCdsDataList : TClientDataSet;
   D : TDataSource;
   D : TDataSource;
  <br />
   
  '''begin'''
  begin
   FComServer  := null;
   FComServer  := null;
   lCdsDataList := TClientDataSet.Create(nil);
   lCdsDataList := TClientDataSet.Create(nil);
   D := TDataSource(Self.FindComponent('dsDocDetail'));
   D := TDataSource(Self.FindComponent('dsDocDetail'));
   '''try'''
   try
     lSQL                := 'Code='+ QuotedStr(D.DataSet.FindField('ItemCode').AsString);
     lSQL                := 'Code='+ QuotedStr(D.DataSet.FindField('ItemCode').AsString);
     lBizObj              := ComServer.BizObjects.Find('ST_ITEM');
     lBizObj              := ComServer.BizObjects.Find('ST_ITEM');
  <br />
   
     lCdsDataList.XMLData := lBizObj.Select('UDF_GSM, UDF_Width, UDF_Length, UDF_PKT, UDF_Weight_KG, UDF_Weight_MT',lSQL,'','SX',',','');
     lCdsDataList.XMLData := lBizObj.Select('UDF_GSM, UDF_Width, UDF_Length, UDF_PKT, UDF_Weight_KG, UDF_Weight_MT',lSQL,'','SX',',','');
     '''if''' SameText(EditingField, 'ItemCode') '''or'''
     if SameText(EditingField, 'ItemCode') or
     SameText(EditingField, 'Qty') '''then begin'''
     SameText(EditingField, 'Qty') then begin
         D.DataSet.edit;
         D.DataSet.edit;
         D.DataSet.FindField('UDF_GSM').Value := lCdsDataList.FindField('UDF_GSM').Value;
         D.DataSet.FindField('UDF_GSM').Value := lCdsDataList.FindField('UDF_GSM').Value;
Line 137: Line 137:
         D.DataSet.FindField('UDF_Weight_KG').Value := lCdsDataList.FindField('UDF_Weight_KG').Value;
         D.DataSet.FindField('UDF_Weight_KG').Value := lCdsDataList.FindField('UDF_Weight_KG').Value;
         D.DataSet.FindField('UDF_Weight_MT').Value := lCdsDataList.FindField('UDF_Weight_MT').Value;   
         D.DataSet.FindField('UDF_Weight_MT').Value := lCdsDataList.FindField('UDF_Weight_MT').Value;   
         D.DataSet.FindField('UDF_TotWeight_KG').value := D.DataSet.FindField('UDF_Weight_KG').AsFloat*D.DataSet.FindField('Qty').Value;
         D.DataSet.FindField('UDF_TotWeight_KG').value := D.DataSet.FindField('UDF_Weight_KG').AsFloat*
         D.DataSet.FindField('UDF_TotWeight_MT').value := D.DataSet.FindField('UDF_Weight_MT').AsFloat*D.DataSet.FindField('Qty').Value;  
                                                        D.DataSet.FindField('Qty').Value;
     '''end;'''
         D.DataSet.FindField('UDF_TotWeight_MT').value := D.DataSet.FindField('UDF_Weight_MT').AsFloat*
  <br />
                                                        D.DataSet.FindField('Qty').Value;  
   '''finally'''
     end;
   
   finally
     lBizObj    := null;
     lBizObj    := null;
     FComServer := null;
     FComServer := null;
     lCdsDataList.Free;
     lCdsDataList.Free;
   '''end;'''
   end;
  '''end.'''
  end.
 
</syntaxhighlight>
<br />
<br />


==See also==
==See also==
* Others [[Customisation]]
* Others [[Customisation]]

Latest revision as of 04:05, 17 November 2015

Introduction

For mostly paper industries, they have to calculate the total weight in KG converted from different packing size like REAM, PKT or MT. This total weight will be printed in the sales order, delivery order and tax invoice.

Updates

Last Customisation Update : 06 Nov 2015

Criterias

Maintain Stock Group

[Stock | Maintain Stock Group...]

Stock group will be used as the Product Grade and Branding to categorise the stock items list.

Maintain Stock Item

[Stock | Maintain Stock Item...]

1. Stock Master Data.

Types Field Name Data Types Length Usage
STD Code String 30 Product Code, eg. ACGAAA100SK-31004300
STD Description String 200 Product Name, eg. Matt A/Paper China
STD 2nd Description String 200 Paper packaging size to be display in sales tax invoice, eg. 100gsm 31" x 43"
STD Base UOM String 10 stock unit of measurement, usually either enter as REAM or MT or PKT
DIY GSM Float Size :10
SubSize: 2
GSM value for Weight KG calculation
DIY Width Float Size :10
SubSize: 2
Width value for Weight KG calculation
DIY Length Float Size :10
SubSize: 2
Length value for Weight KG calculation
DIY PKT Float Size :10
SubSize: 2
PKT value for Weight KG calculation
DIY Weight_MT Float Size :10
SubSize: 4
Weight MT value
DIY Weight_KG Float Size :10
SubSize: 4
Weight Kgs value


2. Formula:

Weight KG = ((GSM x Width x Length)/3100)/PKT 
Weight MT = Weight KG/1000 

Both formula results are rounding up to 4 decimals.

3. Under Tools | DIY | SQL Control Center...Browse to Stock | Stock Item and insert new event OnBeforeSave with the DIY Script below:

 Var M : TDataSource;
 
 begin
   M := TDataSource(Self.FindComponent('dsAccess'));
   M.DataSet.Edit;
   M.DataSet.FindField('UDF_Weight_KG').Value := SimpleRoundToEx((((M.DataSet.FindField('UDF_GSM').AsFloat* 
                                                 M.DataSet.FindField('UDF_Width').AsFloat* 
                                                 M.DataSet.FindField('UDF_Length').AsFloat)/3100)/M.DataSet.FindField('UDF_PKT').AsFloat),-4);
                                                
   M.DataSet.FindField('UDF_Weight_MT').Value := SimpleRoundToEx((M.DataSet.FindField('UDF_Weight_KG').AsFloat/1000),-4);                                                  
                                              
 end.


Sales Documents Entry

1. Sales documents entry are:-

  • Quotation
  • Sales Order
  • Delivery Order
  • Invoice
  • Debit Note
  • Credit Note

2. Insert and update the following DIY fields & Script into above mentions sales documents in Tools | DIY | SQL Control Center...
a) DIY Fields

Type Field Name Data Types Length
DIY-F GSM Float Size: 10
SubSize: 2
DIY-F Width Float Size: 10
SubSize: 2
DIY-F Length Float Size: 10
SubSize: 2
DIY-F PKT Float Size: 10
SubSize: 2
DIY-F Weight_MT Float Size: 10
SubSize: 4
DIY-F Weight_KG Float Size: 10
SubSize: 4
DIY-F TotWeight_MT Float Size: 10
SubSize: 4
DIY-F TotWeight_KG Float Size: 10
SubSize: 4


b. DIY Script: OnGridColumnValueChange event

 var
   FComServer : Variant;
 
 function ComServer: Variant;
 begin
   if FComServer = Null then begin
     FComServer := CreateOleObject('SQLAcc.BizApp');
   end;
   Result := FComServer;
 end;
 
 var
   lBizObj,S,S2 : Variant;
   lSQL    : String;
   lCdsDataList : TClientDataSet;
   D : TDataSource;
 
 begin
   FComServer   := null;
   lCdsDataList := TClientDataSet.Create(nil);
   D := TDataSource(Self.FindComponent('dsDocDetail'));
   try
     lSQL                 := 'Code='+ QuotedStr(D.DataSet.FindField('ItemCode').AsString);
     lBizObj              := ComServer.BizObjects.Find('ST_ITEM');
 
     lCdsDataList.XMLData := lBizObj.Select('UDF_GSM, UDF_Width, UDF_Length, UDF_PKT, UDF_Weight_KG, UDF_Weight_MT',lSQL,'','SX',',','');
     if SameText(EditingField, 'ItemCode') or
     SameText(EditingField, 'Qty') then begin
        D.DataSet.edit;
        D.DataSet.FindField('UDF_GSM').Value := lCdsDataList.FindField('UDF_GSM').Value;
        D.DataSet.FindField('UDF_Width').Value := lCdsDataList.FindField('UDF_Width').Value;
        D.DataSet.FindField('UDF_Length').Value := lCdsDataList.FindField('UDF_Length').Value;
        D.DataSet.FindField('UDF_PKT').Value := lCdsDataList.FindField('UDF_PKT').Value;
        D.DataSet.FindField('UDF_Weight_KG').Value := lCdsDataList.FindField('UDF_Weight_KG').Value;
        D.DataSet.FindField('UDF_Weight_MT').Value := lCdsDataList.FindField('UDF_Weight_MT').Value;  
        D.DataSet.FindField('UDF_TotWeight_KG').value := D.DataSet.FindField('UDF_Weight_KG').AsFloat*
                                                         D.DataSet.FindField('Qty').Value;
        D.DataSet.FindField('UDF_TotWeight_MT').value := D.DataSet.FindField('UDF_Weight_MT').AsFloat*
                                                         D.DataSet.FindField('Qty').Value; 
     end;
 
   finally
     lBizObj    := null;
     FComServer := null;
     lCdsDataList.Free;
   end;
 end.


See also