關閉Ubuntu Desktop GUI

To disiable GUI

sudo systemctl set-default multi-user.target

To enable GUI again issue the command:

sudo systemctl set-default graphical.target

To start Gnome session on a system without a current GUI just execute:

sudo systemctl start gdm3.service

Leave a comment

iDempiere ERP – Drop Shipment 三角交易總整理

三角交易情境說明

你有一家商店(簡稱 Y)接收訂單, 有一個客戶(簡稱C)向你下單. 你接到單後,委託供應商 (簡稱S)出貨. 單據關係如下:
C: Purchase Order —– Y:Sales Order
Y: Purchase Order —– S:Sales Order
S: Shipment —— Y: Receipt
S: AR Invoice ——– Y: AP Invoice
Y:Shipment ——- C: Receipt
Y:AR Invoice ——— C: AP Invoice

立帳模式有兩種:佣金法及銷貨法


使用時機,若産品的品質及權責在供應商時,使用佣金法立帳.責任在自己企業時,則用銷貨法立帳.
佣金法比較適合應用在沒有自己品牌的經銷商.像經銷 Apple iPhone, Sony LED TV, Dell 電腦等等. 原廠有自己的産品責任.

iDempiere 預設為佣金法.若要採用銷售法,需要調整.

1.若供應商非關係企業(非ERP內的Org)時
1.1可以利用 Web Service 接收供應商送來的出貨單資訊後,自動産生收料單及AP Invoice.再産生出貨單及AR Invoice.
1.2 若供應商ERP系統無法串接時.可以手動産生收料單後抛 AP Invoice ,再用Sales Order 抛轉 Shipment 及 AR Invoice.

2. 若供應商為關係企業時 
2.1 可以直接利用 Workflow自動産收料單.再由收料單自動抛轉AP Invoice ,再由Sales Order 抛轉 Shipment, AR Invoice. 完成進貨及銷貨單據.
2.2 可以利用Model CompleteIt Mehtod 進行自動産生相關單據.

抛轉使用欄位參考
Document Counter 産生的單據會利用 Ref_主鍵名稱來紀錄相關的單據ID.

AR Invocie Fact (System Default Account)

Shipment Fact (System Default Account)

Leave a comment

Workflow 人機簽核分流

Short Code:[SYSTEM]

Workflow 除了員工進行審核,確認. 許多結點(Node)也會配合自動化設備自動執待.等待系統完成工作後.自動推動Workflow.為了避免人員誤觸系統確認結點. 在結點名字定義一組 Short Code [SYSTEM], 人員簽核畫面會自動過濾, 避免誤觸.

	private String getWhereActivities() {
		final String where =
			"a.Processed='N' AND a.WFState='OS' "
			+ " AND (EXISTS (select * from AD_WF_Node wfn where "
					+ " a.AD_WF_Node_ID = wfn.AD_WF_Node_ID "
					+ " and  not ( substring(wfn.name,1,8) = '[SYSTEM]' and wfn.action = 'Z' ) ) )"
			
			+ " AND ("
			//	Owner of Activity
			+ " a.AD_User_ID=?"	//	#1
			//	Invoker (if no invoker = all)
			+ " OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID"
			+ " AND r.ResponsibleType='H' AND COALESCE(r.AD_User_ID,0)=0 AND COALESCE(r.AD_Role_ID,0)=0 AND (a.AD_User_ID=? OR a.AD_User_ID IS NULL))"	//	#2
			//  Responsible User
			+ " OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID"
			+ " AND r.ResponsibleType='H' AND r.AD_User_ID=?)"		//	#3
			//	Responsible Role
			+ " OR EXISTS (SELECT * FROM AD_WF_Responsible r INNER JOIN AD_User_Roles ur ON (r.AD_Role_ID=ur.AD_Role_ID)"
			+ " WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID AND r.ResponsibleType='R' AND ur.AD_User_ID=? AND ur.isActive = 'Y')"	//	#4
			///* Manual Responsible */ 
			+ " OR EXISTS (SELECT * FROM AD_WF_ActivityApprover r "
			+ " WHERE a.AD_WF_Activity_ID=r.AD_WF_Activity_ID AND r.AD_User_ID=? AND r.isActive = 'Y')" 
			+ ") AND a.AD_Client_ID=?";	//	#5
		return where;
	}
Leave a comment

MySQL Quickly set up in 4 step

Create Database

CREATE DATABASE mydatabase CHARACTER SET utf8 COLLATE utf8_general_ci;

Create New User

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';

Set Permission

GRANT ALL PRIVILEGES ON mydatabase. * TO 'newuser'@'localhost';

Refresh Privileges

FLUSH PRIVILEGES;
Leave a comment

獨立SMTP寄信伺服器 + Auto Ban

自架伺服器,一定會遇到擾人的問題。有人不斷來試你的寄信主機,然後試出密碼後,借用你的寄信伺服器大量寄發垃圾郵件。
解決方案:利用 Mail Log 搭配 iptables 防火牆管理惡意入侵IP。

可以自行開發或使用流通的解決方案。

自行開發:

檢查 /var/log/mail.log 登入失敗過多的IP,寫入IPTABLE DROP

使用社群套件:
https://help.ubuntu.com/community/Postfix

https://help.ubuntu.com/community/Fail2ban

Leave a comment