Skip to content

Commit

Permalink
Complete supplier invoice api
Browse files Browse the repository at this point in the history
  • Loading branch information
naku committed May 9, 2023
1 parent 7a4d532 commit dfbecba
Show file tree
Hide file tree
Showing 11 changed files with 370 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## Change Log
### Version 1.8.2 (2023-05-09)
- Complete supplier invoice API
### Version 1.8.1 (2022-02-23)
- Fix client invoice payment
### Version 1.8.0 (2021-04-06)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This plugin adds [Dolibarr](https://www.dolibarr.org/) support to Play! Framewor

```
require:
- dolibarr -> dolibarr 1.8.1
- dolibarr -> dolibarr 1.8.2
repositories:
- sismicsNexusRaw:
Expand Down
8 changes: 8 additions & 0 deletions app/helpers/api/dolibarr/model/PaymentTerm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package helpers.api.dolibarr.model;

/**
* @author jtremeaux
*/
public class PaymentTerm {
public static final Integer AFTER_30_DAYS = 2;
}
8 changes: 8 additions & 0 deletions app/helpers/api/dolibarr/model/ProductType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package helpers.api.dolibarr.model;

/**
* @author jtremeaux
*/
public class ProductType {
public static final Integer SERVICE = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package helpers.api.dolibarr.model.clientInvoice;

/**
* @author jtremeaux
*/
public class ClientInvoiceValidateModel {
public Integer idwarehouse;
public Integer notrigger;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package helpers.api.dolibarr.model.supplierInvoice;

import java.math.BigDecimal;

/**
* @author jtremeaux
*/
public class SupplierInvoiceLineModel {
public String ref;
public String product_ref;
public String ref_supplier;
public String product_desc;
public BigDecimal pu_ht;
public BigDecimal subprice;
public BigDecimal pu_ttc;
public Long fk_facture_fourn;
public String label;
public String description;
public String date_start;
public String date_end;
public String situation_percent;
public Long fk_prev_id;
public String vat_src_code;
public BigDecimal tva_tx;
public BigDecimal localtax1_tx;
public BigDecimal localtax2_tx;
public BigDecimal qty;
public BigDecimal remise_percent;
public BigDecimal total_ht;
public BigDecimal total_ttc;
public BigDecimal total_tva;
public BigDecimal total_localtax1;
public BigDecimal total_localtax2;
public Long fk_product;
public Integer product_type;
public String product_label;
public String info_bits;
public Long fk_remise_except;
public Long fk_parent_line;
public String special_code;
public String rang;
public String localtax1_type;
public Long localtax2_type;
public BigDecimal multicurrency_subprice;
public BigDecimal multicurrency_total_ht;
public BigDecimal multicurrency_total_tva;
public BigDecimal multicurrency_total_ttc;
public Long id;
public Long fk_unit;
public String date_debut_prevue;
public String date_debut_reel;
public String date_fin_prevue;
public String date_fin_reel;
public String weight;
public String weight_units;
public String width;
public String width_units;
public String height;
public String height_units;
public String length;
public String length_units;
public String surface;
public String surface_units;
public String volume;
public String volume_units;
public String multilangs;
public String desc;
public String product;
public String product_barcode;
public Long fk_product_type;
public String duree;
public String entity;
public String import_key;
public String contacts_ids;
public String linked_objects;
public String linkedObjectsIds;
public String canvas;
public String origin;
public String origin_id;
public String ref_ext;
public String statut;
public String status;
public String state_id;
public String region_id;
public String demand_reason_id;
public String transport_mode_id;
public String last_main_doc;
public Long fk_bank;
public Long fk_account;
public String lines;
public String date_creation;
public String date_validation;
public String date_modification;
public String date_cloture;
public String user_author;
public String user_creation;
public String user_creation_id;
public String user_valid;
public String user_validation;
public String user_validation_id;
public String user_closing_id;
public String user_modification;
public String user_modification_id;
public String specimen;
public String libelle;
public String code_ventilation;
public Long fk_accounting_account;

public SupplierInvoiceLineModel() {
}

public SupplierInvoiceLineModel(Integer product_type, BigDecimal pu_ht, BigDecimal tva_tx, BigDecimal qty, String description) {
this.product_type = product_type;
this.pu_ht = pu_ht;
this.tva_tx = tva_tx;
this.qty = qty;
this.description = description;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
package helpers.api.dolibarr.model.supplierInvoice;

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
* @author jtremeaux
*/
public class SupplierInvoiceModel {
public String ref;
public String ref_supplier;
public String label;
public Integer socid;
public Long type;
public Long statut;
public Long status;
public String close_code;
public String close_note;
public String paye;
public String datec;
public String tms;
public String date;
public String date_echeance;
public String amount;
public String remise;
public String tva;
public String localtax1;
public String localtax2;
public BigDecimal total_ht;
public BigDecimal total_tva;
public String total_localtax1;
public String total_localtax2;
public BigDecimal total_ttc;
public String note_private;
public String note_public;
public String propalid;
public Integer cond_reglement_id;
public String cond_reglement_code;
public String cond_reglement_label;
public String cond_reglement_doc;
public Integer fk_account;
public Integer mode_reglement_id;
public String mode_reglement_code;
public Long transport_mode_id;
// "extraparams": [],
public List<SupplierInvoiceLineModel> lines = new ArrayList<>();
public String fournisseur;
public String fk_multicurrency;
public String multicurrency_code;
public BigDecimal multicurrency_tx;
public BigDecimal multicurrency_total_ht;
public BigDecimal multicurrency_total_tva;
public BigDecimal multicurrency_total_ttc;
public Long fk_facture_source;
public String fac_rec;
public String totalpaid;
public String totaldeposits;
public String totalcreditnotes;
public String sumpayed;
public String sumpayed_multicurrency;
public String sumdeposit;
public String sumdeposit_multicurrency;
public String sumcreditnote;
public String sumcreditnote_multicurrency;
public String remaintopay;
public Long id;
public Long entity;
public String import_key;
// public String array_options": [],
public String array_languages;
public String contacts_ids;
public String linked_objects;
public String linkedObjectsIds;
public String canvas;
public String fk_project;
public String contact_id;
public String user;
public String origin;
public String origin_id;
public String ref_ext;
public String country_id;
public String country_code;
public String state_id;
public String region_id;
public String demand_reason_id;
public String shipping_method_id;
public String model_pdf;
public String last_main_doc;
public String fk_bank;
public String name;
public String lastname;
public String firstname;
public String civility_id;
public String date_creation;
public String date_validation;
public String date_modification;
public String date_cloture;
public String user_author;
public String user_creation;
public String user_creation_id;
public String user_valid;
public String user_validation;
public String user_validation_id;
public String user_closing_id;
public String user_modification;
public String user_modification_id;
public Long specimen;
public Long fk_incoterms;
public String label_incoterms;
public String location_incoterms;
public String fk_soc;
public Long datep;
public String libelle;
public Long paid;
public Long fk_statut;
public Long fk_user_author;
public Long fk_user_valid;
public String fk_fac_rec_source;
public String socnom;

public static final String DATE_SHORT_FORMAT = "yyyy-MM-dd";

public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat.forPattern(DATE_SHORT_FORMAT);

public SupplierInvoiceModel() {
}

public SupplierInvoiceModel(String ref_supplier, Integer socid, Date date, Date dateEcheance, Integer cond_reglement_id, Integer mode_reglement_id, Integer fk_account) {
this.ref = "auto";
this.ref_supplier = ref_supplier;
this.socid = socid;
this.date = DATE_TIME_FORMATTER.print(new DateTime(date).withZone(DateTimeZone.UTC));
this.date_echeance = DATE_TIME_FORMATTER.print(new DateTime(dateEcheance).withZone(DateTimeZone.UTC));
this.cond_reglement_id = cond_reglement_id;
this.mode_reglement_id = mode_reglement_id;
this.fk_account = fk_account;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package helpers.api.dolibarr.model.supplierInvoice;

/**
* @author jtremeaux
*/
public class SupplierInvoiceValidateModel {
public Integer idwarehouse;
public Integer notrigger;
}
4 changes: 2 additions & 2 deletions app/helpers/api/dolibarr/service/ClientInvoiceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import helpers.api.dolibarr.DolibarrClient;
import helpers.api.dolibarr.model.clientInvoice.ClientInvoiceModel;
import helpers.api.dolibarr.model.clientInvoice.ClientInvoicePaymentModel;
import helpers.api.dolibarr.model.clientInvoice.InvoiceValidateModel;
import helpers.api.dolibarr.model.clientInvoice.ClientInvoiceValidateModel;
import org.apache.commons.io.IOUtils;

import java.io.InputStreamReader;
Expand Down Expand Up @@ -72,7 +72,7 @@ public Integer createClientInvoice(ClientInvoiceModel clientInvoiceModel) {
* @param invoiceId The invoice ID
* @param invoiceValidateModel The invoice validation model
*/
public String validateInvoice(Integer invoiceId, InvoiceValidateModel invoiceValidateModel) {
public String validateInvoice(Integer invoiceId, ClientInvoiceValidateModel invoiceValidateModel) {
HttpRequest request = dolibarrClient.authRequest(HttpRequest.newBuilder()
.uri(URI.create(dolibarrClient.getUrl("/invoices/" + invoiceId + "/validate"))))
.header("Content-Type", "application/json")
Expand Down
Loading

0 comments on commit dfbecba

Please sign in to comment.