From 455d43e708e69fde7f3fae6747cf392f5ad000ee Mon Sep 17 00:00:00 2001 From: Tim Richardson Date: Sun, 1 Oct 2023 07:29:01 +1100 Subject: [PATCH] Pr purch endpoints (#88) * Merged changed for new credit endpoints * added handling for endpoints SupplierPayment, DebitSettlement, DebitRefund --- myob/endpoints.py | 56 +++++- tests/test_endpoints.py | 392 ++++++++++++++++++++++++++++++---------- 2 files changed, 343 insertions(+), 105 deletions(-) diff --git a/myob/endpoints.py b/myob/endpoints.py index 8d14a36..5da45f2 100755 --- a/myob/endpoints.py +++ b/myob/endpoints.py @@ -37,6 +37,24 @@ (DELETE, '', 'sale customer payment'), ] }, + 'Sale/CreditRefund/': { + 'name': 'credit_refunds', + 'methods': [ + (ALL, '', 'sale credit refund'), + (GET, '', 'sale credit refund'), + (POST, '', 'sale credit refund'), + (DELETE, '', 'sale credit refund'), + ] + }, + 'Sale/CreditSettlement/': { + 'name': 'credit_settlements', + 'methods': [ + (ALL, '', 'sale credit settlement'), + (GET, '', 'sale credit settlement'), + (POST, '', 'sale credit settlement'), + (DELETE, '', 'sale credit settlement'), + ] + }, 'Sale/Invoice/': { 'name': 'invoices', 'methods': [ @@ -45,6 +63,7 @@ (CRUD, 'Service/', 'service type sale invoice'), ] }, + 'Sale/Order/': { 'name': 'orders', 'methods': [ @@ -86,6 +105,33 @@ (CRUD, 'Adjustment/', 'inventory adjustment') ] }, + 'Purchase/Bill/': { + 'name': 'purchase_bills', + 'methods': [ + (ALL, '', 'purchase bill type'), + (CRUD, 'Item/', 'item type purchase bill'), + (CRUD, 'Service/', 'service type purchase bill'), + (CRUD, 'Miscellaneous/', 'miscellaneous type purchase bill'), + ] + }, + 'Purchase/DebitRefund/': { + 'name': 'debit_refunds', + 'methods': [ + (ALL, '', 'purchase debit refund'), + (GET, '', 'purchase debit refund'), + (POST, '', 'purchase debit refund'), + (DELETE, '', 'purchase debit refund'), + ] + }, + 'Purchase/DebitSettlement/': { + 'name': 'debit_settlements', + 'methods': [ + (ALL, '', 'purchase debit settlement'), + (GET, '', 'purchase debit settlement'), + (POST, '', 'purchase debit settlement'), + (DELETE, '', 'purchase debit settlement'), + ] + }, 'Purchase/Order/': { 'name': 'purchase_orders', 'methods': [ @@ -93,15 +139,13 @@ (CRUD, 'Item/', 'item type purchase order'), ] }, - 'Purchase/Bill/': { - 'name': 'purchase_bills', + 'Purchase/SupplierPayment/': { + 'name': 'supplier_payments', 'methods': [ - (ALL, '', 'purchase bill type'), - (CRUD, 'Item/', 'item type purchase bill'), - (CRUD, 'Service/', 'service type purchase bill'), - (CRUD, 'Miscellaneous/', 'miscellaneous type purchase bill'), + (CRUD, '', 'purchase supplier payment'), ] }, + 'Company/': { 'name': 'company', 'methods': [ diff --git a/tests/test_endpoints.py b/tests/test_endpoints.py index a298c38..ead1360 100644 --- a/tests/test_endpoints.py +++ b/tests/test_endpoints.py @@ -129,14 +129,19 @@ def test_companyfile(self): " banking\n" " company\n" " contacts\n" + " credit_refunds\n" + " credit_settlements\n" " customer_payments\n" + " debit_refunds\n" + " debit_settlements\n" " general_ledger\n" " inventory\n" " invoices\n" " orders\n" " purchase_bills\n" " purchase_orders\n" - " quotes" + " quotes\n" + " supplier_payments" )) def test_banking(self): @@ -161,20 +166,34 @@ def test_banking(self): )) self.assertEndpointReached(self.companyfile.banking.all, {}, 'GET', f'/{CID}/Banking/') self.assertEndpointReached(self.companyfile.banking.spendmoneytxn, {}, 'GET', f'/{CID}/Banking/SpendMoneyTxn/') - self.assertEndpointReached(self.companyfile.banking.get_spendmoneytxn, {'uid': UID}, 'GET', f'/{CID}/Banking/SpendMoneyTxn/{UID}/') - self.assertEndpointReached(self.companyfile.banking.put_spendmoneytxn, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Banking/SpendMoneyTxn/{UID}/') - self.assertEndpointReached(self.companyfile.banking.post_spendmoneytxn, {'data': DATA}, 'POST', f'/{CID}/Banking/SpendMoneyTxn/') - self.assertEndpointReached(self.companyfile.banking.delete_spendmoneytxn, {'uid': UID}, 'DELETE', f'/{CID}/Banking/SpendMoneyTxn/{UID}/') - self.assertEndpointReached(self.companyfile.banking.receivemoneytxn, {}, 'GET', f'/{CID}/Banking/ReceiveMoneyTxn/') - self.assertEndpointReached(self.companyfile.banking.get_receivemoneytxn, {'uid': UID}, 'GET', f'/{CID}/Banking/ReceiveMoneyTxn/{UID}/') - self.assertEndpointReached(self.companyfile.banking.put_receivemoneytxn, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Banking/ReceiveMoneyTxn/{UID}/') - self.assertEndpointReached(self.companyfile.banking.post_receivemoneytxn, {'data': DATA}, 'POST', f'/{CID}/Banking/ReceiveMoneyTxn/') - self.assertEndpointReached(self.companyfile.banking.delete_receivemoneytxn, {'uid': UID}, 'DELETE', f'/{CID}/Banking/ReceiveMoneyTxn/{UID}/') - self.assertEndpointReached(self.companyfile.banking.transfermoneytxn, {}, 'GET', f'/{CID}/Banking/TransferMoneyTxn/') - self.assertEndpointReached(self.companyfile.banking.get_transfermoneytxn, {'uid': UID}, 'GET', f'/{CID}/Banking/TransferMoneyTxn/{UID}/') - self.assertEndpointReached(self.companyfile.banking.put_transfermoneytxn, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Banking/TransferMoneyTxn/{UID}/') - self.assertEndpointReached(self.companyfile.banking.post_transfermoneytxn, {'data': DATA}, 'POST', f'/{CID}/Banking/TransferMoneyTxn/') - self.assertEndpointReached(self.companyfile.banking.delete_transfermoneytxn, {'uid': UID}, 'DELETE', f'/{CID}/Banking/TransferMoneyTxn/{UID}/') + self.assertEndpointReached(self.companyfile.banking.get_spendmoneytxn, {'uid': UID}, 'GET', + f'/{CID}/Banking/SpendMoneyTxn/{UID}/') + self.assertEndpointReached(self.companyfile.banking.put_spendmoneytxn, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Banking/SpendMoneyTxn/{UID}/') + self.assertEndpointReached(self.companyfile.banking.post_spendmoneytxn, {'data': DATA}, 'POST', + f'/{CID}/Banking/SpendMoneyTxn/') + self.assertEndpointReached(self.companyfile.banking.delete_spendmoneytxn, {'uid': UID}, 'DELETE', + f'/{CID}/Banking/SpendMoneyTxn/{UID}/') + self.assertEndpointReached(self.companyfile.banking.receivemoneytxn, {}, 'GET', + f'/{CID}/Banking/ReceiveMoneyTxn/') + self.assertEndpointReached(self.companyfile.banking.get_receivemoneytxn, {'uid': UID}, 'GET', + f'/{CID}/Banking/ReceiveMoneyTxn/{UID}/') + self.assertEndpointReached(self.companyfile.banking.put_receivemoneytxn, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Banking/ReceiveMoneyTxn/{UID}/') + self.assertEndpointReached(self.companyfile.banking.post_receivemoneytxn, {'data': DATA}, 'POST', + f'/{CID}/Banking/ReceiveMoneyTxn/') + self.assertEndpointReached(self.companyfile.banking.delete_receivemoneytxn, {'uid': UID}, 'DELETE', + f'/{CID}/Banking/ReceiveMoneyTxn/{UID}/') + self.assertEndpointReached(self.companyfile.banking.transfermoneytxn, {}, 'GET', + f'/{CID}/Banking/TransferMoneyTxn/') + self.assertEndpointReached(self.companyfile.banking.get_transfermoneytxn, {'uid': UID}, 'GET', + f'/{CID}/Banking/TransferMoneyTxn/{UID}/') + self.assertEndpointReached(self.companyfile.banking.put_transfermoneytxn, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Banking/TransferMoneyTxn/{UID}/') + self.assertEndpointReached(self.companyfile.banking.post_transfermoneytxn, {'data': DATA}, 'POST', + f'/{CID}/Banking/TransferMoneyTxn/') + self.assertEndpointReached(self.companyfile.banking.delete_transfermoneytxn, {'uid': UID}, 'DELETE', + f'/{CID}/Banking/TransferMoneyTxn/{UID}/') def test_contacts(self): self.assertEqual(repr(self.companyfile.contacts), ( @@ -198,20 +217,32 @@ def test_contacts(self): )) self.assertEndpointReached(self.companyfile.contacts.all, {}, 'GET', f'/{CID}/Contact/') self.assertEndpointReached(self.companyfile.contacts.customer, {}, 'GET', f'/{CID}/Contact/Customer/') - self.assertEndpointReached(self.companyfile.contacts.get_customer, {'uid': UID}, 'GET', f'/{CID}/Contact/Customer/{UID}/') - self.assertEndpointReached(self.companyfile.contacts.put_customer, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Contact/Customer/{UID}/') - self.assertEndpointReached(self.companyfile.contacts.post_customer, {'data': DATA}, 'POST', f'/{CID}/Contact/Customer/') - self.assertEndpointReached(self.companyfile.contacts.delete_customer, {'uid': UID}, 'DELETE', f'/{CID}/Contact/Customer/{UID}/') + self.assertEndpointReached(self.companyfile.contacts.get_customer, {'uid': UID}, 'GET', + f'/{CID}/Contact/Customer/{UID}/') + self.assertEndpointReached(self.companyfile.contacts.put_customer, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Contact/Customer/{UID}/') + self.assertEndpointReached(self.companyfile.contacts.post_customer, {'data': DATA}, 'POST', + f'/{CID}/Contact/Customer/') + self.assertEndpointReached(self.companyfile.contacts.delete_customer, {'uid': UID}, 'DELETE', + f'/{CID}/Contact/Customer/{UID}/') self.assertEndpointReached(self.companyfile.contacts.employee, {}, 'GET', f'/{CID}/Contact/Employee/') - self.assertEndpointReached(self.companyfile.contacts.get_employee, {'uid': UID}, 'GET', f'/{CID}/Contact/Employee/{UID}/') - self.assertEndpointReached(self.companyfile.contacts.put_employee, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Contact/Employee/{UID}/') - self.assertEndpointReached(self.companyfile.contacts.post_employee, {'data': DATA}, 'POST', f'/{CID}/Contact/Employee/') - self.assertEndpointReached(self.companyfile.contacts.delete_employee, {'uid': UID}, 'DELETE', f'/{CID}/Contact/Employee/{UID}/') + self.assertEndpointReached(self.companyfile.contacts.get_employee, {'uid': UID}, 'GET', + f'/{CID}/Contact/Employee/{UID}/') + self.assertEndpointReached(self.companyfile.contacts.put_employee, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Contact/Employee/{UID}/') + self.assertEndpointReached(self.companyfile.contacts.post_employee, {'data': DATA}, 'POST', + f'/{CID}/Contact/Employee/') + self.assertEndpointReached(self.companyfile.contacts.delete_employee, {'uid': UID}, 'DELETE', + f'/{CID}/Contact/Employee/{UID}/') self.assertEndpointReached(self.companyfile.contacts.supplier, {}, 'GET', f'/{CID}/Contact/Supplier/') - self.assertEndpointReached(self.companyfile.contacts.get_supplier, {'uid': UID}, 'GET', f'/{CID}/Contact/Supplier/{UID}/') - self.assertEndpointReached(self.companyfile.contacts.put_supplier, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Contact/Supplier/{UID}/') - self.assertEndpointReached(self.companyfile.contacts.post_supplier, {'data': DATA}, 'POST', f'/{CID}/Contact/Supplier/') - self.assertEndpointReached(self.companyfile.contacts.delete_supplier, {'uid': UID}, 'DELETE', f'/{CID}/Contact/Supplier/{UID}/') + self.assertEndpointReached(self.companyfile.contacts.get_supplier, {'uid': UID}, 'GET', + f'/{CID}/Contact/Supplier/{UID}/') + self.assertEndpointReached(self.companyfile.contacts.put_supplier, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Contact/Supplier/{UID}/') + self.assertEndpointReached(self.companyfile.contacts.post_supplier, {'data': DATA}, 'POST', + f'/{CID}/Contact/Supplier/') + self.assertEndpointReached(self.companyfile.contacts.delete_supplier, {'uid': UID}, 'DELETE', + f'/{CID}/Contact/Supplier/{UID}/') def test_invoices(self): self.assertEqual(repr(self.companyfile.invoices), ( @@ -230,15 +261,23 @@ def test_invoices(self): )) self.assertEndpointReached(self.companyfile.invoices.all, {}, 'GET', f'/{CID}/Sale/Invoice/') self.assertEndpointReached(self.companyfile.invoices.item, {}, 'GET', f'/{CID}/Sale/Invoice/Item/') - self.assertEndpointReached(self.companyfile.invoices.get_item, {'uid': UID}, 'GET', f'/{CID}/Sale/Invoice/Item/{UID}/') - self.assertEndpointReached(self.companyfile.invoices.put_item, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Sale/Invoice/Item/{UID}/') - self.assertEndpointReached(self.companyfile.invoices.post_item, {'data': DATA}, 'POST', f'/{CID}/Sale/Invoice/Item/') - self.assertEndpointReached(self.companyfile.invoices.delete_item, {'uid': UID}, 'DELETE', f'/{CID}/Sale/Invoice/Item/{UID}/') + self.assertEndpointReached(self.companyfile.invoices.get_item, {'uid': UID}, 'GET', + f'/{CID}/Sale/Invoice/Item/{UID}/') + self.assertEndpointReached(self.companyfile.invoices.put_item, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Sale/Invoice/Item/{UID}/') + self.assertEndpointReached(self.companyfile.invoices.post_item, {'data': DATA}, 'POST', + f'/{CID}/Sale/Invoice/Item/') + self.assertEndpointReached(self.companyfile.invoices.delete_item, {'uid': UID}, 'DELETE', + f'/{CID}/Sale/Invoice/Item/{UID}/') self.assertEndpointReached(self.companyfile.invoices.service, {}, 'GET', f'/{CID}/Sale/Invoice/Service/') - self.assertEndpointReached(self.companyfile.invoices.get_service, {'uid': UID}, 'GET', f'/{CID}/Sale/Invoice/Service/{UID}/') - self.assertEndpointReached(self.companyfile.invoices.put_service, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Sale/Invoice/Service/{UID}/') - self.assertEndpointReached(self.companyfile.invoices.post_service, {'data': DATA}, 'POST', f'/{CID}/Sale/Invoice/Service/') - self.assertEndpointReached(self.companyfile.invoices.delete_service, {'uid': UID}, 'DELETE', f'/{CID}/Sale/Invoice/Service/{UID}/') + self.assertEndpointReached(self.companyfile.invoices.get_service, {'uid': UID}, 'GET', + f'/{CID}/Sale/Invoice/Service/{UID}/') + self.assertEndpointReached(self.companyfile.invoices.put_service, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Sale/Invoice/Service/{UID}/') + self.assertEndpointReached(self.companyfile.invoices.post_service, {'data': DATA}, 'POST', + f'/{CID}/Sale/Invoice/Service/') + self.assertEndpointReached(self.companyfile.invoices.delete_service, {'uid': UID}, 'DELETE', + f'/{CID}/Sale/Invoice/Service/{UID}/') def test_customer_payments(self): self.assertEqual(repr(self.companyfile.customer_payments), ( @@ -249,6 +288,44 @@ def test_customer_payments(self): " post(data) - Create new sale customer payment." )) self.assertEndpointReached(self.companyfile.customer_payments.all, {}, 'GET', f'/{CID}/Sale/CustomerPayment/') + self.assertEndpointReached(self.companyfile.customer_payments.get, {'uid': UID}, 'GET', + f'/{CID}/Sale/CustomerPayment/{UID}/') + self.assertEndpointReached(self.companyfile.customer_payments.delete, {'uid': UID}, 'DELETE', + f'/{CID}/Sale/CustomerPayment/{UID}/') + self.assertEndpointReached(self.companyfile.customer_payments.post, {'data': DATA}, 'POST', + f'/{CID}/Sale/CustomerPayment/') + + def test_credit_refunds(self): + self.assertEqual(repr(self.companyfile.credit_refunds), ( + "Sale_CreditRefundManager:\n" + " all() - Return all sale credit refunds for an AccountRight company file.\n" + " delete(uid) - Delete selected sale credit refund.\n" + " get(uid) - Return selected sale credit refund.\n" + " post(data) - Create new sale credit refund." + )) + self.assertEndpointReached(self.companyfile.credit_refunds.all, {}, 'GET', f'/{CID}/Sale/CreditRefund/') + self.assertEndpointReached(self.companyfile.credit_refunds.get, {'uid': UID}, 'GET', + f'/{CID}/Sale/CreditRefund/{UID}/') + self.assertEndpointReached(self.companyfile.credit_refunds.delete, {'uid': UID}, 'DELETE', + f'/{CID}/Sale/CreditRefund/{UID}/') + self.assertEndpointReached(self.companyfile.credit_refunds.post, {'data': DATA}, 'POST', + f'/{CID}/Sale/CreditRefund/') + + def test_credit_settlements(self): + self.assertEqual(repr(self.companyfile.credit_settlements), ( + "Sale_CreditSettlementManager:\n" + " all() - Return all sale credit settlements for an AccountRight company file.\n" + " delete(uid) - Delete selected sale credit settlement.\n" + " get(uid) - Return selected sale credit settlement.\n" + " post(data) - Create new sale credit settlement." + )) + self.assertEndpointReached(self.companyfile.credit_settlements.all, {}, 'GET', f'/{CID}/Sale/CreditSettlement/') + self.assertEndpointReached(self.companyfile.credit_settlements.get, {'uid': UID}, 'GET', + f'/{CID}/Sale/CreditSettlement/{UID}/') + self.assertEndpointReached(self.companyfile.credit_settlements.delete, {'uid': UID}, 'DELETE', + f'/{CID}/Sale/CreditSettlement/{UID}/') + self.assertEndpointReached(self.companyfile.credit_settlements.post, {'data': DATA}, 'POST', + f'/{CID}/Sale/CreditSettlement/') def test_quotes(self): self.assertEqual(repr(self.companyfile.quotes), ( @@ -267,15 +344,23 @@ def test_quotes(self): )) self.assertEndpointReached(self.companyfile.quotes.all, {}, 'GET', f'/{CID}/Sale/Quote/') self.assertEndpointReached(self.companyfile.quotes.item, {}, 'GET', f'/{CID}/Sale/Quote/Item/') - self.assertEndpointReached(self.companyfile.quotes.get_item, {'uid': UID}, 'GET', f'/{CID}/Sale/Quote/Item/{UID}/') - self.assertEndpointReached(self.companyfile.quotes.put_item, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Sale/Quote/Item/{UID}/') - self.assertEndpointReached(self.companyfile.quotes.post_item, {'data': DATA}, 'POST', f'/{CID}/Sale/Quote/Item/') - self.assertEndpointReached(self.companyfile.quotes.delete_item, {'uid': UID}, 'DELETE', f'/{CID}/Sale/Quote/Item/{UID}/') + self.assertEndpointReached(self.companyfile.quotes.get_item, {'uid': UID}, 'GET', + f'/{CID}/Sale/Quote/Item/{UID}/') + self.assertEndpointReached(self.companyfile.quotes.put_item, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Sale/Quote/Item/{UID}/') + self.assertEndpointReached(self.companyfile.quotes.post_item, {'data': DATA}, 'POST', + f'/{CID}/Sale/Quote/Item/') + self.assertEndpointReached(self.companyfile.quotes.delete_item, {'uid': UID}, 'DELETE', + f'/{CID}/Sale/Quote/Item/{UID}/') self.assertEndpointReached(self.companyfile.quotes.service, {}, 'GET', f'/{CID}/Sale/Quote/Service/') - self.assertEndpointReached(self.companyfile.quotes.get_service, {'uid': UID}, 'GET', f'/{CID}/Sale/Quote/Service/{UID}/') - self.assertEndpointReached(self.companyfile.quotes.put_service, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Sale/Quote/Service/{UID}/') - self.assertEndpointReached(self.companyfile.quotes.post_service, {'data': DATA}, 'POST', f'/{CID}/Sale/Quote/Service/') - self.assertEndpointReached(self.companyfile.quotes.delete_service, {'uid': UID}, 'DELETE', f'/{CID}/Sale/Quote/Service/{UID}/') + self.assertEndpointReached(self.companyfile.quotes.get_service, {'uid': UID}, 'GET', + f'/{CID}/Sale/Quote/Service/{UID}/') + self.assertEndpointReached(self.companyfile.quotes.put_service, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Sale/Quote/Service/{UID}/') + self.assertEndpointReached(self.companyfile.quotes.post_service, {'data': DATA}, 'POST', + f'/{CID}/Sale/Quote/Service/') + self.assertEndpointReached(self.companyfile.quotes.delete_service, {'uid': UID}, 'DELETE', + f'/{CID}/Sale/Quote/Service/{UID}/') def test_orders(self): self.assertEqual(repr(self.companyfile.orders), ( @@ -294,15 +379,23 @@ def test_orders(self): )) self.assertEndpointReached(self.companyfile.invoices.all, {}, 'GET', f'/{CID}/Sale/Invoice/') self.assertEndpointReached(self.companyfile.invoices.item, {}, 'GET', f'/{CID}/Sale/Invoice/Item/') - self.assertEndpointReached(self.companyfile.invoices.get_item, {'uid': UID}, 'GET', f'/{CID}/Sale/Invoice/Item/{UID}/') - self.assertEndpointReached(self.companyfile.invoices.put_item, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Sale/Invoice/Item/{UID}/') - self.assertEndpointReached(self.companyfile.invoices.post_item, {'data': DATA}, 'POST', f'/{CID}/Sale/Invoice/Item/') - self.assertEndpointReached(self.companyfile.invoices.delete_item, {'uid': UID}, 'DELETE', f'/{CID}/Sale/Invoice/Item/{UID}/') + self.assertEndpointReached(self.companyfile.invoices.get_item, {'uid': UID}, 'GET', + f'/{CID}/Sale/Invoice/Item/{UID}/') + self.assertEndpointReached(self.companyfile.invoices.put_item, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Sale/Invoice/Item/{UID}/') + self.assertEndpointReached(self.companyfile.invoices.post_item, {'data': DATA}, 'POST', + f'/{CID}/Sale/Invoice/Item/') + self.assertEndpointReached(self.companyfile.invoices.delete_item, {'uid': UID}, 'DELETE', + f'/{CID}/Sale/Invoice/Item/{UID}/') self.assertEndpointReached(self.companyfile.invoices.service, {}, 'GET', f'/{CID}/Sale/Invoice/Service/') - self.assertEndpointReached(self.companyfile.invoices.get_service, {'uid': UID}, 'GET', f'/{CID}/Sale/Invoice/Service/{UID}/') - self.assertEndpointReached(self.companyfile.invoices.put_service, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Sale/Invoice/Service/{UID}/') - self.assertEndpointReached(self.companyfile.invoices.post_service, {'data': DATA}, 'POST', f'/{CID}/Sale/Invoice/Service/') - self.assertEndpointReached(self.companyfile.invoices.delete_service, {'uid': UID}, 'DELETE', f'/{CID}/Sale/Invoice/Service/{UID}/') + self.assertEndpointReached(self.companyfile.invoices.get_service, {'uid': UID}, 'GET', + f'/{CID}/Sale/Invoice/Service/{UID}/') + self.assertEndpointReached(self.companyfile.invoices.put_service, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Sale/Invoice/Service/{UID}/') + self.assertEndpointReached(self.companyfile.invoices.post_service, {'data': DATA}, 'POST', + f'/{CID}/Sale/Invoice/Service/') + self.assertEndpointReached(self.companyfile.invoices.delete_service, {'uid': UID}, 'DELETE', + f'/{CID}/Sale/Invoice/Service/{UID}/') def test_general_ledger(self): self.assertEqual(repr(self.companyfile.general_ledger), ( @@ -338,23 +431,39 @@ def test_general_ledger(self): " taxcode() - Return all tax codes for an AccountRight company file." )) self.assertEndpointReached(self.companyfile.general_ledger.taxcode, {}, 'GET', f'/{CID}/GeneralLedger/TaxCode/') - self.assertEndpointReached(self.companyfile.general_ledger.get_taxcode, {'uid': UID}, 'GET', f'/{CID}/GeneralLedger/TaxCode/{UID}/') - self.assertEndpointReached(self.companyfile.general_ledger.put_taxcode, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/GeneralLedger/TaxCode/{UID}/') - self.assertEndpointReached(self.companyfile.general_ledger.post_taxcode, {'data': DATA}, 'POST', f'/{CID}/GeneralLedger/TaxCode/') - self.assertEndpointReached(self.companyfile.general_ledger.delete_taxcode, {'uid': UID}, 'DELETE', f'/{CID}/GeneralLedger/TaxCode/{UID}/') + self.assertEndpointReached(self.companyfile.general_ledger.get_taxcode, {'uid': UID}, 'GET', + f'/{CID}/GeneralLedger/TaxCode/{UID}/') + self.assertEndpointReached(self.companyfile.general_ledger.put_taxcode, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/GeneralLedger/TaxCode/{UID}/') + self.assertEndpointReached(self.companyfile.general_ledger.post_taxcode, {'data': DATA}, 'POST', + f'/{CID}/GeneralLedger/TaxCode/') + self.assertEndpointReached(self.companyfile.general_ledger.delete_taxcode, {'uid': UID}, 'DELETE', + f'/{CID}/GeneralLedger/TaxCode/{UID}/') self.assertEndpointReached(self.companyfile.general_ledger.account, {}, 'GET', f'/{CID}/GeneralLedger/Account/') - self.assertEndpointReached(self.companyfile.general_ledger.get_account, {'uid': UID}, 'GET', f'/{CID}/GeneralLedger/Account/{UID}/') - self.assertEndpointReached(self.companyfile.general_ledger.put_account, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/GeneralLedger/Account/{UID}/') - self.assertEndpointReached(self.companyfile.general_ledger.post_account, {'data': DATA}, 'POST', f'/{CID}/GeneralLedger/Account/') - self.assertEndpointReached(self.companyfile.general_ledger.delete_account, {'uid': UID}, 'DELETE', f'/{CID}/GeneralLedger/Account/{UID}/') - self.assertEndpointReached(self.companyfile.general_ledger.category, {}, 'GET', f'/{CID}/GeneralLedger/Category/') - self.assertEndpointReached(self.companyfile.general_ledger.get_category, {'uid': UID}, 'GET', f'/{CID}/GeneralLedger/Category/{UID}/') - self.assertEndpointReached(self.companyfile.general_ledger.put_category, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/GeneralLedger/Category/{UID}/') - self.assertEndpointReached(self.companyfile.general_ledger.post_category, {'data': DATA}, 'POST', f'/{CID}/GeneralLedger/Category/') - self.assertEndpointReached(self.companyfile.general_ledger.delete_category, {'uid': UID}, 'DELETE', f'/{CID}/GeneralLedger/Category/{UID}/') - self.assertEndpointReached(self.companyfile.general_ledger.journaltransaction, {}, 'GET', f'/{CID}/GeneralLedger/JournalTransaction/') - self.assertEndpointReached(self.companyfile.general_ledger.accountregister, {}, 'GET', f'/{CID}/GeneralLedger/AccountRegister/') - self.assertEndpointReached(self.companyfile.general_ledger.accountingproperties, {}, 'GET', f'/{CID}/GeneralLedger/AccountingProperties/') + self.assertEndpointReached(self.companyfile.general_ledger.get_account, {'uid': UID}, 'GET', + f'/{CID}/GeneralLedger/Account/{UID}/') + self.assertEndpointReached(self.companyfile.general_ledger.put_account, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/GeneralLedger/Account/{UID}/') + self.assertEndpointReached(self.companyfile.general_ledger.post_account, {'data': DATA}, 'POST', + f'/{CID}/GeneralLedger/Account/') + self.assertEndpointReached(self.companyfile.general_ledger.delete_account, {'uid': UID}, 'DELETE', + f'/{CID}/GeneralLedger/Account/{UID}/') + self.assertEndpointReached(self.companyfile.general_ledger.category, {}, 'GET', + f'/{CID}/GeneralLedger/Category/') + self.assertEndpointReached(self.companyfile.general_ledger.get_category, {'uid': UID}, 'GET', + f'/{CID}/GeneralLedger/Category/{UID}/') + self.assertEndpointReached(self.companyfile.general_ledger.put_category, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/GeneralLedger/Category/{UID}/') + self.assertEndpointReached(self.companyfile.general_ledger.post_category, {'data': DATA}, 'POST', + f'/{CID}/GeneralLedger/Category/') + self.assertEndpointReached(self.companyfile.general_ledger.delete_category, {'uid': UID}, 'DELETE', + f'/{CID}/GeneralLedger/Category/{UID}/') + self.assertEndpointReached(self.companyfile.general_ledger.journaltransaction, {}, 'GET', + f'/{CID}/GeneralLedger/JournalTransaction/') + self.assertEndpointReached(self.companyfile.general_ledger.accountregister, {}, 'GET', + f'/{CID}/GeneralLedger/AccountRegister/') + self.assertEndpointReached(self.companyfile.general_ledger.accountingproperties, {}, 'GET', + f'/{CID}/GeneralLedger/AccountingProperties/') def test_inventory(self): self.assertEqual(repr(self.companyfile.inventory), ( @@ -379,23 +488,38 @@ def test_inventory(self): " put_location(uid, data) - Update selected inventory location." )) self.assertEndpointReached(self.companyfile.inventory.item, {}, 'GET', f'/{CID}/Inventory/Item/') - self.assertEndpointReached(self.companyfile.inventory.get_item, {'uid': UID}, 'GET', f'/{CID}/Inventory/Item/{UID}/') - self.assertEndpointReached(self.companyfile.inventory.put_item, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Inventory/Item/{UID}/') - self.assertEndpointReached(self.companyfile.inventory.post_item, {'data': DATA}, 'POST', f'/{CID}/Inventory/Item/') - self.assertEndpointReached(self.companyfile.inventory.delete_item, {'uid': UID}, 'DELETE', f'/{CID}/Inventory/Item/{UID}/') - self.assertEndpointReached(self.companyfile.inventory.itempricematrix, {}, 'GET', f'/{CID}/Inventory/ItemPriceMatrix/') - self.assertEndpointReached(self.companyfile.inventory.get_itempricematrix, {'uid': UID}, 'GET', f'/{CID}/Inventory/ItemPriceMatrix/{UID}/') - self.assertEndpointReached(self.companyfile.inventory.put_itempricematrix, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Inventory/ItemPriceMatrix/{UID}/') + self.assertEndpointReached(self.companyfile.inventory.get_item, {'uid': UID}, 'GET', + f'/{CID}/Inventory/Item/{UID}/') + self.assertEndpointReached(self.companyfile.inventory.put_item, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Inventory/Item/{UID}/') + self.assertEndpointReached(self.companyfile.inventory.post_item, {'data': DATA}, 'POST', + f'/{CID}/Inventory/Item/') + self.assertEndpointReached(self.companyfile.inventory.delete_item, {'uid': UID}, 'DELETE', + f'/{CID}/Inventory/Item/{UID}/') + self.assertEndpointReached(self.companyfile.inventory.itempricematrix, {}, 'GET', + f'/{CID}/Inventory/ItemPriceMatrix/') + self.assertEndpointReached(self.companyfile.inventory.get_itempricematrix, {'uid': UID}, 'GET', + f'/{CID}/Inventory/ItemPriceMatrix/{UID}/') + self.assertEndpointReached(self.companyfile.inventory.put_itempricematrix, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Inventory/ItemPriceMatrix/{UID}/') self.assertEndpointReached(self.companyfile.inventory.location, {}, 'GET', f'/{CID}/Inventory/Location/') - self.assertEndpointReached(self.companyfile.inventory.get_location, {'uid': UID}, 'GET', f'/{CID}/Inventory/Location/{UID}/') - self.assertEndpointReached(self.companyfile.inventory.put_location, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Inventory/Location/{UID}/') - self.assertEndpointReached(self.companyfile.inventory.post_location, {'data': DATA}, 'POST', f'/{CID}/Inventory/Location/') - self.assertEndpointReached(self.companyfile.inventory.delete_location, {'uid': UID}, 'DELETE', f'/{CID}/Inventory/Location/{UID}/') + self.assertEndpointReached(self.companyfile.inventory.get_location, {'uid': UID}, 'GET', + f'/{CID}/Inventory/Location/{UID}/') + self.assertEndpointReached(self.companyfile.inventory.put_location, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Inventory/Location/{UID}/') + self.assertEndpointReached(self.companyfile.inventory.post_location, {'data': DATA}, 'POST', + f'/{CID}/Inventory/Location/') + self.assertEndpointReached(self.companyfile.inventory.delete_location, {'uid': UID}, 'DELETE', + f'/{CID}/Inventory/Location/{UID}/') self.assertEndpointReached(self.companyfile.inventory.adjustment, {}, 'GET', f'/{CID}/Inventory/Adjustment/') - self.assertEndpointReached(self.companyfile.inventory.get_adjustment, {'uid': UID}, 'GET', f'/{CID}/Inventory/Adjustment/{UID}/') - self.assertEndpointReached(self.companyfile.inventory.put_adjustment, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Inventory/Adjustment/{UID}/') - self.assertEndpointReached(self.companyfile.inventory.post_adjustment, {'data': DATA}, 'POST', f'/{CID}/Inventory/Adjustment/') - self.assertEndpointReached(self.companyfile.inventory.delete_adjustment, {'uid': UID}, 'DELETE', f'/{CID}/Inventory/Adjustment/{UID}/') + self.assertEndpointReached(self.companyfile.inventory.get_adjustment, {'uid': UID}, 'GET', + f'/{CID}/Inventory/Adjustment/{UID}/') + self.assertEndpointReached(self.companyfile.inventory.put_adjustment, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Inventory/Adjustment/{UID}/') + self.assertEndpointReached(self.companyfile.inventory.post_adjustment, {'data': DATA}, 'POST', + f'/{CID}/Inventory/Adjustment/') + self.assertEndpointReached(self.companyfile.inventory.delete_adjustment, {'uid': UID}, 'DELETE', + f'/{CID}/Inventory/Adjustment/{UID}/') def test_purchase_orders(self): self.assertEqual(repr(self.companyfile.purchase_orders), ( @@ -409,10 +533,14 @@ def test_purchase_orders(self): )) self.assertEndpointReached(self.companyfile.purchase_orders.all, {}, 'GET', f'/{CID}/Purchase/Order/') self.assertEndpointReached(self.companyfile.purchase_orders.item, {}, 'GET', f'/{CID}/Purchase/Order/Item/') - self.assertEndpointReached(self.companyfile.purchase_orders.get_item, {'uid': UID}, 'GET', f'/{CID}/Purchase/Order/Item/{UID}/') - self.assertEndpointReached(self.companyfile.purchase_orders.put_item, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Purchase/Order/Item/{UID}/') - self.assertEndpointReached(self.companyfile.purchase_orders.post_item, {'data': DATA}, 'POST', f'/{CID}/Purchase/Order/Item/') - self.assertEndpointReached(self.companyfile.purchase_orders.delete_item, {'uid': UID}, 'DELETE', f'/{CID}/Purchase/Order/Item/{UID}/') + self.assertEndpointReached(self.companyfile.purchase_orders.get_item, {'uid': UID}, 'GET', + f'/{CID}/Purchase/Order/Item/{UID}/') + self.assertEndpointReached(self.companyfile.purchase_orders.put_item, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Purchase/Order/Item/{UID}/') + self.assertEndpointReached(self.companyfile.purchase_orders.post_item, {'data': DATA}, 'POST', + f'/{CID}/Purchase/Order/Item/') + self.assertEndpointReached(self.companyfile.purchase_orders.delete_item, {'uid': UID}, 'DELETE', + f'/{CID}/Purchase/Order/Item/{UID}/') def test_purchase_bills(self): self.assertEqual(repr(self.companyfile.purchase_bills), ( @@ -436,20 +564,86 @@ def test_purchase_bills(self): )) self.assertEndpointReached(self.companyfile.purchase_bills.all, {}, 'GET', f'/{CID}/Purchase/Bill/') self.assertEndpointReached(self.companyfile.purchase_bills.item, {}, 'GET', f'/{CID}/Purchase/Bill/Item/') - self.assertEndpointReached(self.companyfile.purchase_bills.get_item, {'uid': UID}, 'GET', f'/{CID}/Purchase/Bill/Item/{UID}/') - self.assertEndpointReached(self.companyfile.purchase_bills.put_item, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Purchase/Bill/Item/{UID}/') - self.assertEndpointReached(self.companyfile.purchase_bills.post_item, {'data': DATA}, 'POST', f'/{CID}/Purchase/Bill/Item/') - self.assertEndpointReached(self.companyfile.purchase_bills.delete_item, {'uid': UID}, 'DELETE', f'/{CID}/Purchase/Bill/Item/{UID}/') + self.assertEndpointReached(self.companyfile.purchase_bills.get_item, {'uid': UID}, 'GET', + f'/{CID}/Purchase/Bill/Item/{UID}/') + self.assertEndpointReached(self.companyfile.purchase_bills.put_item, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Purchase/Bill/Item/{UID}/') + self.assertEndpointReached(self.companyfile.purchase_bills.post_item, {'data': DATA}, 'POST', + f'/{CID}/Purchase/Bill/Item/') + self.assertEndpointReached(self.companyfile.purchase_bills.delete_item, {'uid': UID}, 'DELETE', + f'/{CID}/Purchase/Bill/Item/{UID}/') self.assertEndpointReached(self.companyfile.purchase_bills.service, {}, 'GET', f'/{CID}/Purchase/Bill/Service/') - self.assertEndpointReached(self.companyfile.purchase_bills.get_service, {'uid': UID}, 'GET', f'/{CID}/Purchase/Bill/Service/{UID}/') - self.assertEndpointReached(self.companyfile.purchase_bills.put_service, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Purchase/Bill/Service/{UID}/') - self.assertEndpointReached(self.companyfile.purchase_bills.post_service, {'data': DATA}, 'POST', f'/{CID}/Purchase/Bill/Service/') - self.assertEndpointReached(self.companyfile.purchase_bills.delete_service, {'uid': UID}, 'DELETE', f'/{CID}/Purchase/Bill/Service/{UID}/') - self.assertEndpointReached(self.companyfile.purchase_bills.miscellaneous, {}, 'GET', f'/{CID}/Purchase/Bill/Miscellaneous/') - self.assertEndpointReached(self.companyfile.purchase_bills.get_miscellaneous, {'uid': UID}, 'GET', f'/{CID}/Purchase/Bill/Miscellaneous/{UID}/') - self.assertEndpointReached(self.companyfile.purchase_bills.put_miscellaneous, {'uid': UID, 'data': DATA}, 'PUT', f'/{CID}/Purchase/Bill/Miscellaneous/{UID}/') - self.assertEndpointReached(self.companyfile.purchase_bills.post_miscellaneous, {'data': DATA}, 'POST', f'/{CID}/Purchase/Bill/Miscellaneous/') - self.assertEndpointReached(self.companyfile.purchase_bills.delete_miscellaneous, {'uid': UID}, 'DELETE', f'/{CID}/Purchase/Bill/Miscellaneous/{UID}/') + self.assertEndpointReached(self.companyfile.purchase_bills.get_service, {'uid': UID}, 'GET', + f'/{CID}/Purchase/Bill/Service/{UID}/') + self.assertEndpointReached(self.companyfile.purchase_bills.put_service, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Purchase/Bill/Service/{UID}/') + self.assertEndpointReached(self.companyfile.purchase_bills.post_service, {'data': DATA}, 'POST', + f'/{CID}/Purchase/Bill/Service/') + self.assertEndpointReached(self.companyfile.purchase_bills.delete_service, {'uid': UID}, 'DELETE', + f'/{CID}/Purchase/Bill/Service/{UID}/') + self.assertEndpointReached(self.companyfile.purchase_bills.miscellaneous, {}, 'GET', + f'/{CID}/Purchase/Bill/Miscellaneous/') + self.assertEndpointReached(self.companyfile.purchase_bills.get_miscellaneous, {'uid': UID}, 'GET', + f'/{CID}/Purchase/Bill/Miscellaneous/{UID}/') + self.assertEndpointReached(self.companyfile.purchase_bills.put_miscellaneous, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Purchase/Bill/Miscellaneous/{UID}/') + self.assertEndpointReached(self.companyfile.purchase_bills.post_miscellaneous, {'data': DATA}, 'POST', + f'/{CID}/Purchase/Bill/Miscellaneous/') + self.assertEndpointReached(self.companyfile.purchase_bills.delete_miscellaneous, {'uid': UID}, 'DELETE', + f'/{CID}/Purchase/Bill/Miscellaneous/{UID}/') + + def test_supplier_payments(self): + self.assertEqual(repr(self.companyfile.supplier_payments), ( + "Purchase_SupplierPaymentManager:\n" + " all() - Return all purchase supplier payments for an AccountRight company file.\n" + " delete(uid) - Delete selected purchase supplier payment.\n" + " get(uid) - Return selected purchase supplier payment.\n" + " post(data) - Create new purchase supplier payment.\n" + " put(uid, data) - Update selected purchase supplier payment." + )) + self.assertEndpointReached(self.companyfile.supplier_payments.all, {}, 'GET', + f'/{CID}/Purchase/SupplierPayment/') + self.assertEndpointReached(self.companyfile.supplier_payments.get, {'uid': UID}, 'GET', + f'/{CID}/Purchase/SupplierPayment/{UID}/') + self.assertEndpointReached(self.companyfile.supplier_payments.put, {'uid': UID, 'data': DATA}, 'PUT', + f'/{CID}/Purchase/SupplierPayment/{UID}/') + self.assertEndpointReached(self.companyfile.supplier_payments.delete, {'uid': UID}, 'DELETE', + f'/{CID}/Purchase/SupplierPayment/{UID}/') + self.assertEndpointReached(self.companyfile.supplier_payments.post, {'data': DATA}, 'POST', + f'/{CID}/Purchase/SupplierPayment/') + + def test_debit_refunds(self): + self.assertEqual(repr(self.companyfile.debit_refunds), ( + "Purchase_DebitRefundManager:\n" + " all() - Return all purchase debit refunds for an AccountRight company file.\n" + " delete(uid) - Delete selected purchase debit refund.\n" + " get(uid) - Return selected purchase debit refund.\n" + " post(data) - Create new purchase debit refund." + )) + self.assertEndpointReached(self.companyfile.debit_refunds.all, {}, 'GET', f'/{CID}/Purchase/DebitRefund/') + self.assertEndpointReached(self.companyfile.debit_refunds.get, {'uid': UID}, 'GET', + f'/{CID}/Purchase/DebitRefund/{UID}/') + self.assertEndpointReached(self.companyfile.debit_refunds.delete, {'uid': UID}, 'DELETE', + f'/{CID}/Purchase/DebitRefund/{UID}/') + self.assertEndpointReached(self.companyfile.debit_refunds.post, {'data': DATA}, 'POST', + f'/{CID}/Purchase/DebitRefund/') + + def test_debit_settlements(self): + self.assertEqual(repr(self.companyfile.debit_settlements), ( + "Purchase_DebitSettlementManager:\n" + " all() - Return all purchase debit settlements for an AccountRight company file.\n" + " delete(uid) - Delete selected purchase debit settlement.\n" + " get(uid) - Return selected purchase debit settlement.\n" + " post(data) - Create new purchase debit settlement." + )) + self.assertEndpointReached(self.companyfile.debit_settlements.all, {}, 'GET', + f'/{CID}/Purchase/DebitSettlement/') + self.assertEndpointReached(self.companyfile.debit_settlements.get, {'uid': UID}, 'GET', + f'/{CID}/Purchase/DebitSettlement/{UID}/') + self.assertEndpointReached(self.companyfile.debit_settlements.delete, {'uid': UID}, 'DELETE', + f'/{CID}/Purchase/DebitSettlement/{UID}/') + self.assertEndpointReached(self.companyfile.debit_settlements.post, {'data': DATA}, 'POST', + f'/{CID}/Purchase/DebitSettlement/') def test_company(self): self.assertEqual(repr(self.companyfile.company), (