mirror of
https://github.com/ManfredAabye/opensimcurrencyserver-dotnet-tests.git
synced 2026-07-27 22:15:52 +00:00
Document OpenERP plugin development for MoneyServer
Added detailed documentation for developing an OpenERP plugin for C# MoneyServer, including architecture overview, core functions, API integration, and installation steps.
This commit is contained in:
+214
@@ -0,0 +1,214 @@
|
||||
# Ein OpenERP Plugin für den C# MoneyServer entwickeln
|
||||
|
||||
## Architektur-Übersicht
|
||||
|
||||
### 1. Plugin-Struktur
|
||||
```python
|
||||
opensim_currency/
|
||||
├── __init__.py
|
||||
├── __manifest__.py
|
||||
├── models/
|
||||
│ ├── __init__.py
|
||||
│ ├── currency_server.py
|
||||
│ ├── transactions.py
|
||||
│ └── accounts.py
|
||||
├── controllers/
|
||||
│ ├── __init__.py
|
||||
│ └── main.py
|
||||
├── views/
|
||||
│ ├── currency_views.xml
|
||||
│ ├── transaction_views.xml
|
||||
│ └── dashboard.xml
|
||||
└── static/
|
||||
└── src/
|
||||
└── js/
|
||||
└── dashboard.js
|
||||
```
|
||||
|
||||
## Kernfunktionen
|
||||
|
||||
### 1. Kontenverwaltung
|
||||
```python
|
||||
# models/accounts.py
|
||||
class OpenSimAccount(models.Model):
|
||||
_name = 'opensim.currency.account'
|
||||
|
||||
name = fields.Char('Account Name', required=True)
|
||||
account_id = fields.Char('UUID', required=True)
|
||||
balance = fields.Float('Current Balance')
|
||||
currency_type = fields.Selection([
|
||||
('opensim', 'OpenSim Currency'),
|
||||
('virtual', 'Virtual Currency'),
|
||||
('fiat', 'Fiat Currency')
|
||||
])
|
||||
partner_id = fields.Many2one('res.partner', 'Owner')
|
||||
is_active = fields.Boolean('Active', default=True)
|
||||
```
|
||||
|
||||
### 2. Transaktionsmanagement
|
||||
```python
|
||||
# models/transactions.py
|
||||
class OpenSimTransaction(models.Model):
|
||||
_name = 'opensim.currency.transaction'
|
||||
|
||||
transaction_id = fields.Char('Transaction UUID')
|
||||
from_account = fields.Many2one('opensim.currency.account', 'From Account')
|
||||
to_account = fields.Many2one('opensim.currency.account', 'To Account')
|
||||
amount = fields.Float('Amount')
|
||||
transaction_type = fields.Selection([
|
||||
('transfer', 'Transfer'),
|
||||
('payment', 'Payment'),
|
||||
('exchange', 'Exchange'),
|
||||
('fee', 'Fee')
|
||||
])
|
||||
status = fields.Selection([
|
||||
('pending', 'Pending'),
|
||||
('completed', 'Completed'),
|
||||
('failed', 'Failed')
|
||||
])
|
||||
```
|
||||
|
||||
### 3. Server-Konfiguration
|
||||
```python
|
||||
# models/currency_server.py
|
||||
class CurrencyServerConfig(models.Model):
|
||||
_name = 'opensim.currency.server'
|
||||
|
||||
name = fields.Char('Server Name', required=True)
|
||||
base_url = fields.Char('Server URL', required=True)
|
||||
api_key = fields.Char('API Key')
|
||||
is_active = fields.Boolean('Active')
|
||||
currency_code = fields.Char('Currency Code', default='OSC')
|
||||
exchange_rate = fields.Float('Exchange Rate')
|
||||
```
|
||||
|
||||
## API-Integration
|
||||
|
||||
### 1. C# MoneyServer Client
|
||||
```python
|
||||
# models/currency_server.py
|
||||
class OpenSimCurrencyAPI:
|
||||
def __init__(self, config):
|
||||
self.base_url = config.base_url
|
||||
self.api_key = config.api_key
|
||||
|
||||
def create_account(self, account_data):
|
||||
"""Erstellt neues Konto im MoneyServer"""
|
||||
endpoint = f"{self.base_url}/api/account/create"
|
||||
# API Call Implementierung
|
||||
|
||||
def transfer_funds(self, from_uuid, to_uuid, amount):
|
||||
"""Führt Überweisung durch"""
|
||||
endpoint = f"{self.base_url}/api/transaction/transfer"
|
||||
# API Call Implementierung
|
||||
|
||||
def get_balance(self, account_uuid):
|
||||
"""Abfrage Kontostand"""
|
||||
endpoint = f"{self.base_url}/api/account/{account_uuid}/balance"
|
||||
|
||||
def get_transaction_history(self, account_uuid, limit=100):
|
||||
"""Transaktionshistorie abrufen"""
|
||||
```
|
||||
|
||||
## Erweiterte Finanzfunktionen
|
||||
|
||||
### 1. Multi-Währungsunterstützung
|
||||
```python
|
||||
class CurrencyExchange(models.Model):
|
||||
_name = 'opensim.currency.exchange'
|
||||
|
||||
from_currency = fields.Many2one('res.currency', 'From Currency')
|
||||
to_currency = fields.Many2one('res.currency', 'To Currency')
|
||||
exchange_rate = fields.Float('Exchange Rate')
|
||||
fee_percentage = fields.Float('Exchange Fee %')
|
||||
```
|
||||
|
||||
### 2. Rechnungsstellung
|
||||
```python
|
||||
class OpenSimInvoice(models.Model):
|
||||
_name = 'opensim.currency.invoice'
|
||||
|
||||
invoice_number = fields.Char('Invoice Number')
|
||||
amount = fields.Float('Amount')
|
||||
currency = fields.Many2one('res.currency', 'Currency')
|
||||
due_date = fields.Date('Due Date')
|
||||
status = fields.Selection([
|
||||
('draft', 'Draft'),
|
||||
('sent', 'Sent'),
|
||||
('paid', 'Paid')
|
||||
])
|
||||
```
|
||||
|
||||
### 3. Berichte und Analytics
|
||||
```python
|
||||
class CurrencyAnalytics(models.Model):
|
||||
_name = 'opensim.currency.analytics'
|
||||
|
||||
@api.model
|
||||
def get_daily_transactions(self):
|
||||
"""Tägliche Transaktionsstatistiken"""
|
||||
return {
|
||||
'total_volume': self._calculate_daily_volume(),
|
||||
'transaction_count': self._count_daily_transactions(),
|
||||
'average_transaction': self._calculate_average_transaction()
|
||||
}
|
||||
```
|
||||
|
||||
## Manifest-Datei
|
||||
```python
|
||||
# __manifest__.py
|
||||
{
|
||||
'name': 'OpenSim Currency Server Integration',
|
||||
'version': '1.0',
|
||||
'category': 'Accounting',
|
||||
'summary': 'Integration mit C# MoneyServer für virtuelle Währungen',
|
||||
'depends': ['base', 'account'],
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'views/currency_views.xml',
|
||||
'views/transaction_views.xml',
|
||||
'views/dashboard.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'application': True,
|
||||
}
|
||||
```
|
||||
|
||||
## Sicherheitsfeatures
|
||||
|
||||
### 1. Zugriffskontrolle
|
||||
```python
|
||||
# security/ir.model.access.csv
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_opensim_currency_user,opensim.currency.user,model_opensim_currency_account,account.group_account_user,1,1,1,0
|
||||
access_opensim_currency_manager,opensim.currency.manager,model_opensim_currency_account,account.group_account_manager,1,1,1,1
|
||||
```
|
||||
|
||||
### 2. Transaktionssicherheit
|
||||
```python
|
||||
class OpenSimTransaction(models.Model):
|
||||
# ... existing fields ...
|
||||
|
||||
def _validate_transaction(self):
|
||||
"""Validiert Transaktion vor Ausführung"""
|
||||
if self.amount <= 0:
|
||||
raise ValidationError(_("Amount must be positive"))
|
||||
|
||||
if self.from_account.balance < self.amount:
|
||||
raise ValidationError(_("Insufficient funds"))
|
||||
```
|
||||
|
||||
## Installation und Konfiguration
|
||||
|
||||
1. **Plugin installieren** in OpenERP
|
||||
2. **Server konfigurieren** mit C# MoneyServer URL und API Key
|
||||
3. **Währungen einrichten** und Exchange Rates definieren
|
||||
4. **Benutzerkonten synchronisieren** mit MoneyServer
|
||||
|
||||
## Vorteile dieser Integration
|
||||
|
||||
- **Echtzeit-Synchronisation** zwischen OpenERP und MoneyServer
|
||||
- **Umfassende Berichterstattung** für virtuelle Währungen
|
||||
- **Multi-Währungsunterstützung**
|
||||
- **Automatisierte Transaktionsverarbeitung**
|
||||
- **Sicherheits- und Validierungsmechanismen**
|
||||
Reference in New Issue
Block a user